fedora.server.storage
Class DefaultDOManager

java.lang.Object
  extended byfedora.server.Parameterized
      extended byfedora.server.Pluggable
          extended byfedora.server.Module
              extended byfedora.server.storage.DefaultDOManager
All Implemented Interfaces:
DOManager, Logging, RepositoryReader

public class DefaultDOManager
extends Module
implements DOManager

Title: DefaultDOManager.java

Description: 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.

-----------------------------------------------------------------------------

License and Copyright: The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/.

Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.

The entire file consists of original code. Copyright © 2002-2005 by The Rector and Visitors of the University of Virginia and Cornell University. All rights reserved.

-----------------------------------------------------------------------------

Version:
$Id: DefaultDOManager.java,v 1.135 2005/01/18 20:21:14 eddie Exp $
Author:
cwilper@cs.cornell.edu

Field Summary
static java.lang.String DEFAULT_STATE
           
 
Constructor Summary
DefaultDOManager(java.util.Map moduleParameters, Server server, java.lang.String role)
          Creates a new DefaultDOManager.
 
Method Summary
 void doCommit(Context context, DigitalObject obj, java.lang.String logMessage, boolean remove)
          The doCommit method finalizes an ingest/update/remove of a digital object.
 FieldSearchResult findObjects(Context context, java.lang.String[] resultFields, int maxResults, FieldSearchQuery query)
           
 BDefReader getBDefReader(Context context, java.lang.String pid)
          Gets a reader on an an existing behavior definition object.
 BMechReader getBMechReader(Context context, java.lang.String pid)
          Gets a reader on an an existing behavior mechanism object.
 ConnectionPool getConnectionPool()
           
 ILowlevelStorage getDatastreamStore()
           
 java.lang.String getDefaultExportFormat()
           
 DOValidator getDOValidator()
           
 DOWriter getIngestWriter(Context context, java.io.InputStream in, java.lang.String format, java.lang.String encoding, boolean newPid)
          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.
 java.lang.String[] getNextPID(int numPIDs, java.lang.String namespace)
           Gets a list of the requested next available PIDs. the number of PIDs.
 ILowlevelStorage getObjectStore()
           
 java.lang.String getOwnerId(java.lang.String pid)
           
 DOReader getReader(Context context, java.lang.String pid)
          Gets a reader on an an existing digital object.
 DOReplicator getReplicator()
           
 java.lang.String[] getRequiredModuleRoles()
          Gets the names of the roles that are required by this Pluggable.
 java.lang.String getStorageCharacterEncoding()
           
 java.lang.String getStorageFormat()
           
 ILowlevelStorage getTempStore()
           
 fedora.server.storage.translation.DOTranslator getTranslator()
           
 DOWriter getWriter(Context context, java.lang.String pid)
          Gets a writer on an an existing object.
 void initModule()
          Gets initial param values.
 java.lang.String[] listObjectPIDs(Context context)
          Gets a list of PIDs (accessible in the given context) of all objects in the repository.
 boolean objectExists(java.lang.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.
 FieldSearchResult resumeFindObjects(Context context, java.lang.String sessionToken)
           
static java.lang.String toSql(java.lang.String name, java.lang.String in)
           
 
Methods inherited from class fedora.server.Module
getRole, getServer, logConfig, logFine, logFiner, logFinest, loggingConfig, loggingFine, loggingFiner, loggingFinest, loggingInfo, loggingSevere, loggingWarning, logInfo, logSevere, logWarning, shutdownModule
 
Methods inherited from class fedora.server.Pluggable
getHelp, getOptionalParameters, getParameterHelp, getRequiredParameters
 
Methods inherited from class fedora.server.Parameterized
getParameter, getParameters, parameterNames, setParameter, setParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_STATE

public static java.lang.String DEFAULT_STATE
Constructor Detail

DefaultDOManager

public DefaultDOManager(java.util.Map moduleParameters,
                        Server server,
                        java.lang.String role)
                 throws ModuleInitializationException
Creates a new DefaultDOManager.

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.

postInitModule

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

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

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.

getObjectStore

public ILowlevelStorage getObjectStore()

getDatastreamStore

public ILowlevelStorage getDatastreamStore()

getTempStore

public ILowlevelStorage getTempStore()

getConnectionPool

public ConnectionPool getConnectionPool()

getDOValidator

public DOValidator getDOValidator()

getReplicator

public DOReplicator getReplicator()

getRequiredModuleRoles

public java.lang.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 java.lang.String getStorageFormat()

getDefaultExportFormat

public java.lang.String getDefaultExportFormat()

getStorageCharacterEncoding

public java.lang.String getStorageCharacterEncoding()

getTranslator

public fedora.server.storage.translation.DOTranslator getTranslator()

getReader

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

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

getBMechReader

public BMechReader getBMechReader(Context context,
                                  java.lang.String pid)
                           throws ServerException
Gets a reader on an an existing behavior mechanism object.

Specified by:
getBMechReader in interface RepositoryReader
Throws:
ServerException

getBDefReader

public BDefReader getBDefReader(Context context,
                                java.lang.String pid)
                         throws ServerException
Gets a reader on an an existing behavior definition object.

Specified by:
getBDefReader in interface RepositoryReader
Throws:
ServerException

getWriter

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

Specified by:
getWriter in interface DOManager
Parameters:
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(Context context,
                                java.io.InputStream in,
                                java.lang.String format,
                                java.lang.String encoding,
                                boolean newPid)
                         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)
newPid - true if the system should generate a new PID for the object
Returns:
a writer.
Throws:
ServerException - If anything went wrong.

doCommit

public void doCommit(Context context,
                     DigitalObject obj,
                     java.lang.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(java.lang.String pid)
                     throws StorageDeviceException
Checks the object registry for the given object.

Throws:
StorageDeviceException

getOwnerId

public java.lang.String getOwnerId(java.lang.String pid)
                            throws StorageDeviceException,
                                   ObjectNotFoundException
Throws:
StorageDeviceException
ObjectNotFoundException

listObjectPIDs

public java.lang.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 java.lang.String toSql(java.lang.String name,
                                     java.lang.String in)

findObjects

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

resumeFindObjects

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

getNextPID

public java.lang.String[] getNextPID(int numPIDs,
                                     java.lang.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.