use of edu.harvard.iq.dataverse.engine.command.exception.CommandException in project dataverse by IQSS.
the class SubmitDatasetForReviewCommandTest method testDatasetNull.
@Test
public void testDatasetNull() {
dataset = null;
String expected = "Can't submit for review. Dataset is null.";
String actual = null;
Dataset updatedDataset = null;
try {
updatedDataset = testEngine.submit(new SubmitDatasetForReviewCommand(dataverseRequest, dataset));
} catch (CommandException ex) {
actual = ex.getMessage();
}
assertEquals(expected, actual);
assertNull(updatedDataset);
}
use of edu.harvard.iq.dataverse.engine.command.exception.CommandException in project dataverse by IQSS.
the class SubmitDatasetForReviewCommandTest method testDraftDataset.
@Test
public void testDraftDataset() {
dataset.getLatestVersion().setVersionState(DatasetVersion.VersionState.DRAFT);
Dataset updatedDataset = null;
try {
updatedDataset = testEngine.submit(new SubmitDatasetForReviewCommand(dataverseRequest, dataset));
} catch (CommandException ex) {
System.out.println("Error updating dataset: " + ex.getMessage());
}
assertNotNull(updatedDataset);
}
use of edu.harvard.iq.dataverse.engine.command.exception.CommandException in project dataverse by IQSS.
the class ManageFilePermissionsPage method revokeRole.
// internal method used by removeRoleAssignments
private void revokeRole(Long roleAssignmentId) {
try {
RoleAssignment ra = em.find(RoleAssignment.class, roleAssignmentId);
commandEngine.submit(new RevokeRoleCommand(ra, dvRequestService.getDataverseRequest()));
JsfHelper.addSuccessMessage(ra.getRole().getName() + " role for " + roleAssigneeService.getRoleAssignee(ra.getAssigneeIdentifier()).getDisplayInfo().getTitle() + " was removed.");
} catch (PermissionException ex) {
JH.addMessage(FacesMessage.SEVERITY_ERROR, "The role assignment was not able to be removed.", "Permissions " + ex.getRequiredPermissions().toString() + " missing.");
} catch (CommandException ex) {
JH.addMessage(FacesMessage.SEVERITY_FATAL, "The role assignment could not be removed.");
logger.log(Level.SEVERE, "Error removing role assignment: " + ex.getMessage(), ex);
}
}
use of edu.harvard.iq.dataverse.engine.command.exception.CommandException in project dataverse by IQSS.
the class ManageFilePermissionsPage method assignRole.
private boolean assignRole(RoleAssignee ra, DataFile file, DataverseRole r) {
try {
String privateUrlToken = null;
commandEngine.submit(new AssignRoleCommand(ra, r, file, dvRequestService.getDataverseRequest(), privateUrlToken));
JsfHelper.addSuccessMessage(r.getName() + " role assigned to " + ra.getDisplayInfo().getTitle() + " for " + file.getDisplayName() + ".");
} catch (PermissionException ex) {
JH.addMessage(FacesMessage.SEVERITY_ERROR, "The role was not able to be assigned.", "Permissions " + ex.getRequiredPermissions().toString() + " missing.");
return false;
} catch (CommandException ex) {
// JH.addMessage(FacesMessage.SEVERITY_FATAL, "The role was not able to be assigned.");
String message = r.getName() + " role could NOT be assigned to " + ra.getDisplayInfo().getTitle() + " for " + file.getDisplayName() + ".";
JsfHelper.addErrorMessage(message);
logger.log(Level.SEVERE, "Error assiging role: " + ex.getMessage(), ex);
return false;
}
return true;
}
use of edu.harvard.iq.dataverse.engine.command.exception.CommandException in project dataverse by IQSS.
the class ManageGroupsPage method saveExplicitGroup.
public void saveExplicitGroup(ActionEvent ae) {
ExplicitGroup eg = selectedGroup;
if (getSelectedGroupAddRoleAssignees() != null) {
try {
for (RoleAssignee ra : getSelectedGroupAddRoleAssignees()) {
eg.add(ra);
}
} catch (GroupException ge) {
JsfHelper.JH.addMessage(FacesMessage.SEVERITY_ERROR, "Group edit failed.", ge.getMessage());
return;
}
}
try {
eg = engineService.submit(new UpdateExplicitGroupCommand(dvRequestService.getDataverseRequest(), eg));
JsfHelper.addSuccessMessage("Succesfully saved group " + eg.getDisplayName());
} catch (CommandException ex) {
JsfHelper.JH.addMessage(FacesMessage.SEVERITY_ERROR, "Group Save failed.", ex.getMessage());
} catch (Exception ex) {
JH.addMessage(FacesMessage.SEVERITY_FATAL, "The role was not able to be saved.");
logger.log(Level.SEVERE, "Error saving role: " + ex.getMessage(), ex);
}
showAssignmentMessages();
}
Aggregations