Skip to content

Commit

Permalink
Merge branch 'staging' into dataverse_update_v5.12.1_workflow_patch
Browse files Browse the repository at this point in the history
  • Loading branch information
ffritze committed Nov 10, 2023
2 parents 053202d + 6254833 commit cf6b4d6
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ public void downloadCitationBibtex(FileMetadata fileMetadata, Dataset dataset, b
HttpServletResponse response = (HttpServletResponse) ctx.getExternalContext().getResponse();

//Fix for 6029 FireFox was failing to parse it when content type was set to json
response.setContentType("text/plain");
response.setContentType("text/plain;charset=utf-8");

String fileNameString;
if (fileMetadata == null || fileMetadata.getLabel() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public void setInReview(boolean inReview) {
}

public String getTermsOfUse() {
if (termsOfUse != null && termsOfUse.contains("CC0")) {
termsOfUse = termsOfUse.replace("CC0", "CC BY");
}
return termsOfUse;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1132,6 +1132,7 @@ public static void writeAccessRightsElement(XMLStreamWriter xmlw, DatasetVersion
xmlw.writeEndElement(); // </rights>

writeRightsHeader(xmlw, language);

if (datasetVersionDTO.getLicense() != null) {
xmlw.writeAttribute("rightsURI", datasetVersionDTO.getLicense().getUri());
xmlw.writeCharacters(datasetVersionDTO.getLicense().getName());
Expand Down
44 changes: 27 additions & 17 deletions src/main/java/edu/harvard/iq/dataverse/util/FileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ public class FileUtil implements java.io.Serializable {
private static final String FILE_FACET_CLASS_TEXT = "Text";
private static final String FILE_FACET_CLASS_OTHER = "Other";
private static final String FILE_FACET_CLASS_UNKNOWN = "Unknown";

public static final String OVERWRITE_MIME_TYPE_PREFIX = "force-";

// The file type facets and type-specific thumbnail classes (above) are
// very similar, but not exactly 1:1; so the following map is for
Expand Down Expand Up @@ -819,24 +821,32 @@ public static CreateDataFileResult createDataFiles(DatasetVersion version, Input
// than the type supplied:
// -- L.A.
String recognizedType = null;

try {
recognizedType = determineFileType(tempFile.toFile(), fileName);
logger.fine("File utility recognized the file as " + recognizedType);
if (recognizedType != null && !recognizedType.equals("")) {
if (useRecognizedType(suppliedContentType, recognizedType)) {
finalType = recognizedType;
}
}

} catch (Exception ex) {
logger.warning("Failed to run the file utility mime type check on file " + fileName);

// If we detect the dataverse prefix in the supplied mimetype we do no
// further recognition
if (suppliedContentType.toLowerCase().startsWith(OVERWRITE_MIME_TYPE_PREFIX)) {
finalType = suppliedContentType.toLowerCase().substring(OVERWRITE_MIME_TYPE_PREFIX.length());
logger.fine("Overwrite prefix detected. Using supplied mime type.");
}

if (finalType == null) {
finalType = (suppliedContentType == null || suppliedContentType.equals(""))
? MIME_TYPE_UNDETERMINED_DEFAULT
: suppliedContentType;
else {
try {
recognizedType = determineFileType(tempFile.toFile(), fileName);
logger.fine("File utility recognized the file as " + recognizedType);
if (recognizedType != null && !recognizedType.equals("")) {
if (useRecognizedType(suppliedContentType, recognizedType)) {
finalType = recognizedType;
}
}

} catch (Exception ex) {
logger.warning("Failed to run the file utility mime type check on file " + fileName);
}

if (finalType == null) {
finalType = (suppliedContentType == null || suppliedContentType.equals(""))
? MIME_TYPE_UNDETERMINED_DEFAULT
: suppliedContentType;
}
}

// A few special cases:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public static String sanitizeBasicHTML(String unsafe) {
// basic includes: a, b, blockquote, br, cite, code, dd, dl, dt, em, i, li, ol, p, pre, q, small, span, strike, strong, sub, sup, u, ul
//Whitelist wl = Whitelist.basic().addTags("img", "h1", "h2", "h3", "kbd", "hr", "s", "del");

Safelist sl = Safelist.basicWithImages().addTags("h1", "h2", "h3", "kbd", "hr", "s", "del", "map", "area").addAttributes("img", "usemap")
.addAttributes("map", "name").addAttributes("area", "shape", "coords", "href", "title", "alt")
Safelist sl = Safelist.basicWithImages().addTags("h1", "h2", "h3", "kbd", "hr", "s", "del", "map", "area").addAttributes("img", "usemap", "style")
.addAttributes("map", "name").addAttributes("area", "shape", "coords", "href", "title", "alt").addAttributes("ol", "type")
.addEnforcedAttribute("a", "target", "_blank");

return Jsoup.clean(unsafe, sl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ public DatasetVersion parseDatasetVersion(JsonObject obj, DatasetVersion dsv) th
throw new JsonParseException(BundleUtil.getStringFromBundle("jsonparser.error.parsing.number", Arrays.asList(ex.getMessage())), ex);
}
}

private edu.harvard.iq.dataverse.license.License parseLicense(String licenseNameOrUri) throws JsonParseException {
if (licenseNameOrUri == null){
boolean safeDefaultIfKeyNotFound = true;
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/util/json/JsonPrinter.java
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,18 @@ public static JsonObjectBuilder jsonDataFileList(List<DataFile> dataFiles){
return bld;
}

private static String getLicense(DatasetVersion dsv) {
if (dsv.getTermsOfUseAndAccess().getLicense() != null) {
if (dsv.getTermsOfUseAndAccess().getLicense().equals(TermsOfUseAndAccess.License.CC0)) {
return "CC BY";
} else {
return dsv.getTermsOfUseAndAccess().getLicense().toString();
}
} else {
return null;
}
}

/**
* Export formats such as DDI require the citation to be included. See
* https://github.com/IQSS/dataverse/issues/2579 for more on DDI export.
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/propertyFiles/Bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ selectedFiles=Selected Files
htmlAllowedTitle=Allowed HTML Tags
htmlAllowedMsg=This field supports only certain <a class="popoverHTML" tabindex="0" role="button">HTML tags</a>.
htmlAllowedTags=&lt;a&gt;, &lt;b&gt;, &lt;blockquote&gt;, &lt;br&gt;, &lt;code&gt;, &lt;del&gt;, &lt;dd&gt;, &lt;dl&gt;, &lt;dt&gt;, &lt;em&gt;, &lt;hr&gt;, &lt;h1&gt;-&lt;h3&gt;, &lt;i&gt;, &lt;img&gt;, &lt;kbd&gt;, &lt;li&gt;, &lt;ol&gt;, &lt;p&gt;, &lt;pre&gt;, &lt;s&gt;, &lt;sup&gt;, &lt;sub&gt;, &lt;strong&gt;, &lt;strike&gt;, &lt;u&gt;, &lt;ul&gt;
vocabularyFaqMsg=More information about vocabularies, terms and URLs <a href="https://www.izus.uni-stuttgart.de/en/fokus/darus/#id-22d988a4-3" rel="help" target="_blank">here</a>.
conditionalRequiredMsg=One or more of these fields may become required if you add to one or more of these optional fields.
conditionalRequiredMsg.tooltip=This field will become required if you choose to enter values in one or more of these optional fields.
toggleNavigation=Toggle navigation
Expand Down Expand Up @@ -806,7 +807,7 @@ dataverse.enterName=Enter name...
dataverse.host.title=The dataverse which contains this data.
dataverse.host.tip=Changing the host dataverse will clear any fields you may have entered data into.
dataverse.host.autocomplete.nomatches=No matches
dataverse.identifier.title=Short name used for the URL of this dataverse.
dataverse.identifier.title=Short name used for the URL of this dataverse. Use your institutional abbreviation as prefix.
dataverse.affiliation.title=The organization with which this dataverse is affiliated.
dataverse.storage.title=A storage service to be used for datasets in this dataverse.
dataverse.metadatalanguage.title=Metadata entered for datasets in this dataverse will be assumed to be in the selected language.
Expand Down Expand Up @@ -1417,7 +1418,7 @@ dataset.publish.header=Publish Dataset
dataset.rejectBtn=Return to Author
dataset.submitBtn=Submit for Review
dataset.disabledSubmittedBtn=Submitted for Review
dataset.submitMessage=You will not be able to make changes to this dataset while it is in review.
dataset.submitMessage=Please use the publication checklist for authors ( https://www.izus.uni-stuttgart.de/fokus/darus/publication/ ) to ensure publication readiness. You will not be able to make changes to this dataset while it is in review.
dataset.submit.success=Your dataset has been submitted for review.
dataset.inreview.infoMessage=The draft version of this dataset is currently under review prior to publication.
dataset.submit.failure=Dataset Submission Failed - {0}
Expand Down Expand Up @@ -1469,7 +1470,7 @@ dataset.share.datasetShare=Share Dataset
dataset.share.datasetShare.tip=Share this dataset on your favorite social media networks.
dataset.share.datasetShare.shareText=View this dataset.
dataset.locked.message=Dataset Locked
dataset.locked.message.details=This dataset is locked until publication.
dataset.locked.message.details=This dataset is reviewed prior to publication by the DaRUS-team. You will receive an email with further information in the next days.
dataset.locked.inReview.message=Submitted for Review
dataset.locked.ingest.message=The tabular data files uploaded are being processed and converted into the archival format
dataset.unlocked.ingest.message=The tabular files have been ingested.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ mp3=audio/mp3
nii=image/nii
nc=application/netcdf
ods=application/vnd.oasis.opendocument.spreadsheet
pdh=text/plain
png=image/png
pptx=application/vnd.openxmlformats-officedocument.presentationml.presentation
prj=application/prj
Expand Down
6 changes: 6 additions & 0 deletions src/main/webapp/metadataFragment.xhtml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
Expand Down Expand Up @@ -325,6 +326,11 @@
<h:outputText value="#{bundle.conditionalRequiredMsg}"/>
</p>
</ui:fragment>
<ui:fragment rendered="#{dsf.datasetFieldType.name == 'keyword'}">
<p class="help-block">
<h:outputText value="#{bundle.vocabularyFaqMsg}" escape="false"/>
</p>
</ui:fragment>
<ui:repeat value="#{dsf.datasetFieldCompoundValues}" var="compoundValue" varStatus="valCount">
<div class="form-group form-col-container col-sm-9 edit-compound-field" data-cvoc-parentfield="#{cvocConf.containsKey(dsf.datasetFieldType.id)?cvocConf.get(dsf.datasetFieldType.id).getString('field-name'):''}">
<!-- Sub Fields -->
Expand Down
Binary file added src/main/webapp/resources/images/ccby.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/main/webapp/resources/js/shib/idpselect_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function IdPSelectUIParms() {
this.preferredIdP = null; // Array of entityIds to always show
this.hiddenIdPs = null; // Array of entityIds to delete
this.ignoreKeywords = false; // Do we ignore the <mdui:Keywords/> when looking for candidates
this.showListFirst = true; // Do we start with a list of IdPs or just the dropdown
this.showListFirst = false; // Do we start with a list of IdPs or just the dropdown
this.samlIdPCookieTTL = 730; // in days
this.setFocusTextBox = true; // Set to false to supress focus
this.testGUI = false;
Expand Down

0 comments on commit cf6b4d6

Please sign in to comment.