Source:
private String getMetadataFromDvObject(String identifier, Map<String, String> metadata,DvObject dvObject) { Dataset dataset = null; if (dvObject instanceof Dataset){ dataset = (Dataset) dvObject; } else { dataset = (Dataset) dvObject.getOwner(); } DataCiteMetadataTemplate metadataTemplate = new DataCiteMetadataTemplate(); metadataTemplate.setIdentifier(identifier.substring(identifier.indexOf(':') + 1)); metadataTemplate.setCreators(Util.getListFromStr(metadata.get("datacite.creator"))); metadataTemplate.setAuthors(dataset.getLatestVersion().getDatasetAuthors()); if (dvObject.isInstanceofDataset()) { metadataTemplate.setDescription(dataset.getLatestVersion().getDescriptionPlainText()); } if (dvObject.isInstanceofDataFile()) { DataFile df = (DataFile) dvObject; String fileDescription =df.getDescription(); metadataTemplate.setDescription(fileDescription == null ? "" :fileDescription ); } metadataTemplate.setContacts(dataset.getLatestVersion().getDatasetContacts()); metadataTemplate.setProducers(dataset.getLatestVersion().getDatasetProducers()); metadataTemplate.setTitle(dvObject.getDisplayName()); String producerString = dataverseService.findRootDataverse().getName(); if (producerString.isEmpty()) { producerString = ":unav"; } metadataTemplate.setPublisher(producerString); metadataTemplate.setPublisherYear(metadata.get("datacite.publicationyear")); if (dvObject.isInstanceofDataFile()) { DataFile df = (DataFile) dvObject; String datasetPid = df.getOwner().getGlobalId().asString(); metadataTemplate.setDatasetIdentifier(datasetPid); } else { metadataTemplate.setDatasetIdentifier(""); } String xmlMetadata = metadataTemplate.generateXML(dvObject); logger.log(Level.INFO, "XML to send to DataCite: {0}", xmlMetadata); return xmlMetadata; }

Target:
private String getMetadataFromDvObject(String identifier, Map<String, String> metadata, DvObject dvObject) { Dataset dataset = null; if (dvObject instanceof Dataset) { dataset = (Dataset) dvObject; } else { dataset = (Dataset) dvObject.getOwner(); } DataCiteMetadataTemplate metadataTemplate = new DataCiteMetadataTemplate(); metadataTemplate.setIdentifier(identifier.substring(identifier.indexOf(':') + 1)); metadataTemplate.setCreators(Util.getListFromStr(metadata.get("datacite.creator"))); metadataTemplate.setAuthors(dataset.getLatestVersion().getDatasetAuthors()); if (dvObject.isInstanceofDataset()) { metadataTemplate.setDescription(dataset.getLatestVersion().getDescriptionPlainText()); } if (dvObject.isInstanceofDataFile()) { DataFile df = (DataFile) dvObject; String fileDescription = df.getDescription(); metadataTemplate.setDescription(fileDescription == null ? "" : fileDescription); String datasetPid = df.getOwner().getGlobalId().asString(); metadataTemplate.setDatasetIdentifier(datasetPid); } else { metadataTemplate.setDatasetIdentifier(""); } metadataTemplate.setContacts(dataset.getLatestVersion().getDatasetContacts()); metadataTemplate.setProducers(dataset.getLatestVersion().getDatasetProducers()); metadataTemplate.setTitle(dvObject.getDisplayName()); String producerString = dataverseService.findRootDataverse().getName(); if (producerString.isEmpty()) { producerString = ":unav"; } metadataTemplate.setPublisher(producerString); metadataTemplate.setPublisherYear(metadata.get("datacite.publicationyear")); String xmlMetadata = metadataTemplate.generateXML(dvObject); logger.log(Level.FINE, "XML to send to DataCite: {0}", xmlMetadata); return xmlMetadata; }