org.activiti.engine.identity.Group Java Examples

The following examples show how to use org.activiti.engine.identity.Group. 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: SpringSecurityGroupManager.java    From tutorials with MIT License 6 votes vote down vote up
@Override
public List<Group> findGroupsByUser(String userId) {
    UserDetails userDetails = userManager.loadUserByUsername(userId);
    System.out.println("group manager");
    if (userDetails != null) {
        List<Group> groups = userDetails.getAuthorities()
            .stream()
            .map(a -> a.getAuthority())
            .map(a -> {
                Group g = new GroupEntityImpl();
                g.setId(a);
                return g;
            })
            .collect(Collectors.toList());
        return groups;
    }
    return null;
}
 
Example #2
Source File: GroupQueryTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void testQueryByMember() {
  GroupQuery query = identityService.createGroupQuery().groupMember("fozzie");
  verifyQueryResults(query, 2);

  query = identityService.createGroupQuery().groupMember("kermit");
  verifyQueryResults(query, 3);

  query = query.orderByGroupId().asc();
  List<Group> groups = query.list();
  assertEquals(3, groups.size());
  assertEquals("admin", groups.get(0).getId());
  assertEquals("frogs", groups.get(1).getId());
  assertEquals("muppets", groups.get(2).getId());

  query = query.groupType("user");
  groups = query.list();
  assertEquals(2, groups.size());
  assertEquals("frogs", groups.get(0).getId());
  assertEquals("muppets", groups.get(1).getId());
}
 
Example #3
Source File: FieldQuery.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 6 votes vote down vote up
public static void main(String[] args) {
	// 新建流程引擎
	ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();

	IdentityService identityService = engine.getIdentityService();

	List<Group> groups = identityService.createGroupQuery()
			.groupName("Group_3").groupType("TYPE_0").list();

	for (Group group : groups) {
		System.out.println(group.getId() + "---" + group.getName() + "---"
				+ group.getType());
	}

	// 关闭流程引擎
	engine.close();
}
 
Example #4
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 #5
Source File: ListPageGroup.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 6 votes vote down vote up
public static void main(String[] args) {
	// 新建流程引擎
	ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();

	IdentityService identityService = engine.getIdentityService();

	List<Group> groups = identityService.createGroupQuery().listPage(1, 5);

	for (Group group : groups) {
		System.out.println(group.getId() + "---" + group.getName() + "---"
				+ group.getType());
	}

	// 关闭流程引擎
	engine.close();
}
 
Example #6
Source File: DeploymentController.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取流程定义的相关候选启动人、组,根据link信息转换并封装为User、Group对象
 * @param processDefinitionList
 * @return
 */
private Map<String, Map<String, List<? extends Object>>> setCandidateUserAndGroups(List<ProcessDefinition> processDefinitionList) {
    Map<String, Map<String, List<? extends Object>>> linksMap = new HashMap<String, Map<String, List<? extends Object>>>();
    for (ProcessDefinition processDefinition : processDefinitionList) {
        List<IdentityLink> identityLinks = repositoryService.getIdentityLinksForProcessDefinition(processDefinition.getId());

        Map<String, List<? extends Object>> single = new Hashtable<String, List<? extends Object>>();
        List<User> linkUsers = new ArrayList<User>();
        List<Group> linkGroups = new ArrayList<Group>();

        for (IdentityLink link : identityLinks) {
            if (StringUtils.isNotBlank(link.getUserId())) {
                linkUsers.add(identityService.createUserQuery().userId(link.getUserId()).singleResult());
            } else if (StringUtils.isNotBlank(link.getGroupId())) {
                linkGroups.add(identityService.createGroupQuery().groupId(link.getGroupId()).singleResult());
            }
        }

        single.put("user", linkUsers);
        single.put("group", linkGroups);

        linksMap.put(processDefinition.getId(), single);

    }
    return linksMap;
}
 
Example #7
Source File: GroupResource.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@ApiOperation(value = "Update a group", tags = {"Groups"},
    notes = "All request values are optional. For example, you can only include the name attribute in the request body JSON-object, only updating the name of the group, leaving all other fields unaffected. When an attribute is explicitly included and is set to null, the group-value will be updated to null.")
@ApiResponses(value = {
    @ApiResponse(code = 201, message = "Indicates the group was updated."),
    @ApiResponse(code = 404, message = "Indicates the requested group was not found."),
    @ApiResponse(code = 409, message = "Indicates the requested group was updated simultaneously.")
})
@RequestMapping(value = "/identity/groups/{groupId}", method = RequestMethod.PUT, produces = "application/json")
public GroupResponse updateGroup(@ApiParam(name="groupId") @PathVariable String groupId, @RequestBody GroupRequest groupRequest, HttpServletRequest request) {
  Group group = getGroupFromRequest(groupId);

  if (groupRequest.getId() == null || groupRequest.getId().equals(group.getId())) {
    if (groupRequest.isNameChanged()) {
      group.setName(groupRequest.getName());
    }
    if (groupRequest.isTypeChanged()) {
      group.setType(groupRequest.getType());
    }
    identityService.saveGroup(group);
  } else {
    throw new ActivitiIllegalArgumentException("Key provided in request body doesn't match the key in the resource URL.");
  }

  return restResponseFactory.createGroupResponse(group);
}
 
Example #8
Source File: SortMultiGroup.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 6 votes vote down vote up
public static void main(String[] args) {
	// 新建流程引擎
	ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();

	IdentityService identityService = engine.getIdentityService();

	// 先按名称降序,再按类型降序
	List<Group> groups = identityService.createGroupQuery()
			.orderByGroupName().desc().orderByGroupType().desc().list();

	for (Group group : groups) {
		System.out.println(group.getId() + "---" + group.getName() + "---"
				+ group.getType());
	}

	// 关闭流程引擎
	engine.close();
}
 
Example #9
Source File: SaveGroup.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 6 votes vote down vote up
public static void main(String[] args) {
	// 新建流程引擎
	ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
	
	IdentityService identityService = engine.getIdentityService();
	
	Random ran = new Random(10);
	for (int i = 0; i < 10; i++) {
		Group group = identityService.newGroup(String.valueOf(i));
		group.setName("Group_" + ran.nextInt(10));
		group.setType("TYPE_" + ran.nextInt(10));
		identityService.saveGroup(group);
	}

	// 关闭流程引擎
	engine.close();
}
 
Example #10
Source File: BasicAuthenticationProvider.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
  String name = authentication.getName();
  String password = authentication.getCredentials().toString();

  boolean authenticated = identityService.checkPassword(name, password);
  if (authenticated) {
    List<Group> groups = identityService.createGroupQuery().groupMember(name).list();
    Collection<GrantedAuthority> grantedAuthorities = new ArrayList<GrantedAuthority>();
    for (Group group : groups) {
      grantedAuthorities.add(new SimpleGrantedAuthority(group.getId()));
    }
    identityService.setAuthenticatedUserId(name);
    return new UsernamePasswordAuthenticationToken(name, password, grantedAuthorities);
  } else {
    throw new BadCredentialsException("Authentication failed for this username and password");
  }
}
 
Example #11
Source File: EditorGroupsResource.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "/rest/editor-groups", method = RequestMethod.GET)
public ResultListDataRepresentation getGroups(@RequestParam(required = false, value = "filter") String filter) {
  String groupNameFilter = filter;
  if (StringUtils.isEmpty(groupNameFilter)) {
    groupNameFilter = "%";
  } else {
    groupNameFilter = "%" + groupNameFilter + "%";
  }
  List<Group> matchingGroups = identityService.createGroupQuery()
      .groupNameLike(groupNameFilter)
      .groupType(GroupTypes.TYPE_ASSIGNMENT)
      .list();

  ResultListDataRepresentation result = new ResultListDataRepresentation(matchingGroups);
  // TODO: get total result count instead of page-count, in case the matching
  // list's size is equal to the page size
  return result;
}
 
Example #12
Source File: IdentityServiceTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void testDeleteMembership() {
  Group sales = identityService.newGroup("sales");
  identityService.saveGroup(sales);

  User johndoe = identityService.newUser("johndoe");
  identityService.saveUser(johndoe);
  // Add membership
  identityService.createMembership(johndoe.getId(), sales.getId());

  List<Group> groups = identityService.createGroupQuery().groupMember(johndoe.getId()).list();
  assertTrue(groups.size() == 1);
  assertEquals("sales", groups.get(0).getId());

  // Delete the membership and check members of sales group
  identityService.deleteMembership(johndoe.getId(), sales.getId());
  groups = identityService.createGroupQuery().groupMember(johndoe.getId()).list();
  assertTrue(groups.isEmpty());

  identityService.deleteGroup("sales");
  identityService.deleteUser("johndoe");
}
 
Example #13
Source File: IdmGroupsResource.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@ResponseStatus(value = HttpStatus.OK)
@RequestMapping(value = "/{groupId}/members/{userId}", method = RequestMethod.DELETE)
public void deleteGroupMember(@PathVariable String groupId, @PathVariable String userId) {
  validateAdminRole();
  verifyGroupMemberExists(groupId, userId);
  Group group = identityService.createGroupQuery().groupId(groupId).singleResult();
  if (group == null) {
    throw new NotFoundException();
  }
  
  User user = identityService.createUserQuery().userId(userId).singleResult();
  if (user == null) {
    throw new NotFoundException();
  }
  
  identityService.deleteMembership(userId, groupId);
}
 
Example #14
Source File: IdmGroupsResource.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "/{groupId}", method = RequestMethod.PUT)
public GroupRepresentation updateGroup(@PathVariable String groupId, @RequestBody GroupRepresentation groupRepresentation) {
  validateAdminRole();
  if (StringUtils.isBlank(groupRepresentation.getName())) {
    throw new BadRequestException("Group name required");
  }

  Group group = identityService.createGroupQuery().groupId(groupId).singleResult();
  if (group == null) {
    throw new NotFoundException();
  }
  
  group.setName(groupRepresentation.getName());
  identityService.saveGroup(group);
  
  return new GroupRepresentation(group);
}
 
Example #15
Source File: DeploymentController.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取流程定义的相关候选启动人、组,根据link信息转换并封装为User、Group对象
 * @param processDefinitionList
 * @return
 */
private Map<String, Map<String, List<? extends Object>>> setCandidateUserAndGroups(List<ProcessDefinition> processDefinitionList) {
    Map<String, Map<String, List<? extends Object>>> linksMap = new HashMap<String, Map<String, List<? extends Object>>>();
    for (ProcessDefinition processDefinition : processDefinitionList) {
        List<IdentityLink> identityLinks = repositoryService.getIdentityLinksForProcessDefinition(processDefinition.getId());

        Map<String, List<? extends Object>> single = new Hashtable<String, List<? extends Object>>();
        List<User> linkUsers = new ArrayList<User>();
        List<Group> linkGroups = new ArrayList<Group>();

        for (IdentityLink link : identityLinks) {
            if (StringUtils.isNotBlank(link.getUserId())) {
                linkUsers.add(identityService.createUserQuery().userId(link.getUserId()).singleResult());
            } else if (StringUtils.isNotBlank(link.getGroupId())) {
                linkGroups.add(identityService.createGroupQuery().groupId(link.getGroupId()).singleResult());
            }
        }

        single.put("user", linkUsers);
        single.put("group", linkGroups);

        linksMap.put(processDefinition.getId(), single);

    }
    return linksMap;
}
 
Example #16
Source File: IdentityServiceTest.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 组管理API演示
 */
@Test
public void testGroup() throws Exception {
    // 创建一个组对象
    Group group = identityService.newGroup("deptLeader");
    group.setName("部门领导");
    group.setType("assignment");

    // 保存组
    identityService.saveGroup(group);

    // 验证组是否已保存成功,首先需要创建组查询对象
    List<Group> groupList = identityService.createGroupQuery().groupId("deptLeader").list();
    assertEquals(1, groupList.size());

    // 删除组
    identityService.deleteGroup("deptLeader");

    // 验证是否删除成功
    groupList = identityService.createGroupQuery().groupId("deptLeader").list();
    assertEquals(0, groupList.size());
}
 
Example #17
Source File: SecurityAutoConfigurationTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Bean
InitializingBean init(
        final IdentityService identityService) {
    return new InitializingBean() {
        @Override
        public void afterPropertiesSet() throws Exception {

            // install groups & users
            Group userGroup = group("user");
            Group adminGroup = group("admin");

            User joram = user("jbarrez", "Joram", "Barrez");
            identityService.createMembership(joram.getId(), userGroup.getId());
            identityService.createMembership(joram.getId(), adminGroup.getId());

            User josh = user("jlong", "Josh", "Long");
            identityService.createMembership(josh.getId(), userGroup.getId());
        }
    };
}
 
Example #18
Source File: IdentityServiceTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void testCreateMembershipAlreadyExisting() {
  Group sales = identityService.newGroup("sales");
  identityService.saveGroup(sales);
  User johndoe = identityService.newUser("johndoe");
  identityService.saveUser(johndoe);
  
  // Create the membership
  identityService.createMembership(johndoe.getId(), sales.getId());
  
  try {
    identityService.createMembership(johndoe.getId(), sales.getId());      
  } catch(RuntimeException re) {
   // Expected exception, membership already exists
  }
  
  identityService.deleteGroup(sales.getId());
  identityService.deleteUser(johndoe.getId());
}
 
