use of edu.harvard.iq.dataverse.authorization.groups.GroupException 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();
}
use of edu.harvard.iq.dataverse.authorization.groups.GroupException in project dataverse by IQSS.
the class ManageGroupsPage method createExplicitGroup.
public void createExplicitGroup(ActionEvent ae) {
ExplicitGroup eg = explicitGroupService.getProvider().makeGroup();
eg.setDisplayName(getExplicitGroupName());
eg.setGroupAliasInOwner(getExplicitGroupIdentifier());
eg.setDescription(getNewExplicitGroupDescription());
if (getNewExplicitGroupRoleAssignees() != null) {
try {
for (RoleAssignee ra : getNewExplicitGroupRoleAssignees()) {
eg.add(ra);
}
} catch (GroupException ge) {
JsfHelper.JH.addMessage(FacesMessage.SEVERITY_ERROR, "Group Creation failed.", ge.getMessage());
return;
}
}
try {
eg = engineService.submit(new CreateExplicitGroupCommand(dvRequestService.getDataverseRequest(), this.dataverse, eg));
explicitGroups.add(eg);
JsfHelper.addSuccessMessage("Succesfully created group " + eg.getDisplayName() + ". Refresh to update your page.");
} catch (CreateExplicitGroupCommand.GroupAliasExistsException gaee) {
explicitGroupIdentifierField.setValid(false);
FacesContext.getCurrentInstance().addMessage(explicitGroupIdentifierField.getClientId(), new FacesMessage(FacesMessage.SEVERITY_ERROR, gaee.getMessage(), null));
} catch (CommandException ex) {
logger.log(Level.WARNING, "Group creation failed", ex);
JsfHelper.JH.addMessage(FacesMessage.SEVERITY_ERROR, "Group Creation 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();
}
use of edu.harvard.iq.dataverse.authorization.groups.GroupException in project dataverse by IQSS.
the class AddRoleAssigneesToExplicitGroupCommand method execute.
@Override
public ExplicitGroup execute(CommandContext ctxt) throws CommandException {
List<String> nonexistentRAs = new LinkedList<>();
for (String rai : roleAssigneeIdentifiers) {
RoleAssignee ra = null;
try {
ra = ctxt.roleAssignees().getRoleAssignee(rai);
} catch (EJBException iae) {
if (iae.getCausedByException() instanceof IllegalArgumentException) {
throw new IllegalCommandException("Bad role assignee name:" + rai, this);
}
}
if (ra == null) {
nonexistentRAs.add(rai);
} else {
try {
explicitGroup.add(ra);
} catch (GroupException ex) {
Logger.getLogger(AddRoleAssigneesToExplicitGroupCommand.class.getName()).log(Level.WARNING, "Error adding role assignee " + rai + " to group" + " " + explicitGroup.getIdentifier(), ex);
throw new IllegalCommandException("Error adding " + rai + " to group " + explicitGroup.getIdentifier() + ": " + ex.getMessage(), this);
}
}
}
if (nonexistentRAs.isEmpty()) {
return ctxt.explicitGroups().persist(explicitGroup);
} else {
StringBuilder sb = new StringBuilder();
for (String s : nonexistentRAs) {
sb.append(s).append(", ");
}
sb.setLength(sb.length() - 2);
throw new IllegalCommandException("The following role assignees were not found: " + sb.toString(), this);
}
}
Aggregations