org.gcube.contentmanagement.baselayer.rdbmsImpl
Class GenericJDBCDatabase

java.lang.Object
  extended by org.gcube.contentmanagement.baselayer.rdbmsImpl.GenericJDBCDatabase
All Implemented Interfaces:
InstantiableManager, RawFileContentManager, RelationshipAndPropertyManager

public class GenericJDBCDatabase
extends java.lang.Object
implements RawFileContentManager, RelationshipAndPropertyManager, InstantiableManager

Manager for raw file content and relationships and properties backed by a relational database. It tries to be as generic as possible and therefore SQL standard compliant to work with as many RDBMSs as possible. This goal is not easy to achieve, in particular since the handling of BLOBs has been introduced in the SQL standard comparably late and therefore not all databases comply to the standard entirely. It might be necessary to subclass or customize this class for particular databases, that do not work right-away. It has been thoroughly tested and should work fine with Apache Derby 10.1.x and 10.2, MySQL 4.1.x and 5.0. For PostgreSQL 7.3 and prior, raw content handling has been disabled since this did not follow the standard for BLOBs and provides a custom interface that would be should be used in a subclass. Starting with PostgreSQL 8.0, the commonly used BLOB interface is provided and this generic implementation should provide full support for raw content and relationships and properties - but this has not been thoroughly tested.

Author:
michaelspringmann

Field Summary
 
Fields inherited from interface org.gcube.contentmanagement.baselayer.InstantiableManager
MANAGER_INSTANTIATION_METHOD_NAME
 
Constructor Summary
GenericJDBCDatabase(java.lang.String dataSourceName, java.lang.String driverClassName, java.lang.String sourceURL)
          Constructs the manager given the number of maximum parallel connections
GenericJDBCDatabase(java.lang.String dataSourceName, java.lang.String driverClassName, java.lang.String driverURL, java.lang.String maxParallelConnections)
          Constructs the manager given the number of maximum parallel connections
 
Method Summary
 void addLinkContentLocation(java.lang.String oid, RawContentLocation location)
          Registers a location for the content of the information object
 void addReference(java.lang.String sourceoid, java.lang.String targetoid, java.lang.String role, java.lang.String secondaryRole, long position, java.lang.String propagationRule)
          Adds a new reference between two information objects.
 long countReferences(java.lang.String oid, boolean isSource, java.lang.String role, java.lang.String secondaryRole)
          Counts the references of an object
 java.lang.String createInfoObject(java.lang.String name, java.lang.String type, BasicStorageHints hints)
          Creates a new information object
 boolean deleteBinaryContent(RawContentLocation rcl, BasicStorageHints hints)
          Removes the binary content from storage
 void ensureResponsibleFor(RawContentLocation rcl)
           
 boolean existsBinaryContent(RawContentLocation rcl, BasicStorageHints hints)
          Checks whether there is content associated with this content id
 boolean existsInfoObject(java.lang.String oid)
          Checks, whether an information object with the given ID exists.
 boolean existsReference(java.lang.String sourceoid, java.lang.String targetoid, java.lang.String role, java.lang.String secondaryRole)
          Check if a reference exists
 BaseLayerStream getBinaryContent(RawContentLocation rcl, BasicStorageHints hints)
          Opens the content for reading and passes the input stream to the caller
WARNING: This method will leave the database connection open, to give direct access to te BLOB field.
 java.sql.Connection getConnection()
          Convenience method to retrieve a connection from pool including proper failure handling.
 java.lang.String getDataProvider()
           
static java.lang.String getExpliciteMapping(int javaSQLType)
          Returns mapped type for mappings that have been set explicitely.
 BasicInfoObjectDescription getInfoObjectDescription(java.lang.String oid)
          Retrieves an existing information object with all available information
 BasicInfoObjectDescription getInfoObjectDescription(java.lang.String oid, boolean includeProperties, boolean includeReferences, boolean includeReferred)
          Retrieves an existing information object with some tuning parameters, to remove unrequired information