Example #19
Source File: GroupResource.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@ApiOperation(value = "Delete a group", tags = {"Groups"})
@ApiResponses(value = {
    @ApiResponse(code = 204, message = "Indicates the group was found and  has been deleted. Response-body is intentionally empty."),
    @ApiResponse(code = 404, message = "Indicates the requested group does not exist.")
})
@RequestMapping(value = "/identity/groups/{groupId}", method = RequestMethod.DELETE)
public void deleteGroup(@ApiParam(name="groupId", value="The id of the group to delete.") @PathVariable String groupId, HttpServletResponse response) {
  Group group = getGroupFromRequest(groupId);
  identityService.deleteGroup(group.getId());
  response.setStatus(HttpStatus.NO_CONTENT.value());
}
 
Example #20
Source File: DeploymentController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 流程定义列表
 */
@RequestMapping(value = "/process-list")
public ModelAndView processList(HttpServletRequest request) {

    // 对应WEB-INF/views/chapter5/process-list.jsp
    String viewName = "chapter5/process-list";

    Page<ProcessDefinition> page = new Page<ProcessDefinition>(PageUtil.PAGE_SIZE);
    int[] pageParams = PageUtil.init(page, request);

    ModelAndView mav = new ModelAndView(viewName);
    ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();

    List<ProcessDefinition> processDefinitionList = processDefinitionQuery.listPage(pageParams[0], pageParams[1]);

    page.setResult(processDefinitionList);
    page.setTotalCount(processDefinitionQuery.count());
    mav.addObject("page", page);

    // 读取所有人员
    List<User> users = identityService.createUserQuery().list();
    mav.addObject("users", users);

    // 读取所有组
    List<Group> groups = identityService.createGroupQuery().list();
    mav.addObject("groups", groups);

    // 读取每个流程定义的候选属性
    Map<String, Map<String, List<? extends Object>>> linksMap = setCandidateUserAndGroups(processDefinitionList);
    mav.addObject("linksMap", linksMap);

    return mav;
}
 
Example #21
Source File: AccountController.java    From maven-framework-project with MIT License 5 votes vote down vote up
/**
 * 查看组员列表
 * @param request
 * @param response
 * @return
 */
@RequestMapping(value="/grouplist",method={RequestMethod.POST,RequestMethod.GET})
public ModelAndView grouplist(HttpServletRequest request, HttpServletResponse response){
	List<Group> listgroup = accountService.createGroupQuery().list();
	ModelAndView modelAndView=new ModelAndView();
	modelAndView.setViewName("group/listgroup");
	modelAndView.addObject("listgroup", listgroup);
	return modelAndView;
}
 
Example #22
Source File: ActGroupEntityService.java    From Shop-for-JavaWeb with MIT License 5 votes vote down vote up
public List<Group> findGroupsByUser(String userId) {
//		return getDbSqlSession().selectList("selectGroupsByUserId", userId);
		List<Group> list = Lists.newArrayList();
		User user = getSystemService().getUserByLoginName(userId);
		if (user != null && user.getRoleList() != null){
			for (Role role : user.getRoleList()){
				list.add(ActUtils.toActivitiGroup(role));
			}
		}
		return list;
	}
 
Example #23
Source File: DeploymentController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 流程定义列表
 */
@RequestMapping(value = "/process-list")
public ModelAndView processList(HttpServletRequest request) {

    // 对应WEB-INF/views/chapter5/process-list.jsp
    String viewName = "chapter5/process-list";

    Page<ProcessDefinition> page = new Page<ProcessDefinition>(PageUtil.PAGE_SIZE);
    int[] pageParams = PageUtil.init(page, request);

    ModelAndView mav = new ModelAndView(viewName);
    ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();

    List<ProcessDefinition> processDefinitionList = processDefinitionQuery.listPage(pageParams[0], pageParams[1]);

    page.setResult(processDefinitionList);
    page.setTotalCount(processDefinitionQuery.count());
    mav.addObject("page", page);

    // 读取所有人员
    List<User> users = identityService.createUserQuery().list();
    mav.addObject("users", users);

    // 读取所有组
    List<Group> groups = identityService.createGroupQuery().list();
    mav.addObject("groups", groups);

    // 读取每个流程定义的候选属性
    Map<String, Map<String, List<? extends Object>>> linksMap = setCandidateUserAndGroups(processDefinitionList);
    mav.addObject("linksMap", linksMap);

    return mav;
}
 
