Class MetacatUtil

java.lang.Object
edu.ucsb.nceas.metacat.util.MetacatUtil

public class MetacatUtil extends Object
A suite of utility classes for the metadata catalog server
  • Field Details

  • Constructor Details

    • MetacatUtil

      public MetacatUtil()
  • Method Details

    • parseQuery

      public static Hashtable<String,String> parseQuery(String query) throws MalformedURLException
      Utility method to parse the query part of a URL into parameters. This method assumes the format of the query part of the url is an ampersand separated list of name/value pairs, with equal signs separating the name from the value (e.g., name=tom&zip=99801 ). Returns a has of the name value pairs, hashed on name.
      Throws:
      MalformedURLException
    • getOptionList

      public static Vector<String> getOptionList(String optionText)
      Transform a comma-delimited string of options to a vector object which contains those options
      Parameters:
      optiontext - the string contains the options
      Returns:
      a vector object which contains those options
    • normalize

      public static String normalize(String s)
      Normalizes a string read from DB. So it will be compatible to HTML
    • replaceWhiteSpaceForURL

      public static String replaceWhiteSpaceForURL(String urlHasWhiteSpace)
      A method to replace whitespace in url
    • writeDebugToFile

      public static void writeDebugToFile(String debugInfo)
      Writes debug information into a file. In metacat.properties, if property application.writeDebugToFile is set to true, the debug information will be written to debug file, which value is the property application.debugOutputFile in metacat.properties.
    • writeDebugToDelimiteredFile

      public static void writeDebugToDelimiteredFile(String debugInfo, boolean newLine)
      Writes debug information into a file in delimitered format
      Parameters:
      debugInfo - the debug information
      newLine - append the debug info to a line or not
    • writeTempUploadFile

      public static File writeTempUploadFile(org.apache.commons.fileupload.FileItem fi, String fileName) throws Exception
      Write the uploaded file to disk for temporary storage before moving it to its final Metacat location.
      Parameters:
      filePart - the FilePart object containing the file form element
      fileName - the name of the file to be written to disk
      Returns:
      tempFilePath a String containing location of temporary file
      Throws:
      Exception
    • copyFile

      public static void copyFile(String sourceName, String destName) throws IOException
      Copy a file between two locations specified as strings. Fails if either path cannot be created. Based on the public domain FileCopy class in _Java in a Nutshell_.
      Parameters:
      sourceName - the source file to read from disk
      destName - the destination file on disk
      Throws:
      IOException