DLESE Tools
v1.6.0

org.dlese.dpc.schemedit.ndr.writer
Class MetadataWriter

java.lang.Object
  extended by org.dlese.dpc.schemedit.ndr.writer.MetadataWriter
Direct Known Subclasses:
NSDLCollectionWriter

public class MetadataWriter
extends Object

Class responsible for writing Metadata records to the NDR as Metadata Objects.

Author:
Jonathan Ostwald

Field Summary
protected  CollectionConfig collectionConfig
          NOT YET DOCUMENTED
protected  DcsDataRecord dcsDataRecord
          NOT YET DOCUMENTED
protected  XMLDocReader docReader
          NOT YET DOCUMENTED
protected  boolean finalAndValid
          Description of the Field
protected  Document itemRecord
          NOT YET DOCUMENTED
protected  MetadataReader mdReader
          NOT YET DOCUMENTED
protected  String nsdlItemId
           
protected  String recId
          NOT YET DOCUMENTED
protected  RepositoryManager rm
          NOT YET DOCUMENTED
protected  ServletContext servletContext
          NOT YET DOCUMENTED
protected  XMLConversionService xmlConversionService
          NOT YET DOCUMENTED
 
Constructor Summary
MetadataWriter()
          Constructor for the MetadataWriter object
MetadataWriter(ServletContext servletContext)
          Constructor for the MetadataWriter object
 
Method Summary
protected  NdrRequest addMetadataRequest(NdrRequest ndrRequest, String resHandle)
          Augment provided NdrRequest to form an "addMetadataRequest" request to create a new NDR object.
protected  CollectionConfig getCollectionConfig(String collection)
          Gets the collectionConfig attribute of the RepositoryWriterPlugin object
protected  Document getItemRecord(String recordXml)
          Gets the metadata record as a dom4j.Document, converting from recordXml if it is provided, or obtaining from the index (via docReader) otherwise.
protected  MetaDataFramework getMetaDataFramework(String xmlFormat)
          Gets the metaDataFramework attribute of the MetadataWriter object
protected  MetadataReader getMetadataReader()
          Gets the metadataReader attribute of the MetadataWriter object
protected  String getResourceHandle(String resourceUrl)
          Obtain a resource handle from the NDR for the provided resourceURL.
protected  String getResourceUrl(Document itemRecord)
          Get and validate the URL using the urlPath configured for this framework (NOTE: url path must be configured for the framework of the record to be written).
protected  Object getServletContextAttribute(String attrName)
          Gets the requiredContextAttributeValue attribute of the MetadataWriterPlugin object
protected  String getValueOrNull(String s)
          Gets the valueOrNull attribute of the MetadataWriter object
protected  NdrRequest getWriteRequest(String resourceUrl, String resHandle)
          Returns NdrRequest to write metadata to NDR, either as a new metadata object or by updating an existing object.
protected  void init(String recordXml)
          Initialize required values and services for the MetadataWriter.
protected  NdrRequest modifyMetadataRequest(NdrRequest ndrRequest, String resHandle, Element nsdl_dc_stream)
          Augment provided NdrRequest to form a "modifyMetadataRequest" request for updating an existing metadata object in the NDR.
 void setServletContext(ServletContext servletContext)
          Sets the servletContext attribute of the MetadataWriter object
 SyncReportEntry write(String recId, DcsDataRecord dcsDataRecord)
          Convenience method to write the metadata record identified by recId along with dcsDataRecord, to the NDR.
 SyncReportEntry write(String recId, String recordXml, DcsDataRecord dcsDataRecord)
          Writes metadata record to NDR using provided "recordXml" metadata if provided, or metadata obtained from from the index if recordXml is null.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

servletContext

protected ServletContext servletContext
NOT YET DOCUMENTED


mdReader

protected MetadataReader mdReader
NOT YET DOCUMENTED


rm

protected RepositoryManager rm
NOT YET DOCUMENTED


recId

protected String recId
NOT YET DOCUMENTED


docReader

protected XMLDocReader docReader
NOT YET DOCUMENTED


dcsDataRecord

protected DcsDataRecord dcsDataRecord
NOT YET DOCUMENTED


collectionConfig

protected CollectionConfig collectionConfig
NOT YET DOCUMENTED


xmlConversionService

protected XMLConversionService xmlConversionService
NOT YET DOCUMENTED


itemRecord

protected Document itemRecord
NOT YET DOCUMENTED


finalAndValid

protected boolean finalAndValid
Description of the Field


nsdlItemId

protected String nsdlItemId
Constructor Detail

MetadataWriter

public MetadataWriter()
Constructor for the MetadataWriter object


MetadataWriter

public MetadataWriter(ServletContext servletContext)
               throws Exception
Constructor for the MetadataWriter object

Parameters:
servletContext - NOT YET DOCUMENTED
Throws:
Exception - NOT YET DOCUMENTED
Method Detail

setServletContext

public void setServletContext(ServletContext servletContext)
Sets the servletContext attribute of the MetadataWriter object

Parameters:
servletContext - The new servletContext value

init

protected void init(String recordXml)
             throws Exception
Initialize required values and services for the MetadataWriter.

RepositoryManager, docReader, itemRecord, xmlConversionService, collectionConfig.

