Beispiel #1
0
  public String right() {

    try {
      List<Resources> list = userService.getResourcesByUser(user.getId());
      System.out.println("begin to export the list " + list.size() + ":");
      for (Resources r : list) {
        boolean flag = false;
        if (!r.getIsLeaf()) {
          System.out.println("+" + r.getName() + " : " + r.getDescription());
          flag = true;
        }
        if (flag) {
          for (Resources subR : list) {
            if (subR.getParent().getId() == r.getId()) {
              System.out.println("--" + subR.getName() + " : " + subR.getDescription());
            }
          }
        }
      }
      getSession().put("userResources", list);
      getSession().put("something", "this is a test message");
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      return "error";
    }
    return "attrResources";
  }
Beispiel #2
0
  /*public String getUserAll() throws Exception{
  	Session.put("userList", userService.getAll());
  	return SUCCESS;
  }*/
  public String login() {

    String flag = INPUT;
    User user_temp = null;
    if (null != user) {
      if (Common.isEmpty(user.getUsername())) {
        this.addFieldError("usernameEmpty", "Username is required");
        this.setParameters("username=null");
        System.out.println("username is null;");
        return flag;
      } else if (Common.isEmpty(user.getPassword())) {
        this.addFieldError("passwordEmpty", "Password is required");
        this.setParameters("password=null");
        System.out.println("password is null");
        return flag;
      } else {
        try {
          user_temp = userService.isExistUser(user.getUsername(), user.getPassword());
        } catch (Exception e) {
          flag = ERROR;
          e.printStackTrace();
          return flag;
        }
        if (null != user_temp) {
          // Get More User Info
          getSession().put("currentUser", user_temp);
          try {
            List<Resources> list = userService.getResourcesByUser(user_temp.getId());
            System.out.println("begin to export the list " + list.size() + ":");
            for (Resources r : list) {
              boolean flags = false;
              if (!r.getIsLeaf()) {
                System.out.println("+" + r.getName() + " : " + r.getDescription());
                flags = true;
              }
              if (flags) {
                for (Resources subR : list) {
                  if (subR.getParent().getId() == r.getId()) {
                    System.out.println("--" + subR.getName() + " : " + subR.getDescription());
                  }
                }
              }
            }
            getSession().put("userResources", list);
            getSession().put("something", "this is a test message");
          } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return "error";
          }
          this.setParameters("");
          flag = SUCCESS;
          return flag;
        } else {
          this.addFieldError("userEmpty", "User does not exist!");
          System.out.println("no user data from database, user_temp is unll");
          this.setParameters("user=nofound");
          return flag;
        }
      }
    }
    System.out.println("begin to return");
    return flag;
  }