static GenericJDBCDatabase getManagerInstance(java.lang.String[] params, java.lang.String managerName)
          Generic factory method that returns an instance responsible for a particular directory
 java.lang.String getNativeType(int javaSQLType)
          Determines the appropriate datatype for the currently used database for a given Java type.
In some rare cases the database driver may not declare a mapping.
 BasicPropertyDescription getProperty(java.lang.String oid, java.lang.String name)
          Retrieves a particular property of an information object
 BasicReferenceDescription getReference(java.lang.String sourceoid, java.lang.String targetoid)
          Retrieves a single reference
 java.lang.String getUniqueStorageLocationIDFor(java.lang.String objectID)
           
 boolean handles(java.lang.String dataprovider)
          Checks whether the RawFileContentManager can handle this data.
 boolean hasProperty(java.lang.String oid, java.lang.String name)
          Returnes whether an information object has a particular property set
 boolean hasRawContent(java.lang.String oid)
          Returns whether there exists raw content associated with an information object
static boolean isBlacklistedDatatype(java.lang.String dbDataType, java.lang.String databaseProductName, java.lang.String databaseProductVersion)
          Checks whether a type is in the list of types that shoulod be avoided due to known issues.
 boolean isPerformAdditionalChecks()
           
 RawContentLocation makePermanentLocation(RawContentLocation currentLocation, BasicStorageHints hints)
          Returns a raw location, which can be stored and retrieved later without the need to pass again all the hints.
 void releaseConnection(java.sql.Connection connection)
          Convenience method to give a connection back to the pool including proper failure handling.
 boolean removeAllRawContentOf(java.lang.String oid, BasicStorageHints hints)
          Unregisters all locations for the content of the information object and deltes the content physically.
 boolean removeInfoObject(java.lang.String oid)
          Deletes an information object.
 boolean removeLinkContentLocation(RawContentLocation location)
          Unregisters a location for the content of the information object
 boolean removeReference(java.lang.String sourceoid, java.lang.String targetoid, java.lang.String role, java.lang.String secondaryRole)
          Deletes any reference with having the given parameters.
To insure consistency, this method will propagate any defined deletion event.
 java.util.List<RawContentLocation> retrieveObjectContentLocations(java.lang.String oid)
          Adds to the list all locations known for a particular object
 java.util.Map<java.lang.String,BasicPropertyDescription> retrieveObjectProperties(java.lang.String oid)
          Retrieves all properties of an information object
 java.util.List<java.lang.String> retrieveOIDByProperty(java.lang.String name, java.lang.String value)
          Deprecated. prefer #retrieveOIDByProperty(String, String, Collection) because of more effecient handling
 java.util.List<BasicReferenceDescription> retrieveReferences(java.lang.String sourceoid, java.lang.String role, java.lang.String secondaryRole)
          Adds all references from this object to the list
 java.util.List<BasicReferenceDescription> retrieveReferencesOrderedByPosition(java.lang.String sourceoid, java.lang.String role, java.lang.String secondaryRole)
          Adds all references from this object to the list
 java.util.List<BasicReferenceDescription> retrieveReferred(java.lang.String targetoid, java.lang.String role, java.lang.String secondaryRole)
          Retrieves all references which point to this target object.
 java.util.List<java.lang.String> retrieveReferredSourceOIDs(java.lang.String targetoid, java.lang.String role, java.lang.String secondaryRole)
          Adds all source object IDs to this object to the list
 java.util.List<java.lang.String> retrieveReferredTargetOIDs(java.lang.String sourceoid, java.lang.String role, java.lang.String secondaryRole)
          Retrieves all object OIDs of information object, which have a reference from this source object.
 RawContentLocation saveBinaryContent(java.lang.String uniqueStorageID, BaseLayerStream binaryFileContent, BasicStorageHints hints)
          Saves the passed binary content in the managed resource.
 void setPerformAdditionalChecks(boolean performAdditionalChecks)
           
 void setProperty(java.lang.String oid, java.lang.String name, java.lang.String type, java.lang.String value)
          Sets the storage property of a given name for a particular information object.
 boolean supportsAppending()
          Tells whether this content manager supports appending content in addition to overwriting the content when storing
 boolean unsetProperty(java.lang.String oid, java.lang.String name)
          Removes a property (or all properties) of an information object
 void updateLinkContentLocations(java.lang.String oid, RawContentLocation newestLocation)
          Updates the locations for the content of the information object
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericJDBCDatabase

