Class MetadataWriter

java.lang.Object
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 Details

    • 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 org.dom4j.Document itemRecord
      NOT YET DOCUMENTED
    • finalAndValid

      protected boolean finalAndValid
      Description of the Field
    • nsdlItemId

      protected String nsdlItemId
  • Constructor Details

    • 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 Details

    • 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:
      resourceUrl - NOT YET DOCUMENTED
      resHandle - resource object handle
      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:
      ndrRequest - The feature to be added to the Metadata attribute
      resHandle - resource object handle
      Returns:
      report instance indicating success or failure
      Throws:
      Exception - if unable to build ndr request
    • modifyMetadataRequest

      protected NdrRequest modifyMetadataRequest(NdrRequest ndrRequest, String resHandle, org.dom4j.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:
      ndrRequest - NOT YET DOCUMENTED
      resHandle - resource object handle
      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 org.dom4j.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(org.dom4j.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