Package org.activiti.engine.identity

Examples of org.activiti.engine.identity.Group


    identityService.deleteGroup("sales");
    identityService.deleteUser("johndoe");
  }
 
  public void testDeleteMembershipWhenUserIsNoMember() {
    Group sales = identityService.newGroup("sales");
    identityService.saveGroup(sales);

    User johndoe = identityService.newUser("johndoe");
    identityService.saveUser(johndoe);
   
    // Delete the membership when the user is no member
    identityService.deleteMembership(johndoe.getId(), sales.getId());
   
    identityService.deleteGroup("sales");
    identityService.deleteUser("johndoe");
  }
View Full Code Here


    identityService.deleteMembership(johndoe.getId(), "unexistinggroup");
    identityService.deleteUser(johndoe.getId());
  }
 
  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());
  }
View Full Code Here

   
    identityService.deleteUser(user.getId());
  }
 
  public void testGroupOptimisticLockingException() {
    Group group = identityService.newGroup("group");
    identityService.saveGroup(group);
   
    Group group1 = identityService.createGroupQuery().singleResult();
    Group group2 = identityService.createGroupQuery().singleResult();
   
    group1.setName("name one");
    identityService.saveGroup(group1);

    try {
     
      group2.setName("name two");
      identityService.saveGroup(group2);
     
      fail("Expected an exception");
    } catch (ActivitiOptimisticLockingException e) {
      // Expected an exception
View Full Code Here

 
  protected void handleFormSubmit() {
    try {
      // create user
      form.commit(); // will throw exception in case validation is false
      Group group = createGroup();
     
      // close popup and navigate to new group
      close();
      ExplorerApp.get().getViewManager().showGroupPage(group.getId());
     
    } catch (InvalidValueException e) {
      // Do nothing: the Form component will render the errormsgs automatically
      setHeight(270, UNITS_PIXELS);
    }
View Full Code Here

      setHeight(270, UNITS_PIXELS);
    }
  }
 
  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;
  }
View Full Code Here

    user.setFirstName("Manually");
    user.setLastName("created");
    identityService.saveUser(user);
   
    // Add admin group
    Group group = identityService.newGroup("admin");
    identityService.saveGroup(group);

    identityService.createMembership(username, "admin");
  }
View Full Code Here

    runtimeService.startProcessInstanceByKey("multipleServiceInvocations");
   
    // The service task should have created a user which is part of the admin group
    User user = identityService.createUserQuery().singleResult();
    assertEquals("Kermit", user.getId());
    Group group = identityService.createGroupQuery().groupMember(user.getId()).singleResult();
    assertNotNull(group);
    assertEquals("admin", group.getId());
   
    // Cleanup
    identityService.deleteUser("Kermit");
    identityService.deleteGroup("admin");
    identityService.deleteMembership("Kermit", "admin");
View Full Code Here

  @RequestMapping(value="/identity/groups/{groupId}/members", method = RequestMethod.POST, produces = "application/json")
  public MembershipResponse createMembership(@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());
    
    String serverRootUrl = request.getRequestURL().toString();
    serverRootUrl = serverRootUrl.substring(0, serverRootUrl.indexOf("/identity/groups/"));
    return restResponseFactory.createMembershipResponse(memberShip.getUserId(), group.getId(), serverRootUrl);
  }
View Full Code Here

    return restResponseFactory.createGroupResponse(getGroupFromRequest(groupId), serverRootUrl);
  }
 
  @RequestMapping(value="/identity/groups/{groupId}", method = RequestMethod.PUT, produces = "application/json")
  public GroupResponse updateGroup(@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.");
    }
View Full Code Here

    return restResponseFactory.createGroupResponse(group, serverRootUrl);
  }
 
  @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());
  }
View Full Code Here

TOP

Related Classes of org.activiti.engine.identity.Group

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.