Search in sources :

Example 1 with DeleteMapLayerMetadataCommand

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

the class Files method getMapLayerMetadatas.

// end: replaceFileInDataset
@DELETE
@Path("{id}/map")
public Response getMapLayerMetadatas(@PathParam("id") Long idSupplied) {
    DataverseRequest dataverseRequest = null;
    try {
        dataverseRequest = createDataverseRequest(findUserOrDie());
    } catch (WrappedResponse wr) {
        return error(BAD_REQUEST, "Couldn't find user to execute command: " + wr.getLocalizedMessage());
    }
    DataFile dataFile = fileService.find(idSupplied);
    try {
        boolean deleted = engineSvc.submit(new DeleteMapLayerMetadataCommand(dataverseRequest, dataFile));
        if (deleted) {
            return ok("Map deleted from file id " + dataFile.getId());
        } else {
            return error(BAD_REQUEST, "Could not delete map from file id " + dataFile.getId());
        }
    } catch (CommandException ex) {
        return error(BAD_REQUEST, "Problem trying to delete map from file id " + dataFile.getId() + ": " + ex.getLocalizedMessage());
    }
}
Also used : DataverseRequest(edu.harvard.iq.dataverse.engine.command.DataverseRequest) DataFile(edu.harvard.iq.dataverse.DataFile) DeleteMapLayerMetadataCommand(edu.harvard.iq.dataverse.engine.command.impl.DeleteMapLayerMetadataCommand) CommandException(edu.harvard.iq.dataverse.engine.command.exception.CommandException) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Aggregations

DataFile (edu.harvard.iq.dataverse.DataFile)1 DataverseRequest (edu.harvard.iq.dataverse.engine.command.DataverseRequest)1 CommandException (edu.harvard.iq.dataverse.engine.command.exception.CommandException)1 DeleteMapLayerMetadataCommand (edu.harvard.iq.dataverse.engine.command.impl.DeleteMapLayerMetadataCommand)1 DELETE (javax.ws.rs.DELETE)1 Path (javax.ws.rs.Path)1