示例#1
0
  /** @return map of roles Role -> DocumentPermissionSet instances. */
  public Map<Role, DocumentPermissionSet> getRolesMappedToPermissions() {
    RoleIdToDocumentPermissionSetTypeMappings roleIdToDocumentPermissionSetTypeMappings =
        internalDocument.getRoleIdsMappedToDocumentPermissionSetTypes();

    Map<RoleDomainObject, DocumentPermissionSetDomainObject> result = new HashMap<>();
    RoleIdToDocumentPermissionSetTypeMappings.Mapping[] mappings =
        roleIdToDocumentPermissionSetTypeMappings.getMappings();
    RoleGetter roleGetter = contentManagementSystem.getInternal().getRoleGetter();
    for (RoleIdToDocumentPermissionSetTypeMappings.Mapping mapping : mappings) {
      RoleId roleId = mapping.getRoleId();
      RoleDomainObject role = roleGetter.getRole(roleId);
      DocumentPermissionSetTypeDomainObject documentPermissionSetType =
          mapping.getDocumentPermissionSetType();
      if (DocumentPermissionSetTypeDomainObject.FULL.equals(documentPermissionSetType)) {
        result.put(role, DocumentPermissionSetDomainObject.FULL);
      } else if (DocumentPermissionSetTypeDomainObject.RESTRICTED_1.equals(
          documentPermissionSetType)) {
        result.put(role, internalDocument.getPermissionSets().getRestricted1());
      } else if (DocumentPermissionSetTypeDomainObject.RESTRICTED_2.equals(
          documentPermissionSetType)) {
        result.put(role, internalDocument.getPermissionSets().getRestricted2());
      } else if (DocumentPermissionSetTypeDomainObject.READ.equals(documentPermissionSetType)) {
        result.put(role, DocumentPermissionSetDomainObject.READ);
      } else if (!DocumentPermissionSetTypeDomainObject.NONE.equals(documentPermissionSetType)) {
        log.warn("A missing mapping in DocumentPermissionSetMapper");
      }
    }

    return wrapDomainObjectsInMap(result);
  }
示例#2
0
 public DocumentPermissionSet getDocumentPermissionSetForUser() {
   return new DocumentPermissionSet(
       contentManagementSystem
           .getCurrentUser()
           .getInternal()
           .getPermissionSetFor(internalDocument));
 }
示例#3
0
 public User getPublisher() {
   Integer publisherId = internalDocument.getPublisherId();
   if (null != publisherId) {
     return contentManagementSystem.getUserService().getUser(publisherId);
   } else {
     return null;
   }
 }
示例#4
0
 /**
  * @param categoryType
  * @return an array of Categories, empty array if no one found.
  */
 public Category[] getCategoriesOfType(CategoryType categoryType) {
   CategoryMapper categoryMapper = contentManagementSystem.getInternal().getCategoryMapper();
   Set<CategoryDomainObject> categoriesOfType =
       categoryMapper.getCategoriesOfType(
           categoryType.getInternal(), internalDocument.getCategoryIds());
   CategoryDomainObject[] categories =
       categoriesOfType.toArray(new CategoryDomainObject[categoriesOfType.size()]);
   return getCategoryArrayFromCategoryDomainObjectArray(categories);
 }
示例#5
0
 /** @return An array of Categories, an empty if no one found. */
 public Category[] getCategories() {
   Set<CategoryDomainObject> categories =
       contentManagementSystem
           .getInternal()
           .getCategoryMapper()
           .getCategories(internalDocument.getCategoryIds());
   CategoryDomainObject[] categoryDomainObjects =
       categories.toArray(new CategoryDomainObject[categories.size()]);
   return getCategoryArrayFromCategoryDomainObjectArray(categoryDomainObjects);
 }
示例#6
0
 public User getCreator() {
   int creatorId = internalDocument.getCreatorId();
   return contentManagementSystem.getUserService().getUser(creatorId);
 }