|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.gcube.contentmanagement.baselayer.BaseLayerUtils
public class BaseLayerUtils
Convinience tools for converting string representation of BasicStorageHint values to something more usable. Throws corresponding exception if hint was not of expected type.
Field Summary | |
---|---|
static int |
CHAR_NOT_FOUND
Constant that represents that a character has not been found inside a String. |
static java.lang.String |
HINT_NAME_COPY_TO_MESSAGE
Deprecated. no longer needed since InMemoryRawContentLocation has
been introduced |
Fields inherited from interface org.gcube.contentmanagement.baselayer.InstantiableManager |
---|
MANAGER_INSTANTIATION_METHOD_NAME |
Constructor Summary | |
---|---|
BaseLayerUtils()
|
Method Summary | |
---|---|
static boolean |
consumeHint(java.lang.String hintName,
BasicStorageHints hints)
Checks if a hint has been set and if so, if the value corresponds to the boolean true |
static boolean |
containsDownloadCredentials(BasicStorageHints downloadHints)
Returns whether the hints define download credentials such as username and/or password |
static boolean |
convertHintToBoolean(java.lang.String hintValue,
java.lang.String hintName)
Convenience method to convert the string value of a hint into a boolean value with proper (explicite) failure handling instead of runtime exceptions. |
static double |
convertHintToDouble(java.lang.String hintValue,
java.lang.String hintName)
Convenience method to convert the string value of a hint into a double value with proper (explicite) failure handling instead of runtime exceptions. |
static float |
convertHintToFloat(java.lang.String hintValue,
java.lang.String hintName)
Convenience method to convert the string value of a hint into a float value with proper (explicite) failure handling instead of runtime exceptions. |
static int |
convertHintToInteger(java.lang.String hintValue,
java.lang.String hintName)
Convenience method to convert the string value of a hint into an integer value with proper (explicite) failure handling instead of runtime exceptions. |
static long |
convertHintToLong(java.lang.String hintValue,
java.lang.String hintName)
Convenience method to convert the string value of a hint into a long value with proper (explicite) failure handling instead of runtime exceptions. |
static RawContentLocation |
getExternalLocation(java.lang.String fileLocation,
BasicStorageHints hints)
Generates a location that can be stored as an external location |
static RawFileContentManager |
getInMemoryManager()
Returns a manager appropriate for in memory handling of content. |
static java.lang.String |
getNewUUID()
Generates a new unique identifier using a singleton instance of UUIDGen |
static int |
getNumberOfProtocolHandlers()
Returns the number of registered protocol handlers |
static RawFileContentManager |
getProtocolHandler(int position)
Returns a protocol handler that is stored at a particular position of the list of handlers. |
static RawFileContentManager |
getProtocolHandlerFor(java.lang.String fileLocation,
BasicStorageHints hints)
Returns a content manager that is able to retrieve a file from the given location. |
static java.lang.Object |
instantiateManager(java.lang.String managerClassName,
java.lang.String[] params,
java.lang.String managerName,
CredentialsProvider provider)
Convenience method to instatiate a manager using the Java reflection |
static RawContentLocation |
makePseudoUniqueLocation(RawContentLocation location,
RawFileContentManager manager,
BasicStorageHints hints)
Generates a location that is to best knowledge unique. |
static void |
registerProtocolHandler(RawFileContentManager manager)
Registers a content manager as protocol handler by adding it to the end of the list of registered handlers |
static void |
registerProtocolHandler(RawFileContentManager manager,
int position)
Registers a content manager as protocol handler by adding it at a particular position of the list of registered handlers |
static void |
registerProtocolHandler(java.lang.String managerClassName,
java.lang.String[] params,
java.lang.String handlerName,
CredentialsProvider provider)
Registers a newly instantiated protocol handler for subsequent use |
static java.lang.String |
removeProtocolUsernamePasswordFromURL(java.lang.String url)
Removes the protocol, username / password information that is contained inside the URL, e.g. |
static boolean |
requestsFor(java.lang.String hintName,
BasicStorageHints hints)
Checks if a hint has been set and if so, if the value corresponds to the boolean true |
static void |
unregisterProtocolHandler(int position)
Removes a protocol handler at a particular position of the list of registered handlers |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int CHAR_NOT_FOUND
String.indexOf(char c)
.
String.indexOf(int)
,
Constant Field Values@Deprecated public static final java.lang.String HINT_NAME_COPY_TO_MESSAGE
InMemoryRawContentLocation
has
been introduced
Constructor Detail |
---|
public BaseLayerUtils()
Method Detail |
---|
public static RawFileContentManager getInMemoryManager()
public static java.lang.Object instantiateManager(java.lang.String managerClassName, java.lang.String[] params, java.lang.String managerName, CredentialsProvider provider) throws BaseLayerException
managerClassName
- the fully qualified class name of the managerparams
- all parameters that should be send to the constructor in
correct order, e.g. as read from a configuration filemanagerName
- the name, that the manager should be givenprovider
- the provider of credentials or null
, if no
credentials can be provided
BaseLayerException
- in any case the instantiation fails, e.g. class unknownpublic static void registerProtocolHandler(java.lang.String managerClassName, java.lang.String[] params, java.lang.String handlerName, CredentialsProvider provider) throws BaseLayerException
managerClassName
- the fully qualified class name of the managerparams
- all parameters that should be send to the constructor in
correct order, e.g. as read from a configuration filehandlerName
- the name, that the manager should be givenprovider
- the provider of credentials or null
, if no
credentials can be provided
BaseLayerException
- in any case the instantiation fails, e.g. class unknownpublic static void registerProtocolHandler(RawFileContentManager manager)
manager
- the manager that should be used to handle a protocol. The
manager itself determines, whether it feels responsible for
some protocol.RawFileContentManager.handles(String)
public static void registerProtocolHandler(RawFileContentManager manager, int position)
manager
- the manager that should be used to handle a protocol. The
manager itself determines, whether it feels responsible for
some protocol.RawFileContentManager.handles(String)
public static void unregisterProtocolHandler(int position)
position
- the postion of the manager that should no longer be used to
handle a protocol.public static RawFileContentManager getProtocolHandler(int position)
position
- the position of the handler
public static int getNumberOfProtocolHandlers()
public static RawFileContentManager getProtocolHandlerFor(java.lang.String fileLocation, BasicStorageHints hints) throws ValueNotValidException
fileLocation
- the location (including protocol) from which the file should
be retrievedhints
- all hints that should be taken into account by the manager to
retrieve the file
ValueNotValidException
- if none of the registered handlers is applicable for the
given file locationpublic static RawContentLocation getExternalLocation(java.lang.String fileLocation, BasicStorageHints hints) throws ValueNotValidException
fileLocation
- the location of the filehints
- all hints that should be used to retrieve the file later on
ValueNotValidException
- if none of the registered handlers is applicable for the
given file locationpublic static boolean convertHintToBoolean(java.lang.String hintValue, java.lang.String hintName) throws ValueNotValidException
hintValue
- the value as a string
ValueNotValidException
- if the string doesn't represent a boolean valueBoolean.parseBoolean(String)
public static int convertHintToInteger(java.lang.String hintValue, java.lang.String hintName) throws ValueNotValidException
hintValue
- the value as a string
ValueNotValidException
- if the string doesn't represent a integer valueInteger.parseInt(String)
public static long convertHintToLong(java.lang.String hintValue, java.lang.String hintName) throws ValueNotValidException
hintValue
- the value as a string
ValueNotValidException
- if the string doesn't represent a long valueLong.parseLong(String)
public static float convertHintToFloat(java.lang.String hintValue, java.lang.String hintName) throws ValueNotValidException
hintValue
- the value as a string
ValueNotValidException
- if the string doesn't represent a float valueFloat.parseFloat(String)
public static double convertHintToDouble(java.lang.String hintValue, java.lang.String hintName) throws ValueNotValidException
hintValue
- the value as a string
ValueNotValidException
- if the string doesn't represent a double valueDouble.parseDouble(String)
public static boolean requestsFor(java.lang.String hintName, BasicStorageHints hints) throws ValueNotValidException
This method has not been placed in BasicStorageHints, because Exception handling is not as layer independend as it should be to place method directly there.
hintName
- the name of a hinthints
- the hints to analyze
ValueNotValidException
- if hint value was set to a non-boolean valueBasicStorageHints#HINT_NAME_APPEND_CONTENT
public static boolean consumeHint(java.lang.String hintName, BasicStorageHints hints) throws ValueNotValidException
hintName
- the name of a hinthints
- the hints to analyze
ValueNotValidException
- if hint value was set to a non-boolean valueBasicStorageHints#HINT_NAME_APPEND_CONTENT
public static boolean containsDownloadCredentials(BasicStorageHints downloadHints)
downloadHints
- the hints to use for downloading
public static java.lang.String getNewUUID()
UUIDGen.nextUUID()
public static java.lang.String removeProtocolUsernamePasswordFromURL(java.lang.String url)
url
- the URL from which this information should get removed
public static RawContentLocation makePseudoUniqueLocation(RawContentLocation location, RawFileContentManager manager, BasicStorageHints hints) throws BaseLayerException
location
- the location that should be made uniquemanager
- the manager used to check whether the location existshints
- hints that should be passed to the content manager
BaseLayerException
- in case a problem occurs in calling the content manager to
check whether the location existsRawFileContentManager.existsBinaryContent(RawContentLocation,
BasicStorageHints)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |