Search in sources :

Example 1 with CreateExplicitGroupCommand

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));
    });
}
Also used : CreateExplicitGroupCommand(edu.harvard.iq.dataverse.engine.command.impl.CreateExplicitGroupCommand) ExplicitGroupProvider(edu.harvard.iq.dataverse.authorization.groups.impl.explicit.ExplicitGroupProvider) JsonString(javax.json.JsonString) ExplicitGroup(edu.harvard.iq.dataverse.authorization.groups.impl.explicit.ExplicitGroup) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 2 with CreateExplicitGroupCommand

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();
}
Also used : CreateExplicitGroupCommand(edu.harvard.iq.dataverse.engine.command.impl.CreateExplicitGroupCommand) GroupException(edu.harvard.iq.dataverse.authorization.groups.GroupException) CommandException(edu.harvard.iq.dataverse.engine.command.exception.CommandException) FacesMessage(javax.faces.application.FacesMessage) CommandException(edu.harvard.iq.dataverse.engine.command.exception.CommandException) GroupException(edu.harvard.iq.dataverse.authorization.groups.GroupException) ExplicitGroup(edu.harvard.iq.dataverse.authorization.groups.impl.explicit.ExplicitGroup) RoleAssignee(edu.harvard.iq.dataverse.authorization.RoleAssignee)

Aggregations

ExplicitGroup (edu.harvard.iq.dataverse.authorization.groups.impl.explicit.ExplicitGroup)2 CreateExplicitGroupCommand (edu.harvard.iq.dataverse.engine.command.impl.CreateExplicitGroupCommand)2 RoleAssignee (edu.harvard.iq.dataverse.authorization.RoleAssignee)1 GroupException (edu.harvard.iq.dataverse.authorization.groups.GroupException)1 ExplicitGroupProvider (edu.harvard.iq.dataverse.authorization.groups.impl.explicit.ExplicitGroupProvider)1 CommandException (edu.harvard.iq.dataverse.engine.command.exception.CommandException)1 FacesMessage (javax.faces.application.FacesMessage)1 JsonString (javax.json.JsonString)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1