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();
}
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";
}
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);
}
}
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();
}
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();
}
Aggregations