Package edu.ucsb.nceas.metacat.util
Class MetacatUtil
java.lang.Object
edu.ucsb.nceas.metacat.util.MetacatUtil
A suite of utility classes for the metadata catalog server
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Copy a file between two locations specified as strings.getOptionList
(String optionText) Transform a comma-delimited string of options to a vector object which contains those optionsstatic String
Normalizes a string read from DB.parseQuery
(String query) Utility method to parse the query part of a URL into parameters.static String
replaceWhiteSpaceForURL
(String urlHasWhiteSpace) A method to replace whitespace in urlstatic void
writeDebugToDelimiteredFile
(String debugInfo, boolean newLine) Writes debug information into a file in delimitered formatstatic void
writeDebugToFile
(String debugInfo) Writes debug information into a file.static File
writeTempUploadFile
(org.apache.commons.fileupload.FileItem fi, String fileName) Write the uploaded file to disk for temporary storage before moving it to its final Metacat location.
-
Field Details
-
XMLFORMAT
- See Also:
-
dbAdapter
-
-
Constructor Details
-
MetacatUtil
public MetacatUtil()
-
-
Method Details
-
parseQuery
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
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
Normalizes a string read from DB. So it will be compatible to HTML -
replaceWhiteSpaceForURL
A method to replace whitespace in url -
writeDebugToFile
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
Writes debug information into a file in delimitered format- Parameters:
debugInfo
- the debug informationnewLine
- 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 elementfileName
- the name of the file to be written to disk- Returns:
- tempFilePath a String containing location of temporary file
- Throws:
Exception
-
copyFile
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 diskdestName
- the destination file on disk- Throws:
IOException
-