use of org.activiti.engine.identity.Group in project Activiti by Activiti.
the class NewGroupPopupWindow method createGroup.
protected Group createGroup() {
Group group = identityService.newGroup(form.getField("id").getValue().toString());
group.setName(form.getField("name").getValue().toString());
group.setType(form.getField("type").getValue().toString());
identityService.saveGroup(group);
return group;
}
use of org.activiti.engine.identity.Group in project Activiti by Activiti.
the class GroupCollectionResource method createGroup.
@RequestMapping(value = "/identity/groups", method = RequestMethod.POST, produces = "application/json")
public GroupResponse createGroup(@RequestBody GroupRequest groupRequest, HttpServletRequest httpRequest, HttpServletResponse response) {
if (groupRequest.getId() == null) {
throw new ActivitiIllegalArgumentException("Id cannot be null.");
}
// Check if a user with the given ID already exists so we return a CONFLICT
if (identityService.createGroupQuery().groupId(groupRequest.getId()).count() > 0) {
throw new ActivitiConflictException("A group with id '" + groupRequest.getId() + "' already exists.");
}
Group created = identityService.newGroup(groupRequest.getId());
created.setId(groupRequest.getId());
created.setName(groupRequest.getName());
created.setType(groupRequest.getType());
identityService.saveGroup(created);
response.setStatus(HttpStatus.CREATED.value());
return restResponseFactory.createGroupResponse(created);
}
use of org.activiti.engine.identity.Group in project Activiti by Activiti.
the class GroupMembershipResource method deleteMembership.
@RequestMapping(value = "/identity/groups/{groupId}/members/{userId}", method = RequestMethod.DELETE)
public void deleteMembership(@PathVariable("groupId") String groupId, @PathVariable("userId") String userId, HttpServletRequest request, HttpServletResponse response) {
Group group = getGroupFromRequest(groupId);
// Check if user is not a member of group since API doesn't return typed exception
if (identityService.createUserQuery().memberOfGroup(group.getId()).userId(userId).count() != 1) {
throw new ActivitiObjectNotFoundException("User '" + userId + "' is not part of group '" + group.getId() + "'.", null);
}
identityService.deleteMembership(userId, group.getId());
response.setStatus(HttpStatus.NO_CONTENT.value());
}
use of org.activiti.engine.identity.Group in project Activiti by Activiti.
the class GroupResource method deleteGroup.
@RequestMapping(value = "/identity/groups/{groupId}", method = RequestMethod.DELETE)
public void deleteGroup(@PathVariable String groupId, HttpServletResponse response) {
Group group = getGroupFromRequest(groupId);
identityService.deleteGroup(group.getId());
response.setStatus(HttpStatus.NO_CONTENT.value());
}
use of org.activiti.engine.identity.Group in project Activiti by Activiti.
the class DemoDataConfiguration method createGroup.
protected void createGroup(String groupId, String type) {
if (identityService.createGroupQuery().groupId(groupId).count() == 0) {
Group newGroup = identityService.newGroup(groupId);
newGroup.setName(groupId.substring(0, 1).toUpperCase() + groupId.substring(1));
newGroup.setType(type);
identityService.saveGroup(newGroup);
}
}
Aggregations