public GenericJDBCDatabase(java.lang.String dataSourceName,
                           java.lang.String driverClassName,
                           java.lang.String driverURL,
                           java.lang.String maxParallelConnections)
                    throws BaseLayerException
Constructs the manager given the number of maximum parallel connections

Parameters:
dataSourceName - a user-defined name for the datasource that will get used e.g. as data provider for raw content locations
driverClassName - the class of the JDBC driver
driverURL - the URL of the JDBC connection String
maxParallelConnections - the number of maximum parallel connections that should be ued concurrently in the connection pool
Throws:
BaseLayerException - if something goes wrong

GenericJDBCDatabase

public GenericJDBCDatabase(java.lang.String dataSourceName,
                           java.lang.String driverClassName,
                           java.lang.String sourceURL)
                    throws BaseLayerException
Constructs the manager given the number of maximum parallel connections

Parameters:
dataSourceName - a user-defined name for the datasource that will get used e.g. as data provider for raw content locations
driverClassName - the class of the JDBC driver
sourceURL - the URL of the JDBC connection String
Throws:
BaseLayerException - if something goes wrong
Method Detail

getConnection

public java.sql.Connection getConnection()
                                  throws TemporaryUnavailableException
Convenience method to retrieve a connection from pool including proper failure handling.

Returns:
a connection which can be used for database operations
Throws:
BaseLayerException - if connection cannot be established, e.g. because number of concurrent connections and an exceeded timeout
TemporaryUnavailableException

releaseConnection

public void releaseConnection(java.sql.Connection connection)
Convenience method to give a connection back to the pool including proper failure handling. If there are any uncommitted changes, they will be lost.

Parameters:
connection - the connection to add to the pool

saveBinaryContent

public RawContentLocation saveBinaryContent(java.lang.String uniqueStorageID,
                                            BaseLayerStream binaryFileContent,
                                            BasicStorageHints hints)
                                     throws BaseLayerException
Saves the passed binary content in the managed resource. If the resource did previously exist, it is updated and the old content is lost. If the resource did not exist, it will be newly created.

Specified by:
saveBinaryContent in interface RawFileContentManager
Parameters:
binaryFileContent - the content to store
uniqueStorageID - a unique ID to access the content
hints - the hints that should be used
Returns:
the RawContentLocation where the content is now accessible
Throws:
BaseLayerException - in case of failure of underlying storage system

getBinaryContent

public BaseLayerStream getBinaryContent(RawContentLocation rcl,
                                        BasicStorageHints hints)
                                 throws BaseLayerException
Opens the content for reading and passes the input stream to the caller
WARNING: This method will leave the database connection open, to give direct access to te BLOB field. Therefore it is absolutely necessary to close the connection as soon as reading of content is finished. This can easily be done by calling the dispose() method of BaseLayerStream.

Specified by:
getBinaryContent in interface RawFileContentManager
Parameters:
rcl - the location to access the content
hints - the hints that should be used
Returns:
the content stored in the managed resource
Throws:
BaseLayerException - in case of failure of underlying storage system

deleteBinaryContent

public boolean deleteBinaryContent(RawContentLocation rcl,
                                   BasicStorageHints hints)
                            throws BaseLayerException
Removes the binary content from storage

Specified by:
deleteBinaryContent in interface RawFileContentManager
Parameters:
rcl - the RawContentLocation where the content is accessible
hints - the hints that should be used
Returns:
true, if content has been deleted successfully; false if the content did not exist and therefore the operation had no effect.
Throws:
BaseLayerException - in case of failure of underlying storage system

existsBinaryContent

public boolean existsBinaryContent(RawContentLocation rcl,
                                   BasicStorageHints hints)
                            throws BaseLayerException
Checks whether there is content associated with this content id

Specified by:
existsBinaryContent in interface RawFileContentManager
Parameters:
rcl - the location of the content
Returns:
true, if there is raw content; false otherwise
Throws:
BaseLayerException - in case of failure of underlying storage system

createInfoObject

public java.lang.String createInfoObject(java.lang.String name,
                                         java.lang.String type,
                                         BasicStorageHints hints)
                                  throws BaseLayerException
Creates a new information object

Specified by:
createInfoObject in interface RelationshipAndPropertyManager
Parameters:
name - a human readable name (does not need to be unique, can also be null)
type - the type of the information object
hints - hints that should be taken into account, e.g. BasicStorageHints#HINT_NAME_PREDEFINED_ID.
Returns:
the object ID of the new information object
Throws:
BaseLayerException - if something goes wrong

getInfoObjectDescription

public BasicInfoObjectDescription getInfoObjectDescription(java.lang.String oid)
                                                    throws BaseLayerException
Retrieves an existing information object with all available information

Specified by:
getInfoObjectDescription in interface RelationshipAndPropertyManager
Parameters:
oid - the object ID of the object
Returns:
the description
Throws:
BaseLayerException - if something goes wrong

getInfoObjectDescription

public BasicInfoObjectDescription getInfoObjectDescription(java.lang.String oid,
                                                           boolean includeProperties,
                                                           boolean includeReferences,
                                                           boolean includeReferred)
                                                    throws BaseLayerException
Retrieves an existing information object with some tuning parameters, to remove unrequired information

Specified by:
getInfoObjectDescription in interface RelationshipAndPropertyManager
Parameters:
oid - the object ID of the object
includeProperties - if set to true, properties will be retrieved; otherwise properties will not be retrieved
includeReferences - if set to true, references to other info objects will be retrieved; otherwise references will not be retrieved
includeReferred - if set to true, references from other info objects will be retrieved; otherwise those references will not be retrieved
Returns:
the description
Throws:
BaseLayerException - if something goes wrong

existsInfoObject

public boolean existsInfoObject(java.lang.String oid)
                         throws BaseLayerException
Checks, whether an information object with the given ID exists. Since the ID is supposed to be UUID, the main purpose is to ensure that some other operation, e.g. removal of an object finished correctly.

Specified by:
existsInfoObject in interface RelationshipAndPropertyManager
Parameters:
oid - the object ID of the object
Returns:
true, if object exists; false otherwise.
Throws:
BaseLayerException - if something goes wrong

removeInfoObject

public boolean removeInfoObject(java.lang.String oid)
                         throws BaseLayerException
Deletes an information object. This will trigger propagation of deletions if corresponding relations exist.

Specified by:
removeInfoObject in interface RelationshipAndPropertyManager
Parameters:
oid - the object ID of the object that should be deleted
Returns:
true, if object has been deleted successfully; false if the object did not exist and therefore no change to database happened
Throws:
BaseLayerException - if something goes wrong

removeAllRawContentOf

public boolean removeAllRawContentOf(java.lang.String oid,
                                     BasicStorageHints hints)
                              throws BaseLayerException
Unregisters all locations for the content of the information object and deltes the content physically.

Specified by:
removeAllRawContentOf in interface RelationshipAndPropertyManager
Parameters:
oid - the object ID of the object who's raw content should be deleted
Returns:
true, if the state of the database changed as an effect of the operation
Throws:
BaseLayerException - if something goes wrong

addReference

public void addReference(java.lang.String sourceoid,
                         java.lang.String targetoid,
                         java.lang.String role,
                         java.lang.String secondaryRole,
                         long position,
                         java.lang.String propagationRule)
                  throws BaseLayerException
Adds a new reference between two information objects. A reference is always directed and can define propagation rules for deletion of items.

