diff --git a/ccm-cms/src/main/java/org/librecms/contentsection/AttachmentList.java b/ccm-cms/src/main/java/org/librecms/contentsection/AttachmentList.java index d76f065d5..d15f369d0 100644 --- a/ccm-cms/src/main/java/org/librecms/contentsection/AttachmentList.java +++ b/ccm-cms/src/main/java/org/librecms/contentsection/AttachmentList.java @@ -23,6 +23,8 @@ import org.libreccm.core.CcmObject; import org.libreccm.core.Identifiable; import org.libreccm.l10n.LocalizedString; import org.libreccm.security.InheritsPermissions; +import org.libreccm.security.RecursivePermissions; +import org.librecms.contentsection.privileges.AssetPrivileges; import java.io.Serializable; import java.util.ArrayList; @@ -137,6 +139,9 @@ public class AttachmentList implements Comparable, private LocalizedString description; @OneToMany(mappedBy = "attachmentList") + @RecursivePermissions(privileges = {AssetPrivileges.EDIT, + AssetPrivileges.DELETE, + AssetPrivileges.VIEW}) private List> attachments; public AttachmentList() { diff --git a/ccm-cms/src/main/java/org/librecms/contentsection/ContentItem.java b/ccm-cms/src/main/java/org/librecms/contentsection/ContentItem.java index 381007e7d..8824a654d 100644 --- a/ccm-cms/src/main/java/org/librecms/contentsection/ContentItem.java +++ b/ccm-cms/src/main/java/org/librecms/contentsection/ContentItem.java @@ -54,7 +54,11 @@ import javax.persistence.OneToOne; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; + import org.hibernate.search.annotations.IndexedEmbedded; +import org.libreccm.security.RecursivePermissions; +import org.librecms.contentsection.privileges.AssetPrivileges; +import org.librecms.contentsection.privileges.ItemPrivileges; import static org.librecms.CmsConstants.*; @@ -237,6 +241,9 @@ public class ContentItem extends CcmObject implements Serializable, @Column(name = "ANCESTORS", length = 1024) private String ancestors; + @RecursivePermissions(privileges = {AssetPrivileges.EDIT, + AssetPrivileges.DELETE, + AssetPrivileges.VIEW}) @OneToMany(mappedBy = "item") private List attachments; diff --git a/ccm-cms/src/main/java/org/librecms/contentsection/ContentSection.java b/ccm-cms/src/main/java/org/librecms/contentsection/ContentSection.java index 97296538d..75c4085d4 100644 --- a/ccm-cms/src/main/java/org/librecms/contentsection/ContentSection.java +++ b/ccm-cms/src/main/java/org/librecms/contentsection/ContentSection.java @@ -18,6 +18,7 @@ */ package org.librecms.contentsection; +import org.libreccm.security.RecursivePermissions; import org.libreccm.security.Role; import org.libreccm.web.CcmApplication; @@ -42,6 +43,8 @@ import javax.persistence.NamedQuery; import javax.persistence.OneToMany; import org.libreccm.workflow.WorkflowTemplate; +import org.librecms.contentsection.privileges.AssetPrivileges; +import org.librecms.contentsection.privileges.ItemPrivileges; import org.librecms.lifecycle.LifecycleDefinition; import static org.librecms.CmsConstants.*; @@ -54,14 +57,15 @@ import static org.librecms.CmsConstants.*; @Table(name = "CONTENT_SECTIONS", schema = DB_SCHEMA) @NamedQueries({ @NamedQuery( - name = "ContentSection.findByLabel", - query = "SELECT s FROM ContentSection s WHERE s.label = :label"), + name = "ContentSection.findByLabel", + query = "SELECT s FROM ContentSection s WHERE s.label = :label") + , @NamedQuery( - name = "ContentSection.findPermissions", - query = "SELECT p FROM Permission p " - + "WHERE (p.object = :section " - + " OR p.object = :rootDocumentsFolder) " - + "AND p.grantee = :role") + name = "ContentSection.findPermissions", + query = "SELECT p FROM Permission p " + + "WHERE (p.object = :section " + + " OR p.object = :rootDocumentsFolder) " + + "AND p.grantee = :role") }) //@ApplicationType( // name = CONTENT_SECTION_APP_TYPE, @@ -86,10 +90,25 @@ public class ContentSection extends CcmApplication implements Serializable { @Column(name = "LABEL", length = 512) private String label; + @RecursivePermissions(privileges = {ItemPrivileges.ADMINISTER, + ItemPrivileges.APPLY_ALTERNATE_WORKFLOW, + ItemPrivileges.APPROVE, + ItemPrivileges.CATEGORIZE, + ItemPrivileges.CREATE_NEW, + ItemPrivileges.DELETE, + ItemPrivileges.EDIT, + ItemPrivileges.PREVIEW, + ItemPrivileges.PUBLISH, + ItemPrivileges.VIEW_PUBLISHED}) @OneToOne @JoinColumn(name = "ROOT_DOCUMENTS_FOLDER_ID") private Folder rootDocumentsFolder; + @RecursivePermissions(privileges = {AssetPrivileges.CREATE_NEW, + AssetPrivileges.DELETE, + AssetPrivileges.EDIT, + AssetPrivileges.USE, + AssetPrivileges.VIEW}) @OneToOne @JoinColumn(name = "ROOT_ASSETS_FOLDER_ID") private Folder rootAssetsFolder; @@ -125,27 +144,27 @@ public class ContentSection extends CcmApplication implements Serializable { @OneToMany @JoinTable( - name = "CONTENT_SECTION_LIFECYCLE_DEFINITIONS", - schema = DB_SCHEMA, - joinColumns = { - @JoinColumn(name = "CONTENT_SECTION_ID") - }, - inverseJoinColumns = { - @JoinColumn(name = "LIFECYCLE_DEFINITION_ID") - } + name = "CONTENT_SECTION_LIFECYCLE_DEFINITIONS", + schema = DB_SCHEMA, + joinColumns = { + @JoinColumn(name = "CONTENT_SECTION_ID") + }, + inverseJoinColumns = { + @JoinColumn(name = "LIFECYCLE_DEFINITION_ID") + } ) private List lifecycleDefinitions; @OneToMany @JoinTable( - name = "CONTENT_SECTION_WORKFLOW_TEMPLATES", - schema = DB_SCHEMA, - joinColumns = { - @JoinColumn(name = "CONTENT_SECTION_ID") - }, - inverseJoinColumns = { - @JoinColumn(name = "WORKFLOW_TEMPLATE_ID") - } + name = "CONTENT_SECTION_WORKFLOW_TEMPLATES", + schema = DB_SCHEMA, + joinColumns = { + @JoinColumn(name = "CONTENT_SECTION_ID") + }, + inverseJoinColumns = { + @JoinColumn(name = "WORKFLOW_TEMPLATE_ID") + } ) private List workflowTemplates; @@ -267,7 +286,7 @@ public class ContentSection extends CcmApplication implements Serializable { } protected void setLifecycleDefinitions( - final List lifecycleDefinitions) { + final List lifecycleDefinitions) { this.lifecycleDefinitions = lifecycleDefinitions; } @@ -276,25 +295,26 @@ public class ContentSection extends CcmApplication implements Serializable { } protected void removeLifecycleDefinition( - final LifecycleDefinition definition) { + final LifecycleDefinition definition) { lifecycleDefinitions.remove(definition); } - - public List getWorkflowTemplates() { - return Collections.unmodifiableList(workflowTemplates); - } - - protected void setWorkflowTemplates(final List workflowTemplates) { - this.workflowTemplates = workflowTemplates; - } - - protected void addWorkflowTemplate(final WorkflowTemplate template) { - workflowTemplates.add(template); - } - - protected void removeWorkflowTemplate(final WorkflowTemplate template) { - workflowTemplates.remove(template); - } + + public List getWorkflowTemplates() { + return Collections.unmodifiableList(workflowTemplates); + } + + protected void setWorkflowTemplates( + final List workflowTemplates) { + this.workflowTemplates = workflowTemplates; + } + + protected void addWorkflowTemplate(final WorkflowTemplate template) { + workflowTemplates.add(template); + } + + protected void removeWorkflowTemplate(final WorkflowTemplate template) { + workflowTemplates.remove(template); + } @Override public int hashCode() { @@ -362,23 +382,23 @@ public class ContentSection extends CcmApplication implements Serializable { @Override public String toString(final String data) { return super.toString(String.format( - ", label = \"%s\", " - + "rootDocumentsFolder = \"%s\", " - + "rootAssetsFolder = \"%s\", " - + "pageResolverClass = \"%s\", " - + "itemResolverClass = \"%s\", " - + "templateResolverClass = \"%s\", " - + "xmlGeneratorClass = \"%s\", " - + "defaultLocale = \"%s\"%s", - label, - Objects.toString(rootDocumentsFolder), - Objects.toString(rootAssetsFolder), - pageResolverClass, - itemResolverClass, - templateResolverClass, - xmlGeneratorClass, - Objects.toString(defaultLocale), - data)); + ", label = \"%s\", " + + "rootDocumentsFolder = \"%s\", " + + "rootAssetsFolder = \"%s\", " + + "pageResolverClass = \"%s\", " + + "itemResolverClass = \"%s\", " + + "templateResolverClass = \"%s\", " + + "xmlGeneratorClass = \"%s\", " + + "defaultLocale = \"%s\"%s", + label, + Objects.toString(rootDocumentsFolder), + Objects.toString(rootAssetsFolder), + pageResolverClass, + itemResolverClass, + templateResolverClass, + xmlGeneratorClass, + Objects.toString(defaultLocale), + data)); } } diff --git a/ccm-cms/src/test/resources-wildfly-remote-h2-mem/scripts/create_ccm_cms_schema.sql b/ccm-cms/src/test/resources-wildfly-remote-h2-mem/scripts/create_ccm_cms_schema.sql index 0b3cc609f..c0cb57c53 100644 --- a/ccm-cms/src/test/resources-wildfly-remote-h2-mem/scripts/create_ccm_cms_schema.sql +++ b/ccm-cms/src/test/resources-wildfly-remote-h2-mem/scripts/create_ccm_cms_schema.sql @@ -856,50 +856,49 @@ create schema CCM_CORE; alter table CCM_CMS.CONTENT_SECTION_WORKFLOW_TEMPLATES 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, - OBJECT_ID int8 not null, + OBJECT_ID bigint not null, primary key (OBJECT_ID) ); create table CCM_CORE.ATTACHMENTS ( - ATTACHMENT_ID int8 not null, - ATTACHMENT_DATA oid, + ATTACHMENT_ID bigint not null, + ATTACHMENT_DATA blob, DESCRIPTION varchar(255), MIME_TYPE varchar(255), TITLE varchar(255), - MESSAGE_ID int8, + MESSAGE_ID bigint, primary key (ATTACHMENT_ID) ); create table CCM_CORE.CATEGORIES ( ABSTRACT_CATEGORY boolean, - CATEGORY_ORDER int8, + CATEGORY_ORDER bigint, ENABLED boolean, NAME varchar(255) not null, UNIQUE_ID varchar(255), VISIBLE boolean, - OBJECT_ID int8 not null, - PARENT_CATEGORY_ID int8, + OBJECT_ID bigint not null, + PARENT_CATEGORY_ID bigint, primary key (OBJECT_ID) ); create table CCM_CORE.CATEGORIZATIONS ( - CATEGORIZATION_ID int8 not null, - CATEGORY_ORDER int8, + CATEGORIZATION_ID bigint not null, + CATEGORY_ORDER bigint, CATEGORY_INDEX boolean, - OBJECT_ORDER int8, + OBJECT_ORDER bigint, TYPE varchar(255), - OBJECT_ID int8, - CATEGORY_ID int8, + OBJECT_ID bigint, + CATEGORY_ID bigint, primary key (CATEGORIZATION_ID) ); create table CCM_CORE.CATEGORY_DESCRIPTIONS ( - OBJECT_ID int8 not null, - LOCALIZED_VALUE text, + OBJECT_ID bigint not null, + LOCALIZED_VALUE longvarchar, LOCALE varchar(255) not null, primary key (OBJECT_ID, LOCALE) ); @@ -909,86 +908,86 @@ create schema CCM_CORE; RELEASED timestamp, URI varchar(1024), VERSION varchar(255), - OBJECT_ID int8 not null, - ROOT_CATEGORY_ID int8, + OBJECT_ID bigint not null, + ROOT_CATEGORY_ID bigint, primary key (OBJECT_ID) ); create table CCM_CORE.CATEGORY_TITLES ( - OBJECT_ID int8 not null, - LOCALIZED_VALUE text, + OBJECT_ID bigint not null, + LOCALIZED_VALUE longvarchar, LOCALE varchar(255) not null, primary key (OBJECT_ID, LOCALE) ); create table CCM_CORE.CCM_OBJECTS ( - OBJECT_ID int8 not null, + OBJECT_ID bigint not null, DISPLAY_NAME varchar(255), UUID varchar(255), primary key (OBJECT_ID) ); create table CCM_CORE.CCM_OBJECTS_AUD ( - OBJECT_ID int8 not null, - REV int4 not null, - REVTYPE int2, - REVEND int4, + OBJECT_ID bigint not null, + REV integer not null, + REVTYPE tinyint, + REVEND integer, DISPLAY_NAME varchar(255), primary key (OBJECT_ID, REV) ); create table CCM_CORE.CCM_REVISIONS ( - id int4 not null, - timestamp int8 not null, + id integer not null, + timestamp bigint not null, USER_NAME varchar(255), primary key (id) ); create table CCM_CORE.CCM_ROLES ( - ROLE_ID int8 not null, + ROLE_ID bigint not null, NAME varchar(512) not null, primary key (ROLE_ID) ); create table CCM_CORE.DIGESTS ( - FREQUENCY int4, + FREQUENCY integer, HEADER varchar(4096) not null, NEXT_RUN timestamp, DIGEST_SEPARATOR varchar(128) not null, SIGNATURE varchar(4096) not null, SUBJECT varchar(255) not null, - OBJECT_ID int8 not null, - FROM_PARTY_ID int8, + OBJECT_ID bigint not null, + FROM_PARTY_ID bigint, primary key (OBJECT_ID) ); create table CCM_CORE.DOMAIN_DESCRIPTIONS ( - OBJECT_ID int8 not null, - LOCALIZED_VALUE text, + OBJECT_ID bigint not null, + LOCALIZED_VALUE longvarchar, LOCALE varchar(255) not null, primary key (OBJECT_ID, LOCALE) ); create table CCM_CORE.DOMAIN_OWNERSHIPS ( - OWNERSHIP_ID int8 not null, + OWNERSHIP_ID bigint not null, CONTEXT varchar(255), - DOMAIN_ORDER int8, - OWNER_ORDER int8, - domain_OBJECT_ID int8 not null, - owner_OBJECT_ID int8 not null, + DOMAIN_ORDER bigint, + OWNER_ORDER bigint, + domain_OBJECT_ID bigint not null, + owner_OBJECT_ID bigint not null, primary key (OWNERSHIP_ID) ); create table CCM_CORE.DOMAIN_TITLES ( - OBJECT_ID int8 not null, - LOCALIZED_VALUE text, + OBJECT_ID bigint not null, + LOCALIZED_VALUE longvarchar, LOCALE varchar(255) not null, primary key (OBJECT_ID, LOCALE) ); create table CCM_CORE.FORMBUILDER_COMPONENT_DESCRIPTIONS ( - COMPONENT_ID int8 not null, - LOCALIZED_VALUE text, + COMPONENT_ID bigint not null, + LOCALIZED_VALUE longvarchar, LOCALE varchar(255) not null, primary key (COMPONENT_ID, LOCALE) ); @@ -997,65 +996,65 @@ create schema CCM_CORE; ACTIVE boolean, ADMIN_NAME varchar(255), ATTRIBUTE_STRING varchar(255), - COMPONENT_ORDER int8, + COMPONENT_ORDER bigint, SELECTED boolean, - OBJECT_ID int8 not null, - parentComponent_OBJECT_ID int8, + OBJECT_ID bigint not null, + parentComponent_OBJECT_ID bigint, primary key (OBJECT_ID) ); create table CCM_CORE.FORMBUILDER_CONFIRM_EMAIL_LISTENER ( - BODY text, + BODY clob, FROM_EMAIL varchar(255), SUBJECT varchar(255), - OBJECT_ID int8 not null, + OBJECT_ID bigint not null, primary key (OBJECT_ID) ); create table CCM_CORE.FORMBUILDER_CONFIRM_REDIRECT_LISTENERS ( URL varchar(255), - OBJECT_ID int8 not null, + OBJECT_ID bigint not null, primary key (OBJECT_ID) ); create table CCM_CORE.FORMBUILDER_DATA_DRIVEN_SELECTS ( MULTIPLE boolean, QUERY varchar(255), - OBJECT_ID int8 not null, + OBJECT_ID bigint not null, primary key (OBJECT_ID) ); create table CCM_CORE.FORMBUILDER_DATA_QUERIES ( QUERY_ID varchar(255), - OBJECT_ID int8 not null, + OBJECT_ID bigint not null, primary key (OBJECT_ID) ); create table CCM_CORE.FORMBUILDER_DATA_QUERY_DESCRIPTIONS ( - DATA_QUERY_ID int8 not null, - LOCALIZED_VALUE text, + DATA_QUERY_ID bigint not null, + LOCALIZED_VALUE longvarchar, LOCALE varchar(255) not null, primary key (DATA_QUERY_ID, LOCALE) ); create table CCM_CORE.FORMBUILDER_DATA_QUERY_NAMES ( - DATA_QUERY_ID int8 not null, - LOCALIZED_VALUE text, + DATA_QUERY_ID bigint not null, + LOCALIZED_VALUE longvarchar, LOCALE varchar(255) not null, primary key (DATA_QUERY_ID, LOCALE) ); create table CCM_CORE.FORMBUILDER_FORMSECTIONS ( FORMSECTION_ACTION varchar(255), - OBJECT_ID int8 not null, + OBJECT_ID bigint not null, primary key (OBJECT_ID) ); create table CCM_CORE.FORMBUILDER_LISTENERS ( ATTRIBUTE_STRING varchar(255), CLASS_NAME varchar(255), - OBJECT_ID int8 not null, - widget_OBJECT_ID int8, + OBJECT_ID bigint not null, + widget_OBJECT_ID bigint, primary key (OBJECT_ID) ); @@ -1064,76 +1063,76 @@ create schema CCM_CORE; PRETTY_NAME varchar(255), PRETTY_PLURAL varchar(255), PROPERTIES_FORM varchar(255), - OBJECT_ID int8 not null, + OBJECT_ID bigint not null, primary key (OBJECT_ID) ); create table CCM_CORE.FORMBUILDER_OBJECT_TYPES ( APP_NAME varchar(255), CLASS_NAME varchar(255), - OBJECT_ID int8 not null, + OBJECT_ID bigint not null, primary key (OBJECT_ID) ); create table CCM_CORE.FORMBUILDER_OPTION_LABELS ( - OPTION_ID int8 not null, - LOCALIZED_VALUE text, + OPTION_ID bigint not null, + LOCALIZED_VALUE longvarchar, LOCALE varchar(255) not null, primary key (OPTION_ID, LOCALE) ); create table CCM_CORE.FORMBUILDER_OPTIONS ( PARAMETER_VALUE varchar(255), - OBJECT_ID int8 not null, + OBJECT_ID bigint not null, primary key (OBJECT_ID) ); create table CCM_CORE.FORMBUILDER_PROCESS_LISTENER_DESCRIPTIONS ( - PROCESS_LISTENER_ID int8 not null, - LOCALIZED_VALUE text, + PROCESS_LISTENER_ID bigint not null, + LOCALIZED_VALUE longvarchar, LOCALE varchar(255) not null, primary key (PROCESS_LISTENER_ID, LOCALE) ); create table CCM_CORE.FORMBUILDER_PROCESS_LISTENER_NAMES ( - PROCESS_LISTENER_ID int8 not null, - LOCALIZED_VALUE text, + PROCESS_LISTENER_ID bigint not null, + LOCALIZED_VALUE longvarchar, LOCALE varchar(255) not null, primary key (PROCESS_LISTENER_ID, LOCALE) ); create table CCM_CORE.FORMBUILDER_PROCESS_LISTENERS ( LISTENER_CLASS varchar(255), - PROCESS_LISTENER_ORDER int8, - OBJECT_ID int8 not null, - formSection_OBJECT_ID int8, + PROCESS_LISTENER_ORDER bigint, + OBJECT_ID bigint not null, + formSection_OBJECT_ID bigint, primary key (OBJECT_ID) ); create table CCM_CORE.FORMBUILDER_REMOTE_SERVER_POST_LISTENER ( REMOTE_URL varchar(2048), - OBJECT_ID int8 not null, + OBJECT_ID bigint not null, primary key (OBJECT_ID) ); create table CCM_CORE.FORMBUILDER_SIMPLE_EMAIL_LISTENERS ( RECIPIENT varchar(255), SUBJECT varchar(255), - OBJECT_ID int8 not null, + OBJECT_ID bigint not null, primary key (OBJECT_ID) ); create table CCM_CORE.FORMBUILDER_TEMPLATE_EMAIL_LISTENERS ( - BODY text, + BODY clob, RECIPIENT varchar(255), SUBJECT varchar(255), - OBJECT_ID int8 not null, + OBJECT_ID bigint not null, primary key (OBJECT_ID) ); create table CCM_CORE.FORMBUILDER_WIDGET_LABELS ( - OBJECT_ID int8 not null, - widget_OBJECT_ID int8, + OBJECT_ID bigint not null, + widget_OBJECT_ID bigint, primary key (OBJECT_ID) ); @@ -1141,58 +1140,58 @@ create schema CCM_CORE; DEFAULT_VALUE varchar(255), PARAMETER_MODEL varchar(255), PARAMETER_NAME varchar(255), - OBJECT_ID int8 not null, - label_OBJECT_ID int8, + OBJECT_ID bigint not null, + label_OBJECT_ID bigint, primary key (OBJECT_ID) ); create table CCM_CORE.FORMBUILDER_XML_EMAIL_LISTENERS ( RECIPIENT varchar(255), SUBJECT varchar(255), - OBJECT_ID int8 not null, + OBJECT_ID bigint not null, primary key (OBJECT_ID) ); create table CCM_CORE.GROUP_MEMBERSHIPS ( - MEMBERSHIP_ID int8 not null, - GROUP_ID int8, - MEMBER_ID int8, + MEMBERSHIP_ID bigint not null, + GROUP_ID bigint, + MEMBER_ID bigint, primary key (MEMBERSHIP_ID) ); create table CCM_CORE.GROUPS ( - PARTY_ID int8 not null, + PARTY_ID bigint not null, primary key (PARTY_ID) ); create table CCM_CORE.HOSTS ( - HOST_ID int8 not null, + HOST_ID bigint not null, SERVER_NAME varchar(512), - SERVER_PORT int8, + SERVER_PORT bigint, primary key (HOST_ID) ); create table CCM_CORE.INITS ( - INITIALIZER_ID int8 not null, + INITIALIZER_ID bigint not null, CLASS_NAME varchar(255), - REQUIRED_BY_ID int8, + REQUIRED_BY_ID bigint, primary key (INITIALIZER_ID) ); create table CCM_CORE.INSTALLED_MODULES ( - MODULE_ID int4 not null, + MODULE_ID integer not null, MODULE_CLASS_NAME varchar(2048), STATUS varchar(255), primary key (MODULE_ID) ); create table CCM_CORE.LUCENE_DOCUMENTS ( - DOCUMENT_ID int8 not null, - CONTENT text, + DOCUMENT_ID bigint not null, + CONTENT clob, CONTENT_SECTION varchar(512), COUNTRY varchar(8), CREATED timestamp, - DIRTY int8, + DIRTY bigint, DOCUMENT_LANGUAGE varchar(8), LAST_MODIFIED timestamp, SUMMARY varchar(4096), @@ -1200,15 +1199,15 @@ create schema CCM_CORE; TITLE varchar(4096), TYPE varchar(255), TYPE_SPECIFIC_INFO varchar(512), - CREATED_BY_PARTY_ID int8, - LAST_MODIFIED_BY int8, + CREATED_BY_PARTY_ID bigint, + LAST_MODIFIED_BY bigint, primary key (DOCUMENT_ID) ); create table CCM_CORE.LUCENE_INDEXES ( - INDEX_ID int8 not null, - LUCENE_INDEX_ID int8, - HOST_ID int8, + INDEX_ID bigint not null, + LUCENE_INDEX_ID bigint, + HOST_ID bigint, primary key (INDEX_ID) ); @@ -1217,9 +1216,9 @@ create schema CCM_CORE; BODY_MIME_TYPE varchar(255), SENT timestamp, SUBJECT varchar(255), - OBJECT_ID int8 not null, - IN_REPLY_TO_ID int8, - SENDER_ID int8, + OBJECT_ID bigint not null, + IN_REPLY_TO_ID bigint, + SENDER_ID bigint, primary key (OBJECT_ID) ); @@ -1229,127 +1228,131 @@ create schema CCM_CORE; EXPUNGE_MESSAGE boolean, FULFILL_DATE timestamp, HEADER varchar(4096), - MAX_RETRIES int8, + MAX_RETRIES bigint, REQUEST_DATE timestamp, SIGNATURE varchar(4096), STATUS varchar(32), - OBJECT_ID int8 not null, - DIGEST_ID int8, - MESSAGE_ID int8, - RECEIVER_ID int8, + OBJECT_ID bigint not null, + DIGEST_ID bigint, + MESSAGE_ID bigint, + RECEIVER_ID bigint, primary key (OBJECT_ID) ); create table CCM_CORE.ONE_TIME_AUTH_TOKENS ( - TOKEN_ID int8 not null, + TOKEN_ID bigint not null, PURPOSE varchar(255), TOKEN varchar(255), VALID_UNTIL timestamp, - USER_ID int8, + USER_ID bigint, primary key (TOKEN_ID) ); create table CCM_CORE.PAGE_MODEL_COMPONENT_MODELS ( - COMPONENT_MODEL_ID int8 not null, + COMPONENT_MODEL_ID bigint not null, 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 int8, + PAGE_MODEL_ID bigint, primary key (COMPONENT_MODEL_ID) ); create table CCM_CORE.PAGE_MODEL_DESCRIPTIONS ( - PAGE_MODEL_ID int8 not null, - LOCALIZED_VALUE text, + PAGE_MODEL_ID bigint not null, + LOCALIZED_VALUE longvarchar, LOCALE varchar(255) not null, primary key (PAGE_MODEL_ID, LOCALE) ); create table CCM_CORE.PAGE_MODEL_TITLES ( - PAGE_MODEL_ID int8 not null, - LOCALIZED_VALUE text, + PAGE_MODEL_ID bigint not null, + LOCALIZED_VALUE longvarchar, LOCALE varchar(255) not null, primary key (PAGE_MODEL_ID, LOCALE) ); create table CCM_CORE.PAGE_MODELS ( - PAGE_MODEL_ID int8 not null, + 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, VERSION varchar(255) not null, - APPLICATION_ID int8, + APPLICATION_ID bigint, primary key (PAGE_MODEL_ID) ); create table CCM_CORE.PARTIES ( - PARTY_ID int8 not null, + PARTY_ID bigint not null, NAME varchar(256) not null, primary key (PARTY_ID) ); create table CCM_CORE.PERMISSIONS ( - PERMISSION_ID int8 not null, + PERMISSION_ID bigint not null, CREATION_DATE timestamp, CREATION_IP varchar(255), granted_privilege varchar(255), - CREATION_USER_ID int8, - GRANTEE_ID int8, - OBJECT_ID int8, + INHERITED boolean, + CREATION_USER_ID bigint, + GRANTEE_ID bigint, + INHERITED_FROM_ID bigint, + OBJECT_ID bigint, primary key (PERMISSION_ID) ); create table CCM_CORE.PORTALS ( TEMPLATE boolean, - OBJECT_ID int8 not null, + OBJECT_ID bigint not null, primary key (OBJECT_ID) ); create table CCM_CORE.PORTLETS ( - CELL_NUMBER int8, - SORT_KEY int8, - OBJECT_ID int8 not null, - PORTAL_ID int8, + CELL_NUMBER bigint, + SORT_KEY bigint, + OBJECT_ID bigint not null, + PORTAL_ID bigint, primary key (OBJECT_ID) ); create table CCM_CORE.QUEUE_ITEMS ( - QUEUE_ITEM_ID int8 not null, + QUEUE_ITEM_ID bigint not null, HEADER varchar(4096), RECEIVER_ADDRESS varchar(512), - RETRY_COUNT int8, + RETRY_COUNT bigint, SIGNATURE varchar(4096), SUCCESSFUL_SENDED boolean, - MESSAGE_ID int8, - RECEIVER_ID int8, + MESSAGE_ID bigint, + RECEIVER_ID bigint, primary key (QUEUE_ITEM_ID) ); create table CCM_CORE.RESOURCE_DESCRIPTIONS ( - OBJECT_ID int8 not null, - LOCALIZED_VALUE text, + OBJECT_ID bigint not null, + LOCALIZED_VALUE longvarchar, LOCALE varchar(255) not null, primary key (OBJECT_ID, LOCALE) ); create table CCM_CORE.RESOURCE_TITLES ( - OBJECT_ID int8 not null, - LOCALIZED_VALUE text, + OBJECT_ID bigint not null, + LOCALIZED_VALUE longvarchar, LOCALE varchar(255) not null, primary key (OBJECT_ID, LOCALE) ); create table CCM_CORE.RESOURCE_TYPE_DESCRIPTIONS ( - RESOURCE_TYPE_ID int8 not null, - LOCALIZED_VALUE text, + RESOURCE_TYPE_ID bigint not null, + LOCALIZED_VALUE longvarchar, LOCALE varchar(255) not null, primary key (RESOURCE_TYPE_ID, LOCALE) ); create table CCM_CORE.RESOURCE_TYPES ( - RESOURCE_TYPE_ID int8 not null, + RESOURCE_TYPE_ID bigint not null, SINGLETON boolean, TITLE varchar(254) not null, EMBEDDED_VIEW boolean, @@ -1360,64 +1363,64 @@ create schema CCM_CORE; create table CCM_CORE.RESOURCES ( CREATED timestamp, - OBJECT_ID int8 not null, - parent_OBJECT_ID int8, - resourceType_RESOURCE_TYPE_ID int8, + OBJECT_ID bigint not null, + parent_OBJECT_ID bigint, + resourceType_RESOURCE_TYPE_ID bigint, primary key (OBJECT_ID) ); create table CCM_CORE.ROLE_DESCRIPTIONS ( - ROLE_ID int8 not null, - LOCALIZED_VALUE text, + ROLE_ID bigint not null, + LOCALIZED_VALUE longvarchar, LOCALE varchar(255) not null, primary key (ROLE_ID, LOCALE) ); create table CCM_CORE.ROLE_MEMBERSHIPS ( - MEMBERSHIP_ID int8 not null, - MEMBER_ID int8, - ROLE_ID int8, + MEMBERSHIP_ID bigint not null, + MEMBER_ID bigint, + ROLE_ID bigint, primary key (MEMBERSHIP_ID) ); create table CCM_CORE.SETTINGS ( DTYPE varchar(31) not null, - SETTING_ID int8 not null, + SETTING_ID bigint not null, CONFIGURATION_CLASS varchar(512) not null, NAME varchar(512) not null, + SETTING_VALUE_BIG_DECIMAL decimal(19,2), SETTING_VALUE_BOOLEAN boolean, SETTING_VALUE_STRING varchar(1024), - SETTING_VALUE_DOUBLE float8, - SETTING_VALUE_BIG_DECIMAL numeric(19, 2), - SETTING_VALUE_LONG int8, + SETTING_VALUE_DOUBLE double, + SETTING_VALUE_LONG bigint, primary key (SETTING_ID) ); create table CCM_CORE.SETTINGS_ENUM_VALUES ( - ENUM_ID int8 not null, + ENUM_ID bigint not null, value varchar(255) ); create table CCM_CORE.SETTINGS_L10N_STR_VALUES ( - ENTRY_ID int8 not null, - LOCALIZED_VALUE text, + ENTRY_ID bigint not null, + LOCALIZED_VALUE longvarchar, LOCALE varchar(255) not null, primary key (ENTRY_ID, LOCALE) ); create table CCM_CORE.SETTINGS_STRING_LIST ( - LIST_ID int8 not null, + LIST_ID bigint not null, value varchar(255) ); create table CCM_CORE.THREADS ( - OBJECT_ID int8 not null, - ROOT_ID int8, + OBJECT_ID bigint not null, + ROOT_ID bigint, primary key (OBJECT_ID) ); create table CCM_CORE.USER_EMAIL_ADDRESSES ( - USER_ID int8 not null, + USER_ID bigint not null, EMAIL_ADDRESS varchar(512) not null, BOUNCING boolean, VERIFIED boolean @@ -1432,92 +1435,92 @@ create schema CCM_CORE; EMAIL_ADDRESS varchar(512) not null, BOUNCING boolean, VERIFIED boolean, - PARTY_ID int8 not null, + PARTY_ID bigint not null, primary key (PARTY_ID) ); create table CCM_CORE.WORKFLOW_ASSIGNABLE_TASKS ( DUE_DATE timestamp, - DURATION_MINUTES int8, + DURATION_MINUTES bigint, LOCKED boolean, START_DATE timestamp, - TASK_ID int8 not null, - LOCKING_USER_ID int8, - NOTIFICATION_SENDER int8, + TASK_ID bigint not null, + LOCKING_USER_ID bigint, + NOTIFICATION_SENDER bigint, primary key (TASK_ID) ); create table CCM_CORE.WORKFLOW_DESCRIPTIONS ( - WORKFLOW_ID int8 not null, - LOCALIZED_VALUE text, + WORKFLOW_ID bigint not null, + LOCALIZED_VALUE longvarchar, LOCALE varchar(255) not null, primary key (WORKFLOW_ID, LOCALE) ); create table CCM_CORE.WORKFLOW_NAMES ( - WORKFLOW_ID int8 not null, - LOCALIZED_VALUE text, + WORKFLOW_ID bigint not null, + LOCALIZED_VALUE longvarchar, LOCALE varchar(255) not null, primary key (WORKFLOW_ID, LOCALE) ); create table CCM_CORE.WORKFLOW_TASK_ASSIGNMENTS ( - TASK_ASSIGNMENT_ID int8 not null, - ROLE_ID int8, - TASK_ID int8, + TASK_ASSIGNMENT_ID bigint not null, + ROLE_ID bigint, + TASK_ID bigint, primary key (TASK_ASSIGNMENT_ID) ); create table CCM_CORE.WORKFLOW_TASK_COMMENTS ( - COMMENT_ID int8 not null, - COMMENT text, + COMMENT_ID bigint not null, + COMMENT longvarchar, UUID varchar(255) not null, - AUTHOR_ID int8, - TASK_ID int8, + AUTHOR_ID bigint, + TASK_ID bigint, primary key (COMMENT_ID) ); create table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES ( - DEPENDS_ON_TASK_ID int8 not null, - DEPENDENT_TASK_ID int8 not null + DEPENDS_ON_TASK_ID bigint not null, + DEPENDENT_TASK_ID bigint not null ); create table CCM_CORE.WORKFLOW_TASK_DESCRIPTIONS ( - TASK_ID int8 not null, - LOCALIZED_VALUE text, + TASK_ID bigint not null, + LOCALIZED_VALUE longvarchar, LOCALE varchar(255) not null, primary key (TASK_ID, LOCALE) ); create table CCM_CORE.WORKFLOW_TASK_LABELS ( - TASK_ID int8 not null, - LOCALIZED_VALUE text, + TASK_ID bigint not null, + LOCALIZED_VALUE longvarchar, LOCALE varchar(255) not null, primary key (TASK_ID, LOCALE) ); create table CCM_CORE.WORKFLOW_TASKS ( - TASK_ID int8 not null, + TASK_ID bigint not null, ACTIVE boolean, TASK_STATE varchar(512), UUID varchar(255) not null, - WORKFLOW_ID int8, + WORKFLOW_ID bigint, primary key (TASK_ID) ); create table CCM_CORE.WORKFLOW_TEMPLATES ( - WORKFLOW_ID int8 not null, + WORKFLOW_ID bigint not null, primary key (WORKFLOW_ID) ); create table CCM_CORE.WORKFLOWS ( - WORKFLOW_ID int8 not null, + WORKFLOW_ID bigint not null, ACTIVE boolean, WORKFLOW_STATE varchar(255), TASKS_STATE varchar(255), UUID varchar(255) not null, - OBJECT_ID int8, - TEMPLATE_ID int8, + OBJECT_ID bigint, + TEMPLATE_ID bigint, primary key (WORKFLOW_ID) ); @@ -1547,7 +1550,7 @@ create schema CCM_CORE; alter table CCM_CORE.WORKFLOWS add constraint UK_o113id7d1cxql0edsrohlnn9x unique (UUID); -create sequence hibernate_sequence start 1 increment 1; +create sequence hibernate_sequence start with 1 increment by 1; alter table CCM_CORE.APPLICATIONS add constraint FKatcp9ij6mbkx0nfeig1o6n3lm @@ -1884,6 +1887,11 @@ create sequence hibernate_sequence start 1 increment 1; foreign key (GRANTEE_ID) references CCM_CORE.CCM_ROLES; + alter table CCM_CORE.PERMISSIONS + add constraint FKc1x3h1p3o20qiwmonpmva7t5i + foreign key (INHERITED_FROM_ID) + references CCM_CORE.CCM_OBJECTS; + alter table CCM_CORE.PERMISSIONS add constraint FKkamckexjnffnt8lay9nqeawhm foreign key (OBJECT_ID) @@ -2077,4 +2085,4 @@ create sequence hibernate_sequence start 1 increment 1; alter table CCM_CORE.WORKFLOWS add constraint FKeixdxau4jebw682gd49tdbsjy foreign key (TEMPLATE_ID) - references CCM_CORE.WORKFLOW_TEMPLATES; \ No newline at end of file + references CCM_CORE.WORKFLOW_TEMPLATES; diff --git a/ccm-cms/src/test/resources-wildfly-remote-pgsql/scripts/create_ccm_cms_schema.sql b/ccm-cms/src/test/resources-wildfly-remote-pgsql/scripts/create_ccm_cms_schema.sql index 7dafcf038..25bb8d923 100644 --- a/ccm-cms/src/test/resources-wildfly-remote-pgsql/scripts/create_ccm_cms_schema.sql +++ b/ccm-cms/src/test/resources-wildfly-remote-pgsql/scripts/create_ccm_cms_schema.sql @@ -856,50 +856,49 @@ create schema CCM_CORE; alter table CCM_CMS.CONTENT_SECTION_WORKFLOW_TEMPLATES 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, - OBJECT_ID bigint not null, + OBJECT_ID int8 not null, primary key (OBJECT_ID) ); create table CCM_CORE.ATTACHMENTS ( - ATTACHMENT_ID bigint not null, - ATTACHMENT_DATA blob, + ATTACHMENT_ID int8 not null, + ATTACHMENT_DATA oid, DESCRIPTION varchar(255), MIME_TYPE varchar(255), TITLE varchar(255), - MESSAGE_ID bigint, + MESSAGE_ID int8, primary key (ATTACHMENT_ID) ); create table CCM_CORE.CATEGORIES ( ABSTRACT_CATEGORY boolean, - CATEGORY_ORDER bigint, + CATEGORY_ORDER int8, ENABLED boolean, NAME varchar(255) not null, UNIQUE_ID varchar(255), VISIBLE boolean, - OBJECT_ID bigint not null, - PARENT_CATEGORY_ID bigint, + OBJECT_ID int8 not null, + PARENT_CATEGORY_ID int8, primary key (OBJECT_ID) ); create table CCM_CORE.CATEGORIZATIONS ( - CATEGORIZATION_ID bigint not null, - CATEGORY_ORDER bigint, + CATEGORIZATION_ID int8 not null, + CATEGORY_ORDER int8, CATEGORY_INDEX boolean, - OBJECT_ORDER bigint, + OBJECT_ORDER int8, TYPE varchar(255), - OBJECT_ID bigint, - CATEGORY_ID bigint, + OBJECT_ID int8, + CATEGORY_ID int8, primary key (CATEGORIZATION_ID) ); create table CCM_CORE.CATEGORY_DESCRIPTIONS ( - OBJECT_ID bigint not null, - LOCALIZED_VALUE longvarchar, + OBJECT_ID int8 not null, + LOCALIZED_VALUE text, LOCALE varchar(255) not null, primary key (OBJECT_ID, LOCALE) ); @@ -909,86 +908,86 @@ create schema CCM_CORE; RELEASED timestamp, URI varchar(1024), VERSION varchar(255), - OBJECT_ID bigint not null, - ROOT_CATEGORY_ID bigint, + OBJECT_ID int8 not null, + ROOT_CATEGORY_ID int8, primary key (OBJECT_ID) ); create table CCM_CORE.CATEGORY_TITLES ( - OBJECT_ID bigint not null, - LOCALIZED_VALUE longvarchar, + OBJECT_ID int8 not null, + LOCALIZED_VALUE text, LOCALE varchar(255) not null, primary key (OBJECT_ID, LOCALE) ); create table CCM_CORE.CCM_OBJECTS ( - OBJECT_ID bigint not null, + OBJECT_ID int8 not null, DISPLAY_NAME varchar(255), UUID varchar(255), primary key (OBJECT_ID) ); create table CCM_CORE.CCM_OBJECTS_AUD ( - OBJECT_ID bigint not null, - REV integer not null, - REVTYPE tinyint, - REVEND integer, + OBJECT_ID int8 not null, + REV int4 not null, + REVTYPE int2, + REVEND int4, DISPLAY_NAME varchar(255), primary key (OBJECT_ID, REV) ); create table CCM_CORE.CCM_REVISIONS ( - id integer not null, - timestamp bigint not null, + id int4 not null, + timestamp int8 not null, USER_NAME varchar(255), primary key (id) ); create table CCM_CORE.CCM_ROLES ( - ROLE_ID bigint not null, + ROLE_ID int8 not null, NAME varchar(512) not null, primary key (ROLE_ID) ); create table CCM_CORE.DIGESTS ( - FREQUENCY integer, + FREQUENCY int4, HEADER varchar(4096) not null, NEXT_RUN timestamp, DIGEST_SEPARATOR varchar(128) not null, SIGNATURE varchar(4096) not null, SUBJECT varchar(255) not null, - OBJECT_ID bigint not null, - FROM_PARTY_ID bigint, + OBJECT_ID int8 not null, + FROM_PARTY_ID int8, primary key (OBJECT_ID) ); create table CCM_CORE.DOMAIN_DESCRIPTIONS ( - OBJECT_ID bigint not null, - LOCALIZED_VALUE longvarchar, + OBJECT_ID int8 not null, + LOCALIZED_VALUE text, LOCALE varchar(255) not null, primary key (OBJECT_ID, LOCALE) ); create table CCM_CORE.DOMAIN_OWNERSHIPS ( - OWNERSHIP_ID bigint not null, + OWNERSHIP_ID int8 not null, CONTEXT varchar(255), - DOMAIN_ORDER bigint, - OWNER_ORDER bigint, - domain_OBJECT_ID bigint not null, - owner_OBJECT_ID bigint not null, + DOMAIN_ORDER int8, + OWNER_ORDER int8, + domain_OBJECT_ID int8 not null, + owner_OBJECT_ID int8 not null, primary key (OWNERSHIP_ID) ); create table CCM_CORE.DOMAIN_TITLES ( - OBJECT_ID bigint not null, - LOCALIZED_VALUE longvarchar, + OBJECT_ID int8 not null, + LOCALIZED_VALUE text, 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, + COMPONENT_ID int8 not null, + LOCALIZED_VALUE text, LOCALE varchar(255) not null, primary key (COMPONENT_ID, LOCALE) ); @@ -997,65 +996,65 @@ create schema CCM_CORE; ACTIVE boolean, ADMIN_NAME varchar(255), ATTRIBUTE_STRING varchar(255), - COMPONENT_ORDER bigint, + COMPONENT_ORDER int8, SELECTED boolean, - OBJECT_ID bigint not null, - parentComponent_OBJECT_ID bigint, + OBJECT_ID int8 not null, + parentComponent_OBJECT_ID int8, primary key (OBJECT_ID) ); create table CCM_CORE.FORMBUILDER_CONFIRM_EMAIL_LISTENER ( - BODY clob, + BODY text, FROM_EMAIL varchar(255), SUBJECT varchar(255), - OBJECT_ID bigint not null, + OBJECT_ID int8 not null, primary key (OBJECT_ID) ); create table CCM_CORE.FORMBUILDER_CONFIRM_REDIRECT_LISTENERS ( URL varchar(255), - OBJECT_ID bigint not null, + OBJECT_ID int8 not null, primary key (OBJECT_ID) ); create table CCM_CORE.FORMBUILDER_DATA_DRIVEN_SELECTS ( MULTIPLE boolean, QUERY varchar(255), - OBJECT_ID bigint not null, + OBJECT_ID int8 not null, primary key (OBJECT_ID) ); create table CCM_CORE.FORMBUILDER_DATA_QUERIES ( QUERY_ID varchar(255), - OBJECT_ID bigint not null, + OBJECT_ID int8 not null, primary key (OBJECT_ID) ); create table CCM_CORE.FORMBUILDER_DATA_QUERY_DESCRIPTIONS ( - DATA_QUERY_ID bigint not null, - LOCALIZED_VALUE longvarchar, + DATA_QUERY_ID int8 not null, + LOCALIZED_VALUE text, 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, + DATA_QUERY_ID int8 not null, + LOCALIZED_VALUE text, LOCALE varchar(255) not null, primary key (DATA_QUERY_ID, LOCALE) ); create table CCM_CORE.FORMBUILDER_FORMSECTIONS ( FORMSECTION_ACTION varchar(255), - OBJECT_ID bigint not null, + OBJECT_ID int8 not null, primary key (OBJECT_ID) ); create table CCM_CORE.FORMBUILDER_LISTENERS ( ATTRIBUTE_STRING varchar(255), CLASS_NAME varchar(255), - OBJECT_ID bigint not null, - widget_OBJECT_ID bigint, + OBJECT_ID int8 not null, + widget_OBJECT_ID int8, primary key (OBJECT_ID) ); @@ -1064,76 +1063,76 @@ create schema CCM_CORE; PRETTY_NAME varchar(255), PRETTY_PLURAL varchar(255), PROPERTIES_FORM varchar(255), - OBJECT_ID bigint not null, + OBJECT_ID int8 not null, primary key (OBJECT_ID) ); create table CCM_CORE.FORMBUILDER_OBJECT_TYPES ( APP_NAME varchar(255), CLASS_NAME varchar(255), - OBJECT_ID bigint not null, + OBJECT_ID int8 not null, primary key (OBJECT_ID) ); create table CCM_CORE.FORMBUILDER_OPTION_LABELS ( - OPTION_ID bigint not null, - LOCALIZED_VALUE longvarchar, + OPTION_ID int8 not null, + LOCALIZED_VALUE text, LOCALE varchar(255) not null, primary key (OPTION_ID, LOCALE) ); create table CCM_CORE.FORMBUILDER_OPTIONS ( PARAMETER_VALUE varchar(255), - OBJECT_ID bigint not null, + OBJECT_ID int8 not null, primary key (OBJECT_ID) ); create table CCM_CORE.FORMBUILDER_PROCESS_LISTENER_DESCRIPTIONS ( - PROCESS_LISTENER_ID bigint not null, - LOCALIZED_VALUE longvarchar, + PROCESS_LISTENER_ID int8 not null, + LOCALIZED_VALUE text, 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, + PROCESS_LISTENER_ID int8 not null, + LOCALIZED_VALUE text, LOCALE varchar(255) not null, primary key (PROCESS_LISTENER_ID, LOCALE) ); create table CCM_CORE.FORMBUILDER_PROCESS_LISTENERS ( LISTENER_CLASS varchar(255), - PROCESS_LISTENER_ORDER bigint, - OBJECT_ID bigint not null, - formSection_OBJECT_ID bigint, + PROCESS_LISTENER_ORDER int8, + OBJECT_ID int8 not null, + formSection_OBJECT_ID int8, primary key (OBJECT_ID) ); create table CCM_CORE.FORMBUILDER_REMOTE_SERVER_POST_LISTENER ( REMOTE_URL varchar(2048), - OBJECT_ID bigint not null, + OBJECT_ID int8 not null, primary key (OBJECT_ID) ); create table CCM_CORE.FORMBUILDER_SIMPLE_EMAIL_LISTENERS ( RECIPIENT varchar(255), SUBJECT varchar(255), - OBJECT_ID bigint not null, + OBJECT_ID int8 not null, primary key (OBJECT_ID) ); create table CCM_CORE.FORMBUILDER_TEMPLATE_EMAIL_LISTENERS ( - BODY clob, + BODY text, RECIPIENT varchar(255), SUBJECT varchar(255), - OBJECT_ID bigint not null, + OBJECT_ID int8 not null, primary key (OBJECT_ID) ); create table CCM_CORE.FORMBUILDER_WIDGET_LABELS ( - OBJECT_ID bigint not null, - widget_OBJECT_ID bigint, + OBJECT_ID int8 not null, + widget_OBJECT_ID int8, primary key (OBJECT_ID) ); @@ -1141,58 +1140,58 @@ create schema CCM_CORE; DEFAULT_VALUE varchar(255), PARAMETER_MODEL varchar(255), PARAMETER_NAME varchar(255), - OBJECT_ID bigint not null, - label_OBJECT_ID bigint, + OBJECT_ID int8 not null, + label_OBJECT_ID int8, primary key (OBJECT_ID) ); create table CCM_CORE.FORMBUILDER_XML_EMAIL_LISTENERS ( RECIPIENT varchar(255), SUBJECT varchar(255), - OBJECT_ID bigint not null, + OBJECT_ID int8 not null, primary key (OBJECT_ID) ); create table CCM_CORE.GROUP_MEMBERSHIPS ( - MEMBERSHIP_ID bigint not null, - GROUP_ID bigint, - MEMBER_ID bigint, + MEMBERSHIP_ID int8 not null, + GROUP_ID int8, + MEMBER_ID int8, primary key (MEMBERSHIP_ID) ); create table CCM_CORE.GROUPS ( - PARTY_ID bigint not null, + PARTY_ID int8 not null, primary key (PARTY_ID) ); create table CCM_CORE.HOSTS ( - HOST_ID bigint not null, + HOST_ID int8 not null, SERVER_NAME varchar(512), - SERVER_PORT bigint, + SERVER_PORT int8, primary key (HOST_ID) ); create table CCM_CORE.INITS ( - INITIALIZER_ID bigint not null, + INITIALIZER_ID int8 not null, CLASS_NAME varchar(255), - REQUIRED_BY_ID bigint, + REQUIRED_BY_ID int8, primary key (INITIALIZER_ID) ); create table CCM_CORE.INSTALLED_MODULES ( - MODULE_ID integer not null, + MODULE_ID int4 not null, MODULE_CLASS_NAME varchar(2048), STATUS varchar(255), primary key (MODULE_ID) ); create table CCM_CORE.LUCENE_DOCUMENTS ( - DOCUMENT_ID bigint not null, - CONTENT clob, + DOCUMENT_ID int8 not null, + CONTENT text, CONTENT_SECTION varchar(512), COUNTRY varchar(8), CREATED timestamp, - DIRTY bigint, + DIRTY int8, DOCUMENT_LANGUAGE varchar(8), LAST_MODIFIED timestamp, SUMMARY varchar(4096), @@ -1200,15 +1199,15 @@ create schema CCM_CORE; TITLE varchar(4096), TYPE varchar(255), TYPE_SPECIFIC_INFO varchar(512), - CREATED_BY_PARTY_ID bigint, - LAST_MODIFIED_BY bigint, + CREATED_BY_PARTY_ID int8, + LAST_MODIFIED_BY int8, primary key (DOCUMENT_ID) ); create table CCM_CORE.LUCENE_INDEXES ( - INDEX_ID bigint not null, - LUCENE_INDEX_ID bigint, - HOST_ID bigint, + INDEX_ID int8 not null, + LUCENE_INDEX_ID int8, + HOST_ID int8, primary key (INDEX_ID) ); @@ -1217,9 +1216,9 @@ create schema CCM_CORE; BODY_MIME_TYPE varchar(255), SENT timestamp, SUBJECT varchar(255), - OBJECT_ID bigint not null, - IN_REPLY_TO_ID bigint, - SENDER_ID bigint, + OBJECT_ID int8 not null, + IN_REPLY_TO_ID int8, + SENDER_ID int8, primary key (OBJECT_ID) ); @@ -1229,127 +1228,131 @@ create schema CCM_CORE; EXPUNGE_MESSAGE boolean, FULFILL_DATE timestamp, HEADER varchar(4096), - MAX_RETRIES bigint, + MAX_RETRIES int8, REQUEST_DATE timestamp, SIGNATURE varchar(4096), STATUS varchar(32), - OBJECT_ID bigint not null, - DIGEST_ID bigint, - MESSAGE_ID bigint, - RECEIVER_ID bigint, + OBJECT_ID int8 not null, + DIGEST_ID int8, + MESSAGE_ID int8, + RECEIVER_ID int8, primary key (OBJECT_ID) ); create table CCM_CORE.ONE_TIME_AUTH_TOKENS ( - TOKEN_ID bigint not null, + TOKEN_ID int8 not null, PURPOSE varchar(255), TOKEN varchar(255), VALID_UNTIL timestamp, - USER_ID bigint, + USER_ID int8, primary key (TOKEN_ID) ); create table CCM_CORE.PAGE_MODEL_COMPONENT_MODELS ( - COMPONENT_MODEL_ID bigint not null, + COMPONENT_MODEL_ID int8 not null, 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, + PAGE_MODEL_ID int8, primary key (COMPONENT_MODEL_ID) ); create table CCM_CORE.PAGE_MODEL_DESCRIPTIONS ( - PAGE_MODEL_ID bigint not null, - LOCALIZED_VALUE longvarchar, + PAGE_MODEL_ID int8 not null, + LOCALIZED_VALUE text, 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, + PAGE_MODEL_ID int8 not null, + LOCALIZED_VALUE text, LOCALE varchar(255) not null, primary key (PAGE_MODEL_ID, LOCALE) ); create table CCM_CORE.PAGE_MODELS ( - PAGE_MODEL_ID bigint not null, + PAGE_MODEL_ID int8 not null, + MODEL_UUID varchar(255) not null, NAME varchar(255), TYPE varchar(255) not null, UUID varchar(255) not null, VERSION varchar(255) not null, - APPLICATION_ID bigint, + APPLICATION_ID int8, primary key (PAGE_MODEL_ID) ); create table CCM_CORE.PARTIES ( - PARTY_ID bigint not null, + PARTY_ID int8 not null, NAME varchar(256) not null, primary key (PARTY_ID) ); create table CCM_CORE.PERMISSIONS ( - PERMISSION_ID bigint not null, + PERMISSION_ID int8 not null, CREATION_DATE timestamp, CREATION_IP varchar(255), granted_privilege varchar(255), - CREATION_USER_ID bigint, - GRANTEE_ID bigint, - OBJECT_ID bigint, + INHERITED boolean, + CREATION_USER_ID int8, + GRANTEE_ID int8, + INHERITED_FROM_ID int8, + OBJECT_ID int8, primary key (PERMISSION_ID) ); create table CCM_CORE.PORTALS ( TEMPLATE boolean, - OBJECT_ID bigint not null, + OBJECT_ID int8 not null, primary key (OBJECT_ID) ); create table CCM_CORE.PORTLETS ( - CELL_NUMBER bigint, - SORT_KEY bigint, - OBJECT_ID bigint not null, - PORTAL_ID bigint, + CELL_NUMBER int8, + SORT_KEY int8, + OBJECT_ID int8 not null, + PORTAL_ID int8, primary key (OBJECT_ID) ); create table CCM_CORE.QUEUE_ITEMS ( - QUEUE_ITEM_ID bigint not null, + QUEUE_ITEM_ID int8 not null, HEADER varchar(4096), RECEIVER_ADDRESS varchar(512), - RETRY_COUNT bigint, + RETRY_COUNT int8, SIGNATURE varchar(4096), SUCCESSFUL_SENDED boolean, - MESSAGE_ID bigint, - RECEIVER_ID bigint, + MESSAGE_ID int8, + RECEIVER_ID int8, primary key (QUEUE_ITEM_ID) ); create table CCM_CORE.RESOURCE_DESCRIPTIONS ( - OBJECT_ID bigint not null, - LOCALIZED_VALUE longvarchar, + OBJECT_ID int8 not null, + LOCALIZED_VALUE text, LOCALE varchar(255) not null, primary key (OBJECT_ID, LOCALE) ); create table CCM_CORE.RESOURCE_TITLES ( - OBJECT_ID bigint not null, - LOCALIZED_VALUE longvarchar, + OBJECT_ID int8 not null, + LOCALIZED_VALUE text, 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, + RESOURCE_TYPE_ID int8 not null, + LOCALIZED_VALUE text, LOCALE varchar(255) not null, primary key (RESOURCE_TYPE_ID, LOCALE) ); create table CCM_CORE.RESOURCE_TYPES ( - RESOURCE_TYPE_ID bigint not null, + RESOURCE_TYPE_ID int8 not null, SINGLETON boolean, TITLE varchar(254) not null, EMBEDDED_VIEW boolean, @@ -1360,64 +1363,64 @@ create schema CCM_CORE; create table CCM_CORE.RESOURCES ( CREATED timestamp, - OBJECT_ID bigint not null, - parent_OBJECT_ID bigint, - resourceType_RESOURCE_TYPE_ID bigint, + OBJECT_ID int8 not null, + parent_OBJECT_ID int8, + resourceType_RESOURCE_TYPE_ID int8, primary key (OBJECT_ID) ); create table CCM_CORE.ROLE_DESCRIPTIONS ( - ROLE_ID bigint not null, - LOCALIZED_VALUE longvarchar, + ROLE_ID int8 not null, + LOCALIZED_VALUE text, LOCALE varchar(255) not null, primary key (ROLE_ID, LOCALE) ); create table CCM_CORE.ROLE_MEMBERSHIPS ( - MEMBERSHIP_ID bigint not null, - MEMBER_ID bigint, - ROLE_ID bigint, + MEMBERSHIP_ID int8 not null, + MEMBER_ID int8, + ROLE_ID int8, primary key (MEMBERSHIP_ID) ); create table CCM_CORE.SETTINGS ( DTYPE varchar(31) not null, - SETTING_ID bigint not null, + SETTING_ID int8 not null, CONFIGURATION_CLASS varchar(512) not null, NAME varchar(512) not null, + SETTING_VALUE_BIG_DECIMAL numeric(19, 2), SETTING_VALUE_BOOLEAN boolean, SETTING_VALUE_STRING varchar(1024), - SETTING_VALUE_DOUBLE double, - SETTING_VALUE_BIG_DECIMAL decimal(19,2), - SETTING_VALUE_LONG bigint, + SETTING_VALUE_DOUBLE float8, + SETTING_VALUE_LONG int8, primary key (SETTING_ID) ); create table CCM_CORE.SETTINGS_ENUM_VALUES ( - ENUM_ID bigint not null, + ENUM_ID int8 not null, value varchar(255) ); create table CCM_CORE.SETTINGS_L10N_STR_VALUES ( - ENTRY_ID bigint not null, - LOCALIZED_VALUE longvarchar, + ENTRY_ID int8 not null, + LOCALIZED_VALUE text, LOCALE varchar(255) not null, primary key (ENTRY_ID, LOCALE) ); create table CCM_CORE.SETTINGS_STRING_LIST ( - LIST_ID bigint not null, + LIST_ID int8 not null, value varchar(255) ); create table CCM_CORE.THREADS ( - OBJECT_ID bigint not null, - ROOT_ID bigint, + OBJECT_ID int8 not null, + ROOT_ID int8, primary key (OBJECT_ID) ); create table CCM_CORE.USER_EMAIL_ADDRESSES ( - USER_ID bigint not null, + USER_ID int8 not null, EMAIL_ADDRESS varchar(512) not null, BOUNCING boolean, VERIFIED boolean @@ -1432,92 +1435,92 @@ create schema CCM_CORE; EMAIL_ADDRESS varchar(512) not null, BOUNCING boolean, VERIFIED boolean, - PARTY_ID bigint not null, + PARTY_ID int8 not null, primary key (PARTY_ID) ); create table CCM_CORE.WORKFLOW_ASSIGNABLE_TASKS ( DUE_DATE timestamp, - DURATION_MINUTES bigint, + DURATION_MINUTES int8, LOCKED boolean, START_DATE timestamp, - TASK_ID bigint not null, - LOCKING_USER_ID bigint, - NOTIFICATION_SENDER bigint, + TASK_ID int8 not null, + LOCKING_USER_ID int8, + NOTIFICATION_SENDER int8, primary key (TASK_ID) ); create table CCM_CORE.WORKFLOW_DESCRIPTIONS ( - WORKFLOW_ID bigint not null, - LOCALIZED_VALUE longvarchar, + WORKFLOW_ID int8 not null, + LOCALIZED_VALUE text, LOCALE varchar(255) not null, primary key (WORKFLOW_ID, LOCALE) ); create table CCM_CORE.WORKFLOW_NAMES ( - WORKFLOW_ID bigint not null, - LOCALIZED_VALUE longvarchar, + WORKFLOW_ID int8 not null, + LOCALIZED_VALUE text, LOCALE varchar(255) not null, primary key (WORKFLOW_ID, LOCALE) ); create table CCM_CORE.WORKFLOW_TASK_ASSIGNMENTS ( - TASK_ASSIGNMENT_ID bigint not null, - ROLE_ID bigint, - TASK_ID bigint, + TASK_ASSIGNMENT_ID int8 not null, + ROLE_ID int8, + TASK_ID int8, primary key (TASK_ASSIGNMENT_ID) ); create table CCM_CORE.WORKFLOW_TASK_COMMENTS ( - COMMENT_ID bigint not null, - COMMENT longvarchar, + COMMENT_ID int8 not null, + COMMENT text, UUID varchar(255) not null, - AUTHOR_ID bigint, - TASK_ID bigint, + AUTHOR_ID int8, + TASK_ID int8, primary key (COMMENT_ID) ); create table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES ( - DEPENDS_ON_TASK_ID bigint not null, - DEPENDENT_TASK_ID bigint not null + DEPENDS_ON_TASK_ID int8 not null, + DEPENDENT_TASK_ID int8 not null ); create table CCM_CORE.WORKFLOW_TASK_DESCRIPTIONS ( - TASK_ID bigint not null, - LOCALIZED_VALUE longvarchar, + TASK_ID int8 not null, + LOCALIZED_VALUE text, 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, + TASK_ID int8 not null, + LOCALIZED_VALUE text, LOCALE varchar(255) not null, primary key (TASK_ID, LOCALE) ); create table CCM_CORE.WORKFLOW_TASKS ( - TASK_ID bigint not null, + TASK_ID int8 not null, ACTIVE boolean, TASK_STATE varchar(512), UUID varchar(255) not null, - WORKFLOW_ID bigint, + WORKFLOW_ID int8, primary key (TASK_ID) ); create table CCM_CORE.WORKFLOW_TEMPLATES ( - WORKFLOW_ID bigint not null, + WORKFLOW_ID int8 not null, primary key (WORKFLOW_ID) ); create table CCM_CORE.WORKFLOWS ( - WORKFLOW_ID bigint not null, + WORKFLOW_ID int8 not null, ACTIVE boolean, WORKFLOW_STATE varchar(255), TASKS_STATE varchar(255), UUID varchar(255) not null, - OBJECT_ID bigint, - TEMPLATE_ID bigint, + OBJECT_ID int8, + TEMPLATE_ID int8, primary key (WORKFLOW_ID) ); @@ -1547,7 +1550,7 @@ create schema CCM_CORE; alter table CCM_CORE.WORKFLOWS add constraint UK_o113id7d1cxql0edsrohlnn9x unique (UUID); -create sequence hibernate_sequence start with 1 increment by 1; +create sequence hibernate_sequence start 1 increment 1; alter table CCM_CORE.APPLICATIONS add constraint FKatcp9ij6mbkx0nfeig1o6n3lm @@ -1884,6 +1887,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 FKc1x3h1p3o20qiwmonpmva7t5i + foreign key (INHERITED_FROM_ID) + references CCM_CORE.CCM_OBJECTS; + alter table CCM_CORE.PERMISSIONS add constraint FKkamckexjnffnt8lay9nqeawhm foreign key (OBJECT_ID) @@ -2077,4 +2085,4 @@ create sequence hibernate_sequence start with 1 increment by 1; alter table CCM_CORE.WORKFLOWS add constraint FKeixdxau4jebw682gd49tdbsjy foreign key (TEMPLATE_ID) - references CCM_CORE.WORKFLOW_TEMPLATES; \ No newline at end of file + references CCM_CORE.WORKFLOW_TEMPLATES; diff --git a/ccm-core/src/main/java/org/libreccm/categorization/Categorization.java b/ccm-core/src/main/java/org/libreccm/categorization/Categorization.java index a0af9fe89..30c987946 100644 --- a/ccm-core/src/main/java/org/libreccm/categorization/Categorization.java +++ b/ccm-core/src/main/java/org/libreccm/categorization/Categorization.java @@ -19,7 +19,6 @@ package org.libreccm.categorization; import com.fasterxml.jackson.annotation.JsonBackReference; -import com.fasterxml.jackson.annotation.JsonManagedReference; import org.libreccm.core.CcmObject; import org.libreccm.portation.Portable; @@ -33,11 +32,14 @@ import javax.persistence.ManyToOne; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.Table; + import java.io.Serializable; import java.util.Objects; import static org.libreccm.core.CoreConstants.DB_SCHEMA; +import org.libreccm.security.RecursivePermissions; + /** * Association class describing the association between a category and an * object. Instances of these class should not created manually. The methods @@ -91,6 +93,7 @@ public class Categorization implements Serializable, Portable { /** * The categorised object. */ + @RecursivePermissions @ManyToOne @JoinColumn(name = "OBJECT_ID") @JsonBackReference(value = "object-categorization") diff --git a/ccm-core/src/main/java/org/libreccm/categorization/Category.java b/ccm-core/src/main/java/org/libreccm/categorization/Category.java index c2ed03b9e..7854bd593 100644 --- a/ccm-core/src/main/java/org/libreccm/categorization/Category.java +++ b/ccm-core/src/main/java/org/libreccm/categorization/Category.java @@ -29,6 +29,7 @@ import org.libreccm.core.DefaultEntityGraph; import org.libreccm.l10n.LocalizedString; import org.libreccm.portation.Portable; import org.libreccm.security.InheritsPermissions; +import org.libreccm.security.RecursivePermissions; import java.io.Serializable; import java.util.ArrayList; @@ -180,6 +181,7 @@ public class Category extends CcmObject implements InheritsPermissions, /** * The objects assigned to this category. */ + @RecursivePermissions @OneToMany(mappedBy = "category") @XmlElementWrapper(name = "objects", namespace = CAT_XML_NS) @JsonManagedReference(value = "category-categorization") @@ -188,6 +190,7 @@ public class Category extends CcmObject implements InheritsPermissions, /** * The sub categories of this category. */ + @RecursivePermissions @OneToMany(mappedBy = "parentCategory") @XmlElementWrapper(name = "subcategories", namespace = CAT_XML_NS) @XmlElement(name = "category") diff --git a/ccm-core/src/main/java/org/libreccm/categorization/Domain.java b/ccm-core/src/main/java/org/libreccm/categorization/Domain.java index 069924bff..f1a6054ea 100644 --- a/ccm-core/src/main/java/org/libreccm/categorization/Domain.java +++ b/ccm-core/src/main/java/org/libreccm/categorization/Domain.java @@ -26,6 +26,7 @@ import org.hibernate.validator.constraints.URL; import org.libreccm.core.CcmObject; import org.libreccm.core.DefaultEntityGraph; import org.libreccm.l10n.LocalizedString; +import org.libreccm.security.RecursivePermissions; import org.libreccm.web.CcmApplication; import java.io.Serializable; @@ -189,6 +190,7 @@ public class Domain extends CcmObject implements Serializable { /** * The root category of the domain. */ + @RecursivePermissions @ManyToOne @JoinColumn(name = "ROOT_CATEGORY_ID") @XmlElement(name = "root", namespace = CAT_XML_NS) diff --git a/ccm-core/src/main/java/org/libreccm/security/Permission.java b/ccm-core/src/main/java/org/libreccm/security/Permission.java index 3c346e035..a85b49522 100644 --- a/ccm-core/src/main/java/org/libreccm/security/Permission.java +++ b/ccm-core/src/main/java/org/libreccm/security/Permission.java @@ -19,7 +19,6 @@ package org.libreccm.security; import com.fasterxml.jackson.annotation.JsonBackReference; -import com.fasterxml.jackson.annotation.JsonManagedReference; import org.hibernate.search.annotations.ContainedIn; import org.hibernate.search.annotations.Field; import org.hibernate.search.annotations.IndexedEmbedded; @@ -42,6 +41,7 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; + import java.io.Serializable; import java.util.Date; import java.util.Objects; @@ -49,6 +49,8 @@ import java.util.Objects; import static org.libreccm.core.CoreConstants.CORE_XML_NS; import static org.libreccm.core.CoreConstants.DB_SCHEMA; +import javax.persistence.OneToOne; + /** * A permission grants a privilege on an object or system wide to {@link Role}. * @@ -61,15 +63,18 @@ import static org.libreccm.core.CoreConstants.DB_SCHEMA; query = "SELECT COUNT(p) FROM Permission p " + "WHERE p.grantedPrivilege = :privilege " + "AND p.grantee = :grantee " - + "AND p.object = :object"), + + "AND p.object = :object") + , @NamedQuery(name = "Permission.existsForPrivilegeAndRole", query = "SELECT count(p) FROM Permission p " + "WHERE p.grantedPrivilege = :privilege " + "AND p.grantee = :grantee " - + "AND p.object IS NULL"), + + "AND p.object IS NULL") + , @NamedQuery(name = "Permission.findPermissionsForRole", query = "SELECT p FROM Permission p " - + "WHERE p.grantee = :grantee"), + + "WHERE p.grantee = :grantee") + , @NamedQuery(name = "Permission.findPermissionsForCcmObject", query = "SELECT p FROM Permission p " + "WHERE p.object = :object") @@ -92,7 +97,7 @@ public class Permission implements Serializable, Portable { /** * The granted privilege. */ - @Column(name = "granted_privilege") + @Column(name = "GRANTED_PRIVILEGE") @Field @XmlElement(name = "privilege", namespace = CORE_XML_NS) private String grantedPrivilege; @@ -144,6 +149,21 @@ public class Permission implements Serializable, Portable { @XmlElement(name = "creation-ip", namespace = CORE_XML_NS) private String creationIp; + /** + * If the permission is inherited from another object this field is set to + * {@code true}. + */ + @Column(name = "INHERITED") + private boolean inherited; + + /** + * If the permission is inherited from another object this field points to + * the object from the which the permission was inherited. + */ + @OneToOne + @JoinColumn(name = "INHERITED_FROM_ID") + private CcmObject inheritedForm; + protected Permission() { //Nothing } @@ -208,6 +228,22 @@ public class Permission implements Serializable, Portable { this.creationIp = creationIp; } + public boolean isInherited() { + return inherited; + } + + protected void setInherited(boolean inherited) { + this.inherited = inherited; + } + + public CcmObject getInheritedForm() { + return inheritedForm; + } + + protected void setInheritedForm(CcmObject inheritedForm) { + this.inheritedForm = inheritedForm; + } + @Override public int hashCode() { int hash = 3; @@ -215,6 +251,7 @@ public class Permission implements Serializable, Portable { hash = 97 * hash + Objects.hashCode(grantedPrivilege); hash = 97 * hash + Objects.hashCode(creationDate); hash = 97 * hash + Objects.hashCode(creationIp); + hash = 97 * hash + Boolean.hashCode(inherited); return hash; } @@ -241,7 +278,11 @@ public class Permission implements Serializable, Portable { return false; } - return Objects.equals(creationIp, other.getCreationIp()); + if (!Objects.equals(creationIp, other.getCreationIp())) { + return false; + } + + return inherited == other.isInherited(); } public boolean canEqual(final Object obj) { diff --git a/ccm-core/src/main/java/org/libreccm/security/RecursivePermissions.java b/ccm-core/src/main/java/org/libreccm/security/RecursivePermissions.java new file mode 100644 index 000000000..f18a883e5 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/security/RecursivePermissions.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2017 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package org.libreccm.security; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Marker interface which an be added to a property to indicate that permissions + * granted on the owing object should recursivly applied to the child objects. + * + * The privileges for which this applied can be defined using + * {@link #privileges()}. + * + * @author Jens Pelzetter + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +public @interface RecursivePermissions { + + /** + * If set only permissions for the privileges in listed here will be applied + * recursivly. + * + * @return + */ + String[] privileges() default {}; + +} diff --git a/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/h2/V7_0_0_12__permission_add_inherited.sql b/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/h2/V7_0_0_12__permission_add_inherited.sql new file mode 100644 index 000000000..1e0b1529f --- /dev/null +++ b/ccm-core/src/main/resources/db/migrations/org/libreccm/ccm_core/h2/V7_0_0_12__permission_add_inherited.sql @@ -0,0 +1,10 @@ +alter table CCM_CORE.PERMISSIONS + add column INHERITED boolean; + +alter table CCM_CORE.PERMISSIONS + add column INHERITED_FROM_ID bigint; + +alter table CCM_CORE.PERMISSIONS + add constraint FKc1x3h1p3o20qiwmonpmva7t5i + foreign key (INHERITED_FROM_ID) + references CCM_CORE.CCM_OBJECTS; diff --git a/ccm-core/src/test/java/org/libreccm/security/DatasetsTest.java b/ccm-core/src/test/java/org/libreccm/security/DatasetsTest.java index ce9e8d0c4..1d33f1346 100644 --- a/ccm-core/src/test/java/org/libreccm/security/DatasetsTest.java +++ b/ccm-core/src/test/java/org/libreccm/security/DatasetsTest.java @@ -57,8 +57,12 @@ public class DatasetsTest extends DatasetsVerifier { "/datasets/org/libreccm/security/PartyRepositoryTest/after-save-new.yml", "/datasets/org/libreccm/security/PermissionManagerTest/data.yml", + "/datasets/org/libreccm/security/PermissionManagerTest/data-recursivly.yml", "/datasets/org/libreccm/security/PermissionManagerTest/after-grant.yml", + "/datasets/org/libreccm/security/PermissionManagerTest/after-grant-recursivly.yml", + "/datasets/org/libreccm/security/PermissionManagerTest/after-grant-inherited.yml", "/datasets/org/libreccm/security/PermissionManagerTest/after-revoke.yml", + "/datasets/org/libreccm/security/PermissionManagerTest/after-revoke-recursivly.yml", "/datasets/org/libreccm/security/PermissionManagerTest/after-copy.yml", "/datasets/org/libreccm/security/RoleManagerTest/data.yml", 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 694cb7dfc..e1caa7293 100644 --- a/ccm-core/src/test/java/org/libreccm/security/PermissionManagerTest.java +++ b/ccm-core/src/test/java/org/libreccm/security/PermissionManagerTest.java @@ -215,6 +215,40 @@ public class PermissionManagerTest { }); } + /** + * Verifies that permissions are granted recursivly when a permission is + * granted if the object has properties which are annototed with + * {@link RecursivePermissions}. + */ + @Test + @UsingDataSet("datasets/org/libreccm/security/PermissionManagerTest/" + + "data-recursivly.yml") + @ShouldMatchDataSet( + value = "datasets/org/libreccm/security/PermissionManagerTest/" + + "after-grant-recursivly.yml", + excludeColumns = {"permission_id"}) + @InSequence(211) + public void grantPermissionRecursively() { + fail(); + } + + /** + * 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() { + fail(); + } + /** * Verifies that * {@link PermissionManager#grantPrivilege(java.lang.String, org.libreccm.security.Role)} @@ -434,6 +468,21 @@ public class PermissionManagerTest { () -> permissionManager.revokePrivilege("privilege999", role1)); } + /** + * Verifies that inherited permissions are revoked when they revoked from + * the object on which the permissions were granted. + */ + @Test + @UsingDataSet("datasets/org/libreccm/security/PermissionManagerTest/" + + "after-grant-recursivly.yml") + @ShouldMatchDataSet( + value = "datasets/org/libreccm/security/PermissionManagerTest/" + + "after-revoke-recursivly.yml") + @InSequence(311) + public void revokePermissionRecursivly() { + fail(); + } + /** * Verifies that * {@link PermissionManager#revokePrivilege(java.lang.String, org.libreccm.security.Role, org.libreccm.core.CcmObject)} @@ -581,7 +630,8 @@ public class PermissionManagerTest { } /** - * Verifies that null null null null null {@link PermissionManager#revokePrivilege(java.lang.String, org.libreccm.security.Role, org.libreccm.core.CcmObject) + * Verifies that + * {@link PermissionManager#revokePrivilege(java.lang.String, org.libreccm.security.Role, org.libreccm.core.CcmObject)} * throws an {@link IllegalArgumentException} if called with {@code null} * for the role to revoke the permission from. * diff --git a/ccm-core/src/test/resources-wildfly-remote-h2-mem/scripts/create_ccm_core_schema.sql b/ccm-core/src/test/resources-wildfly-remote-h2-mem/scripts/create_ccm_core_schema.sql index a2686259e..4e0f6b550 100644 --- a/ccm-core/src/test/resources-wildfly-remote-h2-mem/scripts/create_ccm_core_schema.sql +++ b/ccm-core/src/test/resources-wildfly-remote-h2-mem/scripts/create_ccm_core_schema.sql @@ -4,7 +4,6 @@ drop sequence if exists HIBERNATE_SEQUENCE; create schema CCM_CORE; - create table CCM_CORE.APPLICATIONS ( APPLICATION_TYPE varchar(1024) not null, PRIMARY_URL varchar(1024) not null, @@ -402,6 +401,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, @@ -424,6 +424,7 @@ create schema CCM_CORE; 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, @@ -443,8 +444,10 @@ create schema CCM_CORE; CREATION_DATE timestamp, CREATION_IP 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) ); @@ -533,10 +536,10 @@ create schema CCM_CORE; SETTING_ID bigint not null, CONFIGURATION_CLASS varchar(512) not null, NAME varchar(512) not null, + SETTING_VALUE_BIG_DECIMAL decimal(19,2), SETTING_VALUE_BOOLEAN boolean, SETTING_VALUE_STRING varchar(1024), SETTING_VALUE_DOUBLE double, - SETTING_VALUE_BIG_DECIMAL decimal(19,2), SETTING_VALUE_LONG bigint, primary key (SETTING_ID) ); @@ -1032,6 +1035,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 FKc1x3h1p3o20qiwmonpmva7t5i + foreign key (INHERITED_FROM_ID) + references CCM_CORE.CCM_OBJECTS; + alter table CCM_CORE.PERMISSIONS add constraint FKkamckexjnffnt8lay9nqeawhm foreign key (OBJECT_ID) @@ -1225,4 +1233,4 @@ create sequence hibernate_sequence start with 1 increment by 1; alter table CCM_CORE.WORKFLOWS add constraint FKeixdxau4jebw682gd49tdbsjy foreign key (TEMPLATE_ID) - references CCM_CORE.WORKFLOW_TEMPLATES; \ No newline at end of file + references CCM_CORE.WORKFLOW_TEMPLATES; diff --git a/ccm-core/src/test/resources-wildfly-remote-pgsql/scripts/create_ccm_core_schema.sql b/ccm-core/src/test/resources-wildfly-remote-pgsql/scripts/create_ccm_core_schema.sql index a44665b1d..50eeda345 100644 --- a/ccm-core/src/test/resources-wildfly-remote-pgsql/scripts/create_ccm_core_schema.sql +++ b/ccm-core/src/test/resources-wildfly-remote-pgsql/scripts/create_ccm_core_schema.sql @@ -401,6 +401,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 int8, @@ -423,6 +424,7 @@ create schema CCM_CORE; create table CCM_CORE.PAGE_MODELS ( PAGE_MODEL_ID int8 not null, + MODEL_UUID varchar(255) not null, NAME varchar(255), TYPE varchar(255) not null, UUID varchar(255) not null, @@ -442,8 +444,10 @@ create schema CCM_CORE; CREATION_DATE timestamp, CREATION_IP varchar(255), granted_privilege varchar(255), + INHERITED boolean, CREATION_USER_ID int8, GRANTEE_ID int8, + INHERITED_FROM_ID int8, OBJECT_ID int8, primary key (PERMISSION_ID) ); @@ -532,10 +536,10 @@ create schema CCM_CORE; SETTING_ID int8 not null, CONFIGURATION_CLASS varchar(512) not null, NAME varchar(512) not null, + SETTING_VALUE_BIG_DECIMAL numeric(19, 2), SETTING_VALUE_BOOLEAN boolean, SETTING_VALUE_STRING varchar(1024), SETTING_VALUE_DOUBLE float8, - SETTING_VALUE_BIG_DECIMAL numeric(19, 2), SETTING_VALUE_LONG int8, primary key (SETTING_ID) ); @@ -1031,6 +1035,11 @@ create sequence hibernate_sequence start 1 increment 1; foreign key (GRANTEE_ID) references CCM_CORE.CCM_ROLES; + alter table CCM_CORE.PERMISSIONS + add constraint FKc1x3h1p3o20qiwmonpmva7t5i + foreign key (INHERITED_FROM_ID) + references CCM_CORE.CCM_OBJECTS; + alter table CCM_CORE.PERMISSIONS add constraint FKkamckexjnffnt8lay9nqeawhm foreign key (OBJECT_ID) @@ -1224,4 +1233,4 @@ create sequence hibernate_sequence start 1 increment 1; alter table CCM_CORE.WORKFLOWS add constraint FKeixdxau4jebw682gd49tdbsjy foreign key (TEMPLATE_ID) - references CCM_CORE.WORKFLOW_TEMPLATES; \ No newline at end of file + references CCM_CORE.WORKFLOW_TEMPLATES; diff --git a/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-grant-inherited.yml b/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-grant-inherited.yml new file mode 100644 index 000000000..ca6623d18 --- /dev/null +++ b/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-grant-inherited.yml @@ -0,0 +1,84 @@ +ccm_core.ccm_roles: + - role_id: -10001 + name: role1 + - role_id: -10002 + name: role2 +ccm_core.ccm_objects: + - object_id: -20001 + display_name: category1 + uuid: 17239bc1-5db3-4448-b37c-cac0fddd7342 + - object_id: -20002 + display_name: category2 + uuid: 686a5d09-36ec-46ba-9c97-a5d6db4b9008 + - object_id: -20003 + display_name: category3 + uuid: 1c31700a-f9db-4188-812f-12dba4186c75 + - object_id: -20004 + display_name: objectA +ccm_core.categories: + - object_id: -20001 + unique_id: 17239bc1-5db3-4448-b37c-cac0fddd7342 + name: category1 + enabled: true + visible: true + abstract_category: false + category_order: 0 + - object_id: -20002 + unique_id: 686a5d09-36ec-46ba-9c97-a5d6db4b9008 + name: category2 + enabled: true + visible: true + abstract_category: false + category_order: 0 + parent_category_id: -20001 + - object_id: -20003 + unique_id: 1c31700a-f9db-4188-812f-12dba4186c75 + name: category3 + enabled: true + visible: true + abstract_category: false + category_order: 0 + parent_category_id: -20002 +ccm_core.categorizations: + - categorization_id: -40001 + category_id: -20003 + object_id: -20004 +ccm_core.permissions: + - permission_id: -30001 + granted_privilege: privilege1 + grantee_id: -10001 + inherited: false + - permission_id: -30002 + granted_privilege: privilege2 + object_id: -20001 + grantee_id: -10001 + inherited: false + - permission_id: -30003 + granted_privilege: privilege2 + object_id: -20002 + grantee_id: -10002 + inherited: false + - permission_id: -30004 + granted_privilege: privilege4 + object_id: -20001 + grantee_id: -10001 + inherited: false + - permission_id: -30005 + granted_privilege: privilege4 + object_id: -20002 + grantee_id: -10001 + inherited: false + - permission_id: -30006 + granted_privilege: privilege4 + object_id: -20003 + grantee_id: -10001 + inherited: true + inherited_from_id: -20002 + - permission_id: -30007 + granted_privilege: privilege4 + object_id: -20004 + grantee_id: -10001 + inherited: true + inherited_from_id: -20002 + + diff --git a/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-grant-recursivly.yml b/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-grant-recursivly.yml new file mode 100644 index 000000000..ae9f33baf --- /dev/null +++ b/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-grant-recursivly.yml @@ -0,0 +1,84 @@ +ccm_core.ccm_roles: + - role_id: -10001 + name: role1 + - role_id: -10002 + name: role2 +ccm_core.ccm_objects: + - object_id: -20001 + display_name: category1 + uuid: 17239bc1-5db3-4448-b37c-cac0fddd7342 + - object_id: -20002 + display_name: category2 + uuid: 686a5d09-36ec-46ba-9c97-a5d6db4b9008 + - object_id: -20003 + display_name: category3 + uuid: 1c31700a-f9db-4188-812f-12dba4186c75 + - object_id: -20004 + display_name: objectA +ccm_core.categories: + - object_id: -20001 + unique_id: 17239bc1-5db3-4448-b37c-cac0fddd7342 + name: category1 + enabled: true + visible: true + abstract_category: false + category_order: 0 + - object_id: -20002 + unique_id: 686a5d09-36ec-46ba-9c97-a5d6db4b9008 + name: category2 + enabled: true + visible: true + abstract_category: false + category_order: 0 + parent_category_id: -20001 + - object_id: -20003 + unique_id: 1c31700a-f9db-4188-812f-12dba4186c75 + name: category3 + enabled: true + visible: true + abstract_category: false + category_order: 0 + parent_category_id: -20002 +ccm_core.categorizations: + - categorization_id: -40001 + category_id: -20003 + object_id: -20004 +ccm_core.permissions: + - permission_id: -30001 + granted_privilege: privilege1 + grantee_id: -10001 + inherited: false + - permission_id: -30002 + granted_privilege: privilege2 + object_id: -20001 + grantee_id: -10001 + inherited: false + - permission_id: -30003 + granted_privilege: privilege2 + object_id: -20002 + grantee_id: -10002 + inherited: false + - permission_id: -30004 + granted_privilege: privilege4 + object_id: -20001 + grantee_id: -10001 + inherited: false + - permission_id: -30005 + granted_privilege: privilege4 + object_id: -20002 + grantee_id: -10001 + inherited: true + inherited_from_id: -20001 + - permission_id: -30006 + granted_privilege: privilege4 + object_id: -20003 + grantee_id: -10001 + inherited: true + inherited_from_id: -20001 + - permission_id: -30007 + granted_privilege: privilege4 + object_id: -20004 + grantee_id: -10001 + inherited: true + inherited_from_id: -20001 + diff --git a/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-revoke-recursivly.yml b/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-revoke-recursivly.yml new file mode 100644 index 000000000..6b35673e5 --- /dev/null +++ b/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/after-revoke-recursivly.yml @@ -0,0 +1,61 @@ +ccm_core.ccm_roles: + - role_id: -10001 + name: role1 + - role_id: -10002 + name: role2 +ccm_core.ccm_objects: + - object_id: -20001 + display_name: category1 + uuid: 17239bc1-5db3-4448-b37c-cac0fddd7342 + - object_id: -20002 + display_name: category2 + uuid: 686a5d09-36ec-46ba-9c97-a5d6db4b9008 + - object_id: -20003 + display_name: category3 + uuid: 1c31700a-f9db-4188-812f-12dba4186c75 + - object_id: -20004 + display_name: objectA +ccm_core.categories: + - object_id: -20001 + unique_id: 17239bc1-5db3-4448-b37c-cac0fddd7342 + name: category1 + enabled: true + visible: true + abstract_category: false + category_order: 0 + - object_id: -20002 + unique_id: 686a5d09-36ec-46ba-9c97-a5d6db4b9008 + name: category2 + enabled: true + visible: true + abstract_category: false + category_order: 0 + parent_category_id: -20001 + - object_id: -20003 + unique_id: 1c31700a-f9db-4188-812f-12dba4186c75 + name: category3 + enabled: true + visible: true + abstract_category: false + category_order: 0 + parent_category_id: -20002 +ccm_core.categorizations: + - categorization_id: -40001 + category_id: -20003 + object_id: -20004 +ccm_core.permissions: + - permission_id: -30001 + granted_privilege: privilege1 + grantee_id: -10001 + inherited: false + - permission_id: -30002 + granted_privilege: privilege2 + object_id: -20001 + grantee_id: -10001 + inherited: false + - permission_id: -30003 + granted_privilege: privilege2 + object_id: -20002 + grantee_id: -10002 + inherited: false + diff --git a/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/data-recursivly.yml b/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/data-recursivly.yml new file mode 100644 index 000000000..6b35673e5 --- /dev/null +++ b/ccm-core/src/test/resources/datasets/org/libreccm/security/PermissionManagerTest/data-recursivly.yml @@ -0,0 +1,61 @@ +ccm_core.ccm_roles: + - role_id: -10001 + name: role1 + - role_id: -10002 + name: role2 +ccm_core.ccm_objects: + - object_id: -20001 + display_name: category1 + uuid: 17239bc1-5db3-4448-b37c-cac0fddd7342 + - object_id: -20002 + display_name: category2 + uuid: 686a5d09-36ec-46ba-9c97-a5d6db4b9008 + - object_id: -20003 + display_name: category3 + uuid: 1c31700a-f9db-4188-812f-12dba4186c75 + - object_id: -20004 + display_name: objectA +ccm_core.categories: + - object_id: -20001 + unique_id: 17239bc1-5db3-4448-b37c-cac0fddd7342 + name: category1 + enabled: true + visible: true + abstract_category: false + category_order: 0 + - object_id: -20002 + unique_id: 686a5d09-36ec-46ba-9c97-a5d6db4b9008 + name: category2 + enabled: true + visible: true + abstract_category: false + category_order: 0 + parent_category_id: -20001 + - object_id: -20003 + unique_id: 1c31700a-f9db-4188-812f-12dba4186c75 + name: category3 + enabled: true + visible: true + abstract_category: false + category_order: 0 + parent_category_id: -20002 +ccm_core.categorizations: + - categorization_id: -40001 + category_id: -20003 + object_id: -20004 +ccm_core.permissions: + - permission_id: -30001 + granted_privilege: privilege1 + grantee_id: -10001 + inherited: false + - permission_id: -30002 + granted_privilege: privilege2 + object_id: -20001 + grantee_id: -10001 + inherited: false + - permission_id: -30003 + granted_privilege: privilege2 + object_id: -20002 + grantee_id: -10002 + inherited: false + diff --git a/ccm-shortcuts/src/test/resources-wildfly-remote-h2-mem/scripts/create_ccm_shortcuts_schema.sql b/ccm-shortcuts/src/test/resources-wildfly-remote-h2-mem/scripts/create_ccm_shortcuts_schema.sql index 83d75da79..467caf733 100644 --- a/ccm-shortcuts/src/test/resources-wildfly-remote-h2-mem/scripts/create_ccm_shortcuts_schema.sql +++ b/ccm-shortcuts/src/test/resources-wildfly-remote-h2-mem/scripts/create_ccm_shortcuts_schema.sql @@ -81,6 +81,7 @@ CREATE SCHEMA ccm_shortcuts; OBJECT_ID bigint not null, REV integer not null, REVTYPE tinyint, + REVEND integer, DISPLAY_NAME varchar(255), primary key (OBJECT_ID, REV) ); @@ -397,6 +398,43 @@ CREATE SCHEMA ccm_shortcuts; primary key (TOKEN_ID) ); + create table CCM_CORE.PAGE_MODEL_COMPONENT_MODELS ( + COMPONENT_MODEL_ID bigint not null, + 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, + primary key (COMPONENT_MODEL_ID) + ); + + create table CCM_CORE.PAGE_MODEL_DESCRIPTIONS ( + PAGE_MODEL_ID bigint not null, + LOCALIZED_VALUE longvarchar, + 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, + 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, + VERSION varchar(255) not null, + APPLICATION_ID bigint, + primary key (PAGE_MODEL_ID) + ); + create table CCM_CORE.PARTIES ( PARTY_ID bigint not null, NAME varchar(256) not null, @@ -408,8 +446,10 @@ CREATE SCHEMA ccm_shortcuts; CREATION_DATE timestamp, CREATION_IP 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) ); @@ -498,11 +538,11 @@ CREATE SCHEMA ccm_shortcuts; SETTING_ID bigint not null, CONFIGURATION_CLASS varchar(512) not null, NAME varchar(512) not null, - SETTING_VALUE_LONG bigint, - SETTING_VALUE_DOUBLE double, - SETTING_VALUE_BOOLEAN boolean, SETTING_VALUE_BIG_DECIMAL decimal(19,2), + SETTING_VALUE_BOOLEAN boolean, SETTING_VALUE_STRING varchar(1024), + SETTING_VALUE_DOUBLE double, + SETTING_VALUE_LONG bigint, primary key (SETTING_ID) ); @@ -523,13 +563,6 @@ CREATE SCHEMA ccm_shortcuts; value varchar(255) ); - create table CCM_CORE.TASK_ASSIGNMENTS ( - TASK_ASSIGNMENT_ID bigint not null, - ROLE_ID bigint, - TASK_ID bigint, - primary key (TASK_ASSIGNMENT_ID) - ); - create table CCM_CORE.THREADS ( OBJECT_ID bigint not null, ROOT_ID bigint, @@ -556,6 +589,17 @@ CREATE SCHEMA ccm_shortcuts; primary key (PARTY_ID) ); + create table CCM_CORE.WORKFLOW_ASSIGNABLE_TASKS ( + DUE_DATE timestamp, + DURATION_MINUTES bigint, + LOCKED boolean, + START_DATE timestamp, + TASK_ID bigint not null, + LOCKING_USER_ID bigint, + NOTIFICATION_SENDER bigint, + primary key (TASK_ID) + ); + create table CCM_CORE.WORKFLOW_DESCRIPTIONS ( WORKFLOW_ID bigint not null, LOCALIZED_VALUE longvarchar, @@ -570,9 +614,20 @@ CREATE SCHEMA ccm_shortcuts; primary key (WORKFLOW_ID, LOCALE) ); + create table CCM_CORE.WORKFLOW_TASK_ASSIGNMENTS ( + TASK_ASSIGNMENT_ID bigint not null, + ROLE_ID bigint, + TASK_ID bigint, + primary key (TASK_ASSIGNMENT_ID) + ); + create table CCM_CORE.WORKFLOW_TASK_COMMENTS ( - TASK_ID bigint not null, - COMMENT clob + COMMENT_ID bigint not null, + COMMENT longvarchar, + UUID varchar(255) not null, + AUTHOR_ID bigint, + TASK_ID bigint, + primary key (COMMENT_ID) ); create table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES ( @@ -580,6 +635,13 @@ CREATE SCHEMA ccm_shortcuts; DEPENDENT_TASK_ID bigint not null ); + create table CCM_CORE.WORKFLOW_TASK_DESCRIPTIONS ( + TASK_ID bigint not null, + LOCALIZED_VALUE longvarchar, + 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, @@ -591,35 +653,23 @@ CREATE SCHEMA ccm_shortcuts; TASK_ID bigint not null, ACTIVE boolean, TASK_STATE varchar(512), + UUID varchar(255) not null, WORKFLOW_ID bigint, primary key (TASK_ID) ); - create table CCM_CORE.WORKFLOW_TASKS_DESCRIPTIONS ( - TASK_ID bigint not null, - LOCALIZED_VALUE longvarchar, - LOCALE varchar(255) not null, - primary key (TASK_ID, LOCALE) - ); - create table CCM_CORE.WORKFLOW_TEMPLATES ( WORKFLOW_ID bigint not null, primary key (WORKFLOW_ID) ); - create table CCM_CORE.WORKFLOW_USER_TASKS ( - DUE_DATE timestamp, - DURATION_MINUTES bigint, - LOCKED boolean, - START_DATE timestamp, - TASK_ID bigint not null, - LOCKING_USER_ID bigint, - NOTIFICATION_SENDER bigint, - primary key (TASK_ID) - ); - create table CCM_CORE.WORKFLOWS ( WORKFLOW_ID bigint not null, + ACTIVE boolean, + WORKFLOW_STATE varchar(255), + TASKS_STATE varchar(255), + UUID varchar(255) not null, + OBJECT_ID bigint, TEMPLATE_ID bigint, primary key (WORKFLOW_ID) ); @@ -642,15 +692,14 @@ CREATE SCHEMA ccm_shortcuts; alter table CCM_CORE.SETTINGS add constraint UK5whinfxdaepqs09e5ia9y71uk unique (CONFIGURATION_CLASS, NAME); - create table CCM_SHORTCUTS.SHORTCUTS ( - SHORTCUT_ID bigint not null, - REDIRECT varchar(1024), - URL_KEY varchar(1024), - primary key (SHORTCUT_ID) - ); + alter table CCM_CORE.WORKFLOW_TASK_COMMENTS + add constraint UK_4nnedf08odyjxalfkg16fmjoi unique (UUID); - alter table CCM_SHORTCUTS.SHORTCUTS - add constraint UK_4otuwtog6qqdbg4e6p8xdpw8h unique (URL_KEY); + alter table CCM_CORE.WORKFLOW_TASKS + add constraint UK_2u6ruatxij8wfojl8a1eigqqd unique (UUID); + + alter table CCM_CORE.WORKFLOWS + add constraint UK_o113id7d1cxql0edsrohlnn9x unique (UUID); create sequence hibernate_sequence start with 1 increment by 1; alter table CCM_CORE.APPLICATIONS @@ -708,6 +757,11 @@ create sequence hibernate_sequence start with 1 increment by 1; foreign key (REV) references CCM_CORE.CCM_REVISIONS; + alter table CCM_CORE.CCM_OBJECTS_AUD + add constraint FKo5s37ctcdny7tmewjwv7705h5 + foreign key (REVEND) + references CCM_CORE.CCM_REVISIONS; + alter table CCM_CORE.DIGESTS add constraint FKc53g09agnye3w1v4euy3e0gsi foreign key (FROM_PARTY_ID) @@ -953,6 +1007,26 @@ create sequence hibernate_sequence start with 1 increment by 1; foreign key (USER_ID) references CCM_CORE.USERS; + alter table CCM_CORE.PAGE_MODEL_COMPONENT_MODELS + add constraint FKo696ch035fe7rrueol1po13od + foreign key (PAGE_MODEL_ID) + references CCM_CORE.PAGE_MODELS; + + alter table CCM_CORE.PAGE_MODEL_DESCRIPTIONS + add constraint FKcc5d6eqxu1369k8ycyyt6vn3e + foreign key (PAGE_MODEL_ID) + references CCM_CORE.PAGE_MODELS; + + alter table CCM_CORE.PAGE_MODEL_TITLES + add constraint FKj14q9911yhd4js9p6rs21rwjf + foreign key (PAGE_MODEL_ID) + references CCM_CORE.PAGE_MODELS; + + alter table CCM_CORE.PAGE_MODELS + add constraint FKk2lihllrxj89mn3tqv43amafe + foreign key (APPLICATION_ID) + references CCM_CORE.APPLICATIONS; + alter table CCM_CORE.PERMISSIONS add constraint FKj9di7pawxgtouxmu2k44bj5c4 foreign key (CREATION_USER_ID) @@ -963,6 +1037,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 FKc1x3h1p3o20qiwmonpmva7t5i + foreign key (INHERITED_FROM_ID) + references CCM_CORE.CCM_OBJECTS; + alter table CCM_CORE.PERMISSIONS add constraint FKkamckexjnffnt8lay9nqeawhm foreign key (OBJECT_ID) @@ -1053,16 +1132,6 @@ create sequence hibernate_sequence start with 1 increment by 1; foreign key (LIST_ID) references CCM_CORE.SETTINGS; - alter table CCM_CORE.TASK_ASSIGNMENTS - add constraint FKe29uwmvxdmol1fjob3auej4qv - foreign key (ROLE_ID) - references CCM_CORE.CCM_ROLES; - - alter table CCM_CORE.TASK_ASSIGNMENTS - add constraint FKc1vovbjg9mp5yegx2fdoutx7u - foreign key (TASK_ID) - references CCM_CORE.WORKFLOW_USER_TASKS; - alter table CCM_CORE.THREADS add constraint FKsx08mpwvwnw97uwdgjs76q39g foreign key (ROOT_ID) @@ -1083,6 +1152,21 @@ create sequence hibernate_sequence start with 1 increment by 1; foreign key (PARTY_ID) references CCM_CORE.PARTIES; + alter table CCM_CORE.WORKFLOW_ASSIGNABLE_TASKS + add constraint FK1pnsq9ur3ylq0ghuj23p4cogs + foreign key (LOCKING_USER_ID) + references CCM_CORE.USERS; + + alter table CCM_CORE.WORKFLOW_ASSIGNABLE_TASKS + add constraint FK9ngp088m8xa82swy7yg3qx6vh + foreign key (NOTIFICATION_SENDER) + references CCM_CORE.USERS; + + alter table CCM_CORE.WORKFLOW_ASSIGNABLE_TASKS + add constraint FKt9ha3no3bj8a50pnw8cnqh2cq + foreign key (TASK_ID) + references CCM_CORE.WORKFLOW_TASKS; + alter table CCM_CORE.WORKFLOW_DESCRIPTIONS add constraint FKgx7upkqky82dpxvbs95imfl9l foreign key (WORKFLOW_ID) @@ -1093,6 +1177,21 @@ create sequence hibernate_sequence start with 1 increment by 1; foreign key (WORKFLOW_ID) references CCM_CORE.WORKFLOWS; + alter table CCM_CORE.WORKFLOW_TASK_ASSIGNMENTS + add constraint FKpq4paqtfbi5erhh98wl1ja005 + foreign key (ROLE_ID) + references CCM_CORE.CCM_ROLES; + + alter table CCM_CORE.WORKFLOW_TASK_ASSIGNMENTS + add constraint FK3933ol31co3yn5ee75b2hmhgp + foreign key (TASK_ID) + references CCM_CORE.WORKFLOW_ASSIGNABLE_TASKS; + + alter table CCM_CORE.WORKFLOW_TASK_COMMENTS + add constraint FKd2ymdg8nay9pmh2nn2whba0j8 + foreign key (AUTHOR_ID) + references CCM_CORE.USERS; + alter table CCM_CORE.WORKFLOW_TASK_COMMENTS add constraint FKkfqrf9jdvm7livu5if06w0r5t foreign key (TASK_ID) @@ -1108,6 +1207,11 @@ create sequence hibernate_sequence start with 1 increment by 1; foreign key (DEPENDS_ON_TASK_ID) references CCM_CORE.WORKFLOW_TASKS; + alter table CCM_CORE.WORKFLOW_TASK_DESCRIPTIONS + add constraint FKeb7mqbdx3bk7t01vo7kp2hpf + foreign key (TASK_ID) + references CCM_CORE.WORKFLOW_TASKS; + alter table CCM_CORE.WORKFLOW_TASK_LABELS add constraint FKf715qud6g9xv2xeb8rrpnv4xs foreign key (TASK_ID) @@ -1118,32 +1222,28 @@ create sequence hibernate_sequence start with 1 increment by 1; foreign key (WORKFLOW_ID) references CCM_CORE.WORKFLOWS; - alter table CCM_CORE.WORKFLOW_TASKS_DESCRIPTIONS - add constraint FK2s2498d2tpojjrtghq7iyaosv - foreign key (TASK_ID) - references CCM_CORE.WORKFLOW_TASKS; - alter table CCM_CORE.WORKFLOW_TEMPLATES add constraint FK8692vdme4yxnkj1m0k1dw74pk foreign key (WORKFLOW_ID) references CCM_CORE.WORKFLOWS; - alter table CCM_CORE.WORKFLOW_USER_TASKS - add constraint FKf09depwj5rgso2dair07vnu33 - foreign key (LOCKING_USER_ID) - references CCM_CORE.USERS; - - alter table CCM_CORE.WORKFLOW_USER_TASKS - add constraint FK6evo9y34awhdfcyl8gv78qb7f - foreign key (NOTIFICATION_SENDER) - references CCM_CORE.USERS; - - alter table CCM_CORE.WORKFLOW_USER_TASKS - add constraint FKefpdf9ojplu7loo31hfm0wl2h - foreign key (TASK_ID) - references CCM_CORE.WORKFLOW_TASKS; + alter table CCM_CORE.WORKFLOWS + add constraint FKrm2yfrs6veoxoy304upq2wc64 + foreign key (OBJECT_ID) + references CCM_CORE.CCM_OBJECTS; alter table CCM_CORE.WORKFLOWS add constraint FKeixdxau4jebw682gd49tdbsjy foreign key (TEMPLATE_ID) - references CCM_CORE.WORKFLOW_TEMPLATES; \ No newline at end of file + references CCM_CORE.WORKFLOW_TEMPLATES; + + create table CCM_SHORTCUTS.SHORTCUTS ( + SHORTCUT_ID bigint not null, + REDIRECT varchar(1024), + URL_KEY varchar(1024), + primary key (SHORTCUT_ID) + ); + + alter table CCM_SHORTCUTS.SHORTCUTS + add constraint UK_4otuwtog6qqdbg4e6p8xdpw8h unique (URL_KEY); +create sequence hibernate_sequence start with 1 increment by 1; diff --git a/ccm-shortcuts/src/test/resources-wildfly-remote-pgsql/scripts/create_ccm_shortcuts_schema.sql b/ccm-shortcuts/src/test/resources-wildfly-remote-pgsql/scripts/create_ccm_shortcuts_schema.sql index 79ec45306..7d45fb264 100644 --- a/ccm-shortcuts/src/test/resources-wildfly-remote-pgsql/scripts/create_ccm_shortcuts_schema.sql +++ b/ccm-shortcuts/src/test/resources-wildfly-remote-pgsql/scripts/create_ccm_shortcuts_schema.sql @@ -6,7 +6,7 @@ DROP SEQUENCE IF EXISTS hibernate_sequence; CREATE SCHEMA ccm_core; CREATE SCHEMA ccm_shortcuts; - create table CCM_CORE.APPLICATIONS ( +create table CCM_CORE.APPLICATIONS ( APPLICATION_TYPE varchar(1024) not null, PRIMARY_URL varchar(1024) not null, OBJECT_ID int8 not null, @@ -81,6 +81,7 @@ CREATE SCHEMA ccm_shortcuts; OBJECT_ID int8 not null, REV int4 not null, REVTYPE int2, + REVEND int4, DISPLAY_NAME varchar(255), primary key (OBJECT_ID, REV) ); @@ -397,6 +398,43 @@ CREATE SCHEMA ccm_shortcuts; primary key (TOKEN_ID) ); + create table CCM_CORE.PAGE_MODEL_COMPONENT_MODELS ( + COMPONENT_MODEL_ID int8 not null, + 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 int8, + primary key (COMPONENT_MODEL_ID) + ); + + create table CCM_CORE.PAGE_MODEL_DESCRIPTIONS ( + PAGE_MODEL_ID int8 not null, + LOCALIZED_VALUE text, + LOCALE varchar(255) not null, + primary key (PAGE_MODEL_ID, LOCALE) + ); + + create table CCM_CORE.PAGE_MODEL_TITLES ( + PAGE_MODEL_ID int8 not null, + LOCALIZED_VALUE text, + LOCALE varchar(255) not null, + primary key (PAGE_MODEL_ID, LOCALE) + ); + + create table CCM_CORE.PAGE_MODELS ( + PAGE_MODEL_ID int8 not null, + MODEL_UUID varchar(255) not null, + NAME varchar(255), + TYPE varchar(255) not null, + UUID varchar(255) not null, + VERSION varchar(255) not null, + APPLICATION_ID int8, + primary key (PAGE_MODEL_ID) + ); + create table CCM_CORE.PARTIES ( PARTY_ID int8 not null, NAME varchar(256) not null, @@ -408,8 +446,10 @@ CREATE SCHEMA ccm_shortcuts; CREATION_DATE timestamp, CREATION_IP varchar(255), granted_privilege varchar(255), + INHERITED boolean, CREATION_USER_ID int8, GRANTEE_ID int8, + INHERITED_FROM_ID int8, OBJECT_ID int8, primary key (PERMISSION_ID) ); @@ -498,11 +538,11 @@ CREATE SCHEMA ccm_shortcuts; SETTING_ID int8 not null, CONFIGURATION_CLASS varchar(512) not null, NAME varchar(512) not null, - SETTING_VALUE_LONG int8, - SETTING_VALUE_DOUBLE float8, - SETTING_VALUE_BOOLEAN boolean, SETTING_VALUE_BIG_DECIMAL numeric(19, 2), + SETTING_VALUE_BOOLEAN boolean, SETTING_VALUE_STRING varchar(1024), + SETTING_VALUE_DOUBLE float8, + SETTING_VALUE_LONG int8, primary key (SETTING_ID) ); @@ -523,13 +563,6 @@ CREATE SCHEMA ccm_shortcuts; value varchar(255) ); - create table CCM_CORE.TASK_ASSIGNMENTS ( - TASK_ASSIGNMENT_ID int8 not null, - ROLE_ID int8, - TASK_ID int8, - primary key (TASK_ASSIGNMENT_ID) - ); - create table CCM_CORE.THREADS ( OBJECT_ID int8 not null, ROOT_ID int8, @@ -556,6 +589,17 @@ CREATE SCHEMA ccm_shortcuts; primary key (PARTY_ID) ); + create table CCM_CORE.WORKFLOW_ASSIGNABLE_TASKS ( + DUE_DATE timestamp, + DURATION_MINUTES int8, + LOCKED boolean, + START_DATE timestamp, + TASK_ID int8 not null, + LOCKING_USER_ID int8, + NOTIFICATION_SENDER int8, + primary key (TASK_ID) + ); + create table CCM_CORE.WORKFLOW_DESCRIPTIONS ( WORKFLOW_ID int8 not null, LOCALIZED_VALUE text, @@ -570,9 +614,20 @@ CREATE SCHEMA ccm_shortcuts; primary key (WORKFLOW_ID, LOCALE) ); + create table CCM_CORE.WORKFLOW_TASK_ASSIGNMENTS ( + TASK_ASSIGNMENT_ID int8 not null, + ROLE_ID int8, + TASK_ID int8, + primary key (TASK_ASSIGNMENT_ID) + ); + create table CCM_CORE.WORKFLOW_TASK_COMMENTS ( - TASK_ID int8 not null, - COMMENT text + COMMENT_ID int8 not null, + COMMENT text, + UUID varchar(255) not null, + AUTHOR_ID int8, + TASK_ID int8, + primary key (COMMENT_ID) ); create table CCM_CORE.WORKFLOW_TASK_DEPENDENCIES ( @@ -580,6 +635,13 @@ CREATE SCHEMA ccm_shortcuts; DEPENDENT_TASK_ID int8 not null ); + create table CCM_CORE.WORKFLOW_TASK_DESCRIPTIONS ( + TASK_ID int8 not null, + LOCALIZED_VALUE text, + LOCALE varchar(255) not null, + primary key (TASK_ID, LOCALE) + ); + create table CCM_CORE.WORKFLOW_TASK_LABELS ( TASK_ID int8 not null, LOCALIZED_VALUE text, @@ -591,35 +653,23 @@ CREATE SCHEMA ccm_shortcuts; TASK_ID int8 not null, ACTIVE boolean, TASK_STATE varchar(512), + UUID varchar(255) not null, WORKFLOW_ID int8, primary key (TASK_ID) ); - create table CCM_CORE.WORKFLOW_TASKS_DESCRIPTIONS ( - TASK_ID int8 not null, - LOCALIZED_VALUE text, - LOCALE varchar(255) not null, - primary key (TASK_ID, LOCALE) - ); - create table CCM_CORE.WORKFLOW_TEMPLATES ( WORKFLOW_ID int8 not null, primary key (WORKFLOW_ID) ); - create table CCM_CORE.WORKFLOW_USER_TASKS ( - DUE_DATE timestamp, - DURATION_MINUTES int8, - LOCKED boolean, - START_DATE timestamp, - TASK_ID int8 not null, - LOCKING_USER_ID int8, - NOTIFICATION_SENDER int8, - primary key (TASK_ID) - ); - create table CCM_CORE.WORKFLOWS ( WORKFLOW_ID int8 not null, + ACTIVE boolean, + WORKFLOW_STATE varchar(255), + TASKS_STATE varchar(255), + UUID varchar(255) not null, + OBJECT_ID int8, TEMPLATE_ID int8, primary key (WORKFLOW_ID) ); @@ -642,15 +692,14 @@ CREATE SCHEMA ccm_shortcuts; alter table CCM_CORE.SETTINGS add constraint UK5whinfxdaepqs09e5ia9y71uk unique (CONFIGURATION_CLASS, NAME); - create table CCM_SHORTCUTS.SHORTCUTS ( - SHORTCUT_ID int8 not null, - REDIRECT varchar(1024), - URL_KEY varchar(1024), - primary key (SHORTCUT_ID) - ); + alter table CCM_CORE.WORKFLOW_TASK_COMMENTS + add constraint UK_4nnedf08odyjxalfkg16fmjoi unique (UUID); - alter table CCM_SHORTCUTS.SHORTCUTS - add constraint UK_4otuwtog6qqdbg4e6p8xdpw8h unique (URL_KEY); + alter table CCM_CORE.WORKFLOW_TASKS + add constraint UK_2u6ruatxij8wfojl8a1eigqqd unique (UUID); + + alter table CCM_CORE.WORKFLOWS + add constraint UK_o113id7d1cxql0edsrohlnn9x unique (UUID); create sequence hibernate_sequence start 1 increment 1; alter table CCM_CORE.APPLICATIONS @@ -708,6 +757,11 @@ create sequence hibernate_sequence start 1 increment 1; foreign key (REV) references CCM_CORE.CCM_REVISIONS; + alter table CCM_CORE.CCM_OBJECTS_AUD + add constraint FKo5s37ctcdny7tmewjwv7705h5 + foreign key (REVEND) + references CCM_CORE.CCM_REVISIONS; + alter table CCM_CORE.DIGESTS add constraint FKc53g09agnye3w1v4euy3e0gsi foreign key (FROM_PARTY_ID) @@ -953,6 +1007,26 @@ create sequence hibernate_sequence start 1 increment 1; foreign key (USER_ID) references CCM_CORE.USERS; + alter table CCM_CORE.PAGE_MODEL_COMPONENT_MODELS + add constraint FKo696ch035fe7rrueol1po13od + foreign key (PAGE_MODEL_ID) + references CCM_CORE.PAGE_MODELS; + + alter table CCM_CORE.PAGE_MODEL_DESCRIPTIONS + add constraint FKcc5d6eqxu1369k8ycyyt6vn3e + foreign key (PAGE_MODEL_ID) + references CCM_CORE.PAGE_MODELS; + + alter table CCM_CORE.PAGE_MODEL_TITLES + add constraint FKj14q9911yhd4js9p6rs21rwjf + foreign key (PAGE_MODEL_ID) + references CCM_CORE.PAGE_MODELS; + + alter table CCM_CORE.PAGE_MODELS + add constraint FKk2lihllrxj89mn3tqv43amafe + foreign key (APPLICATION_ID) + references CCM_CORE.APPLICATIONS; + alter table CCM_CORE.PERMISSIONS add constraint FKj9di7pawxgtouxmu2k44bj5c4 foreign key (CREATION_USER_ID) @@ -963,6 +1037,11 @@ create sequence hibernate_sequence start 1 increment 1; foreign key (GRANTEE_ID) references CCM_CORE.CCM_ROLES; + alter table CCM_CORE.PERMISSIONS + add constraint FKc1x3h1p3o20qiwmonpmva7t5i + foreign key (INHERITED_FROM_ID) + references CCM_CORE.CCM_OBJECTS; + alter table CCM_CORE.PERMISSIONS add constraint FKkamckexjnffnt8lay9nqeawhm foreign key (OBJECT_ID) @@ -1053,16 +1132,6 @@ create sequence hibernate_sequence start 1 increment 1; foreign key (LIST_ID) references CCM_CORE.SETTINGS; - alter table CCM_CORE.TASK_ASSIGNMENTS - add constraint FKe29uwmvxdmol1fjob3auej4qv - foreign key (ROLE_ID) - references CCM_CORE.CCM_ROLES; - - alter table CCM_CORE.TASK_ASSIGNMENTS - add constraint FKc1vovbjg9mp5yegx2fdoutx7u - foreign key (TASK_ID) - references CCM_CORE.WORKFLOW_USER_TASKS; - alter table CCM_CORE.THREADS add constraint FKsx08mpwvwnw97uwdgjs76q39g foreign key (ROOT_ID) @@ -1083,6 +1152,21 @@ create sequence hibernate_sequence start 1 increment 1; foreign key (PARTY_ID) references CCM_CORE.PARTIES; + alter table CCM_CORE.WORKFLOW_ASSIGNABLE_TASKS + add constraint FK1pnsq9ur3ylq0ghuj23p4cogs + foreign key (LOCKING_USER_ID) + references CCM_CORE.USERS; + + alter table CCM_CORE.WORKFLOW_ASSIGNABLE_TASKS + add constraint FK9ngp088m8xa82swy7yg3qx6vh + foreign key (NOTIFICATION_SENDER) + references CCM_CORE.USERS; + + alter table CCM_CORE.WORKFLOW_ASSIGNABLE_TASKS + add constraint FKt9ha3no3bj8a50pnw8cnqh2cq + foreign key (TASK_ID) + references CCM_CORE.WORKFLOW_TASKS; + alter table CCM_CORE.WORKFLOW_DESCRIPTIONS add constraint FKgx7upkqky82dpxvbs95imfl9l foreign key (WORKFLOW_ID) @@ -1093,6 +1177,21 @@ create sequence hibernate_sequence start 1 increment 1; foreign key (WORKFLOW_ID) references CCM_CORE.WORKFLOWS; + alter table CCM_CORE.WORKFLOW_TASK_ASSIGNMENTS + add constraint FKpq4paqtfbi5erhh98wl1ja005 + foreign key (ROLE_ID) + references CCM_CORE.CCM_ROLES; + + alter table CCM_CORE.WORKFLOW_TASK_ASSIGNMENTS + add constraint FK3933ol31co3yn5ee75b2hmhgp + foreign key (TASK_ID) + references CCM_CORE.WORKFLOW_ASSIGNABLE_TASKS; + + alter table CCM_CORE.WORKFLOW_TASK_COMMENTS + add constraint FKd2ymdg8nay9pmh2nn2whba0j8 + foreign key (AUTHOR_ID) + references CCM_CORE.USERS; + alter table CCM_CORE.WORKFLOW_TASK_COMMENTS add constraint FKkfqrf9jdvm7livu5if06w0r5t foreign key (TASK_ID) @@ -1108,6 +1207,11 @@ create sequence hibernate_sequence start 1 increment 1; foreign key (DEPENDS_ON_TASK_ID) references CCM_CORE.WORKFLOW_TASKS; + alter table CCM_CORE.WORKFLOW_TASK_DESCRIPTIONS + add constraint FKeb7mqbdx3bk7t01vo7kp2hpf + foreign key (TASK_ID) + references CCM_CORE.WORKFLOW_TASKS; + alter table CCM_CORE.WORKFLOW_TASK_LABELS add constraint FKf715qud6g9xv2xeb8rrpnv4xs foreign key (TASK_ID) @@ -1118,32 +1222,28 @@ create sequence hibernate_sequence start 1 increment 1; foreign key (WORKFLOW_ID) references CCM_CORE.WORKFLOWS; - alter table CCM_CORE.WORKFLOW_TASKS_DESCRIPTIONS - add constraint FK2s2498d2tpojjrtghq7iyaosv - foreign key (TASK_ID) - references CCM_CORE.WORKFLOW_TASKS; - alter table CCM_CORE.WORKFLOW_TEMPLATES add constraint FK8692vdme4yxnkj1m0k1dw74pk foreign key (WORKFLOW_ID) references CCM_CORE.WORKFLOWS; - alter table CCM_CORE.WORKFLOW_USER_TASKS - add constraint FKf09depwj5rgso2dair07vnu33 - foreign key (LOCKING_USER_ID) - references CCM_CORE.USERS; - - alter table CCM_CORE.WORKFLOW_USER_TASKS - add constraint FK6evo9y34awhdfcyl8gv78qb7f - foreign key (NOTIFICATION_SENDER) - references CCM_CORE.USERS; - - alter table CCM_CORE.WORKFLOW_USER_TASKS - add constraint FKefpdf9ojplu7loo31hfm0wl2h - foreign key (TASK_ID) - references CCM_CORE.WORKFLOW_TASKS; + alter table CCM_CORE.WORKFLOWS + add constraint FKrm2yfrs6veoxoy304upq2wc64 + foreign key (OBJECT_ID) + references CCM_CORE.CCM_OBJECTS; alter table CCM_CORE.WORKFLOWS add constraint FKeixdxau4jebw682gd49tdbsjy foreign key (TEMPLATE_ID) - references CCM_CORE.WORKFLOW_TEMPLATES; \ No newline at end of file + references CCM_CORE.WORKFLOW_TEMPLATES; + + create table CCM_SHORTCUTS.SHORTCUTS ( + SHORTCUT_ID int8 not null, + REDIRECT varchar(1024), + URL_KEY varchar(1024), + primary key (SHORTCUT_ID) + ); + + alter table CCM_SHORTCUTS.SHORTCUTS + add constraint UK_4otuwtog6qqdbg4e6p8xdpw8h unique (URL_KEY); + create sequence hibernate_sequence start 1 increment 1;