コード例 #1
0
  /**
   * ロールをデータベースから読み出します。 <br>
   *
   * @param rundata
   * @param context
   * @param msgList
   * @return TRUE 成功 FALSE 失敗
   */
  @Override
  protected boolean loadFormData(RunData rundata, Context context, List<String> msgList) {
    try {
      // オブジェクトモデルを取得
      EipTAclRole aclrole = AccessControlUtils.getEipTAclRole(rundata, context);
      if (aclrole == null) {
        return false;
      }

      // ロール名
      acl_role_name.setValue(aclrole.getRoleName());

      List<EipTAclUserRoleMap> aclUserRoleMaps =
          AccessControlUtils.getEipTAclUserRoleMaps(aclrole.getRoleId().intValue());
      if (aclUserRoleMaps != null && aclUserRoleMaps.size() > 0) {
        EipTAclUserRoleMap rolemap = null;
        TurbineUser tuser = null;
        int size = aclUserRoleMaps.size();
        for (int i = 0; i < size; i++) {
          rolemap = aclUserRoleMaps.get(i);
          tuser = rolemap.getTurbineUser();
          ALEipUser user = new ALEipUser();
          user.initField();
          user.setUserId(tuser.getUserId().intValue());
          user.setName(tuser.getLoginName());
          user.setAliasName(tuser.getFirstName(), tuser.getLastName());
          // 招待中ユーザでなければ追加
          if (!JetspeedResources.CONFIRM_VALUE_PENDING.equals(tuser.getConfirmValue())) {
            memberList.add(user);
          }
        }
      }

      EipTAclPortletFeature feature = aclrole.getEipTAclPortletFeature();
      feature_id.setValue(feature.getFeatureId().intValue());
      defineAclType = feature.getAclType().intValue();

      // メモ
      note.setValue(aclrole.getNote());

      // アクセス権限
      int tmpAclType = aclrole.getAclType();
      AccessControlUtils.setupAcl(ALAccessControlConstants.VALUE_ACL_LIST, tmpAclType, acllist);
      AccessControlUtils.setupAcl(ALAccessControlConstants.VALUE_ACL_DETAIL, tmpAclType, acldetail);
      AccessControlUtils.setupAcl(ALAccessControlConstants.VALUE_ACL_INSERT, tmpAclType, aclinsert);
      AccessControlUtils.setupAcl(ALAccessControlConstants.VALUE_ACL_UPDATE, tmpAclType, aclupdate);
      AccessControlUtils.setupAcl(ALAccessControlConstants.VALUE_ACL_DELETE, tmpAclType, acldelete);
      AccessControlUtils.setupAcl(ALAccessControlConstants.VALUE_ACL_EXPORT, tmpAclType, aclexport);

    } catch (Exception ex) {
      logger.error("AccessControlFormData.loadFormData", ex);
      return false;
    }
    return true;
  }
コード例 #2
0
ファイル: ALEipManager.java プロジェクト: aipocom/aipo
  @SuppressWarnings("unchecked")
  public Map<Integer, ALEipUser> getUsers(List<Integer> users) {
    Map<Integer, ALEipUser> results = new HashMap<Integer, ALEipUser>(users.size());
    Map<Integer, ALEipUser> map = new HashMap<Integer, ALEipUser>(users.size());

    List<Integer> fetchUsers = new ArrayList<Integer>(users.size());

    HttpServletRequest request = HttpServletRequestLocator.get();

    if (request != null) {
      map = (Map<Integer, ALEipUser>) request.getAttribute(USERS_KEY);
      if (map != null) {
        for (Integer userId : users) {
          ALEipUser user = map.get(userId);
          if (user != null) {
            results.put(userId, user);
          } else {
            fetchUsers.add(userId);
          }
        }
      } else {
        map = new HashMap<Integer, ALEipUser>(users.size());
        fetchUsers.addAll(users);
      }
    } else {
      fetchUsers.addAll(users);
    }

    if (fetchUsers.size() > 0) {

      StringBuilder select = new StringBuilder();

      select.append("SELECT");
      select.append(" turbine_user.user_id,");
      select.append(" turbine_user.last_name,");
      select.append(" turbine_user.first_name,");
      select.append(" turbine_user.login_name,");
      select.append(" turbine_user.has_photo,");
      select.append(" turbine_user.photo_modified");

      StringBuilder body = new StringBuilder();
      body.append(" FROM turbine_user WHERE ");
      body.append(" turbine_user.user_id IN (");
      boolean isFirst = true;
      for (Integer num : fetchUsers) {
        if (!isFirst) {
          body.append(",");
        }
        body.append(num.intValue());
        isFirst = false;
      }
      body.append(")");

      SQLTemplate<VTurbineUserLite> query =
          Database.sql(VTurbineUserLite.class, select.toString() + body.toString());
      List<VTurbineUserLite> list = query.fetchList();

      for (VTurbineUserLite model : list) {
        ALEipUser eipUser = new ALEipUser();
        eipUser.initField();
        eipUser.setAliasName(model.getFirstName(), model.getLastName());
        eipUser.setName(model.getLoginName());
        eipUser.setUserId(model.getUserId());
        eipUser.setHasPhoto("T".equals(model.getHasPhoto()) || "N".equals(model.getHasPhoto()));
        eipUser.setPhotoModified(
            model.getPhotoModified() != null ? model.getPhotoModified().getTime() : 0);

        results.put(model.getUserId(), eipUser);
        map.put(model.getUserId(), eipUser);
      }
    }

    // requestに登録
    if (request != null) {
      request.setAttribute(USERS_KEY, map);
    }

    return results;
  }