示例#1
0
 private boolean checkPrivacyRecord(PrivacyRecordImpl sysRecord, PrivacyRecordImpl userRecord) {
   if (sysRecord != null && userRecord != null) {
     if (userRecordHasPrecedence) {
       return userRecord.getViewable();
     } else return sysRecord.getViewable();
   } else if (sysRecord == null && userRecord == null) {
     if (defaultViewable) return true;
     else return false;
   } else if (sysRecord != null) {
     return sysRecord.getViewable();
   } else {
     return userRecord.getViewable();
   }
 }
示例#2
0
  public Map getViewableState(String contextId, String recordType) {
    if (contextId == null || recordType == null) {
      throw new IllegalArgumentException("Null Argument in getViewableState");
    }

    try {
      AuthzGroup realm = authzGroupService.getAuthzGroup(contextId);
      List users = new ArrayList();
      users.addAll(UserDirectoryService.getUsers(realm.getUsers()));
      List siteUserIds = new ArrayList();
      for (int i = 0; i < users.size(); i++) siteUserIds.add(((User) users.get(i)).getId());

      // List returnedList = getPrivacyByContextAndType(contextId, recordType);
      List returnedList = new ArrayList();
      List pieceList = new ArrayList();
      List resultPieceList = new ArrayList();
      for (int i = 0; i <= (int) (siteUserIds.size() / maxResultSetNumber); i++) {
        pieceList.clear();
        if (i == (int) (siteUserIds.size() / maxResultSetNumber)) {
          for (int j = 0; j < (siteUserIds.size() % maxResultSetNumber); j++) {
            pieceList.add(siteUserIds.get(j + ((int) i * maxResultSetNumber)));
          }
        } else {
          for (int j = 0; j < maxResultSetNumber; j++) {
            pieceList.add(siteUserIds.get(j + ((int) i * maxResultSetNumber)));
          }
        }

        if (pieceList.size() > 0) {
          resultPieceList = getPrivacyByContextAndTypeAndUserIds(contextId, recordType, pieceList);
          for (int j = 0; j < resultPieceList.size(); j++) returnedList.add(resultPieceList.get(j));
        }
      }

      if (returnedList != null) {
        HashMap returnMap = new HashMap();
        PrivacyRecordImpl pr;
        for (int i = 0; i < returnedList.size(); i++) {
          pr = (PrivacyRecordImpl) returnedList.get(i);
          returnMap.put(pr.getUserId(), Boolean.valueOf(pr.getViewable()));
        }
        return returnMap;
      }
      return null;
    } catch (org.sakaiproject.authz.api.GroupNotDefinedException gnde) {
      return null;
    }
  }