CCM NG: Some bug fixing for the ContentItemManager
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4307 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
5672388578
commit
5421a8dc30
|
|
@ -130,6 +130,9 @@ public class ContentItem extends CcmObject implements Serializable,
|
|||
|
||||
private static final long serialVersionUID = 5897287630227129653L;
|
||||
|
||||
@Column(name = "ITEM_UUID", nullable = false)
|
||||
private String itemUuid;
|
||||
|
||||
/**
|
||||
* The name of the content item which is used to generate the URL of the
|
||||
* content item. We are using a {@link LocalizedString} here to make it
|
||||
|
|
@ -225,7 +228,15 @@ public class ContentItem extends CcmObject implements Serializable,
|
|||
description = new LocalizedString();
|
||||
attachments = new ArrayList<>();
|
||||
}
|
||||
|
||||
|
||||
public String getItemUuid() {
|
||||
return itemUuid;
|
||||
}
|
||||
|
||||
protected void setItemUuid(final String itemUuid) {
|
||||
this.itemUuid = itemUuid;
|
||||
}
|
||||
|
||||
public LocalizedString getName() {
|
||||
return name;
|
||||
}
|
||||
|
|
@ -332,6 +343,7 @@ public class ContentItem extends CcmObject implements Serializable,
|
|||
@Override
|
||||
public int hashCode() {
|
||||
int hash = super.hashCode();
|
||||
hash = 59 * hash + Objects.hashCode(itemUuid);
|
||||
hash = 59 * hash + Objects.hashCode(name);
|
||||
hash = 59 * hash + Objects.hashCode(contentType);
|
||||
hash = 59 * hash + Objects.hashCode(title);
|
||||
|
|
@ -362,6 +374,10 @@ public class ContentItem extends CcmObject implements Serializable,
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!Objects.equals(itemUuid, other.getItemUuid())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Objects.equals(name, other.getName())) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -393,7 +409,8 @@ public class ContentItem extends CcmObject implements Serializable,
|
|||
|
||||
@Override
|
||||
public String toString(final String data) {
|
||||
return super.toString(String.format(", name = %s, "
|
||||
return super.toString(String.format(", itemUuid = %s, "
|
||||
+ "name = %s, "
|
||||
+ "contentType = { %s }, "
|
||||
+ "title = %s, "
|
||||
+ "description = %s, "
|
||||
|
|
@ -402,6 +419,7 @@ public class ContentItem extends CcmObject implements Serializable,
|
|||
+ "lifecycle = { %s }, "
|
||||
+ "workflow = { %s }"
|
||||
+ "%s",
|
||||
itemUuid,
|
||||
Objects.toString(name),
|
||||
Objects.toString(contentType),
|
||||
Objects.toString(title),
|
||||
|
|
|
|||
|
|
@ -202,12 +202,14 @@ public class ContentItemManager {
|
|||
|
||||
item.setVersion(ContentItemVersion.DRAFT);
|
||||
item.setContentType(contentType.get());
|
||||
|
||||
|
||||
if (workflowTemplate != null) {
|
||||
final Workflow workflow = workflowManager.createWorkflow(
|
||||
workflowTemplate);
|
||||
item.setWorkflow(workflow);
|
||||
}
|
||||
|
||||
contentItemRepo.save(item);
|
||||
|
||||
categoryManager.addObjectToCategory(
|
||||
item,
|
||||
|
|
@ -309,6 +311,8 @@ public class ContentItemManager {
|
|||
copy.setWorkflow(copyWorkflow);
|
||||
}
|
||||
|
||||
contentItemRepo.save(copy);
|
||||
|
||||
draftItem.getCategories().forEach(categorization -> categoryManager
|
||||
.addObjectToCategory(copy, categorization.getCategory()));
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import org.libreccm.core.CcmObjectRepository;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
|
|
@ -56,6 +57,15 @@ public class ContentItemRepository
|
|||
public boolean isNew(final ContentItem item) {
|
||||
return ccmObjectRepo.isNew(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initNewEntity(final ContentItem item) {
|
||||
final String uuid = UUID.randomUUID().toString();
|
||||
item.setUuid(uuid);
|
||||
if (item.getItemUuid() == null || item.getItemUuid().isEmpty()) {
|
||||
item.setItemUuid(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a content item by is id.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
ALTER TABLE ccm_cms.content_items
|
||||
ADD COLUMN item_uuid varchar(255) not null;
|
||||
|
||||
ALTER TABLE ccm_cms.content_items_aud
|
||||
ADD COLUMN item_uuid varchar(255) not null;
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
ALTER TABLE ccm_cms.content_items
|
||||
ADD COLUMN item_uuid varchar(255) not null;
|
||||
|
||||
ALTER TABLE ccm_cms.content_items_aud
|
||||
ADD COLUMN item_uuid varchar(255) not null;
|
||||
|
|
@ -236,6 +236,7 @@ public class ContentItemManagerTest {
|
|||
"phase_id",
|
||||
"task_id",
|
||||
"uuid",
|
||||
"item_uuid",
|
||||
"workflow_id"
|
||||
})
|
||||
public void createContentItem() {
|
||||
|
|
@ -338,6 +339,7 @@ public class ContentItemManagerTest {
|
|||
"phase_id",
|
||||
"task_id",
|
||||
"uuid",
|
||||
"item_uuid",
|
||||
"workflow_id"
|
||||
})
|
||||
public void createContentItemWithWorkflow() {
|
||||
|
|
@ -523,6 +525,7 @@ public class ContentItemManagerTest {
|
|||
"phase_id",
|
||||
"task_id",
|
||||
"uuid",
|
||||
"item_uuid",
|
||||
"workflow_id"
|
||||
})
|
||||
public void copyToOtherFolder() {
|
||||
|
|
@ -549,6 +552,7 @@ public class ContentItemManagerTest {
|
|||
"phase_id",
|
||||
"task_id",
|
||||
"uuid",
|
||||
"item_uuid",
|
||||
"workflow_id"
|
||||
})
|
||||
public void copyToSameFolder() {
|
||||
|
|
@ -562,7 +566,7 @@ public class ContentItemManagerTest {
|
|||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@InSequence(4100)
|
||||
@InSequence(4300)
|
||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ContentItemManagerTest/data.xml")
|
||||
@ShouldMatchDataSet(
|
||||
|
|
@ -577,7 +581,7 @@ public class ContentItemManagerTest {
|
|||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@InSequence(4100)
|
||||
@InSequence(4400)
|
||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ContentItemManagerTest/data.xml")
|
||||
@ShouldMatchDataSet(
|
||||
|
|
@ -593,7 +597,7 @@ public class ContentItemManagerTest {
|
|||
|
||||
// publish item (draft)
|
||||
@Test
|
||||
@InSequence(4200)
|
||||
@InSequence(5100)
|
||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||
+ "ContentItemManagerTest/data.xml")
|
||||
@ShouldMatchDataSet(
|
||||
|
|
|
|||
|
|
@ -269,6 +269,7 @@ create table CCM_CMS.ARTICLE_LEADS (
|
|||
|
||||
create table CCM_CMS.CONTENT_ITEMS (
|
||||
ANCESTORS varchar(1024),
|
||||
ITEM_UUID varchar(255) not null,
|
||||
LAUNCH_DATE date,
|
||||
VERSION varchar(255),
|
||||
OBJECT_ID bigint not null,
|
||||
|
|
@ -282,6 +283,7 @@ create table CCM_CMS.ARTICLE_LEADS (
|
|||
OBJECT_ID bigint not null,
|
||||
REV integer not null,
|
||||
ANCESTORS varchar(1024),
|
||||
ITEM_UUID varchar(255),
|
||||
LAUNCH_DATE date,
|
||||
VERSION varchar(255),
|
||||
CONTENT_TYPE_ID bigint,
|
||||
|
|
|
|||
|
|
@ -269,6 +269,7 @@ CREATE SCHEMA ccm_cms;
|
|||
|
||||
create table CCM_CMS.CONTENT_ITEMS (
|
||||
ANCESTORS varchar(1024),
|
||||
ITEM_UUID varchar(255) not null,
|
||||
LAUNCH_DATE date,
|
||||
VERSION varchar(255),
|
||||
OBJECT_ID int8 not null,
|
||||
|
|
@ -282,6 +283,7 @@ CREATE SCHEMA ccm_cms;
|
|||
OBJECT_ID int8 not null,
|
||||
REV int4 not null,
|
||||
ANCESTORS varchar(1024),
|
||||
ITEM_UUID varchar(255),
|
||||
LAUNCH_DATE date,
|
||||
VERSION varchar(255),
|
||||
CONTENT_TYPE_ID int8,
|
||||
|
|
|
|||
|
|
@ -272,6 +272,7 @@ create table CCM_CMS.ARTICLE_LEADS (
|
|||
LAUNCH_DATE date,
|
||||
VERSION varchar(255),
|
||||
OBJECT_ID bigint not null,
|
||||
ITEM_UUID varchar(255) not null,
|
||||
CONTENT_TYPE_ID bigint,
|
||||
LIFECYCLE_ID bigint,
|
||||
WORKFLOW_ID bigint,
|
||||
|
|
@ -282,6 +283,7 @@ create table CCM_CMS.ARTICLE_LEADS (
|
|||
OBJECT_ID bigint not null,
|
||||
REV integer not null,
|
||||
ANCESTORS varchar(1024),
|
||||
ITEM_UUID varchar(255),
|
||||
LAUNCH_DATE date,
|
||||
VERSION varchar(255),
|
||||
CONTENT_TYPE_ID bigint,
|
||||
|
|
|
|||
|
|
@ -199,21 +199,27 @@
|
|||
default_lifecycle_id="-200" />
|
||||
|
||||
<ccm_cms.content_items object_id="-10100"
|
||||
item_uuid="aed4b402-1180-46c6-b42d-7245f4dca248"
|
||||
version="DRAFT"
|
||||
content_type_id="-20100" />
|
||||
<ccm_cms.content_items object_id="-10200"
|
||||
item_uuid="acae860f-2ffa-450d-b486-054292f0dae6"
|
||||
version="DRAFT"
|
||||
content_type_id="-20100" />
|
||||
<ccm_cms.content_items object_id="-10300"
|
||||
item_uuid="f4b38abb-234b-4354-bc92-e36c068a1ebd"
|
||||
version="DRAFT"
|
||||
content_type_id="-20100" />
|
||||
<ccm_cms.content_items object_id="-10400"
|
||||
item_uuid="d9ea527d-c6e3-4bdd-962d-c0a1a80c6c72"
|
||||
version="DRAFT"
|
||||
content_type_id="-20200" />
|
||||
<ccm_cms.content_items object_id="-10500"
|
||||
item_uuid="12b63933-3167-4dc5-9b55-726a727c55b1"
|
||||
version="DRAFT"
|
||||
content_type_id="-20100" />
|
||||
<ccm_cms.content_items object_id="-99200"
|
||||
item_uuid="acae860f-2ffa-450d-b486-054292f0dae6"
|
||||
version="LIVE"
|
||||
content_type_id="-20100" />
|
||||
|
||||
|
|
@ -233,8 +239,8 @@
|
|||
locale="en"
|
||||
localized_value="article1" />
|
||||
<ccm_cms.content_item_names object_id="-99200"
|
||||
locale="en"
|
||||
localized_value="article2" />
|
||||
locale="en"
|
||||
localized_value="article2" />
|
||||
|
||||
<ccm_cms.content_item_titles object_id="-10100"
|
||||
locale="en"
|
||||
|
|
|
|||
|
|
@ -200,21 +200,27 @@
|
|||
default_lifecycle_id="-200" />
|
||||
|
||||
<ccm_cms.content_items object_id="-10100"
|
||||
item_uuid="aed4b402-1180-46c6-b42d-7245f4dca248"
|
||||
version="DRAFT"
|
||||
content_type_id="-20100" />
|
||||
<ccm_cms.content_items object_id="-10200"
|
||||
item_uuid="acae860f-2ffa-450d-b486-054292f0dae6"
|
||||
version="DRAFT"
|
||||
content_type_id="-20100" />
|
||||
<ccm_cms.content_items object_id="-10300"
|
||||
item_uuid="f4b38abb-234b-4354-bc92-e36c068a1ebd"
|
||||
version="DRAFT"
|
||||
content_type_id="-20100" />
|
||||
<ccm_cms.content_items object_id="-10400"
|
||||
item_uuid="d9ea527d-c6e3-4bdd-962d-c0a1a80c6c72"
|
||||
version="DRAFT"
|
||||
content_type_id="-20200" />
|
||||
<ccm_cms.content_items object_id="-10500"
|
||||
item_uuid="12b63933-3167-4dc5-9b55-726a727c55b1"
|
||||
version="DRAFT"
|
||||
content_type_id="-20100" />
|
||||
<ccm_cms.content_items object_id="-99200"
|
||||
item_uuid="acae860f-2ffa-450d-b486-054292f0dae6"
|
||||
version="LIVE"
|
||||
content_type_id="-20100" />
|
||||
|
||||
|
|
|
|||
|
|
@ -223,22 +223,28 @@
|
|||
default_lifecycle_id="-200" />
|
||||
|
||||
<ccm_cms.content_items object_id="-10100"
|
||||
item_uuid="aed4b402-1180-46c6-b42d-7245f4dca248"
|
||||
version="DRAFT"
|
||||
content_type_id="-20100" />
|
||||
<ccm_cms.content_items object_id="-10200"
|
||||
item_uuid="acae860f-2ffa-450d-b486-054292f0dae6"
|
||||
version="DRAFT"
|
||||
content_type_id="-20100" />
|
||||
<ccm_cms.content_items object_id="-10300"
|
||||
item_uuid="f4b38abb-234b-4354-bc92-e36c068a1ebd"
|
||||
version="DRAFT"
|
||||
content_type_id="-20100" />
|
||||
<ccm_cms.content_items object_id="-10400"
|
||||
item_uuid="d9ea527d-c6e3-4bdd-962d-c0a1a80c6c72"
|
||||
version="DRAFT"
|
||||
content_type_id="-20200" />
|
||||
<ccm_cms.content_items object_id="-11100"
|
||||
item_uuid="cfa0efb6-7ce2-41e8-be03-4ee8c7f18b05"
|
||||
version="DRAFT"
|
||||
content_type_id="-20100"
|
||||
workflow_id="-120" />
|
||||
<ccm_cms.content_items object_id="-99200"
|
||||
item_uuid="acae860f-2ffa-450d-b486-054292f0dae6"
|
||||
version="LIVE"
|
||||
content_type_id="-20100" />
|
||||
|
||||
|
|
|
|||
|
|
@ -236,22 +236,28 @@
|
|||
default_lifecycle_id="-200" />
|
||||
|
||||
<ccm_cms.content_items object_id="-10100"
|
||||
item_uuid="aed4b402-1180-46c6-b42d-7245f4dca248"
|
||||
version="DRAFT"
|
||||
content_type_id="-20100" />
|
||||
<ccm_cms.content_items object_id="-10200"
|
||||
item_uuid="acae860f-2ffa-450d-b486-054292f0dae6"
|
||||
version="DRAFT"
|
||||
content_type_id="-20100" />
|
||||
<ccm_cms.content_items object_id="-10300"
|
||||
item_uuid="f4b38abb-234b-4354-bc92-e36c068a1ebd"
|
||||
version="DRAFT"
|
||||
content_type_id="-20100" />
|
||||
<ccm_cms.content_items object_id="-10400"
|
||||
item_uuid="d9ea527d-c6e3-4bdd-962d-c0a1a80c6c72"
|
||||
version="DRAFT"
|
||||
content_type_id="-20200" />
|
||||
<ccm_cms.content_items object_id="-11100"
|
||||
item_uuid="cfa0efb6-7ce2-41e8-be03-4ee8c7f18b05"
|
||||
version="DRAFT"
|
||||
content_type_id="-20100"
|
||||
workflow_id="-120" />
|
||||
<ccm_cms.content_items object_id="-99200"
|
||||
item_uuid="acae860f-2ffa-450d-b486-054292f0dae6"
|
||||
version="LIVE"
|
||||
content_type_id="-20100" />
|
||||
|
||||
|
|
@ -366,12 +372,12 @@
|
|||
category_index="false"
|
||||
type="folder" />
|
||||
<ccm_core.categorizations categorization_id="-98200"
|
||||
category_id="-2100"
|
||||
object_id="-99200"
|
||||
category_order="1"
|
||||
object_order="2"
|
||||
category_index="false"
|
||||
type="folder" />
|
||||
category_id="-2100"
|
||||
object_id="-99200"
|
||||
category_order="1"
|
||||
object_order="2"
|
||||
category_index="false"
|
||||
type="folder" />
|
||||
|
||||
<ccm_core.ccm_roles role_id="-3100"
|
||||
name="info_alert_recipient" />
|
||||
|
|
|
|||
|
|
@ -196,18 +196,23 @@
|
|||
default_lifecycle_id="-200" />
|
||||
|
||||
<ccm_cms.content_items object_id="-10100"
|
||||
item_uuid="aed4b402-1180-46c6-b42d-7245f4dca248"
|
||||
version="DRAFT"
|
||||
content_type_id="-20100" />
|
||||
<ccm_cms.content_items object_id="-10200"
|
||||
item_uuid="acae860f-2ffa-450d-b486-054292f0dae6"
|
||||
version="DRAFT"
|
||||
content_type_id="-20100" />
|
||||
<ccm_cms.content_items object_id="-10300"
|
||||
item_uuid="f4b38abb-234b-4354-bc92-e36c068a1ebd"
|
||||
version="DRAFT"
|
||||
content_type_id="-20100" />
|
||||
<ccm_cms.content_items object_id="-10400"
|
||||
item_uuid="d9ea527d-c6e3-4bdd-962d-c0a1a80c6c72"
|
||||
version="DRAFT"
|
||||
content_type_id="-20200" />
|
||||
<ccm_cms.content_items object_id="-99200"
|
||||
item_uuid="acae860f-2ffa-450d-b486-054292f0dae6"
|
||||
version="LIVE"
|
||||
content_type_id="-20100" />
|
||||
|
||||
|
|
|
|||
|
|
@ -199,21 +199,27 @@
|
|||
default_lifecycle_id="-200" />
|
||||
|
||||
<ccm_cms.content_items object_id="-10100"
|
||||
item_uuid="aed4b402-1180-46c6-b42d-7245f4dca248"
|
||||
version="DRAFT"
|
||||
content_type_id="-20100" />
|
||||
<ccm_cms.content_items object_id="-10200"
|
||||
item_uuid="acae860f-2ffa-450d-b486-054292f0dae6"
|
||||
version="DRAFT"
|
||||
content_type_id="-20100" />
|
||||
<ccm_cms.content_items object_id="-10300"
|
||||
item_uuid="f4b38abb-234b-4354-bc92-e36c068a1ebd"
|
||||
version="DRAFT"
|
||||
content_type_id="-20100" />
|
||||
<ccm_cms.content_items object_id="-10400"
|
||||
item_uuid="d9ea527d-c6e3-4bdd-962d-c0a1a80c6c72"
|
||||
version="DRAFT"
|
||||
content_type_id="-20200" />
|
||||
<ccm_cms.content_items object_id="-99200"
|
||||
item_uuid="acae860f-2ffa-450d-b486-054292f0dae6"
|
||||
version="LIVE"
|
||||
content_type_id="-20100" />
|
||||
<ccm_cms.content_items object_id="-99100"
|
||||
item_uuid="aed4b402-1180-46c6-b42d-7245f4dca248"
|
||||
version="LIVE"
|
||||
content_type_id="-20100" />
|
||||
|
||||
|
|
|
|||
|
|
@ -196,18 +196,23 @@
|
|||
default_lifecycle_id="-200" />
|
||||
|
||||
<ccm_cms.content_items object_id="-10100"
|
||||
item_uuid="aed4b402-1180-46c6-b42d-7245f4dca248"
|
||||
version="DRAFT"
|
||||
content_type_id="-20100" />
|
||||
<ccm_cms.content_items object_id="-10200"
|
||||
item_uuid="acae860f-2ffa-450d-b486-054292f0dae6"
|
||||
version="DRAFT"
|
||||
content_type_id="-20100" />
|
||||
<ccm_cms.content_items object_id="-10300"
|
||||
item_uuid="f4b38abb-234b-4354-bc92-e36c068a1ebd"
|
||||
version="DRAFT"
|
||||
content_type_id="-20100" />
|
||||
<ccm_cms.content_items object_id="-10400"
|
||||
item_uuid="d9ea527d-c6e3-4bdd-962d-c0a1a80c6c72"
|
||||
version="DRAFT"
|
||||
content_type_id="-20200" />
|
||||
<ccm_cms.content_items object_id="-99200"
|
||||
item_uuid="acae860f-2ffa-450d-b486-054292f0dae6"
|
||||
version="LIVE"
|
||||
content_type_id="-20100" />
|
||||
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@
|
|||
display_name="article3"
|
||||
uuid="f4b38abb-234b-4354-bc92-e36c068a1ebd" />
|
||||
<ccm_core.ccm_objects object_id="-10200"
|
||||
display_name="article2"
|
||||
uuid="acae860f-2ffa-450d-b486-054292f0dae6" />
|
||||
display_name="article2"
|
||||
uuid="acae860f-2ffa-450d-b486-054292f0dae6" />
|
||||
<ccm_core.ccm_objects object_id="-10400"
|
||||
display_name="news1"
|
||||
uuid="d9ea527d-c6e3-4bdd-962d-c0a1a80c6c72" />
|
||||
|
|
@ -74,15 +74,19 @@
|
|||
content_section_id="-1100" />
|
||||
|
||||
<ccm_cms.content_items object_id="-10100"
|
||||
item_uuid="aed4b402-1180-46c6-b42d-7245f4dca248"
|
||||
version="DRAFT"
|
||||
content_type_id="-20100" />
|
||||
<ccm_cms.content_items object_id="-10200"
|
||||
item_uuid="acae860f-2ffa-450d-b486-054292f0dae6"
|
||||
version="DRAFT"
|
||||
content_type_id="-20100" />
|
||||
<ccm_cms.content_items object_id="-10300"
|
||||
item_uuid="f4b38abb-234b-4354-bc92-e36c068a1ebd"
|
||||
version="DRAFT"
|
||||
content_type_id="-20100" />
|
||||
<ccm_cms.content_items object_id="-10400"
|
||||
item_uuid="d9ea527d-c6e3-4bdd-962d-c0a1a80c6c72"
|
||||
version="DRAFT"
|
||||
content_type_id="-20200" />
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue