- Abhängigkeiten für ccm-webpage korrigiert (Umbenennung portalworkspace)

- Verschiedene Formatierungen


git-svn-id: https://svn.libreccm.org/ccm/trunk@1539 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2012-03-13 06:29:02 +00:00
parent 18eb7f05c6
commit 216120a4a8
4 changed files with 244 additions and 111 deletions

View File

@ -48,9 +48,8 @@ import java.util.Iterator;
import java.util.Set;
/**
* This class represents an association between a pending or live
* ContentItem (or one of its components) and a separate top-level
* Contenttem.
* This class represents an association between a pending or live ContentItem
* (or one of its components) and a separate top-level Contenttem.
*
*/
class PublishedLink extends DomainObject {
@ -72,8 +71,9 @@ class PublishedLink extends DomainObject {
}
/**
* Default constructor. The contained <code>DataObject</code> is
* initialized with a new <code>DataObject</code> with an
* Default constructor. The contained
* <code>DataObject</code> is initialized with a new
* <code>DataObject</code> with an
* <code>ObjectType</code> of "PublishedLink".
*
* @see com.arsdigita.domain.DomainObject#DomainObject(String)
@ -94,11 +94,13 @@ class PublishedLink extends DomainObject {
}
/**
* Constructor. The contained <code>DataObject</code> is retrieved
* from the persistent storage mechanism with an <code>OID</code>
* specified by <i>oid</i>.
* Constructor. The contained
* <code>DataObject</code> is retrieved from the persistent storage
* mechanism with an
* <code>OID</code> specified by <i>oid</i>.
*
* @param oid The <code>OID</code> for the retrieved
* @param oid The
* <code>OID</code> for the retrieved
* <code>DataObject</code>.
*
* @see com.arsdigita.domain.DomainObject#DomainObject(OID)
@ -110,20 +112,23 @@ class PublishedLink extends DomainObject {
}
/**
* Creates new PublishedLink unless one already exists for the
* specified source, target, and property
* Creates new PublishedLink unless one already exists for the specified
* source, target, and property
*
* @param sourceMasterItem the top-level pending or live <code>ContentItem</code> which
* this <code>PublishedLink</code> is a component of.
* @param sourceMasterItem the top-level pending or live
* <code>ContentItem</code> which this
* <code>PublishedLink</code> is a component of.
* @param linkSource the immediate source of this
* <code>PublishedLink</code>, a component of the sourceMasterItem
* (or the item itself)
* @param propertyName the Property name for this <code>PublishedLink</code>
* @param linkTarget the top-level draft <code>ContentItem</code> which
* is the target of this <code>PublishedLink</code> .
* <code>PublishedLink</code>, a component of the sourceMasterItem (or the
* item itself)
* @param propertyName the Property name for this
* <code>PublishedLink</code>
* @param linkTarget the top-level draft
* <code>ContentItem</code> which is the target of this
* <code>PublishedLink</code> .
*
* @return the newly-created PublishedLink, or the existing one if
* one already exists for these items.
* @return the newly-created PublishedLink, or the existing one if one
* already exists for these items.
*/
static PublishedLink create(ContentItem sourceMasterItem,
DomainObject linkSource,
@ -131,15 +136,19 @@ class PublishedLink extends DomainObject {
ContentItem linkTarget,
ContentItem sourceObject) {
OID oid = new OID(BASE_DATA_OBJECT_TYPE);
oid.set(SOURCE_MASTER_ITEM, DomainServiceInterfaceExposer.getDataObject(sourceMasterItem));
oid.set(SOURCE_MASTER_ITEM, DomainServiceInterfaceExposer.getDataObject(
sourceMasterItem));
oid.set(PROPERTY_NAME, propertyName);
oid.set(DRAFT_TARGET, DomainServiceInterfaceExposer.getDataObject(linkTarget));
oid.set(DRAFT_TARGET, DomainServiceInterfaceExposer.getDataObject(
linkTarget));
// this will need to be refactored if we switch to OID link sourcess
if (linkSource instanceof ACSObject) {
oid.set(PENDING_SOURCE, DomainServiceInterfaceExposer.getDataObject(linkSource));
oid.set(PENDING_SOURCE, DomainServiceInterfaceExposer.getDataObject(
linkSource));
} else {
Assert.fail("Cannot set PublishedLink source " + linkSource + "; it is not an "
Assert.fail("Cannot set PublishedLink source " + linkSource
+ "; it is not an "
+ "ACSObject");
}
@ -150,14 +159,17 @@ class PublishedLink extends DomainObject {
link = new PublishedLink(SessionManager.getSession().create(oid));
}
if ((sourceObject != null) && sourceObject.getObjectType().getProperty(propertyName).isCollection()) {
if ((sourceObject != null) && sourceObject.getObjectType().getProperty(
propertyName).isCollection()) {
DataCollection coll = (DataCollection) sourceObject.get(propertyName + "@link");
DataCollection coll = (DataCollection) sourceObject.get(propertyName
+ "@link");
while (coll.next()) {
DataObject linkObj = coll.getDataObject();
if (linkTarget.getOID().equals(((DataObject) linkObj.getOID().get(propertyName)).getOID())) {
if (linkTarget.getOID().equals(((DataObject) linkObj.getOID().
get(propertyName)).getOID())) {
link.saveLinkAttributes(linkObj);
coll.close();
}
@ -168,11 +180,13 @@ class PublishedLink extends DomainObject {
}
/**
* Returns the top-level pending or live <code>ContentItem</code> which
* this <code>PublishedLink</code> is a component of.
* Returns the top-level pending or live
* <code>ContentItem</code> which this
* <code>PublishedLink</code> is a component of.
*
* @return the top-level pending or live <code>ContentItem</code> which
* this <code>PublishedLink</code> is a component of.
* @return the top-level pending or live
* <code>ContentItem</code> which this
* <code>PublishedLink</code> is a component of.
*
*/
ContentItem getSourceMasterItem() {
@ -183,9 +197,11 @@ class PublishedLink extends DomainObject {
}
/**
* Returns the immediate source of this <code>PublishedLink</code>
* Returns the immediate source of this
* <code>PublishedLink</code>
*
* @return the immediate source of this <code>PublishedLink</code>
* @return the immediate source of this
* <code>PublishedLink</code>
*
*/
DomainObject getLinkSource() {
@ -197,9 +213,11 @@ class PublishedLink extends DomainObject {
}
/**
* Returns the Property name for this <code>PublishedLink</code>
* Returns the Property name for this
* <code>PublishedLink</code>
*
* @return the Property name for this <code>PublishedLink</code>
* @return the Property name for this
* <code>PublishedLink</code>
*
*/
String getPropertyName() {
@ -207,11 +225,13 @@ class PublishedLink extends DomainObject {
}
/**
* Returns the top-level draft <code>ContentItem</code> which
* is the target of this <code>PublishedLink</code> .
* Returns the top-level draft
* <code>ContentItem</code> which is the target of this
* <code>PublishedLink</code> .
*
* @return the top-level draft <code>ContentItem</code> which
* is the target of this <code>PublishedLink</code> .
* @return the top-level draft
* <code>ContentItem</code> which is the target of this
* <code>PublishedLink</code> .
*
*/
ContentItem getLinkTarget() {
@ -222,12 +242,12 @@ class PublishedLink extends DomainObject {
}
/**
* Updates live associations based on PublishedLinks which either
* point <em>from</em> or <em>to</em> the given
* <code>ContentItem</code>. If both ends of the link are now
* live, the live-live association will be updated. In addition,
* for links <em>to</em> this new live item, the source of the
* link is refreshed via <code>QueueManager.queueRepublish</code>.
* Updates live associations based on PublishedLinks which either point
* <em>from</em> or <em>to</em> the given
* <code>ContentItem</code>. If both ends of the link are now live, the
* live-live association will be updated. In addition, for links <em>to</em>
* this new live item, the source of the link is refreshed via
* <code>QueueManager.queueRepublish</code>.
*
* @param item The item which was just published
*/
@ -238,7 +258,8 @@ class PublishedLink extends DomainObject {
ContentItem draftItem = item.getDraftVersion();
DataCollection linksToItem = session.retrieve(BASE_DATA_OBJECT_TYPE);
linksToItem.addEqualsFilter(DRAFT_TARGET + ".id", draftItem.getID());
linksToItem.addEqualsFilter(SOURCE_MASTER_ITEM + "." + ContentItem.VERSION, ContentItem.LIVE);
linksToItem.addEqualsFilter(SOURCE_MASTER_ITEM + "."
+ ContentItem.VERSION, ContentItem.LIVE);
updateLiveLinksFromCollection(linksToItem, itemsToRefresh);
linksToItem.close();
@ -250,14 +271,16 @@ class PublishedLink extends DomainObject {
Iterator refreshIterator = itemsToRefresh.iterator();
while (refreshIterator.hasNext()) {
OID oid = (OID) refreshIterator.next();
ContentItem refreshItem = (ContentItem) DomainObjectFactory.newInstance(oid);
ContentItem refreshItem = (ContentItem) DomainObjectFactory.
newInstance(oid);
if (refreshItem.canPublishToFS()) {
QueueManager.queueRepublish(refreshItem);
}
}
}
private static void updateLiveLinksFromCollection(DataCollection coll, Set itemsToRefresh) {
private static void updateLiveLinksFromCollection(DataCollection coll,
Set itemsToRefresh) {
while (coll.next()) {
// will change w/ OID references
DataObject master = (DataObject) coll.get(SOURCE_MASTER_ITEM);
@ -272,7 +295,8 @@ class PublishedLink extends DomainObject {
DataObject target = null;
DataObject draftTarget = (DataObject) coll.get(DRAFT_TARGET);
DataAssociationCursor targetVersions =
((DataAssociation) draftTarget.get(ContentItem.VERSIONS)).cursor();
((DataAssociation) draftTarget.get(
ContentItem.VERSIONS)).cursor();
targetVersions.addEqualsFilter(ContentItem.VERSION, ContentItem.LIVE);
if (targetVersions.next()) {
target = targetVersions.getDataObject();
@ -281,7 +305,8 @@ class PublishedLink extends DomainObject {
if (target != null) {
ObjectType ot = src.getObjectType();
Property prop = ot.getProperty(propertyName);
Assert.exists(prop, propertyName + " for type " + ot.getQualifiedName() + ", ID: " + src.get("id"));
Assert.exists(prop, propertyName + " for type " + ot.
getQualifiedName() + ", ID: " + src.get("id"));
if (prop.isCollection()) {
DataAssociation da = (DataAssociation) src.get(propertyName);
setLinkAttributesForLiveLink(da.add(target), linkAttributes);
@ -297,8 +322,8 @@ class PublishedLink extends DomainObject {
}
/**
* At unpublish time, for links <em>to</em> this unpublished item,
* the source of the link is refreshed via
* At unpublish time, for links <em>to</em> this unpublished item, the
* source of the link is refreshed via
* <code>QueueManager.queueRepublish</code>.
*
* @param item The item which was just published
@ -309,7 +334,8 @@ class PublishedLink extends DomainObject {
DataCollection linksToItem = session.retrieve(BASE_DATA_OBJECT_TYPE);
linksToItem.addEqualsFilter(DRAFT_TARGET + ".id", item.getID());
linksToItem.addEqualsFilter(SOURCE_MASTER_ITEM + "." + ContentItem.VERSION, ContentItem.LIVE);
linksToItem.addEqualsFilter(SOURCE_MASTER_ITEM + "."
+ ContentItem.VERSION, ContentItem.LIVE);
while (linksToItem.next()) {
// will change w/ OID references
DataObject master = (DataObject) linksToItem.get(SOURCE_MASTER_ITEM);
@ -320,7 +346,8 @@ class PublishedLink extends DomainObject {
Iterator refreshIterator = itemsToRefresh.iterator();
while (refreshIterator.hasNext()) {
OID oid = (OID) refreshIterator.next();
ContentItem refreshItem = (ContentItem) DomainObjectFactory.newInstance(oid);
ContentItem refreshItem = (ContentItem) DomainObjectFactory.
newInstance(oid);
if (refreshItem.canPublishToFS()) {
QueueManager.queueRepublish(refreshItem);
}
@ -357,7 +384,8 @@ class PublishedLink extends DomainObject {
}
}
private static void setLinkAttributesForLiveLink(DataObject link, byte[] linkAttributes) {
private static void setLinkAttributesForLiveLink(DataObject link,
byte[] linkAttributes) {
if (linkAttributes != null) {
ByteArrayInputStream data = null;
@ -386,7 +414,8 @@ class PublishedLink extends DomainObject {
String propertyName = (String) keys.next();
Object value = (Object) attributes.get(propertyName);
if (link.getObjectType().hasDeclaredProperty(propertyName) && link.getSession() != null) {
if (link.getObjectType().hasDeclaredProperty(propertyName)
&& link.getSession() != null) {
link.set(propertyName, value);
}
}

View File

@ -30,9 +30,10 @@ import org.apache.log4j.Logger;
import java.util.HashSet;
/**
* Extends <code>ObjectCopier</code> to create a live version for an
* item. Clones the item, making sure that live versions of all subitems
* point only to other live versions.
* Extends
* <code>ObjectCopier</code> to create a live version for an item. Clones the
* item, making sure that live versions of all subitems point only to other live
* versions.
*
* @author <a href="mailto:sfreidin@arsdigita.com">Stanislav Freidin</a>
* @version $Id: VersionCopier.java 2140 2011-01-16 12:04:20Z pboy $
@ -47,7 +48,8 @@ class VersionCopier extends ObjectCopier {
private OID m_topLevelSourceOID = null;
/**
* Creates a new <code>VersionCopier</code> with a given Lifecycle
* Creates a new
* <code>VersionCopier</code> with a given Lifecycle
*
* @param lifecycle The Lifecycle
*/
@ -57,7 +59,8 @@ class VersionCopier extends ObjectCopier {
}
/**
* Creates a new <code>VersionCopier</code> with no Lifecycle
* Creates a new
* <code>VersionCopier</code> with no Lifecycle
*/
VersionCopier() {
m_traversedComponents = new HashSet();
@ -65,12 +68,10 @@ class VersionCopier extends ObjectCopier {
}
/**
* Copy a {@link ContentItem}, along with all of its component
* sub-objects, and return the copy. Note that the categories to
* which the source item belongs are not automatically transferred
* to the copy; the user must call {@link #copyServices(ContentItem,
* ContentItem)} in order to transfer the categories and other
* services.
* Copy a {@link ContentItem}, along with all of its component sub-objects,
* and return the copy. Note that the categories to which the source item
* belongs are not automatically transferred to the copy; the user must call {@link #copyServices(ContentItem,
* ContentItem)} in order to transfer the categories and other services.
*
* @param item the item to be copied
* @return a copy of the item
@ -127,10 +128,11 @@ class VersionCopier extends ObjectCopier {
/**
* Kicks off the copying process. Creates a copy by value of
* <code>source</code> and then traverses its associations and
* repeats the process.
* <code>source</code> and then traverses its associations and repeats the
* process.
*
* @param source the <code>DomainObject</code> from which to copy
* @param source the
* <code>DomainObject</code> from which to copy
*/
@Override
public DomainObject copy(final DomainObject object) {
@ -142,35 +144,32 @@ class VersionCopier extends ObjectCopier {
/**
* Copies properties. This method is called from {@link
* #copy(DomainObject)} for each property of the object being
* copied.
* #copy(DomainObject)} for each property of the object being copied.
*
* Copying behavior depends on the following:
* <dl>
* <dt> <code>object instanceof ContentItem && prop.isComponent()</code></dt>
* <dd> Copy ContentItem recursively, setting the version attribute, etc.</dd>
* <dt> <code>object instanceof ContentItem &&
* Copying behavior depends on the following: <dl> <dt>
* <code>object instanceof ContentItem && prop.isComponent()</code></dt>
* <dd> Copy ContentItem recursively, setting the version attribute,
* etc.</dd> <dt>
* <code>object instanceof ContentItem &&
* !prop.isComponent() (and target is an already-traversed
* component of the top-level item )</code></dt>
* <dd> Return reference to already-created copy of this item</dd>
* <dt> <code>object instanceof ContentItem &&
* component of the top-level item )</code></dt> <dd> Return reference to
* already-created copy of this item</dd> <dt>
* <code>object instanceof ContentItem &&
* !prop.isComponent() && prop.isRequired (and target is not an already-traversed
* component of the top-level item )</code></dt>
* <dd> Assert failure: required top-level item associations are
* not allowed here.</dd>
* <dt> <code>object instanceof ContentItem &&
* component of the top-level item )</code></dt> <dd> Assert failure:
* required top-level item associations are not allowed here.</dd> <dt>
* <code>object instanceof ContentItem &&
* !prop.isComponent() && !prop.isRequired (and target is not an already-traversed
* component of the top-level item )</code></dt>
* <dd> Create PublishedLink for association; return null</dd>
* <dt> <code>!object instanceof ContentItem </code></dt>
* <dd> object is not a ContentItem, rely on default DomainCopier
* behavior</dd>
* </dl>
* component of the top-level item )</code></dt> <dd> Create PublishedLink
* for association; return null</dd> <dt>
* <code>!object instanceof ContentItem </code></dt> <dd> object is not a
* ContentItem, rely on default DomainCopier behavior</dd> </dl>
*
* @param source the <code>DomainObject</code> being copied
* @param source the
* <code>DomainObject</code> being copied
* @param target the new copy
* @param prop the <code>Property</code> currently under
* consideration
* @param prop the
* <code>Property</code> currently under consideration
*/
@Override
protected DomainObject copy(final DomainObject source,
@ -221,12 +220,18 @@ class VersionCopier extends ObjectCopier {
+ "PublishedLink for the item");
if (source instanceof ContentItem) {
PublishedLink.create((ContentItem) getCopy(
m_topLevelSourceOID), target, prop.getName(), item,
PublishedLink.create(
(ContentItem) getCopy(m_topLevelSourceOID),
target,
prop.getName(),
item,
(ContentItem) source);
} else {
PublishedLink.create((ContentItem) getCopy(
m_topLevelSourceOID), target, prop.getName(), item,
PublishedLink.create(
(ContentItem) getCopy(m_topLevelSourceOID),
target,
prop.getName(),
item,
null);
}
m_trace.exit("copy", null);

View File

@ -0,0 +1,99 @@
package com.arsdigita.london.util.cmd;
import com.arsdigita.cms.ContentBundle;
import com.arsdigita.cms.ContentPage;
import com.arsdigita.domain.DomainObject;
import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.packaging.Program;
import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.OID;
import com.arsdigita.persistence.Session;
import com.arsdigita.persistence.SessionManager;
import com.arsdigita.persistence.metadata.Association;
import com.arsdigita.persistence.metadata.DataType;
import com.arsdigita.persistence.metadata.Model;
import com.arsdigita.persistence.metadata.ObjectType;
import com.arsdigita.persistence.metadata.Property;
import java.math.BigDecimal;
import java.util.Iterator;
import java.util.Set;
import org.apache.commons.cli.CommandLine;
/**
*
* @author Jens Pelzetter
* @version $Id$
*/
public class MetadataPrinter extends Program {
public MetadataPrinter() {
super("MetadataPrinter", "1.0.0", "");
}
@Override
protected void doRun(final CommandLine cmdLine) {
final String[] args = cmdLine.getArgs();
if (args.length < 1) {
System.out.println("Usage:");
System.out.println("MetadataPrinter $oid");
System.exit(-1);
}
final OID oid = OID.valueOf(args[0]);
final Session session = SessionManager.getSession();
final DataObject dobj = session.retrieve(oid);
final ObjectType objType = dobj.getObjectType();
printObjectTypeData(objType);
System.out.println("");
final DomainObject obj = DomainObjectFactory.newInstance(oid);
if (obj instanceof ContentPage) {
final ContentPage page = (ContentPage) obj;
final ContentBundle bundle = page.getContentBundle();
final OID bundleOid = bundle.getOID();
System.out.printf("Bundle OID: %s\n\n", bundleOid.toString());
final DataObject bundleDobj = session.retrieve(bundleOid);
printObjectTypeData(bundleDobj.getObjectType());
}
}
public static void main(final String[] args) {
new MetadataPrinter().run(args);
}
private void printObjectTypeData(final ObjectType objType) {
System.out.printf("ObjectType: %s\n", objType.getName());
System.out.println("Properties: ");
Iterator propIter = objType.getProperties();
while (propIter.hasNext()) {
printPropertyData((Property) propIter.next());
}
}
private void printPropertyData(final Property property) {
System.out.printf("\tName..............: %s\n", property.getName());
System.out.printf("\tisAttribute.......: %b\n", property.isAttribute());
System.out.printf("\tisRole............: %b\n", property.isRole());
System.out.printf("\tisCollection......: %b\n", property.isCollection());
System.out.printf("\tisNullable........: %b\n", property.isNullable());
System.out.printf("\tisRequired........: %b\n", property.isRequired());
System.out.printf("\tisComponent.......: %b\n", property.isComponent());
System.out.printf("\tisComposite.......: %b\n", property.isComponent());
System.out.printf("\tisKeyProperty.....: %b\n", property.isComponent());
if (property.getAssociatedProperty() != null) {
System.out.printf("\tassociatedProperty: %s\n",
property.getAssociatedProperty().getName());
}
System.out.printf("\tType..............:\n");
final DataType dataType = property.getType();
System.out.printf("\t\tName.........: %s\n", dataType.getName());
System.out.printf("\t\tQualifiedName: %s\n", dataType.getQualifiedName());
System.out.printf("\t\tisCompound...: %b\n", dataType.isCompound());
System.out.printf("\t\tisSimple.....: %b\n", dataType.isSimple());
}
}

View File

@ -9,7 +9,7 @@
<ccm:requires name="ccm-core" version="6.6.0" relation="ge"/>
<ccm:requires name="ccm-cms" version="6.6.0" relation="ge"/>
<ccm:requires name="ccm-ldn-util" version="6.6.0" relation="ge"/>
<ccm:requires name="ccm-ldn-portal" version="6.6.0" relation="ge"/>
<ccm:requires name="ccm-portalworkspace" version="6.6.0" relation="ge"/>
</ccm:dependencies>
<ccm:contacts>
<ccm:contact uri="http://www.runtime-collective.com" type="website"/>