use of edu.harvard.iq.dataverse.engine.command.impl.PublishDatasetResult in project dataverse by IQSS.
the class Datasets method publishDataset.
@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').");
}
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'.");
}
Dataset ds = findDatasetOrDie(id);
PublishDatasetResult res = execCommand(new PublishDatasetCommand(ds, createDataverseRequest(findAuthenticatedUserOrDie()), isMinor));
return res.isCompleted() ? ok(json(res.getDataset())) : accepted(json(res.getDataset()));
} catch (WrappedResponse ex) {
return ex.getResponse();
}
}
Aggregations