Specified by:
addReference in interface RelationshipAndPropertyManager
Parameters:
sourceoid - the object ID of the starting information object of the relation
targetoid - the object Id of the referenced information object
role - the role of the information object (sourceoid) with respect to this reference
position - an attribute to allow for position preserving representation, set to ReferenceDescription.UNDEFINED_POSITION if not in use.
secondaryRole - similar to role, but for the secondary role used by Metadata Catalog
propagationRule - rule for propagation of deletion.
Throws:
BaseLayerException - if something goes wrong
See Also:
org.gcube.contentmanagement.layerindependent.descriptions.BasicReferenceDescription

removeReference

public boolean removeReference(java.lang.String sourceoid,
                               java.lang.String targetoid,
                               java.lang.String role,
                               java.lang.String secondaryRole)
                        throws BaseLayerException
Deletes any reference with having the given parameters.
To insure consistency, this method will propagate any defined deletion event.

Specified by:
removeReference in interface RelationshipAndPropertyManager
Parameters:
sourceoid - the object ID of the starting information object of the relation
targetoid - the object Id of the referenced information object
role - the role of the information object (sourceoid) with respect this reference. Can be set to ReferenceDescription.ANY_ROLE to match all possible values of role.
secondaryRole - similar to role, but for the secondary role used by Metadata Catalog
Returns:
true, if reference has been deleted successfully; false if no such reference existed and therefore the operation had no effect.
Throws:
BaseLayerException - if something goes wrong

countReferences

public long countReferences(java.lang.String oid,
                            boolean isSource,
                            java.lang.String role,
                            java.lang.String secondaryRole)
                     throws BaseLayerException
Counts the references of an object

Specified by:
countReferences in interface RelationshipAndPropertyManager
Parameters:
oid - the oid of the known object
isSource - true, if oid is the object ID of the source object, false if oid is the target oid
role - the role, or ReferenceDescription.ANY_ROLE
secondaryRole - similar to role, but for the secondary role used by Metadata Catalog
Returns:
the number of references that the object has
Throws:
java.sql.SQLException
BaseLayerException - if something goes wrong

retrieveReferences

public java.util.List<BasicReferenceDescription> retrieveReferences(java.lang.String sourceoid,
                                                                    java.lang.String role,
                                                                    java.lang.String secondaryRole)
                                                             throws BaseLayerException
Adds all references from this object to the list

Specified by:
retrieveReferences in interface RelationshipAndPropertyManager
Parameters:
sourceoid - the oid of the source object
role - the role, or ReferenceDescription.ANY_ROLE
secondaryRole - similar to role, but for the secondary role used by Metadata Catalog
refDescList - the list to which the references should be added
Throws:
java.sql.SQLException
BaseLayerException - if something goes wrong

getReference

public BasicReferenceDescription getReference(java.lang.String sourceoid,
                                              java.lang.String targetoid)
                                       throws BaseLayerException
Retrieves a single reference

Specified by:
getReference in interface RelationshipAndPropertyManager
Parameters:
sourceoid - the object ID of the starting information object of the relation
targetoid - the object ID of the target information object of the relation
Returns:
the reference
Throws:
BaseLayerException - if something goes wrong

retrieveReferencesOrderedByPosition

public java.util.List<BasicReferenceDescription> retrieveReferencesOrderedByPosition(java.lang.String sourceoid,
                                                                                     java.lang.String role,
                                                                                     java.lang.String secondaryRole)
                                                                              throws BaseLayerException
Adds all references from this object to the list

Specified by:
retrieveReferencesOrderedByPosition in interface RelationshipAndPropertyManager
Parameters:
sourceoid - the oid of the source object
role - the role, or ReferenceDescription.ANY_ROLE
secondaryRole - similar to role, but for the secondary role used by Metadata Catalog
Returns:
the list of references
Throws:
java.sql.SQLException
BaseLayerException - if something goes wrong

retrieveReferred

public java.util.List<BasicReferenceDescription> retrieveReferred(java.lang.String targetoid,
                                                                  java.lang.String role,
                                                                  java.lang.String secondaryRole)
                                                           throws BaseLayerException
Retrieves all references which point to this target object.

Specified by:
retrieveReferred in interface RelationshipAndPropertyManager
Parameters:
targetoid - the object Id of the referenced information object
role - the role of the information object (sourceoid) with respect this reference. Can be set to BasicReferenceDescription.ANY_ROLE to match all possible values of role.
secondaryRole - similar to role, but for the secondary role used by Metadata Catalog
refDescriptions - a collection to which elements of type BasicReferenceDescription will be added
Returns:
a list of elements of type BasicReferenceDescription
Throws:
BaseLayerException - if something goes wrong

retrieveReferredSourceOIDs

public java.util.List<java.lang.String> retrieveReferredSourceOIDs(java.lang.String targetoid,
                                                                   java.lang.String role,
                                                                   java.lang.String secondaryRole)
                                                            throws BaseLayerException
Adds all source object IDs to this object to the list

Specified by:
retrieveReferredSourceOIDs in interface RelationshipAndPropertyManager
Parameters:
targetoid - the oid of the target object
role - the role, or ReferenceDescription.ANY_ROLE
secondaryRole - similar to role, but for the secondary role used by Metadata Catalog
refDescList - the list to which the references should be added
Returns:
Throws:
java.sql.SQLException
BaseLayerException - if something goes wrong

retrieveReferredTargetOIDs

public java.util.List<java.lang.String> retrieveReferredTargetOIDs(java.lang.String sourceoid,
                                                                   java.lang.String role,
                                                                   java.lang.String secondaryRole)
                                                            throws BaseLayerException
Retrieves all object OIDs of information object, which have a reference from this source object.

Specified by:
retrieveReferredTargetOIDs in interface RelationshipAndPropertyManager
Parameters:
sourceoid - the object Id of the referenced information object
role - the role of the information object (sourceoid) with respect this reference. Can be set to BasicReferenceDescription.ANY_ROLE to match all possible values of role.
secondaryRole - similar to role, but for the secondary role used by Metadata Catalog
oids - a collection to which elements of type String will be added
Returns:
the oid list.
Throws:
BaseLayerException - if something goes wrong

retrieveObjectProperties

public java.util.Map<java.lang.String,BasicPropertyDescription> retrieveObjectProperties(java.lang.String oid)
                                                                                  throws BaseLayerException
Retrieves all properties of an information object

Specified by:
retrieveObjectProperties in interface RelationshipAndPropertyManager
Parameters:
oidthe - object ID of the information object
Returns:
the object properties a map, to which each PropertyDescription will be added, the key is the property name
Throws:
BaseLayerException

retrieveOIDByProperty

public java.util.List<java.lang.String> retrieveOIDByProperty(java.lang.String name,
                                                              java.lang.String value)
                                                       throws BaseLayerException
Deprecated. prefer #retrieveOIDByProperty(String, String, Collection) because of more effecient handling

Retrieves all object IDs of information object for which a particular property value has been set

Specified by:
retrieveOIDByProperty in interface RelationshipAndPropertyManager
Parameters:
name - the name of the property
value - the value of the property
Returns:
an array of object OIDs
Throws:
BaseLayerException - if something goes wrong

setProperty

public void setProperty(java.lang.String oid,
                        java.lang.String name,
                        java.lang.String type,
                        java.lang.String value)
                 throws BaseLayerException
Sets the storage property of a given name for a particular information object.

If this property already exists, it will be updated. If not, it will be added with the given values.

Specified by:
setProperty in interface RelationshipAndPropertyManager
Parameters:
oid - the object ID of the information object
name - the name of the property (use prefixes, e.g. namespace prefixes to disambiguate)
type - the type of the value of the property
value - the value of the property
Throws:
BaseLayerException - if something goes wrong

getProperty

public BasicPropertyDescription getProperty(java.lang.String oid,
                                            java.lang.String name)
                                     throws BaseLayerException
Retrieves a particular property of an information object

Specified by:
getProperty in interface RelationshipAndPropertyManager
Parameters:
oid - the object ID of the information object
name - the name of the property
Returns:
a PropertyDescription of the defined property
Throws:
ObjectNotFoundException - if either the OID is invalid or there is no property with this name defined for this information object
BaseLayerException - if something goes wrong

hasProperty

public boolean hasProperty(java.lang.String oid,
                           java.lang.String name)
                    throws BaseLayerException
Returnes whether an information object has a particular property set

Specified by:
hasProperty in interface RelationshipAndPropertyManager
Parameters:
oid - the object ID of the information object
name - the name of the property
Returns:
true, if the property is set
Throws:
ObjectNotFoundException - if the OID is invalid
BaseLayerException - if something goes wrong

existsReference

public boolean existsReference(java.lang.String sourceoid,
                               java.lang.String targetoid,
                               java.lang.String role,
                               java.lang.String secondaryRole)
                        throws BaseLayerException
Description copied from interface: RelationshipAndPropertyManager
Check if a reference exists

Specified by:
existsReference in interface RelationshipAndPropertyManager
Parameters:
sourceoid - the object ID of the starting information object of the relation
targetoid - the object Id of the referenced information object
role - the role of the information object (sourceoid) with respect to this reference
secondaryRole - similar to role, but for the secondary role used by Metadata Catalog
Returns:
true if the reference has been found, false otherwise.
Throws:
BaseLayerException - if something goes wrong
See Also:
org.gcube.contentmanagement.layerindependent.descriptions.BasicReferenceDescription

unsetProperty

public boolean unsetProperty(java.lang.String oid,
                             java.lang.String name)
                      throws BaseLayerException
Removes a property (or all properties) of an information object

Specified by:
unsetProperty in interface RelationshipAndPropertyManager
Parameters:
oid - the object ID of the information object
name - the name of the property, or PropertyDescription.ANY_NAME for all
Returns:
false, If the object didn't have such a property; otherwise true
Throws:
BaseLayerException - if something goes wrong

handles

public boolean handles(java.lang.String dataprovider)
Checks whether the RawFileContentManager can handle this data.

This means that it can handle the requests for content stored at this dataprovider. In the ideal case, this also checks if it has all required access rights. But this cannot be enforced as a strong requirement before the actual calls take place.

Specified by:
handles in interface RawFileContentManager
Parameters:
dataprovider -
Returns:
true, if it can do, false otherwise

isPerformAdditionalChecks

public boolean isPerformAdditionalChecks()

setPerformAdditionalChecks

public void setPerformAdditionalChecks(boolean performAdditionalChecks)

addLinkContentLocation

public void addLinkContentLocation(java.lang.String oid,
                                   RawContentLocation location)
                            throws BaseLayerException
Registers a location for the content of the information object

Specified by:
addLinkContentLocation in interface RelationshipAndPropertyManager
Parameters:
oid - the object ID of the information object
location - the location where the content resides
Throws:
BaseLayerException - if something goes wrong

updateLinkContentLocations

public void updateLinkContentLocations(java.lang.String oid,
                                       RawContentLocation newestLocation)
                                throws BaseLayerException
Updates the locations for the content of the information object

Specified by:
updateLinkContentLocations in interface RelationshipAndPropertyManager
Parameters:
oid - the object ID of the information object
newestLocation - the location where most recent version of the content resides
Throws:
BaseLayerException - if something goes wrong

removeLinkContentLocation

public boolean removeLinkContentLocation(RawContentLocation location)
                                  throws BaseLayerException
Unregisters a location for the content of the information object

Specified by:
removeLinkContentLocation in interface RelationshipAndPropertyManager
Parameters:
location - the location where the content no longer resides
Returns:
true, if location has been deleted successfully; false if the location did not exist and therefore the operation had no effect.
Throws:
BaseLayerException - if something goes wrong

