From bd963bb48dba41609eb1e357521e83b052fff7aa Mon Sep 17 00:00:00 2001 From: jensp Date: Fri, 27 Jan 2017 19:16:52 +0000 Subject: [PATCH] CCM NG/ccm-cms: Bugfixing git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4539 8810af33-2d31-482b-a856-94f89814c4df --- .../ContentSectionManagerTest.java | 5 +- .../datasets/create_ccm_cms_schema.sql | 60 +- .../after-add-contenttype.xml | 526 +++++++- .../after-add-role.xml | 551 +++++++- .../after-create.xml | 1143 ++++++++++++++--- .../after-remove-contenttype.xml | 508 +++++++- .../after-remove-role.xml | 386 +++++- .../after-rename.xml | 514 +++++++- .../ContentSectionManagerTest/data.xml | 510 +++++++- .../src/test/resources/scripts/no-cleanup.sql | 1 + .../libreccm/security/PermissionManager.java | 18 +- .../security/PermissionManagerTest.java | 24 +- 12 files changed, 3670 insertions(+), 576 deletions(-) create mode 100644 ccm-cms/src/test/resources/scripts/no-cleanup.sql diff --git a/ccm-cms/src/test/java/org/librecms/contentsection/ContentSectionManagerTest.java b/ccm-cms/src/test/java/org/librecms/contentsection/ContentSectionManagerTest.java index a41afd973..3ec7955f3 100644 --- a/ccm-cms/src/test/java/org/librecms/contentsection/ContentSectionManagerTest.java +++ b/ccm-cms/src/test/java/org/librecms/contentsection/ContentSectionManagerTest.java @@ -75,7 +75,7 @@ import org.librecms.lifecycle.LifecycleDefinitionRepository; @PersistenceTest @Transactional(TransactionMode.COMMIT) @CreateSchema({"create_ccm_cms_schema.sql"}) -@CleanupUsingScript({"cleanup.sql"}) +@CleanupUsingScript({"no-cleanup.sql"}) public class ContentSectionManagerTest { @Inject @@ -221,7 +221,8 @@ public class ContentSectionManagerTest { "section_id", "creation_date", "content_section_id", - "folder_id"}) + "folder_id", + "inherited_from_id"}) @InSequence(100) public void createSection() { manager.createContentSection("test"); diff --git a/ccm-cms/src/test/resources/datasets/create_ccm_cms_schema.sql b/ccm-cms/src/test/resources/datasets/create_ccm_cms_schema.sql index d1a6cfec4..bf80fdeba 100644 --- a/ccm-cms/src/test/resources/datasets/create_ccm_cms_schema.sql +++ b/ccm-cms/src/test/resources/datasets/create_ccm_cms_schema.sql @@ -857,6 +857,7 @@ create schema CCM_CORE; add constraint UK_goj42ghwu4tf1akfb2r6ensns unique (WORKFLOW_TEMPLATE_ID); + create table CCM_CORE.APPLICATIONS ( APPLICATION_TYPE varchar(1024) not null, PRIMARY_URL varchar(1024) not null, @@ -899,7 +900,7 @@ create schema CCM_CORE; create table CCM_CORE.CATEGORY_DESCRIPTIONS ( OBJECT_ID bigint not null, - LOCALIZED_VALUE longvarchar, + LOCALIZED_VALUE varchar(2147483647), LOCALE varchar(255) not null, primary key (OBJECT_ID, LOCALE) ); @@ -916,7 +917,7 @@ create schema CCM_CORE; create table CCM_CORE.CATEGORY_TITLES ( OBJECT_ID bigint not null, - LOCALIZED_VALUE longvarchar, + LOCALIZED_VALUE varchar(2147483647), LOCALE varchar(255) not null, primary key (OBJECT_ID, LOCALE) ); @@ -964,7 +965,7 @@ create schema CCM_CORE; create table CCM_CORE.DOMAIN_DESCRIPTIONS ( OBJECT_ID bigint not null, - LOCALIZED_VALUE longvarchar, + LOCALIZED_VALUE varchar(2147483647), LOCALE varchar(255) not null, primary key (OBJECT_ID, LOCALE) ); @@ -981,14 +982,14 @@ create schema CCM_CORE; create table CCM_CORE.DOMAIN_TITLES ( OBJECT_ID bigint not null, - LOCALIZED_VALUE longvarchar, + LOCALIZED_VALUE varchar(2147483647), LOCALE varchar(255) not null, primary key (OBJECT_ID, LOCALE) ); create table CCM_CORE.FORMBUILDER_COMPONENT_DESCRIPTIONS ( COMPONENT_ID bigint not null, - LOCALIZED_VALUE longvarchar, + LOCALIZED_VALUE varchar(2147483647), LOCALE varchar(255) not null, primary key (COMPONENT_ID, LOCALE) ); @@ -1033,14 +1034,14 @@ create schema CCM_CORE; create table CCM_CORE.FORMBUILDER_DATA_QUERY_DESCRIPTIONS ( DATA_QUERY_ID bigint not null, - LOCALIZED_VALUE longvarchar, + LOCALIZED_VALUE varchar(2147483647), LOCALE varchar(255) not null, primary key (DATA_QUERY_ID, LOCALE) ); create table CCM_CORE.FORMBUILDER_DATA_QUERY_NAMES ( DATA_QUERY_ID bigint not null, - LOCALIZED_VALUE longvarchar, + LOCALIZED_VALUE varchar(2147483647), LOCALE varchar(255) not null, primary key (DATA_QUERY_ID, LOCALE) ); @@ -1077,7 +1078,7 @@ create schema CCM_CORE; create table CCM_CORE.FORMBUILDER_OPTION_LABELS ( OPTION_ID bigint not null, - LOCALIZED_VALUE longvarchar, + LOCALIZED_VALUE varchar(2147483647), LOCALE varchar(255) not null, primary key (OPTION_ID, LOCALE) ); @@ -1090,14 +1091,14 @@ create schema CCM_CORE; create table CCM_CORE.FORMBUILDER_PROCESS_LISTENER_DESCRIPTIONS ( PROCESS_LISTENER_ID bigint not null, - LOCALIZED_VALUE longvarchar, + LOCALIZED_VALUE varchar(2147483647), LOCALE varchar(255) not null, primary key (PROCESS_LISTENER_ID, LOCALE) ); create table CCM_CORE.FORMBUILDER_PROCESS_LISTENER_NAMES ( PROCESS_LISTENER_ID bigint not null, - LOCALIZED_VALUE longvarchar, + LOCALIZED_VALUE varchar(2147483647), LOCALE varchar(255) not null, primary key (PROCESS_LISTENER_ID, LOCALE) ); @@ -1254,6 +1255,7 @@ create schema CCM_CORE; CLASS_ATTRIBUTE varchar(512), ID_ATTRIBUTE varchar(255), COMPONENT_KEY varchar(255), + MODEL_UUID varchar(255) not null, STYLE_ATTRIBUTE varchar(1024), UUID varchar(255) not null, PAGE_MODEL_ID bigint, @@ -1262,20 +1264,21 @@ create schema CCM_CORE; create table CCM_CORE.PAGE_MODEL_DESCRIPTIONS ( PAGE_MODEL_ID bigint not null, - LOCALIZED_VALUE longvarchar, + LOCALIZED_VALUE varchar(2147483647), LOCALE varchar(255) not null, primary key (PAGE_MODEL_ID, LOCALE) ); create table CCM_CORE.PAGE_MODEL_TITLES ( PAGE_MODEL_ID bigint not null, - LOCALIZED_VALUE longvarchar, + LOCALIZED_VALUE varchar(2147483647), LOCALE varchar(255) not null, primary key (PAGE_MODEL_ID, LOCALE) ); create table CCM_CORE.PAGE_MODELS ( PAGE_MODEL_ID bigint not null, + MODEL_UUID varchar(255) not null, NAME varchar(255), TYPE varchar(255) not null, UUID varchar(255) not null, @@ -1294,9 +1297,11 @@ create schema CCM_CORE; PERMISSION_ID bigint not null, CREATION_DATE timestamp, CREATION_IP varchar(255), - granted_privilege varchar(255), + GRANTED_PRIVILEGE varchar(255), + INHERITED boolean, CREATION_USER_ID bigint, GRANTEE_ID bigint, + INHERITED_FROM_ID bigint, OBJECT_ID bigint, primary key (PERMISSION_ID) ); @@ -1329,21 +1334,21 @@ create schema CCM_CORE; create table CCM_CORE.RESOURCE_DESCRIPTIONS ( OBJECT_ID bigint not null, - LOCALIZED_VALUE longvarchar, + LOCALIZED_VALUE varchar(2147483647), LOCALE varchar(255) not null, primary key (OBJECT_ID, LOCALE) ); create table CCM_CORE.RESOURCE_TITLES ( OBJECT_ID bigint not null, - LOCALIZED_VALUE longvarchar, + LOCALIZED_VALUE varchar(2147483647), LOCALE varchar(255) not null, primary key (OBJECT_ID, LOCALE) ); create table CCM_CORE.RESOURCE_TYPE_DESCRIPTIONS ( RESOURCE_TYPE_ID bigint not null, - LOCALIZED_VALUE longvarchar, + LOCALIZED_VALUE varchar(2147483647), LOCALE varchar(255) not null, primary key (RESOURCE_TYPE_ID, LOCALE) ); @@ -1368,7 +1373,7 @@ create schema CCM_CORE; create table CCM_CORE.ROLE_DESCRIPTIONS ( ROLE_ID bigint not null, - LOCALIZED_VALUE longvarchar, + LOCALIZED_VALUE varchar(2147483647), LOCALE varchar(255) not null, primary key (ROLE_ID, LOCALE) ); @@ -1385,11 +1390,11 @@ create schema CCM_CORE; SETTING_ID bigint not null, CONFIGURATION_CLASS varchar(512) not null, NAME varchar(512) not null, - SETTING_VALUE_BOOLEAN boolean, - SETTING_VALUE_STRING varchar(1024), SETTING_VALUE_DOUBLE double, + SETTING_VALUE_BOOLEAN boolean, SETTING_VALUE_BIG_DECIMAL decimal(19,2), SETTING_VALUE_LONG bigint, + SETTING_VALUE_STRING varchar(1024), primary key (SETTING_ID) ); @@ -1400,7 +1405,7 @@ create schema CCM_CORE; create table CCM_CORE.SETTINGS_L10N_STR_VALUES ( ENTRY_ID bigint not null, - LOCALIZED_VALUE longvarchar, + LOCALIZED_VALUE varchar(2147483647), LOCALE varchar(255) not null, primary key (ENTRY_ID, LOCALE) ); @@ -1449,14 +1454,14 @@ create schema CCM_CORE; create table CCM_CORE.WORKFLOW_DESCRIPTIONS ( WORKFLOW_ID bigint not null, - LOCALIZED_VALUE longvarchar, + LOCALIZED_VALUE varchar(2147483647), LOCALE varchar(255) not null, primary key (WORKFLOW_ID, LOCALE) ); create table CCM_CORE.WORKFLOW_NAMES ( WORKFLOW_ID bigint not null, - LOCALIZED_VALUE longvarchar, + LOCALIZED_VALUE varchar(2147483647), LOCALE varchar(255) not null, primary key (WORKFLOW_ID, LOCALE) ); @@ -1470,7 +1475,7 @@ create schema CCM_CORE; create table CCM_CORE.WORKFLOW_TASK_COMMENTS ( COMMENT_ID bigint not null, - COMMENT longvarchar, + COMMENT varchar(2147483647), UUID varchar(255) not null, AUTHOR_ID bigint, TASK_ID bigint, @@ -1484,14 +1489,14 @@ create schema CCM_CORE; create table CCM_CORE.WORKFLOW_TASK_DESCRIPTIONS ( TASK_ID bigint not null, - LOCALIZED_VALUE longvarchar, + LOCALIZED_VALUE varchar(2147483647), LOCALE varchar(255) not null, primary key (TASK_ID, LOCALE) ); create table CCM_CORE.WORKFLOW_TASK_LABELS ( TASK_ID bigint not null, - LOCALIZED_VALUE longvarchar, + LOCALIZED_VALUE varchar(2147483647), LOCALE varchar(255) not null, primary key (TASK_ID, LOCALE) ); @@ -1884,6 +1889,11 @@ create sequence hibernate_sequence start with 1 increment by 1; foreign key (GRANTEE_ID) references CCM_CORE.CCM_ROLES; + alter table CCM_CORE.PERMISSIONS + add constraint FKg56ujjoe0j30pq579rf0l5yc6 + foreign key (INHERITED_FROM_ID) + references CCM_CORE.CCM_OBJECTS; + alter table CCM_CORE.PERMISSIONS add constraint FKkamckexjnffnt8lay9nqeawhm foreign key (OBJECT_ID) diff --git a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentSectionManagerTest/after-add-contenttype.xml b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentSectionManagerTest/after-add-contenttype.xml index 7d9b3aa7e..ab26c9dc9 100644 --- a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentSectionManagerTest/after-add-contenttype.xml +++ b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentSectionManagerTest/after-add-contenttype.xml @@ -258,306 +258,708 @@ granted_privilege="categorize_items" object_id="-1100" grantee_id="-3200" - creation_date="2016-07-15"/> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> diff --git a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentSectionManagerTest/after-add-role.xml b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentSectionManagerTest/after-add-role.xml index 384204165..76fad3d47 100644 --- a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentSectionManagerTest/after-add-role.xml +++ b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentSectionManagerTest/after-add-role.xml @@ -220,291 +220,712 @@ granted_privilege="categorize_items" object_id="-1100" grantee_id="-3200" - creation_date="2016-07-15"/> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + granted_privilege="use_asset" + object_id="-1100" + grantee_id="-3200" + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + + creation_date="2016-07-15" + inherited="false" /> + + + \ No newline at end of file diff --git a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentSectionManagerTest/after-create.xml b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentSectionManagerTest/after-create.xml index e6f79bef9..c4c8f2f1e 100644 --- a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentSectionManagerTest/after-create.xml +++ b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentSectionManagerTest/after-create.xml @@ -292,553 +292,1332 @@ granted_privilege="categorize_items" object_id="-1100" grantee_id="-3200" - creation_date="2016-07-15"/> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> - + creation_date="2016-07-15" + inherited="false" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - - - - - - + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + creation_date="2016-07-15" + inherited="false" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentSectionManagerTest/after-remove-contenttype.xml b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentSectionManagerTest/after-remove-contenttype.xml index 31433fb83..3c1907533 100644 --- a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentSectionManagerTest/after-remove-contenttype.xml +++ b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentSectionManagerTest/after-remove-contenttype.xml @@ -240,276 +240,672 @@ granted_privilege="categorize_items" object_id="-1100" grantee_id="-3200" - creation_date="2016-07-15"/> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentSectionManagerTest/after-remove-role.xml b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentSectionManagerTest/after-remove-role.xml index 1f40820f9..462a5ebb3 100644 --- a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentSectionManagerTest/after-remove-role.xml +++ b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentSectionManagerTest/after-remove-role.xml @@ -248,211 +248,509 @@ granted_privilege="categorize_items" object_id="-1100" grantee_id="-3200" - creation_date="2016-07-15"/> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> - + + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentSectionManagerTest/after-rename.xml b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentSectionManagerTest/after-rename.xml index 45312feac..21afc6c0c 100644 --- a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentSectionManagerTest/after-rename.xml +++ b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentSectionManagerTest/after-rename.xml @@ -217,276 +217,672 @@ granted_privilege="categorize_items" object_id="-1100" grantee_id="-3200" - creation_date="2016-07-15"/> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + granted_privilege="use_asset" + object_id="-1100" + grantee_id="-3300" + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentSectionManagerTest/data.xml b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentSectionManagerTest/data.xml index 0dadfde16..8ea97c096 100644 --- a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentSectionManagerTest/data.xml +++ b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentSectionManagerTest/data.xml @@ -251,276 +251,672 @@ granted_privilege="categorize_items" object_id="-1100" grantee_id="-3200" - creation_date="2016-07-15"/> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> + creation_date="2016-07-15" + inherited="false" /> - + creation_date="2016-07-15" + inherited="false" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ccm-cms/src/test/resources/scripts/no-cleanup.sql b/ccm-cms/src/test/resources/scripts/no-cleanup.sql new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/ccm-cms/src/test/resources/scripts/no-cleanup.sql @@ -0,0 +1 @@ + diff --git a/ccm-core/src/main/java/org/libreccm/security/PermissionManager.java b/ccm-core/src/main/java/org/libreccm/security/PermissionManager.java index fd890dd78..a7eeb8f0b 100644 --- a/ccm-core/src/main/java/org/libreccm/security/PermissionManager.java +++ b/ccm-core/src/main/java/org/libreccm/security/PermissionManager.java @@ -123,6 +123,11 @@ public class PermissionManager { Arrays.stream(fields) .filter(field -> field.isAnnotationPresent( RecursivePermissions.class)) + .filter(field -> { + return checkIfPrivilegeIsRecursive( + field.getAnnotation(RecursivePermissions.class), + privilege); + }) .forEach(field -> { field.setAccessible(true); grantRecursive(privilege, grantee, field, object, inheritedFrom); @@ -137,6 +142,14 @@ public class PermissionManager { } } + private boolean checkIfPrivilegeIsRecursive( + final RecursivePermissions annotation, + final String privilege) { + + return Arrays.stream(annotation.privileges()) + .anyMatch(privilege::equals); + } + private void grantRecursive(final String privilege, final Role grantee, final Field field, @@ -172,7 +185,10 @@ public class PermissionManager { obj, inheritedFrom)); } else if (CcmObject.class.isAssignableFrom(field.getType())) { - grantPrivilege(privilege, grantee, (CcmObject) value); + grantInherited(privilege, + grantee, + (CcmObject) value, + inheritedFrom); } else if (Relation.class.isAssignableFrom(field.getType())) { final Relation relation = (Relation) value; if (relation.getRelatedObject() != null) { diff --git a/ccm-core/src/test/java/org/libreccm/security/PermissionManagerTest.java b/ccm-core/src/test/java/org/libreccm/security/PermissionManagerTest.java index 7451dcd06..5a8231df7 100644 --- a/ccm-core/src/test/java/org/libreccm/security/PermissionManagerTest.java +++ b/ccm-core/src/test/java/org/libreccm/security/PermissionManagerTest.java @@ -219,7 +219,7 @@ public class PermissionManagerTest { /** * Verifies that permissions are granted recursivly when a permission is - * granted if the object has properties which are annototed with + * granted if the object has properties which are annotated with * {@link RecursivePermissions}. */ @Test @@ -239,28 +239,6 @@ public class PermissionManagerTest { }); } - /** - * Verifies that granting a permission on a object which is already - * inherited from an object converts the permission to a directly granted - * one. - */ -// @Test -// @UsingDataSet("datasets/org/libreccm/security/PermissionManagerTest/" -// + "after-grant-recursivly.yml") -// @ShouldMatchDataSet( -// value = "datasets/org/libreccm/security/PermissionManagerTest/" -// + "after-grant-inherited.yml", -// excludeColumns = {"permission_id"}) -// @InSequence(212) -// public void grantInheritedPermission() { -// final Role role1 = roleRepository.findByName("role1"); -// final CcmObject category2 = ccmObjectRepository.findById(-20002L); -// -// shiro.getSystemUser().execute(() -> { -// permissionManager.grantPrivilege("privilege4", role1, category2); -// }); -// } - /** * Verifies that * {@link PermissionManager#grantPrivilege(java.lang.String, org.libreccm.security.Role)}