Search in sources :

Example 1 with PublishDatasetResult

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();
    }
}
Also used : Dataset(edu.harvard.iq.dataverse.Dataset) PublishDatasetResult(edu.harvard.iq.dataverse.engine.command.impl.PublishDatasetResult) PublishDatasetCommand(edu.harvard.iq.dataverse.engine.command.impl.PublishDatasetCommand) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Aggregations

Dataset (edu.harvard.iq.dataverse.Dataset)1 PublishDatasetCommand (edu.harvard.iq.dataverse.engine.command.impl.PublishDatasetCommand)1 PublishDatasetResult (edu.harvard.iq.dataverse.engine.command.impl.PublishDatasetResult)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1