|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfr.gouv.culture.sdx.utils.Utilities
Useful programming utilities for SDX. Contains some useful static methods.
Constructor Summary | |
Utilities()
|
Method Summary | |
static java.lang.String |
attId(java.lang.String baseId,
java.lang.String relId)
Build an id for an attached document from : the parent document id (@refId) a name unique relatively to the parent document (@relId) Used to store and attach files to a parent document (example: images) |
static java.net.URL |
attUrl(java.net.URL refURL,
java.lang.String path)
Build an URL for an attached document from : the parent document URL (@refURL) a path relative to the parent document (@path) Used for relative URL like |
static java.util.Locale |
buildLocale(org.apache.avalon.framework.configuration.Configuration conf,
java.util.Locale defaultLocale)
Returns a locale from a configuration object |
static java.util.Locale |
buildLocale(java.lang.String xmlLang,
java.lang.String variant,
java.util.Locale defaultLocale)
Returns a locale from a String |
static java.lang.String |
buildRmiName(java.lang.String rmiHost,
int rmiPort,
java.lang.String appId,
java.lang.String dbId)
Builds a rmi url string for RemoteIndex lookups |
static void |
checkConfAttributeValue(java.lang.String attName,
java.lang.String attValue,
java.lang.String attLocation)
Verifies a configuration attribute value, ie it should not be null or an empty String |
static void |
checkConfiguration(org.apache.avalon.framework.configuration.Configuration configuration)
Verifies a configuration object |
static java.io.File |
checkDirectory(java.lang.String dirPath,
org.apache.avalon.framework.logger.Logger logger)
Verifies if a given directory exists, if not the directory is created. |
static void |
checkDocument(org.apache.avalon.framework.logger.Logger logger,
Document doc)
Checks a document to ensure the object is not null and that it's id is not null or an empty string |
static void |
checkOutputStream(org.apache.avalon.framework.logger.Logger logger,
java.io.OutputStream os)
Verifies that an OutputStream is not null |
static boolean |
checkString(java.lang.String s)
Returns true if a string is not null or empty |
static void |
checkXmlConsumer(org.apache.avalon.framework.logger.Logger logger,
org.apache.cocoon.xml.XMLConsumer consumer)
Verifies that an XMLConsumer is not null |
static FieldsDefinition |
configureFieldList(org.apache.avalon.framework.logger.Logger logger,
org.apache.avalon.framework.configuration.Configuration configuration,
java.util.Hashtable props)
|
static Repository |
createRepository(org.apache.avalon.framework.configuration.Configuration repoConf,
org.apache.avalon.framework.component.ComponentManager manager,
java.util.Hashtable props,
org.apache.avalon.framework.logger.Logger logger)
Used to create a repository based upon a 'type' attribute |
static java.lang.String |
decodeURL(java.lang.String url,
java.lang.String encoding)
|
static java.lang.String |
encodeURL(java.lang.String url,
java.lang.String encoding)
|
static Application |
getApplication(org.apache.avalon.framework.component.ComponentManager manager,
java.util.Hashtable props)
|
static RemoteIndex |
getRemoteIndex(org.apache.avalon.framework.logger.Logger logger,
java.lang.String remoteIndexName)
|
static java.lang.String |
getStringFromHashtable(java.lang.String key,
java.util.Hashtable table)
Return's a string value from a hashtable by making the appropriate cast |
static java.io.File |
getSystemTempDir()
|
static java.lang.String |
joinStrings(java.lang.String[] strings,
java.lang.String delimiter)
Joins an array of strings |
static void |
logDebug(org.apache.avalon.framework.logger.Logger logger,
java.lang.String s,
java.lang.Exception e)
Verifies the logger and logs a message |
static void |
logError(org.apache.avalon.framework.logger.Logger logger,
java.lang.String s,
java.lang.Exception e)
Verifies the logger and logs a message |
static void |
logException(org.apache.avalon.framework.logger.Logger logger,
java.lang.Exception e)
Verifies the logger and logs an exception |
static void |
logInfo(org.apache.avalon.framework.logger.Logger logger,
java.lang.String s)
Verifies the logger and logs a message |
static void |
logWarn(org.apache.avalon.framework.logger.Logger logger,
java.lang.String s,
java.lang.Exception e)
Verifies the logger and logs a message |
static java.lang.String |
prefixNodeNameSDX(java.lang.String elemName)
|
static java.io.File |
resolveFile(org.apache.avalon.framework.logger.Logger logger,
java.lang.String confLocation,
java.util.Hashtable props,
java.lang.String path,
boolean isConfDirectory)
This method will attempt to verify if a file exists |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Utilities()
Method Detail |
public static java.io.File getSystemTempDir()
public static java.io.File checkDirectory(java.lang.String dirPath, org.apache.avalon.framework.logger.Logger logger) throws SDXException
dirPath
- The path for the directory to verify.logger
- Logger to use for error handling
SDXException
public static Repository createRepository(org.apache.avalon.framework.configuration.Configuration repoConf, org.apache.avalon.framework.component.ComponentManager manager, java.util.Hashtable props, org.apache.avalon.framework.logger.Logger logger) throws SDXException, org.apache.avalon.framework.configuration.ConfigurationException
repoConf
- The configuration object made up of an 'repository' element.manager
- The component manager to pass to the repositoryprops
- The properties object to pass to the repositorylogger
- The logger to pass to the repository and for error handling
SDXException
org.apache.avalon.framework.configuration.ConfigurationException
public static void logInfo(org.apache.avalon.framework.logger.Logger logger, java.lang.String s)
logger
- The loggers
- The messagepublic static void logDebug(org.apache.avalon.framework.logger.Logger logger, java.lang.String s, java.lang.Exception e)
logger
- The loggers
- The message (maybe null)e
- The exception (maybe null)public static void logError(org.apache.avalon.framework.logger.Logger logger, java.lang.String s, java.lang.Exception e)
logger
- The loggers
- The message (maybe null)e
- The exception (maybe null)public static void logWarn(org.apache.avalon.framework.logger.Logger logger, java.lang.String s, java.lang.Exception e)
logger
- The loggers
- The message (maybe null)e
- The exception (maybe null)public static void logException(org.apache.avalon.framework.logger.Logger logger, java.lang.Exception e)
logger
- The loggere
- The exception (maybe null)public static void checkDocument(org.apache.avalon.framework.logger.Logger logger, Document doc) throws SDXException
logger
- The logger for error handlingdoc
- The document object to verify
SDXException
- Thrown if the object is null, or its id is null
or an empty Stringpublic static void checkOutputStream(org.apache.avalon.framework.logger.Logger logger, java.io.OutputStream os) throws SDXException
logger
- The logger for error handlingos
- The OutputStream to verify
SDXException
public static void checkXmlConsumer(org.apache.avalon.framework.logger.Logger logger, org.apache.cocoon.xml.XMLConsumer consumer) throws SDXException
logger
- The logger for error handlingconsumer
- The XMLConsumer to verify
SDXException
public static void checkConfiguration(org.apache.avalon.framework.configuration.Configuration configuration) throws org.apache.avalon.framework.configuration.ConfigurationException
configuration
- The object to verify
org.apache.avalon.framework.configuration.ConfigurationException
- Thrown if the object is nullpublic static void checkConfAttributeValue(java.lang.String attName, java.lang.String attValue, java.lang.String attLocation) throws org.apache.avalon.framework.configuration.ConfigurationException
attName
- The name of the attributeattValue
- The value of the attributeattLocation
- The location of the configuration object
org.apache.avalon.framework.configuration.ConfigurationException
- Thrown if null
or an empty Stringpublic static java.io.File resolveFile(org.apache.avalon.framework.logger.Logger logger, java.lang.String confLocation, java.util.Hashtable props, java.lang.String path, boolean isConfDirectory) throws SDXException
logger
- The logger if neededconfLocation
- The location string from a configuration object, this way we can determine our current directory location, if neededprops
- The application properties object, containing the path needed to find the filepath
- The path of the document, absolute or relative to see below:isConfDirectory
- Indicates whether the file trying to be resolved could be a non-existent FSRepository base directory,
if so we would like to create it
This method will attempt to do this in the following order:
1)build a file object using the absolute file path, "file:/..."
2)a file object using the base path of the web application directory and the relative path provided, must begin with a "/"
3)a file object using the base path of the current directory (sdx configuration directory or the application configuration directory) and the relative path provided, could be something like: "../dir1/dir2/file.extension" or "dir1/file.extension", etc.
SDXException
public static boolean checkString(java.lang.String s)
s
- The string to verifypublic static java.util.Locale buildLocale(org.apache.avalon.framework.configuration.Configuration conf, java.util.Locale defaultLocale)
conf
- The configuration object for the element which contains the "xml:lang"
attribute with an optional "variant" attribute.defaultLocale
- A default locale to use if the building of the local fails
if a null
defaultLocale is passed, the system default is used.public static java.util.Locale buildLocale(java.lang.String xmlLang, java.lang.String variant, java.util.Locale defaultLocale)
xmlLang
- A valid xml:lang attribute value.variant
- A variant from the Java specs,can be null
defaultLocale
- A default locale to use if the building of the local fails
if a null
defaultLocale is passed, the system default is used.public static java.lang.String attId(java.lang.String baseId, java.lang.String relId)
baseId
- the id of parent documentrelId
- an id relative to the parent document
public static java.net.URL attUrl(java.net.URL refURL, java.lang.String path) throws java.net.MalformedURLException
refURL
- a well-formed URLpath
- a path string it could be relative or absolute
java.net.MalformedURLException
public static java.lang.String getStringFromHashtable(java.lang.String key, java.util.Hashtable table)
key
- The key for the string valuetable
- The hashtable
public static java.lang.String buildRmiName(java.lang.String rmiHost, int rmiPort, java.lang.String appId, java.lang.String dbId)
rmiHost
- The host name or ip address of the machinermiPort
- The port number for the rmi registryappId
- The id of the application to which the RemoteIndex belongsdbId
- The id of the document base to which the RemoteIndex belongs
public static RemoteIndex getRemoteIndex(org.apache.avalon.framework.logger.Logger logger, java.lang.String remoteIndexName) throws SDXException
SDXException
public static java.lang.String joinStrings(java.lang.String[] strings, java.lang.String delimiter)
strings
- The array of stringsdelimiter
- The delimiter, if none desired use null
null
if the array was null or emptypublic static Application getApplication(org.apache.avalon.framework.component.ComponentManager manager, java.util.Hashtable props) throws SDXException
SDXException
public static java.lang.String encodeURL(java.lang.String url, java.lang.String encoding)
public static java.lang.String decodeURL(java.lang.String url, java.lang.String encoding)
public static FieldsDefinition configureFieldList(org.apache.avalon.framework.logger.Logger logger, org.apache.avalon.framework.configuration.Configuration configuration, java.util.Hashtable props) throws org.apache.avalon.framework.configuration.ConfigurationException
org.apache.avalon.framework.configuration.ConfigurationException
public static java.lang.String prefixNodeNameSDX(java.lang.String elemName)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |