Java Code Examples for org.activiti.engine.identity.Group#getId()

The following examples show how to use org.activiti.engine.identity.Group#getId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GroupMembershipResource.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@ApiOperation(value = "Delete a member from a group", tags = {"Groups"})
@ApiResponses(value = {
    @ApiResponse(code = 204, message = "Indicates the group was found and the member has been deleted. The response body is left empty intentionally."),
    @ApiResponse(code = 404, message = "Indicates the requested group was not found or that the user is not a member of the group. The status description contains additional information about the error.")
})
@RequestMapping(value = "/identity/groups/{groupId}/members/{userId}", method = RequestMethod.DELETE)
public void deleteMembership(@ApiParam(name = "groupId", value="The id of the group to remove a member from.") @PathVariable("groupId") String groupId,@ApiParam(name = "userId", value="The id of the user to remove.") @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());
}
 
Example 2
Source File: GroupMembershipCollectionResource.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@ApiOperation(value = "Add a member to a group", tags = {"Groups"})
@ApiResponses(value = {
    @ApiResponse(code = 201, message = "Indicates the group was found and the member has been added."),
    @ApiResponse(code = 400, message = "Indicates the userId was not included in the request body."),
    @ApiResponse(code = 404, message = "Indicates the requested group was not found."),
    @ApiResponse(code = 409, message = "Indicates the requested user is already a member of the group.")
})
@RequestMapping(value = "/identity/groups/{groupId}/members", method = RequestMethod.POST, produces = "application/json")
public MembershipResponse createMembership(@ApiParam(name = "groupId", value="The id of the group to add a member to.") @PathVariable String groupId, @RequestBody MembershipRequest memberShip, HttpServletRequest request, HttpServletResponse response) {

  Group group = getGroupFromRequest(groupId);

  if (memberShip.getUserId() == null) {
    throw new ActivitiIllegalArgumentException("UserId cannot be null.");
  }

  // Check if user is member of group since API doesn't return typed
  // exception
  if (identityService.createUserQuery().memberOfGroup(group.getId()).userId(memberShip.getUserId()).count() > 0) {

    throw new ActivitiConflictException("User '" + memberShip.getUserId() + "' is already part of group '" + group.getId() + "'.");
  }

  identityService.createMembership(memberShip.getUserId(), group.getId());
  response.setStatus(HttpStatus.CREATED.value());

  return restResponseFactory.createMembershipResponse(memberShip.getUserId(), group.getId());
}
 
Example 3
Source File: SerializableVariablesDiabledTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Before
public void setupServer() {
	if (serverUrlPrefix == null) {
		TestServer testServer = TestServerUtil.createAndStartServer(ObjectVariableSerializationDisabledApplicationConfiguration.class);
		serverUrlPrefix = testServer.getServerUrlPrefix();
		
		this.repositoryService = testServer.getApplicationContext().getBean(RepositoryService.class);
		this.runtimeService = testServer.getApplicationContext().getBean(RuntimeService.class);
		this.identityService = testServer.getApplicationContext().getBean(IdentityService.class);
		this.taskService = testServer.getApplicationContext().getBean(TaskService.class);
		
    User user = identityService.newUser("kermit");
    user.setFirstName("Kermit");
    user.setLastName("the Frog");
    user.setPassword("kermit");
    identityService.saveUser(user);
    
    Group group = identityService.newGroup("admin");
    group.setName("Administrators");
    identityService.saveGroup(group);
    
    identityService.createMembership(user.getId(), group.getId());
    
    this.testUserId = user.getId();
    this.testGroupId = group.getId();
	}
}