use of edu.harvard.iq.dataverse.engine.command.impl.CreateExplicitGroupCommand in project dataverse by IQSS.
the class Dataverses method createExplicitGroup.
@POST
@Path("{identifier}/groups/")
public Response createExplicitGroup(ExplicitGroupDTO dto, @PathParam("identifier") String dvIdtf) {
return response(req -> {
ExplicitGroupProvider prv = explicitGroupSvc.getProvider();
ExplicitGroup newGroup = dto.apply(prv.makeGroup());
newGroup = execCommand(new CreateExplicitGroupCommand(req, findDataverseOrDie(dvIdtf), newGroup));
String groupUri = String.format("%s/groups/%s", dvIdtf, newGroup.getGroupAliasInOwner());
return created(groupUri, json(newGroup));
});
}
use of edu.harvard.iq.dataverse.engine.command.impl.CreateExplicitGroupCommand 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();
}
Aggregations