CCM NG/ccm-cms:
- ContentSectionManager#addContentTypeToSection: Create permissions allowing type use for all roles of the contentsection when adding a content type to a content section. - ContentItemManager#createContentItem: Verify that current user is allowed to use the provided type when creating a content item. git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4456 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
b39aa8152f
commit
45c8296282
|
|
@ -68,6 +68,9 @@ import java.util.UUID;
|
|||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.TypedQuery;
|
||||
import javax.transaction.Transactional;
|
||||
import org.libreccm.security.PermissionChecker;
|
||||
import org.libreccm.security.PermissionManager;
|
||||
import org.librecms.contentsection.privileges.TypePrivileges;
|
||||
|
||||
/**
|
||||
* Manager class providing several methods to manipulate {@link ContentItem}s.
|
||||
|
|
@ -113,6 +116,9 @@ public class ContentItemManager {
|
|||
@Inject
|
||||
private AssetManager assetManager;
|
||||
|
||||
@Inject
|
||||
private PermissionChecker permissionChecker;
|
||||
|
||||
/**
|
||||
* Creates a new content item in the provided content section and folder
|
||||
* with the workflow.
|
||||
|
|
@ -198,6 +204,10 @@ public class ContentItemManager {
|
|||
type.getName()));
|
||||
}
|
||||
|
||||
//Check if the current user is allowed to use the content type
|
||||
permissionChecker.checkPermission(TypePrivileges.USE_TYPE,
|
||||
contentType.get());
|
||||
|
||||
if (name == null || name.trim().isEmpty()) {
|
||||
throw new IllegalArgumentException(
|
||||
"The name of a content item can't be blank.");
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ import org.librecms.contentsection.privileges.ItemPrivileges;
|
|||
import org.librecms.lifecycle.LifecycleDefinition;
|
||||
|
||||
import java.util.Optional;
|
||||
import org.librecms.contentsection.privileges.TypePrivileges;
|
||||
|
||||
import static org.librecms.contentsection.ContentSection.*;
|
||||
|
||||
|
|
@ -459,18 +460,15 @@ public class ContentSectionManager {
|
|||
* {@link CmsConstants#AdminPrivileges.ADMINISTER_CONTENT_TYPES} for the
|
||||
* provided content section.
|
||||
*
|
||||
* @param type The type to add (a subclass of
|
||||
* {@link ContentItem}.
|
||||
* @param type The type to add (a subclass of {@link ContentItem}.
|
||||
* @param section The section to which the type is added.
|
||||
* @param defaultLifecycle The default lifecycle for items of the provided
|
||||
* type in the provided content section. The
|
||||
* lifecycle must be part of the provided section.
|
||||
* Otherwise an {@link IllegalArgumentException} is
|
||||
* type in the provided content section. The lifecycle must be part of the
|
||||
* provided section. Otherwise an {@link IllegalArgumentException} is
|
||||
* thrown.
|
||||
* @param defaultWorkflow The default workflow for items of the provided
|
||||
* type in the provided content section. The
|
||||
* workflow must be part of the provided section.
|
||||
* Otherwise an {@link IllegalArgumentException} is
|
||||
* type in the provided content section. The workflow must be part of the
|
||||
* provided section. Otherwise an {@link IllegalArgumentException} is
|
||||
* thrown.
|
||||
*
|
||||
* @return The new {@link ContentType} instance.
|
||||
|
|
@ -544,6 +542,10 @@ public class ContentSectionManager {
|
|||
|
||||
section.addContentType(contentType);
|
||||
|
||||
section.getRoles().stream()
|
||||
.forEach(role -> permissionManager.grantPrivilege(
|
||||
TypePrivileges.USE_TYPE, role, contentType));
|
||||
|
||||
sectionRepo.save(section);
|
||||
typeRepo.save(contentType);
|
||||
|
||||
|
|
@ -587,8 +589,7 @@ public class ContentSectionManager {
|
|||
* @param section The section from which the type is removed.
|
||||
*
|
||||
* @throws IllegalArgumentException if the provided {@link ContentType} is
|
||||
* in use or the parameters or otherwise
|
||||
* illegal.
|
||||
* in use or the parameters or otherwise illegal.
|
||||
* @see
|
||||
* ContentTypeRepository#delete(org.librecms.contentsection.ContentType)
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue