org.fcrepo.server.storage
Class DefaultDOManager

java.lang.Object
  extended by org.fcrepo.server.Parameterized
      extended by org.fcrepo.server.Pluggable
          extended by org.fcrepo.server.Module
              extended by org.fcrepo.server.storage.DefaultDOManager
All Implemented Interfaces:
Constants, DOManager, RepositoryReader
Direct Known Subclasses:
GSearchDOManager, RebuildDOManager

public class DefaultDOManager
extends Module
implements DOManager

Manages the reading and writing of digital objects by instantiating an appropriate object reader or writer. Also, manages the object ingest process and the object replication process.

Version:
$Id$
Author:
Chris Wilper

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.fcrepo.common.Constants
Constants.FedoraHome
 
Field Summary
protected  Connection m_connection
           
protected  ConnectionPool m_connectionPool
           
protected  ExternalContentManager m_contentManager
           
protected  FieldSearch m_fieldSearch
           
protected  Management m_management
           
protected  ILowlevelStorage m_permanentStore
           
protected  PIDGenerator m_pidGenerator
           
protected  ResourceIndex m_resourceIndex
           
protected  Set<String> m_retainPIDs
           
protected  String m_storagePool
           
protected  DOTranslator m_translator
           
protected  DOValidator m_validator
           
 
Fields inherited from interface org.fcrepo.common.Constants
ACCESS, ACTION, API, ATOM_APIM1_0, ATOM_ZIP1_1, ATOM1_1, AUDIT, AUDIT1_0, BATCH_MODIFY, BATCH_MODIFY1_1, BE_SECURITY, BE_SECURITY1_0, BINDING_SPEC, DATASTREAM, DC, DISSEMINATOR, DS_COMPOSITE_MODEL, DS_COMPOSITE_MODEL1_0, DS_INPUT_SPEC1_0, DS_INPUT_SPEC1_1, ENVIRONMENT, FCFG, FEDORA, FEDORA_APP_CONTEXT_NAME, FEDORA_DEFAULT_APP_CONTEXT, FEDORA_HOME, FOXML, FOXML1_0, FOXML1_0_LEGACY, FOXML1_1, HTTP_REQUEST, MANAGEMENT, METHOD_MAP, METS, METS_EXT, METS_EXT1_0, METS_EXT1_0_LEGACY, METS_EXT1_1, MODEL, MULGARA, OAI_DC, OAI_DC2_0, OAI_FRIENDS, OAI_FRIENDS2_0, OAI_IDENTIFIER, OAI_IDENTIFIER2_0, OAI_PMH, OAI_PMH2_0, OAI_PROV, OAI_PROV2_0, OBJ_DATASTREAMS1_0, OBJ_HISTORY1_0, OBJ_ITEMS1_0, OBJ_METHODS1_0, OBJ_PROFILE1_0, OBJ_VALIDATION1_0, OBJECT, OLD_XLINK, PID_LIST1_0, RDF, RDF_XSD, RECOVERY, RELS_EXT, RELS_EXT1_0, RELS_INT1_0, REPO_DESC1_0, RESOURCE, SDEF, SDEF_METHOD_MAP1_0, SDEP, SDEP_METHOD_MAP1_0, SDEP_METHOD_MAP1_1, SERVICE_PROFILE, SOAP, SOAP_ENC, SUBJECT, TYPES, VIEW, WSDL, WSDL_HTTP, WSDL_MIME, XACML_POLICY, XACML_POLICY1_0, XLINK, XML_XSD, XMLNS, XSI
 
Constructor Summary
DefaultDOManager(Map<String,String> moduleParameters, Server server, String role)
          Creates a new DefaultDOManager.
 
Method Summary
 void doCommit(boolean cachedObjectRequired, Context context, DigitalObject obj, String logMessage, boolean remove)
          The doCommit method finalizes an ingest/update/remove of a digital object.
 FieldSearchResult findObjects(Context context, String[] resultFields, int maxResults, FieldSearchQuery query)
           
 ConnectionPool getConnectionPool()
           
 String getDefaultExportFormat()
           
 DOValidator getDOValidator()
           
 DOWriter getIngestWriter(boolean cachedObjectRequired, Context context, InputStream in, String format, String encoding, String pid)
          Manages the INGEST process which includes validation of the ingest XML file, deserialization of the XML into a Digital Object instance, setting of properties on the object by the system (dates and states), PID validation or generation, object registry functions, getting a writer for the digital object, and ultimately writing the object to persistent storage via the writer.
 String[] getNextPID(int numPIDs, String namespace)
           Gets a list of the requested next available PIDs.
 DOReader getReader(boolean cachedObjectRequired, Context context, String pid)
          Gets a reader on an an existing digital object.
 String getRepositoryHash()
          Get a "hash" of the repository.
 String[] getRequiredModuleRoles()
          Gets the names of the roles that are required by this Pluggable.
 ServiceDefinitionReader getServiceDefinitionReader(boolean cachedObjectRequired, Context context, String pid)
          Gets a reader on an an existing service definition object.
 ServiceDeploymentReader getServiceDeploymentReader(boolean cachedObjectRequired, Context context, String pid)
          Gets a reader on an an existing service deployment object.
 String getStorageCharacterEncoding()
           
 String getStorageFormat()
           
 DOTranslator getTranslator()
           
 DOWriter getWriter(boolean cachedObjectRequired, Context context, String pid)
          Gets a writer on an an existing object.
 void initModule()
          Gets initial param values.
