From 930c20ccbd6b2c8a2b769b8f9a0240c6ab68e729 Mon Sep 17 00:00:00 2001 From: jensp Date: Sun, 18 Sep 2016 17:05:06 +0000 Subject: [PATCH] CCM NG: Some bug fixing for H2 compatibility git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4308 8810af33-2d31-482b-a856-94f89814c4df --- .../librecms/contentsection/ContentItem.java | 17 +- .../contentsection/ContentItemManager.java | 272 ++++----- .../ccm_cms/h2/V7_0_0_0__create_tables.sql | 66 +-- ...0_0_5__fix_wrong_col_lifecycle_phases.sql} | 0 ...0_0_5__fix_wrong_col_lifecycle_phases.sql} | 0 .../ContentItemManagerTest.java | 94 ++- .../ContentItemRepositoryTest.java | 21 + .../librecms/contentsection/DatasetsTest.java | 4 +- .../scripts/create_ccm_cms_schema.sql | 56 +- .../datasets/create_ccm_cms_schema.sql | 56 +- .../after-copy-to-other-folder.xml | 2 +- .../after-copy-to-same-folder.xml | 2 +- ...after-create-contentitem-with-workflow.xml | 2 +- .../after-create-contentitem.xml | 2 +- .../ContentItemManagerTest/after-move.xml | 2 +- .../ContentItemManagerTest/after-publish.xml | 2 +- .../after-republish.xml | 533 ++++++++++++++++++ .../ContentItemManagerTest/data.xml | 2 +- .../ContentItemRepositoryTest/after-save.xml | 518 +++++++++++++++++ .../ContentItemRepositoryTest/data.xml | 109 ++++ 20 files changed, 1506 insertions(+), 254 deletions(-) rename ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/h2/{V7_0_0_5_fix_wrong_col_lifecycle_phases.sql => V7_0_0_5__fix_wrong_col_lifecycle_phases.sql} (100%) rename ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/pgsql/{V7_0_0_5_fix_wrong_col_lifecycle_phases.sql => V7_0_0_5__fix_wrong_col_lifecycle_phases.sql} (100%) create mode 100644 ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemManagerTest/after-republish.xml create mode 100644 ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemRepositoryTest/after-save.xml 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 7885f47a6..060e4024c 100644 --- a/ccm-cms/src/main/java/org/librecms/contentsection/ContentItem.java +++ b/ccm-cms/src/main/java/org/librecms/contentsection/ContentItem.java @@ -101,28 +101,23 @@ import static org.librecms.CmsConstants.*; + "WHERE c.category = :folder " + "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER + "' " + "AND LOWER(i.displayName) LIKE CONCAT(LOWER(:name), '%')" - // query = "SELECT COUNT(c) FROM Categorization c " - // + "JOIN c.categorizedObject o " - // + "WHERE c.category = :folder " - // + "AND TYPE(o) IN (ContentItem) " - // + "AND LOWER(o.displayName) LIKE CONCAT(LOWER(:name), '%s') " ), @NamedQuery( name = "ContentItem.hasLiveVersion", query = "SELECT (CASE WHEN COUNT(i) > 0 THEN true ELSE false END) " + "FROM ContentItem i " - + "WHERE i.uuid = ':uuid' " - + "AND i.version = 'LIVE'"), + + "WHERE i.itemUuid = :uuid " + + "AND i.version = org.librecms.contentsection.ContentItemVersion.LIVE"), @NamedQuery( name = "ContentItem.findDraftVersion", query = "SELECT i FROM ContentItem i " - + "WHERE i.uuid = :uuid " - + "AND i.version = 'DRAFT'"), + + "WHERE i.itemUuid = :uuid " + + "AND i.version = org.librecms.contentsection.ContentItemVersion.DRAFT"), @NamedQuery( name = "ContentItem.findLiveVersion", query = "SELECT i FROM ContentItem i " - + "WHERE i.uuid = :uuid " - + "AND i.version = 'LIVE'") + + "WHERE i.itemUuid = :uuid " + + "AND i.version = org.librecms.contentsection.ContentItemVersion.LIVE") }) public class ContentItem extends CcmObject implements Serializable, diff --git a/ccm-cms/src/main/java/org/librecms/contentsection/ContentItemManager.java b/ccm-cms/src/main/java/org/librecms/contentsection/ContentItemManager.java index 79d901825..8c1550b97 100644 --- a/ccm-cms/src/main/java/org/librecms/contentsection/ContentItemManager.java +++ b/ccm-cms/src/main/java/org/librecms/contentsection/ContentItemManager.java @@ -54,7 +54,6 @@ import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.Locale; import java.util.Map; import java.util.Set; @@ -71,7 +70,7 @@ import javax.transaction.Transactional; public class ContentItemManager { private static final Logger LOGGER = LogManager.getLogger( - ContentItemManager.class); + ContentItemManager.class); @Inject private EntityManager entityManager; @@ -105,29 +104,29 @@ public class ContentItemManager { * {@link ContentSection#rootDocumentsFolder} of the provided content * section. Otherwise an {@link IllegalArgumentException} is thrown. * - * @param The type of the content item. - * @param name The name (URL stub) of the new content item. + * @param The type of the content item. + * @param name The name (URL stub) of the new content item. * @param section The content section in which the item is generated. - * @param folder The folder in which in the item is stored. - * @param type The type of the new content item. + * @param folder The folder in which in the item is stored. + * @param type The type of the new content item. * * @return The new content item. */ @Transactional(Transactional.TxType.REQUIRED) public T createContentItem( - final String name, - final ContentSection section, - final Category folder, - final Class type) { + final String name, + final ContentSection section, + final Category folder, + final Class type) { final Optional contentType = typeRepo - .findByContentSectionAndClass(section, type); + .findByContentSectionAndClass(section, type); if (!contentType.isPresent()) { throw new IllegalArgumentException(String.format( - "ContentSection \"%s\" has no content type for \"%s\".", - section.getLabel(), - type.getName())); + "ContentSection \"%s\" has no content type for \"%s\".", + section.getLabel(), + type.getName())); } return createContentItem(name, @@ -149,37 +148,38 @@ public class ContentItemManager { * provided content section. Otherwise an {@link IllegalArgumentException} * is thrown. * - * @param The type of the content item. - * @param name The name (URL stub) of the new content item. - * @param section The content section in which the item is generated. - * @param folder The folder in which in the item is stored. + * @param The type of the content item. + * @param name The name (URL stub) of the new content item. + * @param section The content section in which the item is + * generated. + * @param folder The folder in which in the item is stored. * @param workflowTemplate The template for the workflow to apply to the new - * item. - * @param type The type of the new content item. + * item. + * @param type The type of the new content item. * * @return The new content item. */ @Transactional(Transactional.TxType.REQUIRED) public T createContentItem( - final String name, - final ContentSection section, - final Category folder, - final WorkflowTemplate workflowTemplate, - final Class type) { + final String name, + final ContentSection section, + final Category folder, + final WorkflowTemplate workflowTemplate, + final Class type) { final Optional contentType = typeRepo - .findByContentSectionAndClass(section, type); + .findByContentSectionAndClass(section, type); if (!contentType.isPresent()) { throw new IllegalArgumentException(String.format( - "ContentSection \"%s\" has no content type for \"%s\".", - section.getLabel(), - type.getName())); + "ContentSection \"%s\" has no content type for \"%s\".", + section.getLabel(), + type.getName())); } if (name == null || name.isEmpty()) { throw new IllegalArgumentException( - "The name of a content item can't be blank."); + "The name of a content item can't be blank."); } final T item; @@ -187,14 +187,14 @@ public class ContentItemManager { item = type.newInstance(); } catch (InstantiationException | IllegalAccessException ex) { LOGGER.error("Failed to create new content item of type \"{}\" " - + "in content section \"{}\".", + + "in content section \"{}\".", type.getName(), section.getLabel()); throw new RuntimeException(ex); } final KernelConfig kernelConfig = confManager.findConfiguration( - KernelConfig.class); + KernelConfig.class); item.setDisplayName(name); item.getName().addValue(kernelConfig.getDefaultLocale(), @@ -202,19 +202,19 @@ public class ContentItemManager { item.setVersion(ContentItemVersion.DRAFT); item.setContentType(contentType.get()); - + if (workflowTemplate != null) { final Workflow workflow = workflowManager.createWorkflow( - workflowTemplate); + workflowTemplate); item.setWorkflow(workflow); } - + contentItemRepo.save(item); categoryManager.addObjectToCategory( - item, - folder, - CmsConstants.CATEGORIZATION_TYPE_FOLDER); + item, + folder, + CmsConstants.CATEGORIZATION_TYPE_FOLDER); contentItemRepo.save(item); @@ -226,7 +226,7 @@ public class ContentItemManager { * only moves the draft version of the item. The live version is moved after * a the item is republished. * - * @param item The item to move. + * @param item The item to move. * @param targetFolder The folder to which the item is moved. */ @Transactional(Transactional.TxType.REQUIRED) @@ -237,7 +237,7 @@ public class ContentItemManager { if (targetFolder == null) { throw new IllegalArgumentException( - "The target folder can't be null."); + "The target folder can't be null."); } final ContentItem draftItem = getDraftVersion(item, item.getClass()); @@ -253,9 +253,9 @@ public class ContentItemManager { } categoryManager.addObjectToCategory( - draftItem, - targetFolder, - CmsConstants.CATEGORIZATION_TYPE_FOLDER); + draftItem, + targetFolder, + CmsConstants.CATEGORIZATION_TYPE_FOLDER); } @@ -263,10 +263,11 @@ public class ContentItemManager { * Creates an copy of the draft version of the item in the provided * {@code targetFolder}. * - * @param item The item to copy. + * @param item The item to copy. * @param targetFolder The folder in which the copy is created. If the - * target folder is the same folder as the folder of the original item an - * index is appended to the name of the item. + * target folder is the same folder as the folder of the + * original item an index is appended to the name of the + * item. */ @Transactional(Transactional.TxType.REQUIRED) @SuppressWarnings("unchecked") @@ -277,19 +278,19 @@ public class ContentItemManager { if (targetFolder == null) { throw new IllegalArgumentException( - "The target folder to which the item is copied can't be null"); + "The target folder to which the item is copied can't be null"); } final Optional contentType = typeRepo - .findByContentSectionAndClass( - item.getContentType().getContentSection(), item. - getClass()); + .findByContentSectionAndClass( + item.getContentType().getContentSection(), item. + getClass()); if (!contentType.isPresent()) { throw new IllegalArgumentException(String.format( - "ContentSection \"%s\" has no content type for \"%s\".", - item.getContentType().getContentSection(), - item.getClass().getName())); + "ContentSection \"%s\" has no content type for \"%s\".", + item.getContentType().getContentSection(), + item.getClass().getName())); } final ContentItem draftItem = getDraftVersion(item, item.getClass()); @@ -305,31 +306,31 @@ public class ContentItemManager { if (draftItem.getWorkflow() != null) { final WorkflowTemplate template = draftItem.getWorkflow() - .getTemplate(); + .getTemplate(); final Workflow copyWorkflow = workflowManager.createWorkflow( - template); + template); copy.setWorkflow(copyWorkflow); } contentItemRepo.save(copy); - + draftItem.getCategories().forEach(categorization -> categoryManager - .addObjectToCategory(copy, categorization.getCategory())); + .addObjectToCategory(copy, categorization.getCategory())); final Optional itemFolder = getItemFolder(draftItem); if (itemFolder.isPresent()) { try { categoryManager.removeObjectFromCategory( - copy, getItemFolder(draftItem).get()); + copy, getItemFolder(draftItem).get()); } catch (ObjectNotAssignedToCategoryException ex) { throw new RuntimeException(ex); } } categoryManager.addObjectToCategory( - copy, - targetFolder, - CmsConstants.CATEGORIZATION_TYPE_FOLDER); + copy, + targetFolder, + CmsConstants.CATEGORIZATION_TYPE_FOLDER); // !!!!!!!!!!!!!!!!!!!!! // ToDo copy Attachments @@ -344,7 +345,7 @@ public class ContentItemManager { } for (final PropertyDescriptor propertyDescriptor : beanInfo - .getPropertyDescriptors()) { + .getPropertyDescriptors()) { if (propertyIsExcluded(propertyDescriptor.getName())) { continue; } @@ -370,10 +371,10 @@ public class ContentItemManager { } source.getAvailableLocales().forEach( - locale -> target.addValue(locale, - source.getValue(locale))); + locale -> target.addValue(locale, + source.getValue(locale))); } else if (propType != null - && propType.isAssignableFrom(ContentItem.class)) { + && propType.isAssignableFrom(ContentItem.class)) { final ContentItem linkedItem; try { @@ -385,7 +386,7 @@ public class ContentItemManager { } final ContentItem linkedDraftItem = getDraftVersion( - linkedItem, linkedItem.getClass()); + linkedItem, linkedItem.getClass()); try { writeMethod.invoke(copy, linkedDraftItem); @@ -395,7 +396,7 @@ public class ContentItemManager { throw new RuntimeException(ex); } } else if (propType != null - && propType.isAssignableFrom(List.class)) { + && propType.isAssignableFrom(List.class)) { final List source; final List target; try { @@ -409,7 +410,7 @@ public class ContentItemManager { target.addAll(source); } else if (propType != null - && propType.isAssignableFrom(Map.class)) { + && propType.isAssignableFrom(Map.class)) { final Map source; final Map target; @@ -424,7 +425,7 @@ public class ContentItemManager { source.forEach((key, value) -> target.put(key, value)); } else if (propType != null - && propType.isAssignableFrom(Set.class)) { + && propType.isAssignableFrom(Set.class)) { final Set source; final Set target; @@ -453,14 +454,14 @@ public class ContentItemManager { if (targetFolder.equals(getItemFolder(item).orElse(null))) { final long number = contentItemRepo.countFilterByFolderAndName( - targetFolder, String.format("%s_copy", - item.getDisplayName())); + targetFolder, String.format("%s_copy", + item.getDisplayName())); final long index = number + 1; - copy.setDisplayName(String.format("%s_copy%d", + copy.setDisplayName(String.format("%s_copy%d", copy.getDisplayName(), index)); } - + contentItemRepo.save(copy); } @@ -492,11 +493,11 @@ public class ContentItemManager { public ContentItem publish(final ContentItem item) { if (item == null) { throw new IllegalArgumentException( - "The item to publish can't be null."); + "The item to publish can't be null."); } final LifecycleDefinition lifecycleDefinition = item.getContentType() - .getDefaultLifecycle(); + .getDefaultLifecycle(); return publish(item, lifecycleDefinition); } @@ -505,9 +506,9 @@ public class ContentItemManager { * Creates a live version of content item or updates the live version of a * content item if there already a live version. * - * @param item The content item to publish. + * @param item The content item to publish. * @param lifecycleDefinition The definition of the lifecycle to use for the - * new item. + * new item. * * @return The published content item. */ @@ -516,13 +517,13 @@ public class ContentItemManager { final LifecycleDefinition lifecycleDefinition) { if (item == null) { throw new IllegalArgumentException( - "The item to publish can't be null."); + "The item to publish can't be null."); } if (lifecycleDefinition == null) { throw new IllegalArgumentException( - "The lifecycle definition for the " - + "lifecycle of the item to publish can't be null."); + "The lifecycle definition for the " + + "lifecycle of the item to publish can't be null."); } final ContentItem draftItem = getDraftVersion(item, ContentItem.class); @@ -538,18 +539,20 @@ public class ContentItemManager { } } + liveItem.setVersion(ContentItemVersion.PUBLISHING); + liveItem.setItemUuid(draftItem.getItemUuid()); liveItem.setContentType(draftItem.getContentType()); final Lifecycle lifecycle = lifecycleManager.createLifecycle( - lifecycleDefinition); + lifecycleDefinition); liveItem.setLifecycle(lifecycle); liveItem.setWorkflow(draftItem.getWorkflow()); draftItem.getCategories().forEach(categorization -> categoryManager - .addObjectToCategory(item, categorization.getCategory())); - - liveItem.setUuid(draftItem.getUuid()); + .addObjectToCategory(liveItem, + categorization.getCategory(), + categorization.getType())); // !!!!!!!!!!!!!!!!!!!!! // ToDo copy Attachments @@ -564,7 +567,7 @@ public class ContentItemManager { } for (final PropertyDescriptor propertyDescriptor : beanInfo - .getPropertyDescriptors()) { + .getPropertyDescriptors()) { if (propertyIsExcluded(propertyDescriptor.getName())) { continue; @@ -574,6 +577,10 @@ public class ContentItemManager { final Method readMethod = propertyDescriptor.getReadMethod(); final Method writeMethod = propertyDescriptor.getWriteMethod(); + if (writeMethod == null) { + continue; + } + if (LocalizedString.class.equals(propType)) { final LocalizedString source; final LocalizedString target; @@ -587,10 +594,10 @@ public class ContentItemManager { } source.getAvailableLocales().forEach( - locale -> target.addValue(locale, source. - getValue(locale))); + locale -> target.addValue(locale, source. + getValue(locale))); } else if (propType != null - && propType.isAssignableFrom(ContentItem.class)) { + && propType.isAssignableFrom(ContentItem.class)) { final ContentItem linkedItem; try { linkedItem = (ContentItem) readMethod.invoke(draftItem); @@ -601,13 +608,13 @@ public class ContentItemManager { } final ContentItem linkedDraftItem = getDraftVersion( - linkedItem, linkedItem.getClass()); + linkedItem, linkedItem.getClass()); if (isLive(linkedDraftItem)) { try { final Optional linkedLiveItem - = getLiveVersion( - linkedDraftItem, ContentItem.class); + = getLiveVersion( + linkedDraftItem, ContentItem.class); writeMethod.invoke(liveItem, linkedLiveItem); } catch (IllegalAccessException | IllegalArgumentException | @@ -616,7 +623,7 @@ public class ContentItemManager { } } } else if (propType != null - && propType.isAssignableFrom(List.class)) { + && propType.isAssignableFrom(List.class)) { final List source; final List target; try { @@ -630,7 +637,7 @@ public class ContentItemManager { target.addAll(source); } else if (propType != null - && propType.isAssignableFrom(Map.class)) { + && propType.isAssignableFrom(Map.class)) { final Map source; final Map target; @@ -645,7 +652,7 @@ public class ContentItemManager { source.forEach((key, value) -> target.put(key, value)); } else if (propType != null - && propType.isAssignableFrom(Set.class)) { + && propType.isAssignableFrom(Set.class)) { final Set source; final Set target; @@ -671,7 +678,10 @@ public class ContentItemManager { } } } - + + liveItem.setVersion(ContentItemVersion.LIVE); + contentItemRepo.save(liveItem); + return liveItem; } @@ -685,7 +695,7 @@ public class ContentItemManager { public void unpublish(final ContentItem item ) { final Optional liveItem = getLiveVersion( - item, ContentItem.class); + item, ContentItem.class); if (liveItem.isPresent()) { entityManager.remove(liveItem); @@ -699,11 +709,11 @@ public class ContentItemManager { * @param item The item * * @return {@code true} if the content item has a live version, - * {@code false} if not. + * {@code false} if not. */ public boolean isLive(final ContentItem item) { final TypedQuery query = entityManager.createNamedQuery( - "ContentItem.hasLiveVersion", Boolean.class); + "ContentItem.hasLiveVersion", Boolean.class); query.setParameter("uuid", item.getUuid()); return query.getSingleResult(); @@ -712,22 +722,22 @@ public class ContentItemManager { /** * Retrieves the live version of the provided content item if any. * - * @param Type of the content item. + * @param Type of the content item. * @param item The item of which the live version should be retrieved. * @param type Type of the content item. * * @return The live version of an item. If the item provided is already the - * live version the provided item is returned, otherwise the live version is - * returned. If there is no live version an empty {@link Optional} is - * returned. + * live version the provided item is returned, otherwise the live + * version is returned. If there is no live version an empty + * {@link Optional} is returned. */ public Optional getLiveVersion( - final ContentItem item, - final Class type) { + final ContentItem item, + final Class type) { if (isLive(item)) { final TypedQuery query = entityManager.createNamedQuery( - "ContentItem.findLiveVersion", type); + "ContentItem.findLiveVersion", type); query.setParameter("uuid", item.getUuid()); return Optional.of(query.getSingleResult()); @@ -739,30 +749,30 @@ public class ContentItemManager { /** * Retrieves the pending versions of an item if there are any. * - * @param Type of the content item to retrieve. + * @param Type of the content item to retrieve. * @param item The item of which the pending versions are retrieved. * @param type Type of the content item to retrieve. * * @return A list of the pending versions of the item. */ public List getPendingVersions( - final ContentItem item, - final Class type) { + final ContentItem item, + final Class type) { throw new UnsupportedOperationException(); } /** * Retrieves the draft version * - * @param Type of the item. + * @param Type of the item. * @param item The item of which the draft version is retrieved. * @param type Type of the item. * * @return The draft version of the provided content item. If the provided - * item is the draft version the provided item is simply returned. Otherwise - * the draft version is retrieved from the database and is returned. Each - * content item has a draft version (otherwise something is seriously wrong - * with the database) this method will + * item is the draft version the provided item is simply returned. + * Otherwise the draft version is retrieved from the database and is + * returned. Each content item has a draft version (otherwise + * something is seriously wrong with the database) this method will * never return {@code null}. */ @SuppressWarnings("unchecked") @@ -770,14 +780,14 @@ public class ContentItemManager { final Class type) { if (!ContentItem.class.isAssignableFrom(type)) { throw new IllegalArgumentException(String.format( - "The provided type \"%s\" does match the type of the provided " + "The provided type \"%s\" does match the type of the provided " + "item (\"%s\").", - type.getName(), - item.getClass().getName())); + type.getName(), + item.getClass().getName())); } final TypedQuery query = entityManager.createNamedQuery( - "ContentItem.findDraftVersion", ContentItem.class); + "ContentItem.findDraftVersion", ContentItem.class); query.setParameter("uuid", item.getUuid()); return (T) query.getSingleResult(); @@ -816,9 +826,9 @@ public class ContentItemManager { * {@code info}, the path including the content section would be * {@code info:/research/computer-science/artificial-intelligence/neural-nets}. * - * @param item The item whose path is generated. + * @param item The item whose path is generated. * @param withContentSection Wether to include the content section into the - * path. + * path. * * @return The path of the content item * @@ -827,9 +837,9 @@ public class ContentItemManager { public String getItemPath(final ContentItem item, final boolean withContentSection) { final List result = item.getCategories().stream(). - filter(categorization -> CmsConstants.CATEGORIZATION_TYPE_FOLDER. - equals(categorization.getType())) - .collect(Collectors.toList()); + filter(categorization -> CmsConstants.CATEGORIZATION_TYPE_FOLDER. + equals(categorization.getType())) + .collect(Collectors.toList()); if (result.isEmpty()) { return item.getDisplayName(); @@ -850,9 +860,9 @@ public class ContentItemManager { if (withContentSection) { final String sectionName = item.getContentType(). - getContentSection().getDisplayName(); + getContentSection().getDisplayName(); return String.format( - "%s/%s", sectionName, path); + "%s/%s", sectionName, path); } else { return String.format("/%s", path); } @@ -868,9 +878,9 @@ public class ContentItemManager { */ public List getItemFolders(final ContentItem item) { final List result = item.getCategories().stream(). - filter(categorization -> CmsConstants.CATEGORIZATION_TYPE_FOLDER. - equals(categorization.getType())) - .collect(Collectors.toList()); + filter(categorization -> CmsConstants.CATEGORIZATION_TYPE_FOLDER. + equals(categorization.getType())) + .collect(Collectors.toList()); final List folders = new ArrayList<>(); if (!result.isEmpty()) { @@ -896,13 +906,13 @@ public class ContentItemManager { * @param item The item * * @return An {@link Optional} containing the folder of the item if the item - * is part of a folder. + * is part of a folder. */ public Optional getItemFolder(final ContentItem item) { final List result = item.getCategories().stream(). - filter(categorization -> CmsConstants.CATEGORIZATION_TYPE_FOLDER. - equals(categorization.getType())) - .collect(Collectors.toList()); + filter(categorization -> CmsConstants.CATEGORIZATION_TYPE_FOLDER. + equals(categorization.getType())) + .collect(Collectors.toList()); if (result.size() > 0) { return Optional.of(result.get(0).getCategory()); diff --git a/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/h2/V7_0_0_0__create_tables.sql b/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/h2/V7_0_0_0__create_tables.sql index 4f11a89ef..516132b9f 100644 --- a/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/h2/V7_0_0_0__create_tables.sql +++ b/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/h2/V7_0_0_0__create_tables.sql @@ -15,11 +15,11 @@ create table CCM_CMS.ARTICLE_TEXTS_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.ARTICLES ( @@ -47,7 +47,7 @@ LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, ASSET_ID, LOCALE) + primary key (REV, ASSET_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.ASSETS ( @@ -79,7 +79,7 @@ LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, LIST_ID, LOCALE) + primary key (REV, LIST_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.ATTACHMENT_LISTS ( @@ -100,7 +100,7 @@ primary key (LIST_ID, REV) ); - create table CCM_CMS.AttachmentList_ItemAttachment_AUD ( + create table CCM_CMS.ATTACHMENTLIST_ITEMATTACHMENT_AUD ( REV integer not null, LIST_ID bigint not null, ATTACHMENT_ID bigint not null, @@ -156,7 +156,7 @@ LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, ASSET_ID, LOCALE) + primary key (REV, ASSET_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.BINARY_ASSETS ( @@ -192,7 +192,7 @@ LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, ASSET_ID, LOCALE) + primary key (REV, ASSET_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.BOOKMARKS ( @@ -218,11 +218,11 @@ create table CCM_CMS.CONTENT_ITEM_DESCRIPTIONS_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.CONTENT_ITEM_NAMES ( @@ -235,11 +235,11 @@ create table CCM_CMS.CONTENT_ITEM_NAMES_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.CONTENT_ITEM_TITLES ( @@ -252,11 +252,11 @@ create table CCM_CMS.CONTENT_ITEM_TITLES_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.CONTENT_ITEMS ( @@ -341,11 +341,11 @@ create table CCM_CMS.EVENT_COSTS_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.EVENT_DATES ( @@ -358,11 +358,11 @@ create table CCM_CMS.EVENT_DATES_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.EVENT_LOCATIONS ( @@ -375,11 +375,11 @@ create table CCM_CMS.EVENT_LOCATIONS_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.EVENT_MAIN_CONTRIBUTORS ( @@ -392,11 +392,11 @@ create table CCM_CMS.EVENT_MAIN_CONTRIBUTORS_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.EVENT_TEXTS ( @@ -409,11 +409,11 @@ create table CCM_CMS.EVENT_TEXTS_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.EVENT_TYPES ( @@ -426,11 +426,11 @@ create table CCM_CMS.EVENT_TYPES_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.EVENTS ( @@ -628,11 +628,11 @@ create table CCM_CMS.MPA_SECTION_TEXTS_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.MPA_SECTION_TITLES ( @@ -645,11 +645,11 @@ create table CCM_CMS.MPA_SECTION_TITLES_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.MPA_SUMMARIES ( @@ -662,11 +662,11 @@ create table CCM_CMS.MPA_SUMMARIES_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.MULTIPART_ARTICLE_SECTIONS ( @@ -732,11 +732,11 @@ create table CCM_CMS.NEWS_TEXTS_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.NOTE_TEXTS ( diff --git a/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/h2/V7_0_0_5_fix_wrong_col_lifecycle_phases.sql b/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/h2/V7_0_0_5__fix_wrong_col_lifecycle_phases.sql similarity index 100% rename from ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/h2/V7_0_0_5_fix_wrong_col_lifecycle_phases.sql rename to ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/h2/V7_0_0_5__fix_wrong_col_lifecycle_phases.sql diff --git a/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/pgsql/V7_0_0_5_fix_wrong_col_lifecycle_phases.sql b/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/pgsql/V7_0_0_5__fix_wrong_col_lifecycle_phases.sql similarity index 100% rename from ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/pgsql/V7_0_0_5_fix_wrong_col_lifecycle_phases.sql rename to ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/pgsql/V7_0_0_5__fix_wrong_col_lifecycle_phases.sql diff --git a/ccm-cms/src/test/java/org/librecms/contentsection/ContentItemManagerTest.java b/ccm-cms/src/test/java/org/librecms/contentsection/ContentItemManagerTest.java index 7ee14aa38..595ebd31e 100644 --- a/ccm-cms/src/test/java/org/librecms/contentsection/ContentItemManagerTest.java +++ b/ccm-cms/src/test/java/org/librecms/contentsection/ContentItemManagerTest.java @@ -49,6 +49,7 @@ import org.libreccm.workflow.WorkflowTemplate; import org.libreccm.workflow.WorkflowTemplateRepository; import org.librecms.contenttypes.Article; import org.librecms.contenttypes.Event; +import org.librecms.lifecycle.LifecycleDefinition; import org.librecms.lifecycle.LifecycleDefinitionRepository; import java.io.File; @@ -348,7 +349,7 @@ public class ContentItemManagerTest { final WorkflowTemplate workflowTemplate = workflowTemplateRepo .findById(-110L); - + final Article article = itemManager.createContentItem( "new-article", section, @@ -534,10 +535,10 @@ public class ContentItemManagerTest { final Category targetFolder = categoryRepo.findById(-2120L); assertThat(targetFolder, is(not(nullValue()))); - + itemManager.copy(item.get(), targetFolder); } - + @Test @InSequence(4200) @UsingDataSet("datasets/org/librecms/contentsection/" @@ -561,41 +562,40 @@ public class ContentItemManagerTest { final Category targetFolder = categoryRepo.findById(-2110L); assertThat(targetFolder, is(not(nullValue()))); - + itemManager.copy(item.get(), targetFolder); } - + @Test(expected = IllegalArgumentException.class) @InSequence(4300) @UsingDataSet("datasets/org/librecms/contentsection/" + "ContentItemManagerTest/data.xml") @ShouldMatchDataSet( value = "datasets/org/librecms/contentsection/" - + "ContentItemManagerTest/data.xml") + + "ContentItemManagerTest/data.xml") @ShouldThrowException(IllegalArgumentException.class) public void copyItemNull() { final Category targetFolder = categoryRepo.findById(-2120L); assertThat(targetFolder, is(not(nullValue()))); - + itemManager.copy(null, targetFolder); } - + @Test(expected = IllegalArgumentException.class) @InSequence(4400) @UsingDataSet("datasets/org/librecms/contentsection/" + "ContentItemManagerTest/data.xml") @ShouldMatchDataSet( value = "datasets/org/librecms/contentsection/" - + "ContentItemManagerTest/data.xml") + + "ContentItemManagerTest/data.xml") @ShouldThrowException(IllegalArgumentException.class) public void copyItemToFolderNull() { final Optional item = itemRepo.findById(-10100L); assertThat(item.isPresent(), is(true)); - + itemManager.copy(item.get(), null); } - - // publish item (draft) + @Test @InSequence(5100) @UsingDataSet("datasets/org/librecms/contentsection/" @@ -613,10 +613,74 @@ public class ContentItemManagerTest { "workflow_id" }) public void publishItem() { - + final Optional item = itemRepo.findById(-10100L); + assertThat(item.isPresent(), is(true)); + + final ContentItem live = itemManager.publish(item.get()); + assertThat(live, is(not(nullValue()))); + assertThat(live.getVersion(), is(ContentItemVersion.LIVE)); } - - // publish item (live) + + @Test + @InSequence(5200) + @UsingDataSet("datasets/org/librecms/contentsection/" + + "ContentItemManagerTest/data.xml") + @ShouldMatchDataSet( + value = "datasets/org/librecms/contentsection/" + + "ContentItemManagerTest/after-publish.xml", + excludeColumns = {"categorization_id", + "lifecycle_id", + "object_id", + "object_order", + "phase_id", + "task_id", + "uuid", + "workflow_id" + }) + public void publishItemWithLifecycle() { + final Optional item = itemRepo.findById(-10100L); + final LifecycleDefinition lifecycleDef = lifecycleDefinitionRepo + .findById(-200L); + assertThat(item.isPresent(), is(true)); + assertThat(lifecycleDef, is(not(nullValue()))); + + final ContentItem live = itemManager.publish(item.get(), lifecycleDef); + assertThat(live, is(not(nullValue()))); + assertThat(live.getVersion(), is(ContentItemVersion.LIVE)); + } + + //Republish + @Test + @InSequence(5300) + @UsingDataSet("datasets/org/librecms/contentsection/" + + "ContentItemManagerTest/data.xml") + @ShouldMatchDataSet( + value = "datasets/org/librecms/contentsection/" + + "ContentItemManagerTest/after-republish.xml", + excludeColumns = {"categorization_id", + "lifecycle_id", + "object_id", + "object_order", + "phase_id", + "task_id", + "uuid", + "workflow_id" + }) + public void republishItem() { + final Optional item = itemRepo.findById(-10200L); + assertThat(item.isPresent(), is(true)); + + item.get().getName().addValue(Locale.ENGLISH, "article2-edited"); + item.get().getTitle() + .addValue(Locale.ENGLISH, "Article has been edited"); + itemRepo.save(item.get()); + + final Optional draft = itemRepo.findById(-10200L); + assertThat(draft.get().getName().getValue(Locale.ENGLISH), + is(equalTo("article2-edited"))); + itemManager.publish(draft.get()); + } + // publish item null // unpublish item // unpublish non live diff --git a/ccm-cms/src/test/java/org/librecms/contentsection/ContentItemRepositoryTest.java b/ccm-cms/src/test/java/org/librecms/contentsection/ContentItemRepositoryTest.java index 4f23c88f0..c4d7134fa 100644 --- a/ccm-cms/src/test/java/org/librecms/contentsection/ContentItemRepositoryTest.java +++ b/ccm-cms/src/test/java/org/librecms/contentsection/ContentItemRepositoryTest.java @@ -18,11 +18,13 @@ */ package org.librecms.contentsection; +import com.sun.org.apache.bcel.internal.generic.LADD; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.junit.InSequence; import org.jboss.arquillian.persistence.CreateSchema; import org.jboss.arquillian.persistence.PersistenceTest; +import org.jboss.arquillian.persistence.ShouldMatchDataSet; import org.jboss.arquillian.persistence.UsingDataSet; import org.jboss.arquillian.transaction.api.annotation.TransactionMode; import org.jboss.arquillian.transaction.api.annotation.Transactional; @@ -49,6 +51,7 @@ import org.librecms.contenttypes.News; import java.io.File; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.Optional; import java.util.stream.IntStream; @@ -349,5 +352,23 @@ public class ContentItemRepositoryTest { assertThat(itemRepo.countFilterByFolderAndName(folder, "foo"), is(0L)); } + + @Test + @InSequence(600) + @UsingDataSet("datasets/org/librecms/contentsection/" + + "ContentItemRepositoryTest/data.xml") + @ShouldMatchDataSet(value = "datasets/org/librecms/contentsection/" + + "ContentItemRepositoryTest/after-save.xml", + excludeColumns = {"object_id", "uuid", "item_uuid"}) + public void saveChangedItem() { + final Optional item = itemRepo.findById(-10100L); + + assertThat(item.isPresent(), is(true)); + + item.get().getName().addValue(Locale.ENGLISH, "first-article"); + item.get().getTitle().addValue(Locale.ENGLISH, "First Article"); + + itemRepo.save(item.get()); + } } diff --git a/ccm-cms/src/test/java/org/librecms/contentsection/DatasetsTest.java b/ccm-cms/src/test/java/org/librecms/contentsection/DatasetsTest.java index a73fec9aa..b787cf82c 100644 --- a/ccm-cms/src/test/java/org/librecms/contentsection/DatasetsTest.java +++ b/ccm-cms/src/test/java/org/librecms/contentsection/DatasetsTest.java @@ -50,6 +50,7 @@ public class DatasetsTest extends DatasetsVerifier { "/datasets/org/librecms/contentsection/ContentSectionManagerTest/after-rename.xml", "/datasets/org/librecms/contentsection/ContentItemRepositoryTest/data.xml", + "/datasets/org/librecms/contentsection/ContentItemRepositoryTest/after-save.xml", "/datasets/org/librecms/contentsection/ContentItemManagerTest/data.xml", "/datasets/org/librecms/contentsection/ContentItemManagerTest/after-create-contentitem.xml", @@ -57,7 +58,8 @@ public class DatasetsTest extends DatasetsVerifier { "/datasets/org/librecms/contentsection/ContentItemManagerTest/after-move.xml", "/datasets/org/librecms/contentsection/ContentItemManagerTest/after-copy-to-other-folder.xml", "/datasets/org/librecms/contentsection/ContentItemManagerTest/after-copy-to-same-folder.xml", - "/datasets/org/librecms/contentsection/ContentItemManagerTest/after-publish.xml"}); + "/datasets/org/librecms/contentsection/ContentItemManagerTest/after-publish.xml", + "/datasets/org/librecms/contentsection/ContentItemManagerTest/after-republish.xml"}); } public DatasetsTest(final String datasetPath) { 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 1cf14742c..b231e41b4 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 @@ -23,11 +23,11 @@ create table CCM_CMS.ARTICLE_LEADS ( create table CCM_CMS.ARTICLE_TEXTS_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.ARTICLES ( @@ -226,11 +226,11 @@ create table CCM_CMS.ARTICLE_LEADS ( create table CCM_CMS.CONTENT_ITEM_DESCRIPTIONS_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.CONTENT_ITEM_NAMES ( @@ -243,11 +243,11 @@ create table CCM_CMS.ARTICLE_LEADS ( create table CCM_CMS.CONTENT_ITEM_NAMES_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.CONTENT_ITEM_TITLES ( @@ -260,11 +260,11 @@ create table CCM_CMS.ARTICLE_LEADS ( create table CCM_CMS.CONTENT_ITEM_TITLES_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.CONTENT_ITEMS ( @@ -355,11 +355,11 @@ create table CCM_CMS.ARTICLE_LEADS ( create table CCM_CMS.EVENT_COSTS_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.EVENT_DATES ( @@ -372,11 +372,11 @@ create table CCM_CMS.ARTICLE_LEADS ( create table CCM_CMS.EVENT_DATES_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.EVENT_LOCATIONS ( @@ -389,11 +389,11 @@ create table CCM_CMS.ARTICLE_LEADS ( create table CCM_CMS.EVENT_LOCATIONS_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.EVENT_MAIN_CONTRIBUTORS ( @@ -406,11 +406,11 @@ create table CCM_CMS.ARTICLE_LEADS ( create table CCM_CMS.EVENT_MAIN_CONTRIBUTORS_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.EVENT_TEXTS ( @@ -423,11 +423,11 @@ create table CCM_CMS.ARTICLE_LEADS ( create table CCM_CMS.EVENT_TEXTS_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.EVENT_TYPES ( @@ -440,11 +440,11 @@ create table CCM_CMS.ARTICLE_LEADS ( create table CCM_CMS.EVENT_TYPES_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.EVENTS ( @@ -642,11 +642,11 @@ create table CCM_CMS.ARTICLE_LEADS ( create table CCM_CMS.MPA_SECTION_TEXTS_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.MPA_SECTION_TITLES ( @@ -659,11 +659,11 @@ create table CCM_CMS.ARTICLE_LEADS ( create table CCM_CMS.MPA_SECTION_TITLES_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.MPA_SUMMARIES ( @@ -676,11 +676,11 @@ create table CCM_CMS.ARTICLE_LEADS ( create table CCM_CMS.MPA_SUMMARIES_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.MULTIPART_ARTICLE_SECTIONS ( @@ -746,11 +746,11 @@ create table CCM_CMS.ARTICLE_LEADS ( create table CCM_CMS.NEWS_TEXTS_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.NOTE_TEXTS ( diff --git a/ccm-cms/src/test/resources/datasets/create_ccm_cms_schema.sql b/ccm-cms/src/test/resources/datasets/create_ccm_cms_schema.sql index b6a8e4503..fb38eea89 100644 --- a/ccm-cms/src/test/resources/datasets/create_ccm_cms_schema.sql +++ b/ccm-cms/src/test/resources/datasets/create_ccm_cms_schema.sql @@ -23,11 +23,11 @@ create table CCM_CMS.ARTICLE_LEADS ( create table CCM_CMS.ARTICLE_TEXTS_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.ARTICLES ( @@ -226,11 +226,11 @@ create table CCM_CMS.ARTICLE_LEADS ( create table CCM_CMS.CONTENT_ITEM_DESCRIPTIONS_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.CONTENT_ITEM_NAMES ( @@ -243,11 +243,11 @@ create table CCM_CMS.ARTICLE_LEADS ( create table CCM_CMS.CONTENT_ITEM_NAMES_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.CONTENT_ITEM_TITLES ( @@ -260,11 +260,11 @@ create table CCM_CMS.ARTICLE_LEADS ( create table CCM_CMS.CONTENT_ITEM_TITLES_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.CONTENT_ITEMS ( @@ -355,11 +355,11 @@ create table CCM_CMS.ARTICLE_LEADS ( create table CCM_CMS.EVENT_COSTS_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.EVENT_DATES ( @@ -372,11 +372,11 @@ create table CCM_CMS.ARTICLE_LEADS ( create table CCM_CMS.EVENT_DATES_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.EVENT_LOCATIONS ( @@ -389,11 +389,11 @@ create table CCM_CMS.ARTICLE_LEADS ( create table CCM_CMS.EVENT_LOCATIONS_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.EVENT_MAIN_CONTRIBUTORS ( @@ -406,11 +406,11 @@ create table CCM_CMS.ARTICLE_LEADS ( create table CCM_CMS.EVENT_MAIN_CONTRIBUTORS_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.EVENT_TEXTS ( @@ -423,11 +423,11 @@ create table CCM_CMS.ARTICLE_LEADS ( create table CCM_CMS.EVENT_TEXTS_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.EVENT_TYPES ( @@ -440,11 +440,11 @@ create table CCM_CMS.ARTICLE_LEADS ( create table CCM_CMS.EVENT_TYPES_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.EVENTS ( @@ -642,11 +642,11 @@ create table CCM_CMS.ARTICLE_LEADS ( create table CCM_CMS.MPA_SECTION_TEXTS_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.MPA_SECTION_TITLES ( @@ -659,11 +659,11 @@ create table CCM_CMS.ARTICLE_LEADS ( create table CCM_CMS.MPA_SECTION_TITLES_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.MPA_SUMMARIES ( @@ -676,11 +676,11 @@ create table CCM_CMS.ARTICLE_LEADS ( create table CCM_CMS.MPA_SUMMARIES_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.MULTIPART_ARTICLE_SECTIONS ( @@ -746,11 +746,11 @@ create table CCM_CMS.ARTICLE_LEADS ( create table CCM_CMS.NEWS_TEXTS_AUD ( REV integer not null, OBJECT_ID bigint not null, - LOCALIZED_VALUE clob, + LOCALIZED_VALUE varchar, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, OBJECT_ID, LOCALE) + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.NOTE_TEXTS ( diff --git a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemManagerTest/after-copy-to-other-folder.xml b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemManagerTest/after-copy-to-other-folder.xml index c4a34c3b7..54d696942 100644 --- a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemManagerTest/after-copy-to-other-folder.xml +++ b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemManagerTest/after-copy-to-other-folder.xml @@ -247,7 +247,7 @@ localized_value="Article 1" /> + localized_value="Article 2 Title" /> diff --git a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemManagerTest/after-copy-to-same-folder.xml b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemManagerTest/after-copy-to-same-folder.xml index db098f242..d571c6662 100644 --- a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemManagerTest/after-copy-to-same-folder.xml +++ b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemManagerTest/after-copy-to-same-folder.xml @@ -249,7 +249,7 @@ localized_value="Article 1" /> + localized_value="Article 2 Title" /> diff --git a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemManagerTest/after-create-contentitem-with-workflow.xml b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemManagerTest/after-create-contentitem-with-workflow.xml index 8249fbb7c..3d9b59136 100644 --- a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemManagerTest/after-create-contentitem-with-workflow.xml +++ b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemManagerTest/after-create-contentitem-with-workflow.xml @@ -272,7 +272,7 @@ localized_value="Article 1" /> + localized_value="Article 2 Title" /> diff --git a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemManagerTest/after-create-contentitem.xml b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemManagerTest/after-create-contentitem.xml index 44904a098..deef36114 100644 --- a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemManagerTest/after-create-contentitem.xml +++ b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemManagerTest/after-create-contentitem.xml @@ -285,7 +285,7 @@ localized_value="Article 1" /> + localized_value="Article 2 Title" /> diff --git a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemManagerTest/after-move.xml b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemManagerTest/after-move.xml index d9b1ce907..eddeefcd2 100644 --- a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemManagerTest/after-move.xml +++ b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemManagerTest/after-move.xml @@ -237,7 +237,7 @@ localized_value="Article 1" /> + localized_value="Article 2 Title" /> diff --git a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemManagerTest/after-publish.xml b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemManagerTest/after-publish.xml index bdbb1b191..bae914499 100644 --- a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemManagerTest/after-publish.xml +++ b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemManagerTest/after-publish.xml @@ -247,7 +247,7 @@ localized_value="Article 1" /> + localized_value="Article 2 Title" /> diff --git a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemManagerTest/after-republish.xml b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemManagerTest/after-republish.xml new file mode 100644 index 000000000..426deb4f6 --- /dev/null +++ b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemManagerTest/after-republish.xml @@ -0,0 +1,533 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemManagerTest/data.xml b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemManagerTest/data.xml index d2d59e303..b6076b912 100644 --- a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemManagerTest/data.xml +++ b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemManagerTest/data.xml @@ -237,7 +237,7 @@ localized_value="Article 1" /> + localized_value="Article 2 Title" /> diff --git a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemRepositoryTest/after-save.xml b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemRepositoryTest/after-save.xml new file mode 100644 index 000000000..fcebc25cd --- /dev/null +++ b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemRepositoryTest/after-save.xml @@ -0,0 +1,518 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemRepositoryTest/data.xml b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemRepositoryTest/data.xml index aecf40d78..baeeb1801 100644 --- a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemRepositoryTest/data.xml +++ b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemRepositoryTest/data.xml @@ -1,6 +1,9 @@ + + @@ -29,6 +32,23 @@ display_name="org.librecms.contenttypes.News" uuid="47740f22-f89f-4ec3-90cf-d62859e53c7e" /> + + + + + + + + + + @@ -103,6 +144,27 @@ locale="en" localized_value="news1" /> + + + + + @@ -116,6 +178,27 @@ locale="en" localized_value="News 1" /> + + + + + @@ -127,6 +210,13 @@ + + + + + + + +