Skip to content

Commit

Permalink
Merge branch 'develop' into 3036-support-form-math-bug
Browse files Browse the repository at this point in the history
  • Loading branch information
pdurbin committed Jan 17, 2017
2 parents e0d5e51 + feb4e2c commit b1bafd1
Show file tree
Hide file tree
Showing 33 changed files with 249 additions and 190 deletions.
2 changes: 2 additions & 0 deletions doc/sphinx-guides/source/api/native-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ Publishes the dataset whose id is passed. The new dataset version number is dete

POST http://$SERVER/api/datasets/$id/actions/:publish?type=$type&key=$apiKey

.. note:: POST should be used to publish a dataset. GET is supported for backward compatibility but is deprecated and may be removed: https://github.com/IQSS/dataverse/issues/2431

Deletes the draft version of dataset ``$id``. Only the draft version can be deleted::

DELETE http://$SERVER/api/datasets/$id/versions/:draft?key=$apiKey
Expand Down
2 changes: 2 additions & 0 deletions doc/sphinx-guides/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,3 +425,5 @@

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'http://docs.python.org/': None}
# Suppress "WARNING: unknown mimetype for ..." https://github.com/IQSS/dataverse/issues/3391
suppress_warnings = ['epub.unknown_project_files']
14 changes: 14 additions & 0 deletions doc/sphinx-guides/source/installation/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,20 @@ Set ``GuidesBaseUrl`` to override the default value "http://guides.dataverse.org

``curl -X PUT -d http://dataverse.example.edu http://localhost:8080/api/admin/settings/:GuidesBaseUrl``

:GuidesVersion
++++++++++++++

Set ``:GuidesVersion`` to override the version number in the URL of guides. For example, rather than http://guides.dataverse.org/en/4.6/user/account.html the version is overriden to http://guides.dataverse.org/en/1234-new-feature/user/account.html in the example below:

``curl -X PUT -d 1234-new-feature http://localhost:8080/api/admin/settings/:GuidesVersion``

:MetricsUrl
+++++++++++

Make the metrics component on the root dataverse a clickable link to a website where you present metrics on your Dataverse installation. This could perhaps be an installation of https://github.com/IQSS/miniverse or any site.

``curl -X PUT -d http://metrics.dataverse.example.edu http://localhost:8080/api/admin/settings/:MetricsUrl``

:StatusMessageHeader
++++++++++++++++++++

