diff --git a/dspace-api/src/main/java/org/dspace/identifier/DataCiteXMLCreator.java b/dspace-api/src/main/java/org/dspace/identifier/DataCiteXMLCreator.java
new file mode 100644
index 0000000000..80719849a9
--- /dev/null
+++ b/dspace-api/src/main/java/org/dspace/identifier/DataCiteXMLCreator.java
@@ -0,0 +1,105 @@
+/**
+ * The contents of this file are subject to the license and copyright
+ * detailed in the LICENSE and NOTICE files at the root of the source
+ * tree and available online at
+ *
+ * http://www.dspace.org/license/
+ */
+
+package org.dspace.identifier;
+
+import org.apache.log4j.Logger;
+import org.dspace.content.DSpaceObject;
+import org.dspace.content.crosswalk.DisseminationCrosswalk;
+import org.dspace.core.PluginManager;
+import org.jdom.Element;
+import org.jdom.output.XMLOutputter;
+
+/**
+ * Provide XML based metadata crosswalk for EZID Identifier provider module.
+ *
+ * @author mohideen
+ */
+
+public class DataCiteXMLCreator
+{
+ /** log4j category */
+ private static Logger log = Logger.getLogger(DataCiteXMLCreator.class);
+
+ /**
+ * Name of crosswalk to convert metadata into DataCite Metadata Scheme.
+ */
+ protected String CROSSWALK_NAME = "DataCite";
+
+ /**
+ * DisseminationCrosswalk to map local metadata into DataCite metadata. The
+ * name of the crosswalk is set by {@link setDisseminationCrosswalk(String)
+ * setDisseminationCrosswalk} which instantiates the crosswalk.
+ */
+ protected DisseminationCrosswalk xwalk;
+
+ public String getXMLString(DSpaceObject dso)
+ {
+ if (dso == null)
+ {
+ log.info("Invalid object: " + dso);
+ return null;
+ }
+
+ this.prepareXwalk();
+
+ if (!this.xwalk.canDisseminate(dso))
+ {
+ log.error("Crosswalk " + this.CROSSWALK_NAME
+ + " cannot disseminate DSO with type " + dso.getType()
+ + " and ID " + dso.getID() + ".");
+ return null;
+ }
+
+ Element root = null;
+ try
+ {
+ root = xwalk.disseminateElement(dso);
+ }
+ catch (Exception e)
+ {
+ log.error(
+ "Exception while crosswolking DSO " + "with type "
+ + dso.getType() + " and ID " + dso.getID() + ".", e);
+ return null;
+ }
+
+ XMLOutputter xOut = new XMLOutputter();
+
+ return xOut.outputString(root);
+
+ }
+
+ /**
+ * Set the name of the dissemination crosswalk used to convert the metadata
+ * into DataCite Metadata Schema. Used by spring dependency injection.
+ *
+ * @param CROSSWALK_NAME
+ * The name of the dissemination crosswalk to use.
+ */
+ public void setDisseminationCrosswalkName(String CROSSWALK_NAME)
+ {
+ this.CROSSWALK_NAME = CROSSWALK_NAME;
+ }
+
+ protected void prepareXwalk()
+ {
+ if (null != this.xwalk)
+ return;
+
+ this.xwalk = (DisseminationCrosswalk) PluginManager.getNamedPlugin(
+ DisseminationCrosswalk.class, this.CROSSWALK_NAME);
+
+ if (this.xwalk == null)
+ {
+ throw new RuntimeException("Can't find crosswalk '"
+ + CROSSWALK_NAME + "'!");
+ }
+ }
+
+}
diff --git a/dspace-api/src/main/java/org/dspace/identifier/EZIDIdentifierProvider.java b/dspace-api/src/main/java/org/dspace/identifier/EZIDIdentifierProvider.java
index 50f4cc74a6..9622bda5a0 100644
--- a/dspace-api/src/main/java/org/dspace/identifier/EZIDIdentifierProvider.java
+++ b/dspace-api/src/main/java/org/dspace/identifier/EZIDIdentifierProvider.java
@@ -53,16 +53,25 @@ import org.springframework.beans.factory.annotation.Required;
*
*
Then there are properties injected using Spring:
*
- * - There is a Map (with the property name "crosswalk") from EZID
- * metadata field names into DSpace field names, injected by Spring. Specify
- * the fully-qualified names of all metadata fields to be looked up on a DSpace
- * object and their values set on mapped fully-qualified names in the object's
- * DataCite metadata.
- *
- * - A second map ("crosswalkTransform") provides Transform instances
- * mapped from EZID metadata field names. This allows the crosswalk to rewrite
- * field values where the form maintained by DSpace is not directly usable in
- * EZID metadata.
+ * - There is a Map (with the property name "crosswalk") from EZID metadata
+ * field names into DSpace field names, injected by Spring. Specify the
+ * fully-qualified names of all metadata fields to be looked up on a DSpace
+ * object and their values set on mapped fully-qualified names in the object's
+ * DataCite metadata.
+ *
+ * - A second map ("crosswalkTransform") provides Transform instances mapped
+ * from EZID metadata field names. This allows the crosswalk to rewrite field
+ * values where the form maintained by DSpace is not directly usable in EZID
+ * metadata.
+ *
+ * - Optional: A boolean property ("generateDataciteXML") that controls the
+ * creation and inclusion of DataCite xml schema during the metadata
+ * crosswalking. The default "DataCite" dissemination plugin uses
+ * DIM2DataCite.xsl for crosswalking. Default value: false.
+ *
+ * - Optional: A string property ("disseminationCrosswalkName") that can be
+ * used to set the name of the dissemination crosswalk plugin for metadata
+ * crosswalking. Default value: "DataCite".
*
*
* @author mwood
@@ -90,6 +99,10 @@ public class EZIDIdentifierProvider
private static final String DOI_SCHEME = "doi:";
+ protected boolean GENERATE_DATACITE_XML = false;
+
+ protected String DATACITE_XML_CROSSWALK = "DataCite";
+
/** Map DataCite metadata into local metadata. */
private static Map crosswalk = new HashMap();
@@ -661,8 +674,17 @@ public class EZIDIdentifierProvider
}
}
+ if (GENERATE_DATACITE_XML == true)
+ {
+ DataCiteXMLCreator xmlGen = new DataCiteXMLCreator();
+ xmlGen.setDisseminationCrosswalkName(DATACITE_XML_CROSSWALK);
+ String xmlString = xmlGen.getXMLString(dso);
+ mapped.put("datacite", xmlString);
+ }
+
// Supply a default publisher, if the Item has none.
- if (!mapped.containsKey(DATACITE_PUBLISHER))
+ if (!mapped.containsKey(DATACITE_PUBLISHER)
+ && !mapped.containsKey("datacite"))
{
String publisher = configurationService.getPropertyAsType(CFG_PUBLISHER, "unknown");
log.info("Supplying default publisher: {}", publisher);
@@ -670,7 +692,8 @@ public class EZIDIdentifierProvider
}
// Supply current year as year of publication, if the Item has none.
- if (!mapped.containsKey(DATACITE_PUBLICATION_YEAR))
+ if (!mapped.containsKey(DATACITE_PUBLICATION_YEAR)
+ && !mapped.containsKey("datacite"))
{
String year = String.valueOf(Calendar.getInstance().get(Calendar.YEAR));
log.info("Supplying default publication year: {}", year);
@@ -694,6 +717,16 @@ public class EZIDIdentifierProvider
transforms = transformMap;
}
+ public void setGenerateDataciteXML(boolean GENERATE_DATACITE_XML)
+ {
+ this.GENERATE_DATACITE_XML = GENERATE_DATACITE_XML;
+ }
+
+ public void setDisseminationCrosswalkName(String DATACITE_XML_CROSSWALK)
+ {
+ this.DATACITE_XML_CROSSWALK = DATACITE_XML_CROSSWALK;
+ }
+
@Required
public static void setRequestFactory(EZIDRequestFactory aRequestFactory)
{
diff --git a/dspace/config/dspace.cfg b/dspace/config/dspace.cfg
index c682e0aa69..9172f36e65 100644
--- a/dspace/config/dspace.cfg
+++ b/dspace/config/dspace.cfg
@@ -792,6 +792,8 @@ org.dspace.app.batchitemimport.work.dir = ${dspace.dir}/imports
#identifier.doi.ezid.user = apitest
#identifier.doi.ezid.password = apitest
# A default publisher, for Items not previously published.
+# (If generateDataciteXML bean property is enabled. Set default publisher in the
+# XSL file configured by: crosswalk.dissemination.DataCite.stylesheet file.)
#identifier.doi.ezid.publisher = a publisher
diff --git a/dspace/config/spring/api/identifier-service.xml b/dspace/config/spring/api/identifier-service.xml
index dc91521bda..d9e9f8e843 100644
--- a/dspace/config/spring/api/identifier-service.xml
+++ b/dspace/config/spring/api/identifier-service.xml
@@ -67,6 +67,11 @@
+