Parameters:
recordXml - metadata, can be null.
Throws:
Exception - NOT YET DOCUMENTED

write

public SyncReportEntry write(String recId,
                             DcsDataRecord dcsDataRecord)
                      throws Exception
Convenience method to write the metadata record identified by recId along with dcsDataRecord, to the NDR.

This method is called from OUTSIDE the metadata editor (e.g., Sync), when there is not access to the actual XML of the record.

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

write

public SyncReportEntry write(String recId,
                             String recordXml,
                             DcsDataRecord dcsDataRecord)
                      throws Exception
Writes metadata record to NDR using provided "recordXml" metadata if provided, or metadata obtained from from the index if recordXml is null.

Parameters:
recId - recordId, used to obtain metadata from index if necessary
recordXml - metadata as String (optionally provided)
dcsDataRecord - auxillary information about the metadata record
Returns:
NOT YET DOCUMENTED
Throws:
Exception - NOT YET DOCUMENTED

getWriteRequest

protected NdrRequest getWriteRequest(String resourceUrl,
                                     String resHandle)
                              throws Exception
Returns NdrRequest to write metadata to NDR, either as a new metadata object or by updating an existing object.

Parameters:
resHandle - resource object handle
resourceUrl - NOT YET DOCUMENTED
Returns:
report instance indicating success or failure
Throws:
Exception - if unable to build ndr request

addMetadataRequest

protected NdrRequest addMetadataRequest(NdrRequest ndrRequest,
                                        String resHandle)
                                 throws Exception
Augment provided NdrRequest to form an "addMetadataRequest" request to create a new NDR object.

Parameters:
resHandle - resource object handle
ndrRequest - The feature to be added to the Metadata attribute
Returns:
report instance indicating success or failure
Throws:
Exception - if unable to build ndr request

modifyMetadataRequest

protected NdrRequest modifyMetadataRequest(NdrRequest ndrRequest,
                                           String resHandle,
                                           Element nsdl_dc_stream)
                                    throws Exception
Augment provided NdrRequest to form a "modifyMetadataRequest" request for updating an existing metadata object in the NDR.

Collection-level objects (AggHandle and MdpHandle) are non-null only if the metadata is a NSDL collection record (i.e., ncs_collect format).

Parameters:
resHandle - resource object handle
ndrRequest - NOT YET DOCUMENTED
nsdl_dc_stream - NOT YET DOCUMENTED
Returns:
report instance indicating success or failure
Throws:
Exception - if unable to build ndr request

getMetadataReader

protected MetadataReader getMetadataReader()
                                    throws Exception
Gets the metadataReader attribute of the MetadataWriter object

Returns:
The metadataReader value
Throws:
Exception - NOT YET DOCUMENTED

getResourceHandle

protected String getResourceHandle(String resourceUrl)
                            throws Exception
Obtain a resource handle from the NDR for the provided resourceURL. A new resource is created if one does not already exist in the NDR. In either case, a memberOf relationship is created between the resource and the collection's aggregator.

Parameters:
resourceUrl - url for the resorce to be found or created
Returns:
The resourceHandle value
Throws:
Exception - if a collection aggregator is not found, or if the resource cannot be created or modified.

getItemRecord

protected Document getItemRecord(String recordXml)
                          throws Exception
Gets the metadata record as a dom4j.Document, converting from recordXml if it is provided, or obtaining from the index (via docReader) otherwise.

Parameters:
recordXml - metadata record as XML String
Returns:
The itemRecord value
Throws:
Exception - if provided recordXml is not well-formed.

getValueOrNull

protected String getValueOrNull(String s)
Gets the valueOrNull attribute of the MetadataWriter object

Parameters:
s - Description of the Parameter
Returns:
The valueOrNull value

getResourceUrl

protected String getResourceUrl(Document itemRecord)
                         throws Exception
Get and validate the URL using the urlPath configured for this framework (NOTE: url path must be configured for the framework of the record to be written). For single-namespace frameworks, url must be obtained from localized record.

Parameters:
itemRecord - NOT YET DOCUMENTED
Returns:
The resourceUrl value
Throws:
Exception - if resourceUrl cannot be obtained

getServletContextAttribute

protected Object getServletContextAttribute(String attrName)
                                     throws Exception
Gets the requiredContextAttributeValue attribute of the MetadataWriterPlugin object

Parameters:
attrName - NOT YET DOCUMENTED
Returns:
The requiredContextAttributeValue value
Throws:
Exception - NOT YET DOCUMENTED

getCollectionConfig

protected CollectionConfig getCollectionConfig(String collection)
                                        throws Exception
Gets the collectionConfig attribute of the RepositoryWriterPlugin object

Parameters:
collection - NOT YET DOCUMENTED
Returns:
The collectionConfig value
Throws:
Exception - NOT YET DOCUMENTED

getMetaDataFramework

protected MetaDataFramework getMetaDataFramework(String xmlFormat)
                                          throws Exception
Gets the metaDataFramework attribute of the MetadataWriter object

Parameters:
xmlFormat - NOT YET DOCUMENTED
Returns:
The metaDataFramework value
Throws:
Exception - NOT YET DOCUMENTED

DLESE Tools
v1.6.0