/** @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); }
public DocumentPermissionSet getDocumentPermissionSetForUser() { return new DocumentPermissionSet( contentManagementSystem .getCurrentUser() .getInternal() .getPermissionSetFor(internalDocument)); }
public User getPublisher() { Integer publisherId = internalDocument.getPublisherId(); if (null != publisherId) { return contentManagementSystem.getUserService().getUser(publisherId); } else { return null; } }
/** * @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); }
/** @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); }
public User getCreator() { int creatorId = internalDocument.getCreatorId(); return contentManagementSystem.getUserService().getUser(creatorId); }