コード例 #1
0
  /**
   * 验证用户
   *
   * @param request
   * @param response
   * @param model
   * @return
   */
  @RequestMapping("/checkLogin.do")
  public String checkLogin(
      HttpServletRequest request,
      HttpServletResponse response,
      @RequestParam("userName") String userName,
      @RequestParam("passWord") String passWord,
      Model model) {
    logger.debug("logon request: {username={}, password={}}", userName, passWord);
    boolean checkPassword = identityService.checkPassword(userName, passWord);

    HttpSession session = request.getSession(true);

    if (checkPassword) {
      User user = identityService.createUserQuery().userId(userName).singleResult();
      session.setAttribute("user", user);
      GroupQuery groupQuery = identityService.createGroupQuery();
      List<Group> groupList = groupQuery.groupMember(userName).list();

      session.setAttribute("groups", groupList);

      String[] groupNames = new String[groupList.size()];

      for (int i = 0; i < groupNames.length; i++) {
        groupNames[i] = groupList.get(i).getName();
      }

      session.setAttribute("groupNames", ArrayUtils.toString(groupNames));
      return "redirect:/simple/index.do";
    } else {
      return "redirect:/simple/login.do";
    }
  }
コード例 #2
0
  /**
   * 开始流程
   *
   * @return
   */
  @RequestMapping(value = "/start.do")
  public String startProcessDefinition(
      HttpServletRequest request,
      @RequestParam("processDefId") String processDefId,
      @RequestParam("userId") String userId) {

    // 用来设置启动流程的人员ID,引擎会自动把用户ID保存到activiti:initiator中
    identityService.setAuthenticatedUserId(userId);

    Map map = new HashMap();
    map.put("owner", userId);
    runtimeService.startProcessInstanceById(processDefId, map);

    return "redirect:/simple/index.do";
  }