Bei Publizieren eines Items mit einem RelatatedLink kam es zu einer ClassCastException, da RelatedLink Objekte sich nicht zu ContentItem casten lassen (letzter

Parameter von PublishedLink#create()). Korrigiert, indem in VersionCopier für Objekte, die nicht von ContentItem abgeleitet sind 'null' im Parameter sourceObject 
übergeben wird. In PublishedLink#create() wird nun geprüft, ob sourceObject 'null' ist. Wenn der Parameter nicht 'null' ist, werden LinkAttribute (dafür ist dieser 
Parameter erforderlich) kopiert. Falls der Parameter 'null' ist, wird dieser Methodenaufruf übersprungen (in diesem Fall wäre er auch sinnlos).


git-svn-id: https://svn.libreccm.org/ccm/trunk@634 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2010-11-25 08:00:27 +00:00
parent c5b1f1a405
commit 1a574abe70
2 changed files with 46 additions and 36 deletions

View File

@ -150,7 +150,7 @@ class PublishedLink extends DomainObject {
link = new PublishedLink(SessionManager.getSession().create(oid)); link = new PublishedLink(SessionManager.getSession().create(oid));
} }
if (sourceObject.getObjectType().getProperty(propertyName).isCollection()) { if ((sourceObject != null) && sourceObject.getObjectType().getProperty(propertyName).isCollection()) {
link.saveLinkAttributes((DataCollection) sourceObject.get(propertyName + "@link")); link.saveLinkAttributes((DataCollection) sourceObject.get(propertyName + "@link"));
} }

View File

@ -21,6 +21,7 @@ package com.arsdigita.cms;
import com.arsdigita.cms.lifecycle.Lifecycle; import com.arsdigita.cms.lifecycle.Lifecycle;
import com.arsdigita.cms.lifecycle.LifecycleService; import com.arsdigita.cms.lifecycle.LifecycleService;
import com.arsdigita.domain.DomainObject; import com.arsdigita.domain.DomainObject;
import com.arsdigita.kernel.ACSObject;
import com.arsdigita.persistence.metadata.Property; import com.arsdigita.persistence.metadata.Property;
import com.arsdigita.persistence.OID; import com.arsdigita.persistence.OID;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
@ -39,7 +40,6 @@ import java.util.HashSet;
class VersionCopier extends ObjectCopier { class VersionCopier extends ObjectCopier {
private static Logger s_log = Logger.getLogger(VersionCopier.class); private static Logger s_log = Logger.getLogger(VersionCopier.class);
private final Lifecycle m_lifecycle; private final Lifecycle m_lifecycle;
private boolean m_once = false; private boolean m_once = false;
private long m_start = 0; private long m_start = 0;
@ -108,9 +108,10 @@ class VersionCopier extends ObjectCopier {
} }
if (s_log.isInfoEnabled()) { if (s_log.isInfoEnabled()) {
s_log.info("Done publishing " + item + " (" + s_log.info("Done publishing " + item + " (" + (System.
(System.currentTimeMillis() - m_start) + currentTimeMillis()
" millis)"); - m_start)
+ " millis)");
} }
return version; return version;
@ -197,8 +198,8 @@ class VersionCopier extends ObjectCopier {
} }
if (prop.isComponent()) { if (prop.isComponent()) {
s_log.debug("The property is a component; creating a " + s_log.debug("The property is a component; creating a "
"live or pending version"); + "live or pending version");
final ContentItem copy = createVersion(item); final ContentItem copy = createVersion(item);
@ -212,20 +213,29 @@ class VersionCopier extends ObjectCopier {
return copy; return copy;
} else if (prop.isRequired()) { } else if (prop.isRequired()) {
Assert.fail("1..1 associations to non-component top-level ContentItems are not allowed"); Assert.fail(
"1..1 associations to non-component top-level ContentItems are not allowed");
return null; return null;
} else { } else {
s_log.debug("The property is not a component; creating " + s_log.debug("The property is not a component; creating "
"PublishedLink for the item"); + "PublishedLink for the item");
PublishedLink.create((ContentItem) getCopy(m_topLevelSourceOID), target, prop.getName(), item, (ContentItem) source); if (source instanceof ContentItem) {
PublishedLink.create((ContentItem) getCopy(
m_topLevelSourceOID), target, prop.getName(), item,
(ContentItem) source);
} else {
PublishedLink.create((ContentItem) getCopy(
m_topLevelSourceOID), target, prop.getName(), item,
null);
}
m_trace.exit("copy", null); m_trace.exit("copy", null);
return null; return null;
} }
} else { } else {
s_log.debug("The property is not a content item; using " + s_log.debug("The property is not a content item; using "
"domain object copier"); + "domain object copier");
final DomainObject copy = super.copy(source, target, object, prop); final DomainObject copy = super.copy(source, target, object, prop);
@ -244,8 +254,8 @@ class VersionCopier extends ObjectCopier {
final ContentItem version = (ContentItem) copy(item); final ContentItem version = (ContentItem) copy(item);
s_log.debug("The copy is pending; associating it with " + s_log.debug("The copy is pending; associating it with "
"the draft item"); + "the draft item");
version.setVersion(ContentItem.PENDING); version.setVersion(ContentItem.PENDING);
item.addPendingVersion(version); item.addPendingVersion(version);