Search in sources :

Example 1 with MoveDatasetCommand

use of edu.harvard.iq.dataverse.engine.command.impl.MoveDatasetCommand in project dataverse by IQSS.

the class Datasets method moveDataset.

@POST
@Path("{id}/move/{targetDataverseAlias}")
public Response moveDataset(@PathParam("id") String id, @PathParam("targetDataverseAlias") String targetDataverseAlias, @QueryParam("forceMove") Boolean force) {
    try {
        System.out.print("force: " + force);
        User u = findUserOrDie();
        Dataset ds = findDatasetOrDie(id);
        Dataverse target = dataverseService.findByAlias(targetDataverseAlias);
        if (target == null) {
            return error(Response.Status.BAD_REQUEST, "Target Dataverse not found.");
        }
        // Command requires Super user - it will be tested by the command
        execCommand(new MoveDatasetCommand(createDataverseRequest(u), ds, target, force));
        return ok("Dataset moved successfully");
    } catch (WrappedResponse ex) {
        return ex.getResponse();
    }
}
Also used : AuthenticatedUser(edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser) User(edu.harvard.iq.dataverse.authorization.users.User) Dataset(edu.harvard.iq.dataverse.Dataset) MoveDatasetCommand(edu.harvard.iq.dataverse.engine.command.impl.MoveDatasetCommand) Dataverse(edu.harvard.iq.dataverse.Dataverse) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Aggregations

Dataset (edu.harvard.iq.dataverse.Dataset)1 Dataverse (edu.harvard.iq.dataverse.Dataverse)1 AuthenticatedUser (edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser)1 User (edu.harvard.iq.dataverse.authorization.users.User)1 MoveDatasetCommand (edu.harvard.iq.dataverse.engine.command.impl.MoveDatasetCommand)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1