retrieveObjectContentLocations

public java.util.List<RawContentLocation> retrieveObjectContentLocations(java.lang.String oid)
                                                                  throws BaseLayerException
Adds to the list all locations known for a particular object

Specified by:
retrieveObjectContentLocations in interface RelationshipAndPropertyManager
Parameters:
oid - the oid of the info object or UNLINKED_RAW_CONTENT
Returns:
the object content locations
Throws:
java.sql.SQLException
BaseLayerException - if something goes wrong

hasRawContent

public boolean hasRawContent(java.lang.String oid)
                      throws BaseLayerException
Returns whether there exists raw content associated with an information object

Specified by:
hasRawContent in interface RelationshipAndPropertyManager
Parameters:
oid - the object ID of the information object
Returns:
true, if there is raw content; false otherwise
Throws:
BaseLayerException - if something goes wrong

ensureResponsibleFor

public void ensureResponsibleFor(RawContentLocation rcl)
                          throws ValueNotValidException
Throws:
ValueNotValidException

getDataProvider

public java.lang.String getDataProvider()
Specified by:
getDataProvider in interface RawFileContentManager
Returns:
a string identifying this data source

getNativeType

public java.lang.String getNativeType(int javaSQLType)
Determines the appropriate datatype for the currently used database for a given Java type.
In some rare cases the database driver may not declare a mapping. If no explicite mapping is defined, null will be returned.

Parameters:
javaSQLType - the Java datatype according to java.sql.Types
Returns:
the best matching datatype of the database or null, if no mapping could be identified.

isBlacklistedDatatype

public static boolean isBlacklistedDatatype(java.lang.String dbDataType,
                                            java.lang.String databaseProductName,
                                            java.lang.String databaseProductVersion)
Checks whether a type is in the list of types that shoulod be avoided due to known issues.

Parameters:
dbDataType - the String as used in SQL DDL statements
databaseProductName - the database product name as in the connetion metadata
databaseProductVersion - the database product version as in the connection metadata
Returns:
true, if this type should not be used; false otherwise.

getExpliciteMapping

public static java.lang.String getExpliciteMapping(int javaSQLType)
Returns mapped type for mappings that have been set explicitely.

Parameters:
javaSQLType - the Java SQL Type
Returns:
the String to be used in SQL DDL statements

supportsAppending

public boolean supportsAppending()
Tells whether this content manager supports appending content in addition to overwriting the content when storing

Specified by:
supportsAppending in interface RawFileContentManager
Returns:
true, if appending is supported
See Also:
BasicStorageHints#HINT_NAME_APPEND_CONTENT

makePermanentLocation

public RawContentLocation makePermanentLocation(RawContentLocation currentLocation,
                                                BasicStorageHints hints)
                                         throws ValueNotValidException
Returns a raw location, which can be stored and retrieved later without the need to pass again all the hints.

This is of particular interest for username / password combinations.

Specified by:
makePermanentLocation in interface RawFileContentManager
Parameters:
currentLocation - the location, where content can be accessed currently (may require information from the hints)
hints - hints, that may be needed to request the content
Returns:
a location which can be accessed without providing again the hints. This may not always be possible.
Throws:
ValueNotValidException - If some hints was not defined correctly or there is no possibility to include that in the permanent location.

getManagerInstance

public static GenericJDBCDatabase getManagerInstance(java.lang.String[] params,
                                                     java.lang.String managerName)
                                              throws BaseLayerException
Generic factory method that returns an instance responsible for a particular directory

Parameters:
params - the first String contains the directory that will be managed. If array is empty, the manager will be able to manage any directory
managerName - the name of the manager (currently not in use)
Returns:
the manager
Throws:
BaseLayerException - if location is not manageable by this kind of manager, e.g. because directory does not exist

getUniqueStorageLocationIDFor

public java.lang.String getUniqueStorageLocationIDFor(java.lang.String objectID)
Specified by:
getUniqueStorageLocationIDFor in interface RawFileContentManager