Class MetadataWriter
java.lang.Object
org.dlese.dpc.schemedit.ndr.writer.MetadataWriter
- Direct Known Subclasses:
NSDLCollectionWriter
Class responsible for writing Metadata records to the NDR as Metadata
Objects.
- Author:
- Jonathan Ostwald
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CollectionConfigNOT YET DOCUMENTEDprotected DcsDataRecordNOT YET DOCUMENTEDprotected XMLDocReaderNOT YET DOCUMENTEDprotected booleanDescription of the Fieldprotected org.dom4j.DocumentNOT YET DOCUMENTEDprotected MetadataReaderNOT YET DOCUMENTEDprotected Stringprotected StringNOT YET DOCUMENTEDprotected RepositoryManagerNOT YET DOCUMENTEDprotected ServletContextNOT YET DOCUMENTEDprotected XMLConversionServiceNOT YET DOCUMENTED -
Constructor Summary
ConstructorsConstructorDescriptionConstructor for the MetadataWriter objectMetadataWriter(ServletContext servletContext) Constructor for the MetadataWriter object -
Method Summary
Modifier and TypeMethodDescriptionprotected NdrRequestaddMetadataRequest(NdrRequest ndrRequest, String resHandle) Augment provided NdrRequest to form an "addMetadataRequest" request to create a new NDR object.protected CollectionConfiggetCollectionConfig(String collection) Gets the collectionConfig attribute of the RepositoryWriterPlugin objectprotected org.dom4j.DocumentgetItemRecord(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 MetaDataFrameworkgetMetaDataFramework(String xmlFormat) Gets the metaDataFramework attribute of the MetadataWriter objectprotected MetadataReaderGets the metadataReader attribute of the MetadataWriter objectprotected StringgetResourceHandle(String resourceUrl) Obtain a resource handle from the NDR for the provided resourceURL.protected StringgetResourceUrl(org.dom4j.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 ObjectgetServletContextAttribute(String attrName) Gets the requiredContextAttributeValue attribute of the MetadataWriterPlugin objectprotected StringGets the valueOrNull attribute of the MetadataWriter objectprotected NdrRequestgetWriteRequest(String resourceUrl, String resHandle) Returns NdrRequest to write metadata to NDR, either as a new metadata object or by updating an existing object.protected voidInitialize required values and services for the MetadataWriter.protected NdrRequestmodifyMetadataRequest(NdrRequest ndrRequest, String resHandle, org.dom4j.Element nsdl_dc_stream) Augment provided NdrRequest to form a "modifyMetadataRequest" request for updating an existing metadata object in the NDR.voidsetServletContext(ServletContext servletContext) Sets the servletContext attribute of the MetadataWriter objectwrite(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.write(String recId, DcsDataRecord dcsDataRecord) Convenience method to write the metadata record identified by recId along with dcsDataRecord, to the NDR.
-
Field Details
-
servletContext
NOT YET DOCUMENTED -
mdReader
NOT YET DOCUMENTED -
rm
NOT YET DOCUMENTED -
recId
NOT YET DOCUMENTED -
docReader
NOT YET DOCUMENTED -
dcsDataRecord
NOT YET DOCUMENTED -
collectionConfig
NOT YET DOCUMENTED -
xmlConversionService
NOT YET DOCUMENTED -
itemRecord
protected org.dom4j.Document itemRecordNOT YET DOCUMENTED -
finalAndValid
protected boolean finalAndValidDescription of the Field -
nsdlItemId
-
-
Constructor Details
-
MetadataWriter
public MetadataWriter()Constructor for the MetadataWriter object -
MetadataWriter
Constructor for the MetadataWriter object- Parameters:
servletContext- NOT YET DOCUMENTED- Throws:
Exception- NOT YET DOCUMENTED
-
-
Method Details
-
setServletContext
Sets the servletContext attribute of the MetadataWriter object- Parameters:
servletContext- The new servletContext value
-
init
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
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 DOCUMENTEDdcsDataRecord- 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 necessaryrecordXml- metadata as String (optionally provided)dcsDataRecord- auxillary information about the metadata record- Returns:
- NOT YET DOCUMENTED
- Throws:
Exception- NOT YET DOCUMENTED
-
getWriteRequest
Returns NdrRequest to write metadata to NDR, either as a new metadata object or by updating an existing object.- Parameters:
resourceUrl- NOT YET DOCUMENTEDresHandle- resource object handle- Returns:
- report instance indicating success or failure
- Throws:
Exception- if unable to build ndr request
-
addMetadataRequest
Augment provided NdrRequest to form an "addMetadataRequest" request to create a new NDR object.- Parameters:
ndrRequest- The feature to be added to the Metadata attributeresHandle- 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 DOCUMENTEDresHandle- resource object handlensdl_dc_stream- NOT YET DOCUMENTED- Returns:
- report instance indicating success or failure
- Throws:
Exception- if unable to build ndr request
-
getMetadataReader
Gets the metadataReader attribute of the MetadataWriter object- Returns:
- The metadataReader value
- Throws:
Exception- NOT YET DOCUMENTED
-
getResourceHandle
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
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
Gets the valueOrNull attribute of the MetadataWriter object- Parameters:
s- Description of the Parameter- Returns:
- The valueOrNull value
-
getResourceUrl
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
Gets the requiredContextAttributeValue attribute of the MetadataWriterPlugin object- Parameters:
attrName- NOT YET DOCUMENTED- Returns:
- The requiredContextAttributeValue value
- Throws:
Exception- NOT YET DOCUMENTED
-
getCollectionConfig
Gets the collectionConfig attribute of the RepositoryWriterPlugin object- Parameters:
collection- NOT YET DOCUMENTED- Returns:
- The collectionConfig value
- Throws:
Exception- NOT YET DOCUMENTED
-
getMetaDataFramework
Gets the metaDataFramework attribute of the MetadataWriter object- Parameters:
xmlFormat- NOT YET DOCUMENTED- Returns:
- The metaDataFramework value
- Throws:
Exception- NOT YET DOCUMENTED
-