Package org.activiti.engine

Examples of org.activiti.engine.IdentityService


public class CreateUserAndMembershipTestDelegate implements JavaDelegate {

  @Override
  public void execute(DelegateExecution execution) throws Exception {

    IdentityService identityService = execution.getEngineServices().getIdentityService();
   
    String username = "Kermit";
    User user = identityService.newUser(username);
    user.setPassword("123");
    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


  public TaskEventTextResolver() {
    this.i18nManager = ExplorerApp.get().getI18nManager();
  }
 
  public Label resolveText(Event event) {
    IdentityService identityService = ProcessEngines.getDefaultProcessEngine().getIdentityService();
    User user = identityService.createUserQuery().userId(event.getUserId()).singleResult();
    String eventAuthor = "<span class='" + ExplorerLayout.STYLE_TASK_EVENT_AUTHOR + "'>"
          + user.getFirstName() + " " + user.getLastName() + "</span> ";
   
    String text = null;
    if (Event.ACTION_ADD_USER_LINK.equals(event.getAction())) {
      User involvedUser = identityService.createUserQuery().userId(event.getMessageParts().get(0)).singleResult();
      text = i18nManager.getMessage(Messages.EVENT_ADD_USER_LINK,
              eventAuthor,
              involvedUser.getFirstName() + " " + involvedUser.getLastName(),
              event.getMessageParts().get(1)); // second msg part = role
    } else if (Event.ACTION_DELETE_USER_LINK.equals(event.getAction())) {
      User involvedUser = identityService.createUserQuery().userId(event.getMessageParts().get(0)).singleResult();
      text = i18nManager.getMessage(Messages.EVENT_DELETE_USER_LINK,
              eventAuthor,
              involvedUser.getFirstName() + " " + involvedUser.getLastName(),
              event.getMessageParts().get(1));
    } else if (Event.ACTION_ADD_GROUP_LINK.equals(event.getAction())) {
View Full Code Here

                skipTasks.put("usertask4", "user1"); // 动态设定以
                skipTasks.put("usertask5", "user1"); // 候选人
                skipTasks.put("usertask6", "user1"); // 候选组

                EngineServices engineServices = entityEvent.getEngineServices();
                IdentityService identityService = engineServices.getIdentityService();
                TaskService taskService = engineServices.getTaskService();

                String taskDefinitionKey = taskEntity.getTaskDefinitionKey();
                String userId = skipTasks.get(taskDefinitionKey);

                if (userId == null) {
                    return;
                }
                System.out.println("key: " + taskDefinitionKey + ", userId=" + userId);

                // 查询当前人的组
                List<String> groupIds = new ArrayList<>();
                List<Group> list = identityService.createGroupQuery().groupMember(userId).list();
                for (Group group : list) {
                    groupIds.add(group.getId());
                }

                // 如果当前节点是需要跳过的,直接调用任务完成命令
View Full Code Here

  @Rule
  public ActivitiRule activitiRule = new ActivitiRule();

  @Test
  public void startProcess() throws Exception {
    IdentityService identityService = activitiRule.getIdentityService();
    identityService.setAuthenticatedUserId("henryyan");
    RepositoryService repositoryService = activitiRule.getRepositoryService();
    TaskService taskService = activitiRule.getTaskService();
    repositoryService.createDeployment().addInputStream("process1.bpmn20.xml", new FileInputStream(filename)).deploy();
    RuntimeService runtimeService = activitiRule.getRuntimeService();
    Map<String, Object> variableMap = new HashMap<String, Object>();
View Full Code Here

      ClockUtil.reset();
    }
  }
 
  protected void createUsers() {
    IdentityService identityService = processEngine.getIdentityService();
    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());
  }
View Full Code Here

    if (groupId == null) {
      setStatus(Status.CLIENT_ERROR_BAD_REQUEST, "No groupId provided.");
      return new StateResponse().setSuccess(false);
    }

    IdentityService identityService = ActivitiUtil.getIdentityService();
    // Check if user exists
    if (identityService.createUserQuery().userId(userId).singleResult() == null) {
      setStatus(Status.CLIENT_ERROR_NOT_FOUND, "The user '" + userId
          + "' does not exist.");
      return new StateResponse().setSuccess(false);
    }

    // Add only if not already member
    Group group = identityService.createGroupQuery().groupMember(userId)
        .groupId(groupId).singleResult();
    if (group != null)
      identityService.deleteMembership(userId, groupId);
    return new StateResponse().setSuccess(true);
  }
View Full Code Here

    component.getDefaultHost().attach(new ActivitiRestApplication());
    component.start();
  }
 
  protected void dropUsers() {
    IdentityService identityService = processEngine.getIdentityService();
   
    identityService.deleteUser("kermit");
    identityService.deleteGroup("admin");
    identityService.deleteMembership("kermit", "admin");
  }
View Full Code Here

    }
    if (groupIds == null) {
      throw new ActivitiException("No groupIds provided");
    }

    IdentityService identityService = ActivitiUtil.getIdentityService();
    // Check if user exists
    if (identityService.createUserQuery().userId(userId).singleResult() == null)
      throw new ActivitiException("The user '" + userId + " does not exist.");

    // Check first if all groups exist
    for (String groupId : groupIds) {
      if (identityService.createGroupQuery().groupId(groupId).singleResult() == null)
        throw new ActivitiException("Group '" + groupId + "' does not exist.");
    }
    for (String groupId : groupIds) {
      // Add only if not already member
      if (identityService.createUserQuery().userId(userId)
          .memberOfGroup(groupId).singleResult() == null)
        identityService.createMembership(userId, groupId);
    }
    return new StateResponse().setSuccess(true);
  }
View Full Code Here

 
  @Put()
  public StateResponse createUser(UserInfoWithPassword userInfo){
    if(authenticate() == false) return null;
   
    IdentityService identityService = ActivitiUtil.getIdentityService();
    if(userInfo == null || userInfo.getId() == null) {
      throw new ActivitiException("No user id supplied");
    }

    if (identityService.createUserQuery().userId(userInfo.getId()).count() == 0) {
       User user = identityService.newUser(userInfo.getId());
       user.setFirstName(userInfo.getFirstName());
       user.setLastName(userInfo.getLastName());
       user.setPassword(userInfo.getPassword());
       user.setEmail(userInfo.getEmail());
       identityService.saveUser(user);
    } else  {
      throw new ActivitiException("user id must be unique");
    }
    return new StateResponse().setSuccess(true);
  }
View Full Code Here

    }
    if (userIds == null) {
      throw new ActivitiException("No userIds provided");
    }

    IdentityService identityService = ActivitiUtil.getIdentityService();
    // Check if user exists
    if (identityService.createGroupQuery().groupId(groupId).singleResult() == null)
      throw new ActivitiException("The user '" + groupId + "' does not exist.");

    // Check first if all users exist
    for (String userId : userIds) {
      if (identityService.createUserQuery().userId(userId).singleResult() == null)
        throw new ActivitiException("User '" + userId + " does not exist.");
    }
    for (String userId : userIds) {
      // Add only if not already member
      if (identityService.createUserQuery().userId(userId)
          .memberOfGroup(groupId).singleResult() == null)
        identityService.createMembership(userId, groupId);
    }
    return new StateResponse().setSuccess(true);
  }
View Full Code Here

TOP

Related Classes of org.activiti.engine.IdentityService

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.