Search in sources :

Example 46 with CommandException

use of edu.harvard.iq.dataverse.engine.command.exception.CommandException in project dataverse by IQSS.

the class DatasetPage method deaccessionVersions.

public String deaccessionVersions() {
    Command<DatasetVersion> cmd;
    try {
        if (selectedDeaccessionVersions == null) {
            for (DatasetVersion dv : this.dataset.getVersions()) {
                if (dv.isReleased()) {
                    DatasetVersion deaccession = datasetVersionService.find(dv.getId());
                    cmd = new DeaccessionDatasetVersionCommand(dvRequestService.getDataverseRequest(), setDatasetVersionDeaccessionReasonAndURL(deaccession), true);
                    DatasetVersion datasetv = commandEngine.submit(cmd);
                }
            }
        } else {
            for (DatasetVersion dv : selectedDeaccessionVersions) {
                DatasetVersion deaccession = datasetVersionService.find(dv.getId());
                cmd = new DeaccessionDatasetVersionCommand(dvRequestService.getDataverseRequest(), setDatasetVersionDeaccessionReasonAndURL(deaccession), false);
                DatasetVersion datasetv = commandEngine.submit(cmd);
            }
        }
    } catch (CommandException ex) {
        logger.severe(ex.getMessage());
        JH.addMessage(FacesMessage.SEVERITY_FATAL, JH.localize("dataset.message.deaccessionFailure"));
    }
    JsfHelper.addSuccessMessage(JH.localize("datasetVersion.message.deaccessionSuccess"));
    return returnToDatasetOnly();
}
Also used : CommandException(edu.harvard.iq.dataverse.engine.command.exception.CommandException) IllegalCommandException(edu.harvard.iq.dataverse.engine.command.exception.IllegalCommandException) DeaccessionDatasetVersionCommand(edu.harvard.iq.dataverse.engine.command.impl.DeaccessionDatasetVersionCommand)

Example 47 with CommandException

use of edu.harvard.iq.dataverse.engine.command.exception.CommandException in project dataverse by IQSS.

the class DatasetPage method deleteDataset.

public String deleteDataset() {
    DestroyDatasetCommand cmd;
    try {
        cmd = new DestroyDatasetCommand(dataset, dvRequestService.getDataverseRequest());
        commandEngine.submit(cmd);
    /* - need to figure out what to do 
             Update notification in Delete Dataset Method
             for (UserNotification und : userNotificationService.findByDvObject(dataset.getId())){
             userNotificationService.delete(und);
             } */
    } catch (CommandException ex) {
        JH.addMessage(FacesMessage.SEVERITY_FATAL, JH.localize("dataset.message.deleteFailure"));
        logger.severe(ex.getMessage());
    }
    JsfHelper.addSuccessMessage(JH.localize("dataset.message.deleteSuccess"));
    return "/dataverse.xhtml?alias=" + dataset.getOwner().getAlias() + "&faces-redirect=true";
}
Also used : CommandException(edu.harvard.iq.dataverse.engine.command.exception.CommandException) IllegalCommandException(edu.harvard.iq.dataverse.engine.command.exception.IllegalCommandException) DestroyDatasetCommand(edu.harvard.iq.dataverse.engine.command.impl.DestroyDatasetCommand)

Example 48 with CommandException

use of edu.harvard.iq.dataverse.engine.command.exception.CommandException in project dataverse by IQSS.

the class DatasetPage method releaseParentDV.

private void releaseParentDV() {
    if (session.getUser() instanceof AuthenticatedUser) {
        PublishDataverseCommand cmd = new PublishDataverseCommand(dvRequestService.getDataverseRequest(), dataset.getOwner());
        try {
            commandEngine.submit(cmd);
            JsfHelper.addSuccessMessage(JH.localize("dataverse.publish.success"));
        } catch (CommandException ex) {
            logger.log(Level.SEVERE, "Unexpected Exception calling  publish dataverse command", ex);
            JsfHelper.addErrorMessage(JH.localize("dataverse.publish.failure"));
        }
    } else {
        FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "DataverseNotReleased", "Only authenticated users can release a dataverse.");
        FacesContext.getCurrentInstance().addMessage(null, message);
    }
}
Also used : PublishDataverseCommand(edu.harvard.iq.dataverse.engine.command.impl.PublishDataverseCommand) CommandException(edu.harvard.iq.dataverse.engine.command.exception.CommandException) IllegalCommandException(edu.harvard.iq.dataverse.engine.command.exception.IllegalCommandException) AuthenticatedUser(edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser) FacesMessage(javax.faces.application.FacesMessage)

Example 49 with CommandException

use of edu.harvard.iq.dataverse.engine.command.exception.CommandException in project dataverse by IQSS.

the class DatasetPage method registerDataset.

public String registerDataset() {
    UpdateDatasetCommand cmd;
    try {
        cmd = new UpdateDatasetCommand(dataset, dvRequestService.getDataverseRequest());
        cmd.setValidateLenient(true);
        dataset = commandEngine.submit(cmd);
    } catch (CommandException ex) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, "Dataset Registration Failed", " - " + ex.toString()));
        logger.severe(ex.getMessage());
    }
    FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "DatasetRegistered", "Your dataset is now registered.");
    FacesContext.getCurrentInstance().addMessage(null, message);
    return returnToDatasetOnly();
}
Also used : CommandException(edu.harvard.iq.dataverse.engine.command.exception.CommandException) IllegalCommandException(edu.harvard.iq.dataverse.engine.command.exception.IllegalCommandException) FacesMessage(javax.faces.application.FacesMessage) UpdateDatasetCommand(edu.harvard.iq.dataverse.engine.command.impl.UpdateDatasetCommand)

Example 50 with CommandException

use of edu.harvard.iq.dataverse.engine.command.exception.CommandException in project dataverse by IQSS.

the class DatasetPage method saveLinkedDataset.

public String saveLinkedDataset() {
    if (linkingDataverseId == null) {
        JsfHelper.addFlashMessage("You must select a linking dataverse.");
        return "";
    }
    linkingDataverse = dataverseService.find(linkingDataverseId);
    if (readOnly) {
        // Pass a "real", non-readonly dataset the the LinkDatasetCommand:
        dataset = datasetService.find(dataset.getId());
    }
    LinkDatasetCommand cmd = new LinkDatasetCommand(dvRequestService.getDataverseRequest(), linkingDataverse, dataset);
    try {
        commandEngine.submit(cmd);
        JsfHelper.addSuccessMessage(BundleUtil.getStringFromBundle("dataset.message.linkSuccess", getSuccessMessageArguments()));
    } catch (CommandException ex) {
        String msg = "There was a problem linking this dataset to yours: " + ex;
        logger.severe(msg);
        /**
         * @todo how do we get this message to show up in the GUI?
         */
        FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "DatasetNotLinked", msg);
        FacesContext.getCurrentInstance().addMessage(null, message);
    }
    return returnToLatestVersion();
}
Also used : LinkDatasetCommand(edu.harvard.iq.dataverse.engine.command.impl.LinkDatasetCommand) CommandException(edu.harvard.iq.dataverse.engine.command.exception.CommandException) IllegalCommandException(edu.harvard.iq.dataverse.engine.command.exception.IllegalCommandException) FacesMessage(javax.faces.application.FacesMessage)

Aggregations

CommandException (edu.harvard.iq.dataverse.engine.command.exception.CommandException)86 Dataset (edu.harvard.iq.dataverse.Dataset)21 AuthenticatedUser (edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser)20 IllegalCommandException (edu.harvard.iq.dataverse.engine.command.exception.IllegalCommandException)19 Test (org.junit.Test)16 PermissionException (edu.harvard.iq.dataverse.engine.command.exception.PermissionException)15 EJBException (javax.ejb.EJBException)13 DataverseRequest (edu.harvard.iq.dataverse.engine.command.DataverseRequest)12 DataFile (edu.harvard.iq.dataverse.DataFile)11 Dataverse (edu.harvard.iq.dataverse.Dataverse)9 UpdateDatasetCommand (edu.harvard.iq.dataverse.engine.command.impl.UpdateDatasetCommand)9 ConstraintViolation (javax.validation.ConstraintViolation)9 DatasetThumbnail (edu.harvard.iq.dataverse.dataset.DatasetThumbnail)8 IOException (java.io.IOException)8 Timestamp (java.sql.Timestamp)8 ArrayList (java.util.ArrayList)8 Date (java.util.Date)8 FacesMessage (javax.faces.application.FacesMessage)7 DatasetVersion (edu.harvard.iq.dataverse.DatasetVersion)6 SwordError (org.swordapp.server.SwordError)6