Skip to content

Commit

Permalink
Merge pull request #5548 from QualitativeDataRepository/IQSS/5546-Fil…
Browse files Browse the repository at this point in the history
…e_metadata_going_to_DataCite_is_not_escaped

5546-escape file metadata going to DataCite
  • Loading branch information
kcondon authored Feb 15, 2019
2 parents e9cfb6f + ff5cc42 commit c80c812
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import org.apache.commons.lang.StringEscapeUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
Expand Down Expand Up @@ -149,7 +150,9 @@ public static String getMetadataFromDvObject(String identifier, Map<String, Stri
}
if (dvObject.isInstanceofDataFile()) {
DataFile df = (DataFile) dvObject;
String fileDescription = df.getDescription();
//Note: File metadata is not escaped like dataset metadata is, so adding an xml escape here.
//This could/should be removed if the datafile methods add escaping
String fileDescription = StringEscapeUtils.escapeXml(df.getDescription());
metadataTemplate.setDescription(fileDescription == null ? "" : fileDescription);
String datasetPid = df.getOwner().getGlobalId().asString();
metadataTemplate.setDatasetIdentifier(datasetPid);
Expand All @@ -159,7 +162,12 @@ public static String getMetadataFromDvObject(String identifier, Map<String, Stri

metadataTemplate.setContacts(dataset.getLatestVersion().getDatasetContacts());
metadataTemplate.setProducers(dataset.getLatestVersion().getDatasetProducers());
metadataTemplate.setTitle(dvObject.getDisplayName());
String title = dvObject.getDisplayName();
if(dvObject.isInstanceofDataFile()) {
//Note file title is not currently escaped the way the dataset title is, so adding it here.
title = StringEscapeUtils.escapeXml(title);
}
metadataTemplate.setTitle(title);
String producerString = dataset.getLatestVersion().getRootDataverseNameforCitation();
if (producerString.isEmpty()) {
producerString = ":unav";
Expand Down

0 comments on commit c80c812

Please sign in to comment.