protected  void initRetainPID()
           
 String[] listObjectPIDs(Context context)
          Gets a list of PIDs (accessible in the given context) of all objects in the repository.
 String lookupDeploymentForCModel(String cModelPid, String sDefPid)
           
 boolean objectExists(String pid)
          Checks the object registry for the given object.
 void postInitModule()
          Second stage of Module initialization.
 void releaseWriter(DOWriter writer)
          Relinquishes control of a DOWriter back to the DOManager.
 void reservePIDs(String[] pidList)
          Reserve a series of PIDs so that they are never used for subsequent PID generations.
 FieldSearchResult resumeFindObjects(Context context, String sessionToken)
           
 void shutdownModule()
          Frees system resources allocated by this Module.
static String toSql(String name, String in)
           
 
Methods inherited from class org.fcrepo.server.Module
getRole, getServer
 
Methods inherited from class org.fcrepo.server.Pluggable
getHelp, getOptionalParameters, getParameterHelp, getRequiredParameters
 
Methods inherited from class org.fcrepo.server.Parameterized
getParameter, getParameter, getParameter, getParameterList, getParameters, getParameters, parameterNames, setParameter, setParameters, setParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_storagePool

protected String m_storagePool

m_pidGenerator

protected PIDGenerator m_pidGenerator

m_translator

protected DOTranslator m_translator

m_permanentStore

protected ILowlevelStorage m_permanentStore

m_validator

protected DOValidator m_validator

m_fieldSearch

protected FieldSearch m_fieldSearch

m_contentManager

protected ExternalContentManager m_contentManager

m_management

protected Management m_management

m_retainPIDs

protected Set<String> m_retainPIDs

m_resourceIndex

protected ResourceIndex m_resourceIndex

m_connectionPool

protected ConnectionPool m_connectionPool

m_connection

protected Connection m_connection
Constructor Detail

DefaultDOManager

public DefaultDOManager(Map<String,String> moduleParameters,
                        Server server,
                        String role)
                 throws ModuleInitializationException
Creates a new DefaultDOManager.

Throws:
ModuleInitializationException
Method Detail

initModule

public void initModule()
                throws ModuleInitializationException
Gets initial param values.

Overrides:
initModule in class Module
Throws:
ModuleInitializationException - If initialization values are invalid or initialization fails for some other reason.

initRetainPID

protected void initRetainPID()

postInitModule

public void postInitModule()
                    throws ModuleInitializationException
Description copied from class: Module
Second stage of Module initialization. This is guaranteed to run after all Modules' initModule() methods have run.

Overrides:
postInitModule in class Module
Throws:
ModuleInitializationException - If initialization values are invalid or initialization fails for some other reason.

lookupDeploymentForCModel

public String lookupDeploymentForCModel(String cModelPid,
                                        String sDefPid)
Specified by:
lookupDeploymentForCModel in interface DOManager

shutdownModule

public void shutdownModule()
Description copied from class: Module
Frees system resources allocated by this Module.

Overrides:
shutdownModule in class Module

releaseWriter

public void releaseWriter(DOWriter writer)
Description copied from interface: DOManager
Relinquishes control of a DOWriter back to the DOManager.

When a DOManager provides a DOWriter, it creates a session lock. This is used to guarantee that there will never be concurrent changes to the same object. To release the session lock, a DOWriter user calls this method.

Specified by:
releaseWriter in interface DOManager
Parameters:
writer - an instance of a digital object writer.

getConnectionPool

public ConnectionPool getConnectionPool()

getDOValidator

public DOValidator getDOValidator()

getRequiredModuleRoles

public String[] getRequiredModuleRoles()
Description copied from class: Pluggable
Gets the names of the roles that are required by this Pluggable.

By default, no roles need to be fulfilled.

Overrides:
getRequiredModuleRoles in class Pluggable
Returns:
The roles.

getStorageFormat

public String getStorageFormat()

getDefaultExportFormat

public String getDefaultExportFormat()

getStorageCharacterEncoding

public String getStorageCharacterEncoding()

getTranslator

public DOTranslator getTranslator()

getReader

public DOReader getReader(boolean cachedObjectRequired,
                          Context context,
                          String pid)
                   throws ServerException
Gets a reader on an an existing digital object.

Specified by:
getReader in interface RepositoryReader
context - The context of this request.
pid - The PID of the object.
Returns:
A reader.
Throws:
ServerException - If anything went wrong.

getServiceDeploymentReader

public ServiceDeploymentReader getServiceDeploymentReader(boolean cachedObjectRequired,
                                                          Context context,
                                                          String pid)
                                                   throws ServerException
Gets a reader on an an existing service deployment object.

Specified by:
getServiceDeploymentReader in interface RepositoryReader
Throws:
ServerException

getServiceDefinitionReader

public ServiceDefinitionReader getServiceDefinitionReader(boolean cachedObjectRequired,
                                                          Context context,
                                                          String pid)
                                                   throws ServerException
Gets a reader on an an existing service definition object.

Specified by:
getServiceDefinitionReader in interface RepositoryReader
Throws:
ServerException

getWriter

public DOWriter getWriter(boolean cachedObjectRequired,
                          Context context,
                          String pid)
                   throws ServerException,
                          ObjectLockedException
Gets a writer on an an existing object.

Specified by:
getWriter in interface DOManager
context - The context of this request.
pid - The PID of the object.
Returns:
A writer, or null if the pid didn't point to an accessible object.
Throws:
ServerException - If anything went wrong.
ObjectLockedException

getIngestWriter

public DOWriter getIngestWriter(boolean cachedObjectRequired,
                                Context context,
                                InputStream in,
                                String format,
                                String encoding,
                                String pid)
                         throws ServerException
Manages the INGEST process which includes validation of the ingest XML file, deserialization of the XML into a Digital Object instance, setting of properties on the object by the system (dates and states), PID validation or generation, object registry functions, getting a writer for the digital object, and ultimately writing the object to persistent storage via the writer.

Specified by:
getIngestWriter in interface DOManager
Parameters:
context -
in - the input stream that is the XML ingest file for a digital object
format - the format of the XML ingest file (e.g., FOXML, Fedora METS)
encoding - the character encoding of the XML ingest file (e.g., UTF-8)
pid - "new" if the system should generate a new PID for the object, otherwise the value of the additional pid parameter for ingests (may be null or any valid pid)
Returns:
a writer.
Throws:
ServerException - If anything went wrong.

doCommit

public void doCommit(boolean cachedObjectRequired,
                     Context context,
                     DigitalObject obj,
                     String logMessage,
                     boolean remove)
              throws ServerException
The doCommit method finalizes an ingest/update/remove of a digital object. The process makes updates the object modified date, stores managed content datastreams, creates the final XML serialization of the digital object, saves the object to persistent storage, updates the object registry, and replicates the object's current version information to the relational db. In the case where it is not a deletion, the session lock (TODO) is released, too. This happens as the result of a writer.commit() call.

Throws:
ServerException

objectExists

public boolean objectExists(String pid)
                     throws StorageDeviceException
Checks the object registry for the given object.

Specified by:
objectExists in interface DOManager
Throws:
StorageDeviceException

listObjectPIDs

public String[] listObjectPIDs(Context context)
                        throws StorageDeviceException
Description copied from interface: RepositoryReader
Gets a list of PIDs (accessible in the given context) of all objects in the repository.

Specified by:
listObjectPIDs in interface RepositoryReader
Throws:
StorageDeviceException

toSql

public static String toSql(String name,
                           String in)

findObjects

public FieldSearchResult findObjects(Context context,
                                     String[] resultFields,
                                     int maxResults,
                                     FieldSearchQuery query)
                              throws ServerException
Specified by:
findObjects in interface DOManager
Throws:
ServerException

resumeFindObjects

public FieldSearchResult resumeFindObjects(Context context,
                                           String sessionToken)
                                    throws ServerException
Specified by:
resumeFindObjects in interface DOManager
Throws:
ServerException

getNextPID

public String[] getNextPID(int numPIDs,
                           String namespace)
                    throws ServerException

Gets a list of the requested next available PIDs. the number of PIDs.

Specified by:
getNextPID in interface DOManager
Parameters:
numPIDs - The number of PIDs to generate. Defaults to 1 if the number is not a positive integer.
namespace - The namespace to be used when generating the PIDs. If null, the namespace defined by the pidNamespace parameter in the fedora.fcfg configuration file is used.
Returns:
An array of PIDs.
Throws:
ServerException - If an error occurs in generating the PIDs.

reservePIDs

public void reservePIDs(String[] pidList)
                 throws ServerException
Description copied from interface: DOManager
Reserve a series of PIDs so that they are never used for subsequent PID generations.

Specified by:
reservePIDs in interface DOManager
Throws:
ServerException

getRepositoryHash

public String getRepositoryHash()
                         throws ServerException
Description copied from interface: DOManager
Get a "hash" of the repository. This value can be compared to a previous value to determine whether the content of the repository has changed. It is not necessary for this value to precisely reflect the state of the repository, but if the repository hasn't changed, subsequent calls should return the same value.

Specified by:
getRepositoryHash in interface DOManager
Throws:
ServerException


Copyright © 2011 DuraSpace. All Rights Reserved.