Example #24
Source File: DeploymentController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 流程定义列表
 */
@RequestMapping(value = "/processes")
public ModelAndView processList(HttpServletRequest request) {

    // 对应WEB-INF/views/chapter5/process-list.jsp
    String viewName = "chapter5/process-list";

    Page<ProcessDefinition> page = new Page<ProcessDefinition>(PageUtil.PAGE_SIZE);
    int[] pageParams = PageUtil.init(page, request);

    ModelAndView mav = new ModelAndView(viewName);
    ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();

    List<ProcessDefinition> processDefinitionList = processDefinitionQuery.listPage(pageParams[0], pageParams[1]);

    page.setResult(processDefinitionList);
    page.setTotalCount(processDefinitionQuery.count());
    mav.addObject("page", page);

    // 读取所有人员
    List<User> users = identityService.createUserQuery().list();
    mav.addObject("users", users);

    // 读取所有组
    List<Group> groups = identityService.createGroupQuery().list();
    mav.addObject("groups", groups);

    // 读取每个流程定义的候选属性
    Map<String, Map<String, List<? extends Object>>> linksMap = setCandidateUserAndGroups(processDefinitionList);
    mav.addObject("linksMap", linksMap);

    return mav;
}
 
Example #25
Source File: IdmProfileResource.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/profile", method = RequestMethod.GET, produces = "application/json")
public UserRepresentation getProfile() {
  User user = SecurityUtils.getCurrentActivitiAppUser().getUserObject();
  
  UserRepresentation userRepresentation = new UserRepresentation(user);
  
  List<Group> groups = identityService.createGroupQuery().groupMember(user.getId()).list();
  for (Group group : groups) {
    userRepresentation.getGroups().add(new GroupRepresentation(group));
  }
  
  return userRepresentation;
}
 
Example #26
Source File: UserController.java    From maven-framework-project with MIT License 5 votes vote down vote up
@RequestMapping(value = "/groups", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Response<List<Group>>> getGroups(HttpServletRequest request) {

    List<Group> groups = userService.getAllAssignmentGroups();
    log.debug("returning json response of {} groups",  groups.size());
    Response res = new Response(true, "groups",  groups);
    return new ResponseEntity<Response<List<Group>>>(res, HttpStatus.OK);
}
 
Example #27
Source File: DeploymentController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 流程定义列表
 */
@RequestMapping(value = "/process-list")
public ModelAndView processList(HttpServletRequest request) {

    // 对应WEB-INF/views/chapter5/process-list.jsp
    String viewName = "chapter5/process-list";

    Page<ProcessDefinition> page = new Page<ProcessDefinition>(PageUtil.PAGE_SIZE);
    int[] pageParams = PageUtil.init(page, request);

    ModelAndView mav = new ModelAndView(viewName);
    ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();

    List<ProcessDefinition> processDefinitionList = processDefinitionQuery.listPage(pageParams[0], pageParams[1]);

    page.setResult(processDefinitionList);
    page.setTotalCount(processDefinitionQuery.count());
    mav.addObject("page", page);

    // 读取所有人员
    List<User> users = identityService.createUserQuery().list();
    mav.addObject("users", users);

    // 读取所有组
    List<Group> groups = identityService.createGroupQuery().list();
    mav.addObject("groups", groups);

    // 读取每个流程定义的候选属性
    Map<String, Map<String, List<? extends Object>>> linksMap = setCandidateUserAndGroups(processDefinitionList);
    mav.addObject("linksMap", linksMap);

    return mav;
}
 
Example #28
Source File: IdentityServiceTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testDeleteMembershipUnexistingUser() {
  Group sales = identityService.newGroup("sales");
  identityService.saveGroup(sales);
  // No exception should be thrown when user doesn't exist
  identityService.deleteMembership("unexistinguser", sales.getId());
  identityService.deleteGroup(sales.getId());
}
 
Example #29
Source File: PermissionService.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
private List<String> getGroupIdsForUser(User user) {
  List<String> groupIds = new ArrayList<String>();
  for (Group group : identityService.createGroupQuery().groupMember(user.getId()).list()) {
    groupIds.add(String.valueOf(group.getId()));
  }
  return groupIds;
}
 
Example #30
Source File: GroupCollectionResource.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@ApiOperation(value = "Create a group", tags = {"Groups"})
@ApiResponses(value = {
    @ApiResponse(code = 201, message = "Indicates the group was created."),
    @ApiResponse(code = 400, message = "Indicates the id of the group was missing.")
})
@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);
}