Source:
<code>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); <START> logger.log(Level.INFO, "XML to send to DataCite: {0}", xmlMetadata); <END> return xmlMetadata; }</code><technical_language>Kinda picky, some of indentation whitespace in this file cleaned up. Other ok though</technical_language>

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; }