Package org.dlese.dpc.schemedit
Class SchemEditUtils
java.lang.Object
org.dlese.dpc.schemedit.SchemEditUtils
Utility methods for SchemEdit
- Author:
- ostwald
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic SimpleDateFormat* Formats and parses dates according tofullDateFormatString.static Stringsame as utcDateFormatStringstatic SimpleDateFormatFormats and parses dates according tosimpleDateFormatString.static String"yyyy-MM-dd"static SimpleDateFormatFormats and parses dates according to utcDateFormatString.static String"yyyy-MM-dd'T'HH:mm:ss'Z'" -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidDescription of the Methodstatic StringContract expanded ampersands (&) that are part of entity references.static StringescapeUriSpaces(String uriStr) Escape spaces in the given uriStr so that it may be accepted by URI constructor.static StringExpand expanded ampersands that are part of entities.static StringEncodes query strings beginning with "id:" or "url:" usingSimpleLuceneIndex.encodeToTerm(java.lang.String).static org.apache.struts.action.ActionForwardforwardToCaller(HttpServletRequest request, String editedRecId, SessionBean sessionBean) General method to forward control to the appropriate page (Collections, Search or View) after completing an operation.static StringfullDateString(Date date) Converts a Date object into a string formatted withfullDateFormatstatic ObjectBased on attribute name, attempts to get the value of that attribute using a bean-style "gettter".static StringgetCollectionFromIndex(String id, SimpleLuceneIndex index) DEPRECIATED - use getCollectionOfIndexedRecord Returns the collection associated with an indexed record.static StringReturns the collection associated with an indexed record.static DcsSetInfogetDcsSetInfo(String collection, List dcsSetInfos) pick a given DcsSetInfo from a liststatic DcsSetInfogetDcsSetInfo(String collection, RepositoryManager rm) Gets the dcsSetInfo attribute of the SchemEditUtils classstatic org.dom4j.DocumentgetEditableDocument(String docUri, MetaDataFramework framework) Returns the localized dom4j.Document from the given uri after checking that the schemaLocation declared by the document at uri corresponds with the schemaLocation known to the MetaDataFramework parameter.static StringgetEditableXml(File file) Gets the editableXml attribute of the SchemEditUtils classstatic StringgetElapsedTimeSimple(long clicks) Return a string representation of the elapsed time since an event date (which is represented as "clicks" since "the epoch").static FilegetFileFromIndex(String id, RepositoryManager rm) Returns the file associated with an id in an index.static org.dom4j.DocumentReturns a localized xmlDocument for the given uri.static ListgetMirrorUrls(String recordXml) Extracts mirrorUrl values from an adn recordstatic SetInfogetSetInfo(String collection, RepositoryManager rm) Gets the setInfo attribute of the SchemEditUtils classstatic StringGets the uniqueId attribute of the SchemEditUtils classstatic ObjectGets the uriRef attribute of the SchemEditUtils classstatic ObjectGets the uriRef attribute of the SchemEditUtils classstatic ObjectGets the uriRef attribute of the SchemEditUtils classstatic ObjectGiven a string representation of a uri, returns either a File or URL instance.static DateGets the utcTime attribute of the SchemEditUtils classstatic DategetUtcTime(Date date) Gets the utcTime attribute of the SchemEditUtils classstatic booleanhasBadChar(String s) Checks given string for characters outside the range of ASCII valuesstatic voidThe main program for the SchemEditUtils classstatic voidPrint a line to standard out.static voidDescription of the Methodstatic StringReturn the given string wrapped in quotation marksstatic voidshowReferer(HttpServletRequest request) Displays request params for debugging.static voidshowRequestHeaders(HttpServletRequest request) Display request headers for debugging.static voidshowRequestParameters(HttpServletRequest request) Displays request params for debugging.static voidshowRequestParameters(HttpServletRequest request, String[] paramFilter) Description of the Methodstatic voidshowRoleInfo(User sessionUser, org.apache.struts.action.ActionMapping mapping) Description of the Methodstatic StringsimpleDateString(Date date) Converts a Date object into a string formatted withsimpleDateFormatstatic StringstuffId(String recordXml, String id, MetaDataFramework framework) Insert a new id into an existing metadata recordstatic StringReplace forward slashes in provided path with backward slashesstatic StringutcDateString(Date date) formats the given date in the form "yyyy-MM-dd'T'HH:mm:ss'Z'".
-
Field Details
-
utcDateFormatString
"yyyy-MM-dd'T'HH:mm:ss'Z'" -
utcDateFormat
Formats and parses dates according to utcDateFormatString. -
fullDateFormatString
same as utcDateFormatString -
fullDateFormat
* Formats and parses dates according tofullDateFormatString. -
simpleDateFormatString
"yyyy-MM-dd" -
simpleDateFormat
Formats and parses dates according tosimpleDateFormatString.
-
-
Constructor Details
-
SchemEditUtils
public SchemEditUtils()
-
-
Method Details
-
forwardToCaller
public static org.apache.struts.action.ActionForward forwardToCaller(HttpServletRequest request, String editedRecId, SessionBean sessionBean) General method to forward control to the appropriate page (Collections, Search or View) after completing an operation. The editedRecId parameter is supplied by metadata editor. It is used to highlight a record in the search view. It may be different from SessionBean.getId(), which is set by the viewing tool.- Parameters:
request- the request objecteditedRecId- id of record edited in metadata editor (if any)sessionBean- a sessionBean instance- Returns:
- ActionForward directing to the caller of last operation.
-
contractAmpersands
Contract expanded ampersands (&) that are part of entity references. For example, "©" and "©" both become "invalid input: '©'". "&" by itself is not contracted. Used to convert xml record into a form desireable for xml files- Parameters:
in- String to be processed- Returns:
- processed string
-
escapeUriSpaces
Escape spaces in the given uriStr so that it may be accepted by URI constructor.- Parameters:
uriStr- Description of the Parameter- Returns:
- Description of the Return Value
-
expandAmpersands
Expand expanded ampersands that are part of entities. For example, "©" becomes "©". Used to convert xml text from file form into a from preferred by dom4j.- Parameters:
in- Description of the Parameter- Returns:
- Description of the Return Value
-
getLocalizedXmlDocument
Returns a localized xmlDocument for the given uri. NOTE: URI's must have a scheme of either "file" or "http".NOTEs:
- this method should use getUriRef to resolve the uri into either a file or url.
- what is the difference between this and getEditableXml()?
- Parameters:
uri- uri pointing to a file containing xml- Returns:
- A localized Document
- Throws:
Exception- If scheme is not recognized or if a Document could not be created
-
getUriRef
Gets the uriRef attribute of the SchemEditUtils class- Parameters:
uriStr- Description of the Parameter- Returns:
- The uriRef value
- Throws:
Exception- Description of the ExceptionURISyntaxException- Description of the Exception
-
getUriRef
Gets the uriRef attribute of the SchemEditUtils class- Parameters:
uri- Description of the Parameter- Returns:
- The uriRef value
- Throws:
Exception- Description of the Exception
-
getUriRef
Gets the uriRef attribute of the SchemEditUtils class- Parameters:
uriStr- Description of the ParameterdocRoot- Description of the Parameter- Returns:
- The uriRef value
- Throws:
Exception- Description of the ExceptionURISyntaxException- Description of the Exception
-
getUriRef
Given a string representation of a uri, returns either a File or URL instance.Relative paths are assumed to be file paths relative to "docRoot" and expanded accordingly into absolute files.
- Parameters:
uri- Description of the ParameterdocRoot- Path to docRoot for this application to aid in resolving relative paths.- Returns:
- The uriRef value
- Throws:
Exception- NOT YET DOCUMENTED
-
getEditableXml
Gets the editableXml attribute of the SchemEditUtils class- Parameters:
file- NOT YET DOCUMENTED- Returns:
- The editableXml value
- Throws:
Exception- NOT YET DOCUMENTED
-
getEditableDocument
public static org.dom4j.Document getEditableDocument(String docUri, MetaDataFramework framework) throws org.dom4j.DocumentException Returns the localized dom4j.Document from the given uri after checking that the schemaLocation declared by the document at uri corresponds with the schemaLocation known to the MetaDataFramework parameter.called from MetaDataFramework.getEditableDocument.
- Parameters:
docUri- uri of xml documentframework- MetaDataFramework instance for consistency checking.- Returns:
- localized dom4j.Document with ampersands expanded for editing.
- Throws:
org.dom4j.DocumentException- Description of the Exception
-
showReferer
Displays request params for debugging.- Parameters:
request- Description of the Parameter
-
showRequestParameters
Displays request params for debugging.Filtering out kinds of parameters. Construct an array containing strings which, if found in a parameter name, will filter that param from the display. E.g.,
- metadata editor form values contain params: "("
- metadata editor collapse params contain "_^_"
- Parameters:
request- Description of the Parameter
-
showRequestParameters
Description of the Method- Parameters:
request- Description of the ParameterparamFilter- Description of the Parameter
-
getCollectionFromIndex
DEPRECIATED - use getCollectionOfIndexedRecord Returns the collection associated with an indexed record.- Parameters:
id- record idindex- a SimpleLuceneIndex instance- Returns:
- The collection attribute for the record identified by id
-
getCollectionOfIndexedRecord
Returns the collection associated with an indexed record.- Parameters:
id- record idrm- Description of the Parameter- Returns:
- The collection attribute for the record identified by id
-
getSetInfo
Gets the setInfo attribute of the SchemEditUtils class- Parameters:
collection- Description of the Parameterrm- Description of the Parameter- Returns:
- The setInfo value
-
getDcsSetInfo
Gets the dcsSetInfo attribute of the SchemEditUtils class- Parameters:
collection- Description of the Parameterrm- Description of the Parameter- Returns:
- The dcsSetInfo value
-
getDcsSetInfo
pick a given DcsSetInfo from a list- Parameters:
collection- Description of the ParameterdcsSetInfos- Description of the Parameter- Returns:
- The dcsSetInfo value
-
getFileFromIndex
Returns the file associated with an id in an index.- Parameters:
id- record idrm- Description of the Parameter- Returns:
- The source file for the record identified by id
-
showRoleInfo
Description of the Method- Parameters:
sessionUser- Description of the Parametermapping- Description of the Parameter
-
hasBadChar
Checks given string for characters outside the range of ASCII values- Parameters:
s- String to be checked- Returns:
- true if String contains characters with ASCII value above 127.
-
getUniqueId
Gets the uniqueId attribute of the SchemEditUtils class- Returns:
- The uniqueId value
-
showRequestHeaders
Display request headers for debugging.- Parameters:
request- Description of the Parameter
-
formatQuery
Encodes query strings beginning with "id:" or "url:" usingSimpleLuceneIndex.encodeToTerm(java.lang.String).- Parameters:
q- the query string- Returns:
- thge formatted query string
-
quoteWrap
Return the given string wrapped in quotation marks- Parameters:
s- the string to quote wrap- Returns:
- the quoted string
-
fullDateString
Converts a Date object into a string formatted withfullDateFormat- Parameters:
date- date to be formatted- Returns:
- formatted date
-
simpleDateString
Converts a Date object into a string formatted withsimpleDateFormat- Parameters:
date- date to be formatted- Returns:
- formatted date
-
utcDateString
formats the given date in the form "yyyy-MM-dd'T'HH:mm:ss'Z'". If given date is null the string return reflects "the epoch", namely January 1, 1970, 00:00:00 GMT.- Parameters:
date- a date object to be formatted- Returns:
- the formatted string representation of date
-
getUtcTime
Gets the utcTime attribute of the SchemEditUtils class- Returns:
- The utcTime value
-
getUtcTime
Gets the utcTime attribute of the SchemEditUtils class- Parameters:
date- the date object- Returns:
- The utcTime value
-
getElapsedTimeSimple
Return a string representation of the elapsed time since an event date (which is represented as "clicks" since "the epoch").NOTE: this method does not consider elapsed times greater than 24 hours (the elapsed days are simply not shown).
- Parameters:
clicks- Description of the Parameter- Returns:
- The elapsedTimeSimple value
-
main
The main program for the SchemEditUtils class- Parameters:
args- The command line arguments- Throws:
Exception- Description of the Exception
-
toWinPath
Replace forward slashes in provided path with backward slashes- Parameters:
path- the path to convert- Returns:
- converted path
-
getMirrorUrls
Extracts mirrorUrl values from an adn record- Parameters:
recordXml- xml string to search for mirrorUrls- Returns:
- The mirrorUrls value
-
stuffId
public static String stuffId(String recordXml, String id, MetaDataFramework framework) throws Exception Insert a new id into an existing metadata record- Parameters:
recordXml- metadata record as xml stringid- id to insert into the metadata recordframework- MetaDataFramework object for the format of the record- Returns:
- Description of the Return Value
- Throws:
Exception- Description of the Exception
-
getAttr
Based on attribute name, attempts to get the value of that attribute using a bean-style "gettter".- Parameters:
obj- object for which to get attrattr- attribute to get- Returns:
- The attr value
-
prtln
Description of the Method- Parameters:
s- Description of the Parameterprefix- Description of the Parameter
-
prtln
Print a line to standard out.- Parameters:
s- The String to print.
-
box
Description of the Method- Parameters:
s- Description of the Parameter
-