Expand Down
1 change: 1 addition & 0 deletions src/main/java/Bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,7 @@ dataset.exportBtn.itemLabel.ddi=DDI
dataset.exportBtn.itemLabel.dublinCore=Dublin Core
dataset.exportBtn.itemLabel.json=JSON
metrics.title=Metrics
metrics.title.tip=View more metrics information
metrics.comingsoon=Coming soon...
metrics.views=Views
metrics.downloads={0, choice, 0#Downloads|1#Download|2#Downloads}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/harvard/iq/dataverse/DataversePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ public String save() {
if (editMode != null && editMode.equals(EditMode.FEATURED)) {
message = "The featured dataverses for this dataverse have been updated.";
} else {
message = (create) ? BundleUtil.getStringFromBundle("dataverse.create.success", Arrays.asList(settingsWrapper.getGuidesBaseUrl(), systemConfig.getVersion())) : BundleUtil.getStringFromBundle("dataverse.update.success");
message = (create) ? BundleUtil.getStringFromBundle("dataverse.create.success", Arrays.asList(settingsWrapper.getGuidesBaseUrl(), systemConfig.getGuidesVersion())) : BundleUtil.getStringFromBundle("dataverse.update.success");
}
JsfHelper.addSuccessMessage(message);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import edu.harvard.iq.dataverse.engine.command.exception.CommandException;
import edu.harvard.iq.dataverse.engine.command.impl.CreateGuestbookResponseCommand;
import edu.harvard.iq.dataverse.engine.command.impl.RequestAccessCommand;
import edu.harvard.iq.dataverse.util.FileUtil;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.ArrayList;
Expand Down Expand Up @@ -295,7 +296,7 @@ public void downloadCitationXML(FileMetadata fileMetadata, Dataset dataset) {
fileNameString = "attachment;filename=" + getFileNameDOI(workingVersion) + ".xml";
} else {
// Datafile-level citation:
fileNameString = "attachment;filename=" + getFileNameDOI(workingVersion) + "-" + fileMetadata.getLabel().replaceAll("\\.tab$", "-endnote.xml");
fileNameString = "attachment;filename=" + getFileNameDOI(workingVersion) + "-" + FileUtil.getCiteDataFileFilename(fileMetadata, FileUtil.FileCitationExtension.ENDNOTE);
}
response.setHeader("Content-Disposition", fileNameString);
try {
Expand Down Expand Up @@ -336,7 +337,7 @@ public void downloadCitationRIS(FileMetadata fileMetadata, Dataset dataset) {
fileNameString = "attachment;filename=" + getFileNameDOI(workingVersion) + ".ris";
} else {
// Datafile-level citation:
fileNameString = "attachment;filename=" + getFileNameDOI(workingVersion) + "-" + fileMetadata.getLabel().replaceAll("\\.tab$", ".ris");
fileNameString = "attachment;filename=" + getFileNameDOI(workingVersion) + "-" + FileUtil.getCiteDataFileFilename(fileMetadata, FileUtil.FileCitationExtension.RIS);
}
response.setHeader("Content-Disposition", fileNameString);

Expand Down Expand Up @@ -383,7 +384,7 @@ public void downloadCitationBibtex(FileMetadata fileMetadata, Dataset dataset) {
fileNameString = "attachment;filename=" + getFileNameDOI(workingVersion) + ".bib";
} else {
// Datafile-level citation:
fileNameString = "attachment;filename=" + getFileNameDOI(workingVersion) + "-" + fileMetadata.getLabel().replaceAll("\\.tab$", ".bib");
fileNameString = "attachment;filename=" + getFileNameDOI(workingVersion) + "-" + FileUtil.getCiteDataFileFilename(fileMetadata, FileUtil.FileCitationExtension.BIBTEX);
}
response.setHeader("Content-Disposition", fileNameString);

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/edu/harvard/iq/dataverse/MailServiceBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ private String getMessageTextBasedOnNotification(UserNotification userNotificati
parentDataverseDisplayName,
parentDataverseUrl,
systemConfig.getGuidesBaseUrl(),
systemConfig.getVersion()));
systemConfig.getGuidesVersion()));
logger.fine(dataverseCreatedMessage);
return messageText += dataverseCreatedMessage;
case REQUESTFILEACCESS:
Expand Down Expand Up @@ -393,7 +393,7 @@ private String getMessageTextBasedOnNotification(UserNotification userNotificati
version.getDataset().getOwner().getDisplayName(),
getDataverseLink(version.getDataset().getOwner()),
systemConfig.getGuidesBaseUrl(),
systemConfig.getVersion()
systemConfig.getGuidesVersion()
));
logger.fine(datasetCreatedMessage);
return messageText += datasetCreatedMessage;
Expand Down Expand Up @@ -427,7 +427,7 @@ private String getMessageTextBasedOnNotification(UserNotification userNotificati
case CREATEACC:
String accountCreatedMessage = BundleUtil.getStringFromBundle("notification.email.welcome", Arrays.asList(
systemConfig.getGuidesBaseUrl(),
systemConfig.getVersion()
systemConfig.getGuidesVersion()
));
String optionalConfirmEmailAddon = confirmEmailService.optionalConfirmEmailAddonMsg(userNotification.getUser());
accountCreatedMessage += optionalConfirmEmailAddon;
Expand Down
69 changes: 39 additions & 30 deletions src/main/java/edu/harvard/iq/dataverse/api/Datasets.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
@Path("datasets")
public class Datasets extends AbstractApiBean {

private static final Logger LOGGER = Logger.getLogger(Datasets.class.getName());
private static final Logger logger = Logger.getLogger(Datasets.class.getCanonicalName());

private static final String PERSISTENT_ID_KEY=":persistentId";

Expand Down Expand Up @@ -148,7 +148,7 @@ public Response exportDataset(@QueryParam("persistentId") String persistentId, @
// (the way Access API streams its output).
// -- L.A., 4.5

LOGGER.fine("xml to return: " + xml);
logger.fine("xml to return: " + xml);
String mediaType = MediaType.TEXT_PLAIN;
if (instance.isXMLFormat(exporter)){
mediaType = MediaType.APPLICATION_XML;
Expand Down Expand Up @@ -334,7 +334,7 @@ public Response updateDraftVersion( String jsonBody, @PathParam("id") String id,
return ok( json(managedVersion) );

} catch (JsonParseException ex) {
LOGGER.log(Level.SEVERE, "Semantic error parsing dataset version Json: " + ex.getMessage(), ex);
logger.log(Level.SEVERE, "Semantic error parsing dataset version Json: " + ex.getMessage(), ex);
return error( Response.Status.BAD_REQUEST, "Error parsing dataset version: " + ex.getMessage() );

} catch (WrappedResponse ex) {
Expand All @@ -343,36 +343,45 @@ public Response updateDraftVersion( String jsonBody, @PathParam("id") String id,
}
}

/**
* @deprecated This was shipped as a GET but should have been a POST, see https://github.com/IQSS/dataverse/issues/2431
*/
@GET
@Path("{id}/actions/:publish")
public Response publishDataset( @PathParam("id") String id, @QueryParam("type") String type ) {
@Path("{id}/actions/:publish")
@Deprecated
public Response publishDataseUsingGetDeprecated( @PathParam("id") String id, @QueryParam("type") String type ) {
logger.info("publishDataseUsingGetDeprecated called on id " + id + ". Encourage use of POST rather than GET, which is deprecated.");
return publishDataset(id, type);
}

@POST
@Path("{id}/actions/:publish")
public Response publishDataset(@PathParam("id") String id, @QueryParam("type") String type) {
try {
if ( type == null ) {
return error( Response.Status.BAD_REQUEST, "Missing 'type' parameter (either 'major' or 'minor').");
if (type == null) {
return error(Response.Status.BAD_REQUEST, "Missing 'type' parameter (either 'major' or 'minor').");
}

type = type.toLowerCase();
boolean isMinor;
switch ( type ) {
case "minor": isMinor = true; break;
case "major": isMinor = false; break;
default: return error( Response.Status.BAD_REQUEST, "Illegal 'type' parameter value '" + type + "'. It needs to be either 'major' or 'minor'.");
switch (type) {
case "minor":
isMinor = true;
break;
case "major":
isMinor = false;
break;
default:
return error(Response.Status.BAD_REQUEST, "Illegal 'type' parameter value '" + type + "'. It needs to be either 'major' or 'minor'.");
}
long dsId;
try {
dsId = Long.parseLong(id);
} catch ( NumberFormatException nfe ) {
return error( Response.Status.BAD_REQUEST, "Bad dataset id. Please provide a number.");
}

Dataset ds = datasetService.find(dsId);

return ( ds == null ) ? notFound("Can't find dataset with id '" + id + "'")
: ok( json(execCommand(new PublishDatasetCommand(ds,
createDataverseRequest(findAuthenticatedUserOrDie()),
isMinor))) );

} catch (WrappedResponse ex) {

Dataset ds = findDatasetOrDie(id);

return ok(json(execCommand(new PublishDatasetCommand(ds,
createDataverseRequest(findAuthenticatedUserOrDie()),
isMinor))));

} catch (WrappedResponse ex) {
return ex.getResponse();
}
}
Expand Down Expand Up @@ -420,7 +429,7 @@ public Response getDdi(@QueryParam("id") long id, @QueryParam("persistentId") St
return error(Response.Status.FORBIDDEN, "Not a superuser");
}

LOGGER.fine("looking up " + persistentId);
logger.fine("looking up " + persistentId);
Dataset dataset = datasetService.findByGlobalId(persistentId);
if (dataset == null) {
return error(Response.Status.NOT_FOUND, "A dataset with the persistentId " + persistentId + " could not be found.");
Expand All @@ -439,7 +448,7 @@ public Response getDdi(@QueryParam("id") long id, @QueryParam("persistentId") St
ddiExportService.exportDataset(dataset.getId(), outputStream, null, null);
xml = outputStream.toString();
}
LOGGER.fine("xml to return: " + xml);
logger.fine("xml to return: " + xml);

return Response.ok()
.entity(xml)
Expand Down Expand Up @@ -473,7 +482,7 @@ public Response createAssignment(String userOrGroup, @PathParam("identifier") St
return ok(
json(execCommand(new AssignRoleCommand(assignee, theRole, dataset, createDataverseRequest(findUserOrDie()), privateUrlToken))));
} catch (WrappedResponse ex) {
LOGGER.log(Level.WARNING, "Can''t create assignment: {0}", ex.getMessage());
logger.log(Level.WARNING, "Can''t create assignment: {0}", ex.getMessage());
return ex.getResponse();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ public Dataset execute(CommandContext ctxt) throws CommandException {
throw new IllegalCommandException("Latest version of dataset " + theDataset.getIdentifier() + " is already released. Only draft versions can be released.", this);
}

// prevent publishing of 0.1 version
if (minorRelease && theDataset.getVersions().size() == 1 && theDataset.getLatestVersion().isDraft()) {
throw new IllegalCommandException("Cannot publish as minor version. Re-try as major release.", this);
}

if (minorRelease && !theDataset.getLatestVersion().isMinorUpdate()) {
throw new IllegalCommandException("Cannot release as minor version. Re-try as major release.", this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,14 @@ public enum Key {
TwoRavensUrl,
/** Optionally override http://guides.dataverse.org . */
GuidesBaseUrl,
/**
* A link to an installation of https://github.com/IQSS/miniverse or
* some other metrics app.
*/
MetricsUrl,
/* zip download size limit */
/** Optionally override version number in guides. */
GuidesVersion,
ZipDownloadLimit,
/* zip upload number of files limit */
ZipUploadFilesLimit,
Expand Down
33 changes: 30 additions & 3 deletions src/main/java/edu/harvard/iq/dataverse/util/FileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,34 @@ private static void createIngestReport (DataFile dataFile, int status, String me
dataFile.setIngestReport(errorReport);
}
}




public enum FileCitationExtension {

ENDNOTE("-endnote.xml"),
RIS(".ris"),
BIBTEX(".bib");

private final String text;

private FileCitationExtension(final String text) {
this.text = text;
}
}

public static String getCiteDataFileFilename(FileMetadata fileMetadata, FileCitationExtension fileCitationExtension) {
if (fileMetadata == null) {
logger.info("In getCitationBibtex but FileMetadata is null!");
return null;
}
if (fileCitationExtension == null) {
logger.info("In getCitationBibtex but fileCitationExtension is null!");
return null;
}
if (fileMetadata.getLabel().endsWith("tab")) {
return fileMetadata.getLabel().replaceAll("\\.tab$", fileCitationExtension.text);
} else {
return fileMetadata.getLabel() + fileCitationExtension.text;
}
}

}
15 changes: 15 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/util/SystemConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,21 @@ private String getGuidesLanguage() {
return saneDefault;
}

public String getGuidesVersion() {
String saneDefault = getVersion();
String guidesVersion = settingsService.getValueForKey(SettingsServiceBean.Key.GuidesVersion, saneDefault);
if (guidesVersion != null) {
return guidesVersion;
}
return saneDefault;
}

public String getMetricsUrl() {
String saneDefault = null;
String metricsUrl = settingsService.getValueForKey(SettingsServiceBean.Key.MetricsUrl, saneDefault);
return metricsUrl;
}

/**
* Download-as-zip size limit.
* returns 0 if not specified;
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/dashboard.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<span class="glyphicon glyphicon-info-sign"/>
<h:outputFormat value=" #{bundle['dashboard.card.metadataexport.message']}" escape="false">
<f:param value="#{dataverseServiceBean.findRootDataverse().displayName}"/>
<f:param value="&lt;a href=&#34;#{systemConfig.guidesBaseUrl}/#{systemConfig.version}/api&#34; target=&#34;_blank&#34;&gt;"/>
<f:param value="&lt;a href=&#34;#{systemConfig.guidesBaseUrl}/#{systemConfig.guidesVersion}/api&#34; target=&#34;_blank&#34;&gt;"/>
<f:param value="&lt;/a&gt;"/>
</h:outputFormat>
</p>
Expand Down
6 changes: 3 additions & 3 deletions src/main/webapp/dataset-widgets.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@
<li>
<h:outputFormat value="#{bundle['dataset.widgets.notPublished.how.tip3']}" escape="false">
<f:param value="#{systemConfig.guidesBaseUrl}"/>
<f:param value="#{systemConfig.version}"/>
<f:param value="#{systemConfig.guidesVersion}"/>
</h:outputFormat>
</li>
</ul>
<p>
<h:outputFormat value="#{bundle['dataset.widgets.notPublished.getStarted']}" escape="false">
<f:param value="#{systemConfig.guidesBaseUrl}"/>
<f:param value="#{systemConfig.version}"/>
<f:param value="#{systemConfig.guidesVersion}"/>
</h:outputFormat>
</p>
</div>
Expand All @@ -52,7 +52,7 @@
<p class="help-block"><span class="glyphicon glyphicon-info-sign"/>
<h:outputFormat value=" #{bundle['dataset.widgets.tip']}" escape="false">
<f:param value="#{systemConfig.guidesBaseUrl}"/>
<f:param value="#{systemConfig.version}"/>
<f:param value="#{systemConfig.guidesVersion}"/>
</h:outputFormat>
</p>
<div>
Expand Down
Loading

0 comments on commit b1bafd1

Please sign in to comment.