DLESE Tools
v1.6.0

org.dlese.dpc.schemedit.repository
Class RepositoryService

java.lang.Object
  extended by org.dlese.dpc.schemedit.repository.RepositoryService

public class RepositoryService
extends Object

Methods to wrap the RepositoryManager class and provide other methods and services over the repository.

Author:
ostwald


Constructor Summary
RepositoryService(ServletContext servletContext)
          Constructor for the RepositoryService object, requiring ServletContext.
 
Method Summary
 void addListener(RepositoryEventListener listener)
          Adds a feature to the Listener attribute of the DcsDataRecord object
 RecordList batchCopyMoveRecords(RecordList records, String collection)
          Moves a batch of records into the specified collection.
 RecordList batchDeleteRecords(RecordList records)
          returns list of records that could not be deleted
 RecordList batchMoveRecords(RecordList records, String collection)
          Moves a batch of records into the specified collection.
 RecordList batchStatusUpdate(RecordList records, StatusEntry statusEntry)
          Updates the status of a set of records (but does not validate or update the lastTouchDate.
 String copyMoveRecord(String srcRecordId, String destCollection)
          Write a copied version of a metadata record into a destination collectioni
 XMLDocReader copyRecord(String originalId, User user)
          Create a new record within the same collection as the original.
 void deleteCollection(String collection)
          Delete a collection from the repository
 void deleteRecord(String recId)
          Delete a record from the repository
 List getAuthorizedSets(User user, Roles.Role requiredRole)
          Gets the authorizedSets attribute of the RepositoryService object
 RecordList getCollectionItemRecords(String collection)
          Gets all item records for the specified collection by performing index query.
static String getDateString()
          Gets the dateString attribute of the RepositoryService class
 DcsDataRecord getDcsDataRecord(String recId)
          Gets the dcsDataRecord attribute of the RepositoryService object
 List getDups(String url, String collection)
          Gets the dups attribute of the RepositoryService object
static String getRecordFormat(String id, RepositoryManager rm)
          Gets the recordFormat attribute of the RepositoryService class
 RepositoryWriter getRepositoryWriter()
          Gets the repositoryWriter attribute of the RepositoryService object
 ArrayList getSetInfos()
          Update the list of sets.
 List getSims(String url, String collection)
          Gets the sims attribute of the RepositoryService object
 XMLDocReader getXMLDocReader(String id)
          Gets the xMLDocReader attribute of the RepositoryService object
static XMLDocReader getXMLDocReader(String id, RepositoryManager rm)
          Gets the XMLDocReader associated with an id
 void indexAnnotatedRecord(DocMap annoDocMap)
          Reindexes the annotated item record of an annotation record so the annotated item record is linked to its annotation.
static boolean indexedRecordIsStale(File sourceFile, XMLDocReader docReader)
          Test to see if record has been modified outside of DCS.
 boolean indexedRecordIsStale(String id)
          NOT YET DOCUMENTED
 boolean isAuthorizedSet(String collection, User user, Roles.Role requiredRole)
          Returns true if the specified user is authorized for the specified collection (set).
 String moveRecord(String recId, String collection)
          Move record to the destination collection, returning the ID of the new record.
 void removeListener(RepositoryEventListener listener)
          Description of the Method
 void saveEditedRecord(String recId, Document doc, User user)
          Save an edited record to disk and update the index accordingly.
 void saveNewRecord(String recId, String recordXml, String collection, String username)
          Saves and indexes a newly created record.
 void updateRecord(String recId)
          Updates the record by writing it to the repository.
 void updateRecordStatus(String recId, StatusEntry statusEntry)
          Update the status of a metadata record with provided statusEntry instance.
 void validateRecord(Object record, DcsDataRecord dcsData, String xmlFormat)
          Validate the record and update the DcsDataRecord.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RepositoryService

public RepositoryService(ServletContext servletContext)
                  throws Exception
Constructor for the RepositoryService object, requiring ServletContext.

Parameters:
servletContext -
Throws:
Exception - if repositoryWriter or autoExport service cannot be initialized.
Method Detail

getRepositoryWriter

public RepositoryWriter getRepositoryWriter()
Gets the repositoryWriter attribute of the RepositoryService object

Returns:
The repositoryWriter value

getDups

public List getDups(String url,
                    String collection)
Gets the dups attribute of the RepositoryService object

Parameters:
url - NOT YET DOCUMENTED
collection - NOT YET DOCUMENTED
Returns:
The dups value

getSims

public List getSims(String url,
                    String collection)
Gets the sims attribute of the RepositoryService object

Parameters:
url - NOT YET DOCUMENTED
collection - NOT YET DOCUMENTED
Returns:
The sims value

indexedRecordIsStale

public boolean indexedRecordIsStale(String id)
                             throws Exception
NOT YET DOCUMENTED

Parameters:
id - NOT YET DOCUMENTED
Returns:
NOT YET DOCUMENTED
Throws:
Exception - NOT YET DOCUMENTED

indexedRecordIsStale

public static boolean indexedRecordIsStale(File sourceFile,
                                           XMLDocReader docReader)
Test to see if record has been modified outside of DCS.

Parameters:
sourceFile - file on disk
docReader - the docReader
Returns:
true if file has changed on disk

indexAnnotatedRecord

public void indexAnnotatedRecord(DocMap annoDocMap)
                          throws Exception
Reindexes the annotated item record of an annotation record so the annotated item record is linked to its annotation.

Parameters:
annoDocMap - NOT YET DOCUMENTED
Throws:
Exception - Description of the Exception

updateRecordStatus

public void updateRecordStatus(String recId,
                               StatusEntry statusEntry)
                        throws Exception
Update the status of a metadata record with provided statusEntry instance.

Parameters:
recId - id of record to update
statusEntry - new status for record
Throws:
Exception - if record cannot be saved and indexed with provided status

saveEditedRecord

public void saveEditedRecord(String recId,
                             Document doc,
                             User user)
                      throws Exception
Save an edited record to disk and update the index accordingly.

Parameters:
recId - id of metadata record to be saved
doc - metadata record as dom4j.Document
user - NOT YET DOCUMENTED
Throws:
Exception - if unable to successfully update index

saveNewRecord

public void saveNewRecord(String recId,
                          String recordXml,
                          String collection,
                          String username)
                   throws Exception
Saves and indexes a newly created record. New records cannot be found in the index, so recId,recordXml, and collection must be passed as parameters, rather than derived from a docReader.

Callers of this method are controllers who collect key information from user and create an item-level metadata record outside of the metadata editor (currently only CreateADNRecordAction.handleNewRecordRequest does this).

Parameters:
recId - record id
recordXml - record content as delocalized xml string
collection - collection key (e.g., "dcc")
username - NOT YET DOCUMENTED
Throws:
Exception - if unable to save new record

updateRecord

public void updateRecord(String recId)
                  throws Exception
Updates the record by writing it to the repository. NOTE: Does NOT affect the metadata but updates the indexed record, which includes DcsDataRecord information. Therefore, this method is appropriate for indexing updated DcsDataRecord information, but it is not appropriate for updating changes to metadata content.

Called by DCSSchemEditAction.indexAnnotatedRecord() and ThreadedServices.validate().

Parameters:
recId - Description of the Parameter
Throws:
Exception - Description of the Exception

validateRecord

public void validateRecord(Object record,
                           DcsDataRecord dcsData,
                           String xmlFormat)
Validate the record and update the DcsDataRecord. NOTE: DcsDataRecord is not saved here - it must be saved (flushed to disk) by the caller.

Parameters:
dcsData - status record corresponding to the xml record.
record - An xml record, represented either as String or File
xmlFormat - NOT YET DOCUMENTED

batchMoveRecords

public RecordList batchMoveRecords(RecordList records,
                                   String collection)
                            throws Exception
Moves a batch of records into the specified collection.

Parameters:
records - A list of records to move to collection
collection - collection key of the destination collection
Returns:
returns list of records that could not be moved, if any
Throws:
Exception - NOT YET DOCUMENTED

batchCopyMoveRecords

public RecordList batchCopyMoveRecords(RecordList records,
                                       String collection)
                                throws Exception
Moves a batch of records into the specified collection.

Parameters:
records - A list of records to move to collection
collection - collection key of the destination collection
Returns:
returns list of records that could not be moved, if any
Throws:
Exception - NOT YET DOCUMENTED

batchStatusUpdate

public RecordList batchStatusUpdate(RecordList records,
                                    StatusEntry statusEntry)
                             throws Exception
Updates the status of a set of records (but does not validate or update the lastTouchDate.

Parameters:
records - an array of records represented as ResultDocs
statusEntry - contains status, statusNote and editor information to be added to each record
Returns:
a list of records that could not be updated
Throws:
Exception - NOT YET DOCUMENTED

moveRecord

public String moveRecord(String recId,
                         String collection)
                  throws Exception
Move record to the destination collection, returning the ID of the new record. Status and lastTouchDate are updated in the DcsDataRecord, but the metadata is not re-validated.

Ensures that source and destination collections are different before making move, so batch moves don't have to make this check.

Parameters:
recId - id of the record to be moved
collection - Destination collection for the record to be moved
Returns:
id of the moved record
Throws:
Exception - Description of the Exception

batchDeleteRecords

public RecordList batchDeleteRecords(RecordList records)
                              throws Exception
returns list of records that could not be deleted

Parameters:
records - Description of the Parameter
Returns:
Description of the Return Value
Throws:
Exception - NOT YET DOCUMENTED

deleteCollection

public void deleteCollection(String collection)
                      throws Exception
Delete a collection from the repository

Parameters:
collection - key of collection to be deleted
Throws:
Exception - NOT YET DOCUMENTED

deleteRecord

public void deleteRecord(String recId)
                  throws Exception
Delete a record from the repository

Parameters:
recId - Description of the Parameter
Throws:
Exception - Description of the Exception

copyRecord

public XMLDocReader copyRecord(String originalId,
                               User user)
                        throws Exception
Create a new record within the same collection as the original. A new DcsDataRecord is created with a status of "Uknown" and statusNote signifying it is copied. Validation is not performed - the new record gets the isValid attribute of the original.

Parameters:
originalId - id of the record to be copied
Returns:
XMLDocReader for the new record
Throws:
Exception - Description of the Exception

copyMoveRecord

public String copyMoveRecord(String srcRecordId,
                             String destCollection)
                      throws Exception
Write a copied version of a metadata record into a destination collectioni

Parameters:
originalId - NOT YET DOCUMENTED
destCollection - NOT YET DOCUMENTED
Returns:
NOT YET DOCUMENTED
Throws:
Exception - NOT YET DOCUMENTED

getDcsDataRecord

public DcsDataRecord getDcsDataRecord(String recId)
                               throws Exception
Gets the dcsDataRecord attribute of the RepositoryService object

Parameters:
recId - NOT YET DOCUMENTED
Returns:
The dcsDataRecord value
Throws:
Exception - NOT YET DOCUMENTED

getXMLDocReader

public XMLDocReader getXMLDocReader(String id)
                             throws Exception
Gets the xMLDocReader attribute of the RepositoryService object

Parameters:
id - NOT YET DOCUMENTED
Returns:
The xMLDocReader value
Throws:
Exception - NOT YET DOCUMENTED

getXMLDocReader

public static XMLDocReader getXMLDocReader(String id,
                                           RepositoryManager rm)
                                    throws Exception
Gets the XMLDocReader associated with an id

Parameters:
id - Record ID
rm - RepositoryManager
Returns:
XMLDocReader or null if not found
Throws:
Exception - NOT YET DOCUMENTED

getRecordFormat

public static String getRecordFormat(String id,
                                     RepositoryManager rm)
                              throws Exception
Gets the recordFormat attribute of the RepositoryService class

Parameters:
id - NOT YET DOCUMENTED
rm - NOT YET DOCUMENTED
Returns:
The recordFormat value
Throws:
Exception - NOT YET DOCUMENTED

getSetInfos

public ArrayList getSetInfos()
Update the list of sets.

Returns:
The sets value

isAuthorizedSet

public boolean isAuthorizedSet(String collection,
                               User user,
                               Roles.Role requiredRole)
Returns true if the specified user is authorized for the specified collection (set).

Parameters:
collection - NOT YET DOCUMENTED
user - NOT YET DOCUMENTED
requiredRole - NOT YET DOCUMENTED
Returns:
The authorizedSet value

getAuthorizedSets

public List getAuthorizedSets(User user,
                              Roles.Role requiredRole)
Gets the authorizedSets attribute of the RepositoryService object

Parameters:
user - NOT YET DOCUMENTED
requiredRole - NOT YET DOCUMENTED
Returns:
The authorizedSets value

getCollectionItemRecords

public RecordList getCollectionItemRecords(String collection)
Gets all item records for the specified collection by performing index query.

Parameters:
collection - collection key
Returns:
RecordList containing IDs of item records

addListener

public void addListener(RepositoryEventListener listener)
Adds a feature to the Listener attribute of the DcsDataRecord object

Parameters:
listener - The feature to be added to the Listener attribute

removeListener

public void removeListener(RepositoryEventListener listener)
Description of the Method

Parameters:
listener - Description of the Parameter

getDateString

public static String getDateString()
Gets the dateString attribute of the RepositoryService class

Returns:
The dateString value

DLESE Tools
v1.6.0