public class SchemEditUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.text.SimpleDateFormat |
fullDateFormat
* Formats and parses dates according to
fullDateFormatString . |
static java.lang.String |
fullDateFormatString
same as utcDateFormatString
|
static java.text.SimpleDateFormat |
simpleDateFormat
Formats and parses dates according to
simpleDateFormatString . |
static java.lang.String |
simpleDateFormatString
"yyyy-MM-dd"
|
static java.text.SimpleDateFormat |
utcDateFormat
Formats and parses dates according to utcDateFormatString.
|
static java.lang.String |
utcDateFormatString
"yyyy-MM-dd'T'HH:mm:ss'Z'"
|
Constructor and Description |
---|
SchemEditUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
box(java.lang.String s)
Description of the Method
|
static java.lang.String |
contractAmpersands(java.lang.String in)
Contract expanded ampersands (&) that are part of entity references.
|
static java.lang.String |
escapeUriSpaces(java.lang.String uriStr)
Escape spaces in the given uriStr so that it may be accepted by URI
constructor.
|
static java.lang.String |
expandAmpersands(java.lang.String in)
Expand expanded ampersands that are part of entities.
|
static java.lang.String |
formatQuery(java.lang.String q)
Encodes query strings beginning with "id:" or "url:" using
SimpleLuceneIndex.encodeToTerm(java.lang.String) . |
static org.apache.struts.action.ActionForward |
forwardToCaller(javax.servlet.http.HttpServletRequest request,
java.lang.String editedRecId,
SessionBean sessionBean)
General method to forward control to the appropriate page (Collections,
Search or View) after completing an operation.
|
static java.lang.String |
fullDateString(java.util.Date date)
Converts a Date object into a string formatted with
fullDateFormat |
static java.lang.Object |
getAttr(java.lang.Object obj,
java.lang.String attr)
Based on attribute name, attempts to get the value of that attribute using
a bean-style "gettter".
|
static java.lang.String |
getCollectionFromIndex(java.lang.String id,
SimpleLuceneIndex index)
DEPRECIATED - use getCollectionOfIndexedRecord Returns the collection
associated with an indexed record.
|
static java.lang.String |
getCollectionOfIndexedRecord(java.lang.String id,
RepositoryManager rm)
Returns the collection associated with an indexed record.
|
static DcsSetInfo |
getDcsSetInfo(java.lang.String collection,
java.util.List dcsSetInfos)
pick a given DcsSetInfo from a list
|
static DcsSetInfo |
getDcsSetInfo(java.lang.String collection,
RepositoryManager rm)
Gets the dcsSetInfo attribute of the SchemEditUtils class
|
static org.dom4j.Document |
getEditableDocument(java.lang.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 java.lang.String |
getEditableXml(java.io.File file)
Gets the editableXml attribute of the SchemEditUtils class
|
static java.lang.String |
getElapsedTimeSimple(long clicks)
Return a string representation of the elapsed time since an event date
(which is represented as "clicks" since "the epoch").
|
static java.io.File |
getFileFromIndex(java.lang.String id,
RepositoryManager rm)
Returns the file associated with an id in an index.
|
static org.dom4j.Document |
getLocalizedXmlDocument(java.net.URI uri)
Returns a localized xmlDocument for the given uri.
|
static java.util.List |
getMirrorUrls(java.lang.String recordXml)
Extracts mirrorUrl values from an adn record
|
static SetInfo |
getSetInfo(java.lang.String collection,
RepositoryManager rm)
Gets the setInfo attribute of the SchemEditUtils class
|
static java.lang.String |
getUniqueId()
Gets the uniqueId attribute of the SchemEditUtils class
|
static java.lang.Object |
getUriRef(java.lang.String uriStr)
Gets the uriRef attribute of the SchemEditUtils class
|
static java.lang.Object |
getUriRef(java.lang.String uriStr,
java.lang.String docRoot)
Gets the uriRef attribute of the SchemEditUtils class
|
static java.lang.Object |
getUriRef(java.net.URI uri)
Gets the uriRef attribute of the SchemEditUtils class
|
static java.lang.Object |
getUriRef(java.net.URI uri,
java.lang.String docRoot)
Given a string representation of a uri, returns either a File or URL
instance.
|
static java.util.Date |
getUtcTime()
Gets the utcTime attribute of the SchemEditUtils class
|
static java.util.Date |
getUtcTime(java.util.Date date)
Gets the utcTime attribute of the SchemEditUtils class
|
static boolean |
hasBadChar(java.lang.String s)
Checks given string for characters outside the range of ASCII values
|
static void |
main(java.lang.String[] args)
The main program for the SchemEditUtils class
|
static void |
prtln(java.lang.String s)
Print a line to standard out.
|
static void |
prtln(java.lang.String s,
java.lang.String prefix)
Description of the Method
|
static java.lang.String |
quoteWrap(java.lang.String s)
Return the given string wrapped in quotation marks
|
static void |
showReferer(javax.servlet.http.HttpServletRequest request)
Displays request params for debugging.
|
static void |
showRequestHeaders(javax.servlet.http.HttpServletRequest request)
Display request headers for debugging.
|
static void |
showRequestParameters(javax.servlet.http.HttpServletRequest request)
Displays request params for debugging.
|
static void |
showRequestParameters(javax.servlet.http.HttpServletRequest request,
java.lang.String[] paramFilter)
Description of the Method
|
static void |
showRoleInfo(User sessionUser,
org.apache.struts.action.ActionMapping mapping)
Description of the Method
|
static java.lang.String |
simpleDateString(java.util.Date date)
Converts a Date object into a string formatted with
simpleDateFormat |
static java.lang.String |
stuffId(java.lang.String recordXml,
java.lang.String id,
MetaDataFramework framework)
Insert a new id into an existing metadata record
|
static java.lang.String |
toWinPath(java.lang.String path)
Replace forward slashes in provided path with backward slashes
|
static java.lang.String |
utcDateString(java.util.Date date)
formats the given date in the form "yyyy-MM-dd'T'HH:mm:ss'Z'".
|
public static java.lang.String utcDateFormatString
public static java.text.SimpleDateFormat utcDateFormat
public static java.lang.String fullDateFormatString
public static java.text.SimpleDateFormat fullDateFormat
fullDateFormatString
.public static java.lang.String simpleDateFormatString
public static java.text.SimpleDateFormat simpleDateFormat
simpleDateFormatString
.public static org.apache.struts.action.ActionForward forwardToCaller(javax.servlet.http.HttpServletRequest request, java.lang.String editedRecId, SessionBean sessionBean)
request
- the request objecteditedRecId
- id of record edited in metadata editor (if any)sessionBean
- a sessionBean instancepublic static java.lang.String contractAmpersands(java.lang.String in)
in
- String to be processedpublic static java.lang.String escapeUriSpaces(java.lang.String uriStr)
uriStr
- Description of the Parameterpublic static java.lang.String expandAmpersands(java.lang.String in)
in
- Description of the Parameterpublic static org.dom4j.Document getLocalizedXmlDocument(java.net.URI uri) throws java.lang.Exception
NOTEs:
uri
- uri pointing to a file containing xmljava.lang.Exception
- If scheme is not recognized or if a Document could
not be createdpublic static java.lang.Object getUriRef(java.lang.String uriStr) throws java.lang.Exception, java.net.URISyntaxException
uriStr
- Description of the Parameterjava.lang.Exception
- Description of the Exceptionjava.net.URISyntaxException
- Description of the Exceptionpublic static java.lang.Object getUriRef(java.net.URI uri) throws java.lang.Exception
uri
- Description of the Parameterjava.lang.Exception
- Description of the Exceptionpublic static java.lang.Object getUriRef(java.lang.String uriStr, java.lang.String docRoot) throws java.lang.Exception, java.net.URISyntaxException
uriStr
- Description of the ParameterdocRoot
- Description of the Parameterjava.lang.Exception
- Description of the Exceptionjava.net.URISyntaxException
- Description of the Exceptionpublic static java.lang.Object getUriRef(java.net.URI uri, java.lang.String docRoot) throws java.lang.Exception
Relative paths are assumed to be file paths relative to "docRoot" and expanded accordingly into absolute files.
docRoot
- Path to docRoot for this application to aid in
resolving relative paths.uri
- Description of the Parameterjava.lang.Exception
- NOT YET DOCUMENTEDpublic static java.lang.String getEditableXml(java.io.File file) throws java.lang.Exception
file
- NOT YET DOCUMENTEDjava.lang.Exception
- NOT YET DOCUMENTEDpublic static org.dom4j.Document getEditableDocument(java.lang.String docUri, MetaDataFramework framework) throws org.dom4j.DocumentException
called from MetaDataFramework.getEditableDocument.
docUri
- uri of xml documentframework
- MetaDataFramework instance for consistency
checking.org.dom4j.DocumentException
- Description of the Exceptionpublic static void showReferer(javax.servlet.http.HttpServletRequest request)
request
- Description of the Parameterpublic static void showRequestParameters(javax.servlet.http.HttpServletRequest request)
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.,
request
- Description of the Parameterpublic static void showRequestParameters(javax.servlet.http.HttpServletRequest request, java.lang.String[] paramFilter)
request
- Description of the ParameterparamFilter
- Description of the Parameterpublic static java.lang.String getCollectionFromIndex(java.lang.String id, SimpleLuceneIndex index)
id
- record idindex
- a SimpleLuceneIndex instancepublic static java.lang.String getCollectionOfIndexedRecord(java.lang.String id, RepositoryManager rm)
id
- record idrm
- Description of the Parameterpublic static SetInfo getSetInfo(java.lang.String collection, RepositoryManager rm)
collection
- Description of the Parameterrm
- Description of the Parameterpublic static DcsSetInfo getDcsSetInfo(java.lang.String collection, RepositoryManager rm)
collection
- Description of the Parameterrm
- Description of the Parameterpublic static DcsSetInfo getDcsSetInfo(java.lang.String collection, java.util.List dcsSetInfos)
collection
- Description of the ParameterdcsSetInfos
- Description of the Parameterpublic static java.io.File getFileFromIndex(java.lang.String id, RepositoryManager rm)
id
- record idrm
- Description of the Parameterpublic static void showRoleInfo(User sessionUser, org.apache.struts.action.ActionMapping mapping)
sessionUser
- Description of the Parametermapping
- Description of the Parameterpublic static boolean hasBadChar(java.lang.String s)
s
- String to be checkedpublic static java.lang.String getUniqueId()
public static void showRequestHeaders(javax.servlet.http.HttpServletRequest request)
request
- Description of the Parameterpublic static java.lang.String formatQuery(java.lang.String q)
SimpleLuceneIndex.encodeToTerm(java.lang.String)
.q
- the query stringpublic static java.lang.String quoteWrap(java.lang.String s)
s
- the string to quote wrappublic static java.lang.String fullDateString(java.util.Date date)
fullDateFormat
date
- date to be formattedpublic static java.lang.String simpleDateString(java.util.Date date)
simpleDateFormat
date
- date to be formattedpublic static java.lang.String utcDateString(java.util.Date date)
date
- a date object to be formattedpublic static java.util.Date getUtcTime()
public static java.util.Date getUtcTime(java.util.Date date)
date
- the date objectpublic static java.lang.String getElapsedTimeSimple(long clicks)
NOTE: this method does not consider elapsed times greater than 24 hours (the elapsed days are simply not shown).
clicks
- Description of the Parameterpublic static void main(java.lang.String[] args) throws java.lang.Exception
args
- The command line argumentsjava.lang.Exception
- Description of the Exceptionpublic static java.lang.String toWinPath(java.lang.String path)
path
- the path to convertpublic static java.util.List getMirrorUrls(java.lang.String recordXml)
recordXml
- xml string to search for mirrorUrlspublic static java.lang.String stuffId(java.lang.String recordXml, java.lang.String id, MetaDataFramework framework) throws java.lang.Exception
recordXml
- metadata record as xml stringid
- id to insert into the metadata recordframework
- MetaDataFramework object for the format of the recordjava.lang.Exception
- Description of the Exceptionpublic static java.lang.Object getAttr(java.lang.Object obj, java.lang.String attr)
obj
- object for which to get attrattr
- attribute to getpublic static void prtln(java.lang.String s, java.lang.String prefix)
s
- Description of the Parameterprefix
- Description of the Parameterpublic static void prtln(java.lang.String s)
s
- The String to print.public static void box(java.lang.String s)
s
- Description of the Parameter