- Verschiedene Formatierungen

- Bug im ldn-importer gefixt
- SimpleDomainObjectTraversalAdapter um remove-Methoden erweitert


git-svn-id: https://svn.libreccm.org/ccm/trunk@597 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2010-11-04 10:55:31 +00:00
parent db9baf50d5
commit 478a66f4b9
9 changed files with 280 additions and 220 deletions

View File

@ -69,6 +69,7 @@ public class ContentItemTraversalAdapter
* to the asset's adapter, otherwise delegates to * to the asset's adapter, otherwise delegates to
* the content item's primary adapter * the content item's primary adapter
*/ */
@Override
public boolean processProperty(DomainObject obj, public boolean processProperty(DomainObject obj,
String path, String path,
Property prop, Property prop,

View File

@ -18,7 +18,6 @@
*/ */
package com.arsdigita.cms.dispatcher; package com.arsdigita.cms.dispatcher;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.cms.CMS; import com.arsdigita.cms.CMS;
import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentItem;
@ -45,7 +44,6 @@ import org.apache.log4j.Logger;
import java.util.Iterator; import java.util.Iterator;
/** /**
* <p>The default <tt>XMLGenerator</tt> implementation.</p> * <p>The default <tt>XMLGenerator</tt> implementation.</p>
* *
@ -57,8 +55,8 @@ public class SimpleXMLGenerator implements XMLGenerator {
private static Logger s_log = private static Logger s_log =
Logger.getLogger(SimpleXMLGenerator.class); Logger.getLogger(SimpleXMLGenerator.class);
public static final String ADAPTER_CONTEXT = SimpleXMLGenerator.class.
public static final String ADAPTER_CONTEXT = SimpleXMLGenerator.class.getName(); getName();
// Register general purpose adaptor for all content items // Register general purpose adaptor for all content items
static { static {
@ -70,11 +68,11 @@ public class SimpleXMLGenerator implements XMLGenerator {
DomainObjectTraversal.registerAdapter( DomainObjectTraversal.registerAdapter(
ContentItem.BASE_DATA_OBJECT_TYPE, ContentItem.BASE_DATA_OBJECT_TYPE,
adapter, adapter,
ADAPTER_CONTEXT ADAPTER_CONTEXT);
);
} }
public SimpleXMLGenerator() {} public SimpleXMLGenerator() {
}
/** /**
* Generates the XML to render the content panel. * Generates the XML to render the content panel.
@ -101,11 +99,13 @@ public class SimpleXMLGenerator implements XMLGenerator {
// Note that the xml that is generated is only of use if you DO NOT CACHE content pages. // Note that the xml that is generated is only of use if you DO NOT CACHE content pages.
// cg. // cg.
PermissionDescriptor edit = new PermissionDescriptor(PrivilegeDescriptor.get(SecurityManager.CMS_EDIT_ITEM), item, currentParty); PermissionDescriptor edit = new PermissionDescriptor(PrivilegeDescriptor.
get(SecurityManager.CMS_EDIT_ITEM), item, currentParty);
if (PermissionService.checkPermission(edit)) { if (PermissionService.checkPermission(edit)) {
parent.addAttribute("canEdit", "true"); parent.addAttribute("canEdit", "true");
} }
PermissionDescriptor publish = new PermissionDescriptor(PrivilegeDescriptor.get(SecurityManager.CMS_PUBLISH), item, currentParty); PermissionDescriptor publish = new PermissionDescriptor(PrivilegeDescriptor.
get(SecurityManager.CMS_PUBLISH), item, currentParty);
if (PermissionService.checkPermission(publish)) { if (PermissionService.checkPermission(publish)) {
parent.addAttribute("canPublish", "true"); parent.addAttribute("canPublish", "true");
} }
@ -115,26 +115,28 @@ public class SimpleXMLGenerator implements XMLGenerator {
if (!item.getClass().getName().equals(className)) { if (!item.getClass().getName().equals(className)) {
s_log.info("Specializing item"); s_log.info("Specializing item");
try { try {
item = (ContentItem)DomainObjectFactory item = (ContentItem) DomainObjectFactory.newInstance(new OID(item.
.newInstance(new OID(item.getObjectType().getQualifiedName(), getObjectType().getQualifiedName(),
item.getID())); item.
getID()));
} catch (DataObjectNotFoundException ex) { } catch (DataObjectNotFoundException ex) {
throw new UncheckedWrapperException( throw new UncheckedWrapperException(
(String)GlobalizationUtil.globalize( (String) GlobalizationUtil.globalize(
"cms.dispatcher.cannot_find_domain_object" "cms.dispatcher.cannot_find_domain_object").localize(),
).localize(), ex); ex);
} }
} }
// Implementing XMLGenerator directly is now deprecated // Implementing XMLGenerator directly is now deprecated
if ( item instanceof XMLGenerator) { if (item instanceof XMLGenerator) {
s_log.info("Item implements XMLGenerator interface"); s_log.info("Item implements XMLGenerator interface");
XMLGenerator xitem = (XMLGenerator)item; XMLGenerator xitem = (XMLGenerator) item;
xitem.generateXML(state, parent, useContext); xitem.generateXML(state, parent, useContext);
} else if (className.equals("com.arsdigita.cms.UserDefinedContentItem")) { } else if (className.equals(
"com.arsdigita.cms.UserDefinedContentItem")) {
s_log.info("Item is a user defined content item"); s_log.info("Item is a user defined content item");
UserDefinedContentItem UDItem = (UserDefinedContentItem)item; UserDefinedContentItem UDItem = (UserDefinedContentItem) item;
generateUDItemXML(UDItem, state, parent, useContext); generateUDItemXML(UDItem, state, parent, useContext);
} else { } else {
@ -157,7 +159,6 @@ public class SimpleXMLGenerator implements XMLGenerator {
} }
} }
/** /**
* Fetches the current content item. This method can be overidden to * Fetches the current content item. This method can be overidden to
* fetch any {@link com.arsdigita.cms.ContentItem}, but by default, * fetch any {@link com.arsdigita.cms.ContentItem}, but by default,
@ -191,10 +192,9 @@ public class SimpleXMLGenerator implements XMLGenerator {
element.addAttribute("javaClass", UDItem.getContentType().getClassName()); element.addAttribute("javaClass", UDItem.getContentType().getClassName());
DynamicObjectType dot = new DynamicObjectType( DynamicObjectType dot = new DynamicObjectType(
UDItem.getSpecificObjectType() UDItem.getSpecificObjectType());
); Iterator declaredProperties =
Iterator declaredProperties = dot.getObjectType() dot.getObjectType().getDeclaredProperties();
.getDeclaredProperties();
Property currentProperty = null; Property currentProperty = null;
Object value = null; Object value = null;
while (declaredProperties.hasNext()) { while (declaredProperties.hasNext()) {
@ -216,11 +216,9 @@ public class SimpleXMLGenerator implements XMLGenerator {
} }
private Element startElement(String useContext) { private Element startElement(String useContext) {
Element element = new Element("cms:item", CMS.CMS_XML_NS); Element element = new Element("cms:item", CMS.CMS_XML_NS);
if ( useContext != null ) { if (useContext != null) {
element.addAttribute("useContext", useContext); element.addAttribute("useContext", useContext);
} }
return element; return element;
@ -242,5 +240,4 @@ public class SimpleXMLGenerator implements XMLGenerator {
element.addAttribute("UDItemAttrValue", value); element.addAttribute("UDItemAttrValue", value);
return element; return element;
} }
} }

View File

@ -38,18 +38,21 @@ public class ContentPageMetadataProvider extends ContentItemMetadataProvider {
public static final String ADAPTER_CONTEXT = public static final String ADAPTER_CONTEXT =
ContentPageMetadataProvider.class.getName(); ContentPageMetadataProvider.class.getName();
private static final Logger s_log = private static final Logger s_log =
Logger.getLogger(ContentPageMetadataProvider.class); Logger.getLogger(
ContentPageMetadataProvider.class);
public String getTitle(DomainObject dobj) { public String getTitle(DomainObject dobj) {
if (dobj instanceof ContentPage) { if (dobj instanceof ContentPage) {
ContentPage item = (ContentPage)dobj; ContentPage item = (ContentPage) dobj;
s_log.debug(String.format("getting title of item with oid '%s'",
item.getOID().toString()));
s_log.debug(String.format("and name '%s'", item.getName()));
s_log.debug(String.format("and title '%s'", item.getTitle()));
String title = item.getTitle(); String title = item.getTitle();
if (StringUtils.emptyString(title)) { if (StringUtils.emptyString(title)) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"ContentPage must have non-blank title!" "ContentPage must have non-blank title!");
);
} }
return title; return title;
} else { } else {
@ -62,7 +65,7 @@ public class ContentPageMetadataProvider extends ContentItemMetadataProvider {
public String getSummary(DomainObject dobj) { public String getSummary(DomainObject dobj) {
if (dobj instanceof ContentPage) { if (dobj instanceof ContentPage) {
ContentPage item = (ContentPage)dobj; ContentPage item = (ContentPage) dobj;
return item.getSearchSummary(); return item.getSearchSummary();
} else { } else {
return ""; return "";
@ -72,7 +75,7 @@ public class ContentPageMetadataProvider extends ContentItemMetadataProvider {
public String getContentSection(DomainObject dobj) { public String getContentSection(DomainObject dobj) {
String sectionName = ""; String sectionName = "";
if (dobj instanceof ContentPage) { if (dobj instanceof ContentPage) {
ContentPage item = (ContentPage)dobj; ContentPage item = (ContentPage) dobj;
ContentSection section = item.getContentSection(); ContentSection section = item.getContentSection();
if (section != null) { if (section != null) {
sectionName = section.getName(); sectionName = section.getName();

View File

@ -104,21 +104,39 @@ public class SimpleDomainObjectTraversalAdapter
/** /**
* Add a property to the attribute property set. * Add a property to the attribute property set.
* *
* @param path the full path to the property * @param prop the full path to the property
*/ */
public void addAttributeProperty(String prop) { public void addAttributeProperty(String prop) {
m_attr.add(prop); m_attr.add(prop);
} }
/**
* Removes a property from the attribute property set.
*
* @param prop full path of the property to remove
*/
public void removeAttributeProperty(String prop) {
m_attr.remove(prop);
}
/** /**
* Add a property to the association property set. * Add a property to the association property set.
* *
* @param path the full path to the property * @param prop the full path to the property
*/ */
public void addAssociationProperty(String prop) { public void addAssociationProperty(String prop) {
m_assoc.add(prop); m_assoc.add(prop);
} }
/**
* Removes a association property from the association property set.
*
* @param prop full path of the property to remove
*/
public void removeAssociationProperty(String prop) {
m_assoc.remove(prop);
}
/** /**
* Determines whether or not to allow processing * Determines whether or not to allow processing
* of a property, based on the property set and * of a property, based on the property set and

View File

@ -59,7 +59,6 @@ public class OID {
private ObjectType m_type; private ObjectType m_type;
private Map m_values = new HashMap(); private Map m_values = new HashMap();
/** some shorthand names for common content-types */ /** some shorthand names for common content-types */
private final static String[][] TYPE_SHORTHAND = { private final static String[][] TYPE_SHORTHAND = {
{"Article", "com.arsdigita.cms.contenttypes.Article"}, {"Article", "com.arsdigita.cms.contenttypes.Article"},
@ -71,20 +70,17 @@ public class OID {
{"SiteProxy", "com.arsdigita.cms.contenttypes.SiteProxy"}, {"SiteProxy", "com.arsdigita.cms.contenttypes.SiteProxy"},
{"RelatedLink", "com.arsdigita.cms.contentassets.RelatedLink"}, {"RelatedLink", "com.arsdigita.cms.contentassets.RelatedLink"},
{"FileAttachment", "com.arsdigita.cms.contentassets.FileAttachment"}, {"FileAttachment", "com.arsdigita.cms.contentassets.FileAttachment"},
{"Category", "com.arsdigita.categorization.Category"}, {"Category", "com.arsdigita.categorization.Category"},};
};
/** the separator character to be used in the new OID formatting scheme */ /** the separator character to be used in the new OID formatting scheme */
private final static char OID_SEPARATOR_CHAR = '-'; private final static char OID_SEPARATOR_CHAR = '-';
/** A Format used for formatting/parsing OIDs */ /** A Format used for formatting/parsing OIDs */
private static MessageFormat m_format_old = new MessageFormat("[{0}:{1}]"); private static MessageFormat m_format_old = new MessageFormat("[{0}:{1}]");
private static MessageFormat m_format_new = new MessageFormat("{0}" + OID_SEPARATOR_CHAR + "{1}"); private static MessageFormat m_format_new = new MessageFormat("{0}"
+ OID_SEPARATOR_CHAR
+ "{1}");
/** used to log errors */ /** used to log errors */
private static final Logger m_log = Logger.getLogger(OID.class); private static final Logger m_log = Logger.getLogger(OID.class);
/** /**
* Creates an OID for the Object type. An example of an object * Creates an OID for the Object type. An example of an object
* type would be "com.arsdigita.kernel.ACSObject." Using this * type would be "com.arsdigita.kernel.ACSObject." Using this
@ -148,8 +144,7 @@ public class OID {
if (it.hasNext()) { if (it.hasNext()) {
throw new PersistenceException( throw new PersistenceException(
"This object type has a compound key." "This object type has a compound key.");
);
} }
String attr = prop.getName(); String attr = prop.getName();
@ -172,7 +167,6 @@ public class OID {
return type; return type;
} }
/** /**
* Creates an OID for the named ObjectType. The typename of the * Creates an OID for the named ObjectType. The typename of the
* ObjectType must be defined in the MetadataRoot. An example * ObjectType must be defined in the MetadataRoot. An example
@ -197,7 +191,6 @@ public class OID {
this(lookup(typeName)); this(lookup(typeName));
} }
/** /**
* Creates an OID with a single attribute for the key. To create a * Creates an OID with a single attribute for the key. To create a
* multi-valued OID, use a single arg OID constructor, and add * multi-valued OID, use a single arg OID constructor, and add
@ -229,7 +222,6 @@ public class OID {
this(lookup(typeName), value); this(lookup(typeName), value);
} }
/** /**
* Creates an OID with a single attribute for the key. To create a * Creates an OID with a single attribute for the key. To create a
* multi-valued OID, use a single arg OID constructor, and add * multi-valued OID, use a single arg OID constructor, and add
@ -258,7 +250,6 @@ public class OID {
this(typeName, new BigDecimal(value)); this(typeName, new BigDecimal(value));
} }
/** /**
* Creates an OID with a single attribute for the key. To create a * Creates an OID with a single attribute for the key. To create a
* multi-valued OID, use a single arg OID constructor, and add * multi-valued OID, use a single arg OID constructor, and add
@ -300,8 +291,7 @@ public class OID {
// We do some type-checking here, to ensure that OIDs are being // We do some type-checking here, to ensure that OIDs are being
// created with legit types of values. // created with legit types of values.
if (prop == null) { if (prop == null) {
throw new PersistenceException throw new PersistenceException("no such property: " + propertyName
("no such property: " + propertyName
+ " for type " + m_type.getName()); + " for type " + m_type.getName());
} }
@ -310,12 +300,12 @@ public class OID {
if (prop.isAttribute() && value != null) { if (prop.isAttribute() && value != null) {
// we can be sure this is a simpletype because // we can be sure this is a simpletype because
// isAttribute was true. // isAttribute was true.
SimpleType expectedType = (SimpleType)prop.getType(); SimpleType expectedType = (SimpleType) prop.getType();
if (!expectedType.getJavaClass() if (!expectedType.getJavaClass().isAssignableFrom(value.getClass())) {
.isAssignableFrom(value.getClass())) { throw new PersistenceException("expected " + expectedType.
throw new PersistenceException getJavaClass()
("expected " + expectedType.getJavaClass() + "actual type "
+ "actual type " + value.getClass()); + value.getClass());
} }
} else if (value != null) { } else if (value != null) {
if (value instanceof DataObject) { if (value instanceof DataObject) {
@ -323,15 +313,15 @@ public class OID {
DataObject dobj = (DataObject) value; DataObject dobj = (DataObject) value;
ObjectType.verifySubtype(ot, dobj.getObjectType()); ObjectType.verifySubtype(ot, dobj.getObjectType());
} else { } else {
throw new PersistenceException throw new PersistenceException("expected DataObject for property "
("expected DataObject for property " + propertyName + propertyName
+ " but got " + value.getClass()); + " but got " + value.getClass());
} }
} }
if (hasProperty(propertyName)) { if (hasProperty(propertyName)) {
throw new PersistenceException throw new PersistenceException(propertyName + " is already set to " + get(
(propertyName + " is already set to " + get(propertyName)); propertyName));
} }
m_values.put(propertyName, value); m_values.put(propertyName, value);
@ -365,7 +355,7 @@ public class OID {
} }
public boolean isInitialized() { public boolean isInitialized() {
for (Iterator it = m_type.getKeyProperties(); it.hasNext(); ) { for (Iterator it = m_type.getKeyProperties(); it.hasNext();) {
if (!m_values.containsKey(((Property) it.next()).getName())) { if (!m_values.containsKey(((Property) it.next()).getName())) {
return false; return false;
} }
@ -405,7 +395,6 @@ public class OID {
return getObjectType(); return getObjectType();
} }
/** /**
* @return The ObjectType. * @return The ObjectType.
**/ **/
@ -418,7 +407,6 @@ public class OID {
m_type = subtype; m_type = subtype;
} }
/** /**
* Serializes the OID. * Serializes the OID.
*/ */
@ -426,7 +414,7 @@ public class OID {
String fullType = m_type.getQualifiedName(); String fullType = m_type.getQualifiedName();
Map props = getProperties(); Map props = getProperties();
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
for(Iterator it = props.keySet().iterator(); it.hasNext(); ) { for (Iterator it = props.keySet().iterator(); it.hasNext();) {
Object key = it.next(); Object key = it.next();
Object value = props.get(key); Object value = props.get(key);
/*if ((key == null) || (value == null)) { /*if ((key == null) || (value == null)) {
@ -440,8 +428,8 @@ public class OID {
* a NPE in the line below the if. * a NPE in the line below the if.
*/ */
if (null == value) { if (null == value) {
m_log.info(String.format("The value for prop \"%s\" " + m_log.info(String.format("The value for prop \"%s\" "
"is null. Ignoring.", key)); + "is null. Ignoring.", key));
continue; continue;
} }
/* /*
@ -462,7 +450,6 @@ public class OID {
return m_format_new.format(args); return m_format_new.format(args);
} }
/** Parse the oid string. If it contains a left-square-bracket, /** Parse the oid string. If it contains a left-square-bracket,
* use the old parsing scheme. Otherwise, use the new parser. * use the old parsing scheme. Otherwise, use the new parser.
*/ */
@ -478,8 +465,9 @@ public class OID {
public static OID valueOfNew(String s) throws IllegalArgumentException { public static OID valueOfNew(String s) throws IllegalArgumentException {
StringTokenizer st = new StringTokenizer(s, "" + OID_SEPARATOR_CHAR); StringTokenizer st = new StringTokenizer(s, "" + OID_SEPARATOR_CHAR);
if (st.countTokens() < 2) { if (st.countTokens() < 2) {
throw new IllegalArgumentException throw new IllegalArgumentException(
("Invalid OID '" + s + "'. It must have at least the object type and the value"); "Invalid OID '" + s
+ "'. It must have at least the object type and the value");
// } else if (st.countTokens() % 2 != 1) { // } else if (st.countTokens() % 2 != 1) {
// throw new IllegalArgumentException // throw new IllegalArgumentException
// ("Invalid OID '" + s + "'. It must have type followed by name-value pairs"); // ("Invalid OID '" + s + "'. It must have type followed by name-value pairs");
@ -515,22 +503,23 @@ public class OID {
} }
return oid; return oid;
} catch (PersistenceException e) { } catch (PersistenceException e) {
throw new IllegalArgumentException throw new IllegalArgumentException("Invalid OID '" + s
("Invalid OID '" + s + "'. The type specified [" + type + + "'. The type specified ["
"] is not defined"); + type + "] is not defined");
} }
} }
// Couldn't get MessageFormat to work, so I cheated // Couldn't get MessageFormat to work, so I cheated
public static OID valueOfOld(String s) throws IllegalArgumentException { public static OID valueOfOld(String s) throws IllegalArgumentException {
m_log.debug(String.format("Trying to parse OID '%s'...", s));
StringTokenizer st = new StringTokenizer(s, "[:{}],"); StringTokenizer st = new StringTokenizer(s, "[:{}],");
if (st.countTokens() < 2) { if (st.countTokens() < 2) {
st = new StringTokenizer(java.net.URLDecoder.decode(s), "[:{}],"); st = new StringTokenizer(java.net.URLDecoder.decode(s), "[:{}],");
if (st.countTokens() < 2) { if (st.countTokens() < 2) {
throw new IllegalArgumentException throw new IllegalArgumentException("Invalid OID '" + s
("Invalid OID '" + s + "'. It must have at least the object " + + "'. It must have at least the object "
"type and the value"); + "type and the value");
} }
} }
@ -547,6 +536,15 @@ public class OID {
while (st.hasMoreTokens()) { while (st.hasMoreTokens()) {
String nextToken = st.nextToken(); String nextToken = st.nextToken();
int index = nextToken.indexOf("="); int index = nextToken.indexOf("=");
/**
* jensp 2010-11-03: If next token is an empty string, or there
* no '=', throw an exeception.
*/
if ((nextToken.length() < 1) || (index < 0)) {
throw new IllegalArgumentException("Invalid OID '" + s
+ "'. It must have at least the object "
+ "type and the value");
}
String key = (nextToken.substring(0, index)); String key = (nextToken.substring(0, index));
String value = nextToken.substring(index + 1); String value = nextToken.substring(index + 1);
@ -561,8 +559,7 @@ public class OID {
boolean bigDecimal = true; boolean bigDecimal = true;
for (int i = 0; i < value.length(); i++) { for (int i = 0; i < value.length(); i++) {
char c = value.charAt(i); char c = value.charAt(i);
if (!('0' <= c && c <= '9') && if (!('0' <= c && c <= '9') && !((i == 0) && (c == '-'))) {
!((i == 0) && (c == '-'))) {
bigDecimal = false; bigDecimal = false;
break; break;
} }
@ -577,9 +574,9 @@ public class OID {
} }
return oid; return oid;
} catch (PersistenceException e) { } catch (PersistenceException e) {
throw new IllegalArgumentException throw new IllegalArgumentException("Invalid OID '" + s
("Invalid OID '" + s + "'. The type specified [" + type + + "'. The type specified ["
"] is not defined"); + type + "] is not defined");
} }
} }
@ -591,11 +588,11 @@ public class OID {
* for an example). */ * for an example). */
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj instanceof OID) { if (obj instanceof OID) {
OID oid = (OID)obj; OID oid = (OID) obj;
// we rely on the toString ecause the HashMap.equals does not // we rely on the toString ecause the HashMap.equals does not
// give us what we need // give us what we need
return m_type.getBasetype().equals(oid.m_type.getBasetype()) && return m_type.getBasetype().equals(oid.m_type.getBasetype()) && m_values.
m_values.equals(oid.m_values); equals(oid.m_values);
} }
return false; return false;
} }
@ -613,7 +610,7 @@ public class OID {
/** create shorthand names for some common types */ /** create shorthand names for some common types */
private static String convertTypeShorthand(String name) { private static String convertTypeShorthand(String name) {
for (int i=0; i<TYPE_SHORTHAND.length; ++i) { for (int i = 0; i < TYPE_SHORTHAND.length; ++i) {
if (name.equals(TYPE_SHORTHAND[i][1])) { if (name.equals(TYPE_SHORTHAND[i][1])) {
return TYPE_SHORTHAND[i][0]; return TYPE_SHORTHAND[i][0];
} }
@ -623,7 +620,7 @@ public class OID {
/** create longhand name for some common types */ /** create longhand name for some common types */
private static String convertTypeLonghand(String name) { private static String convertTypeLonghand(String name) {
for (int i=0; i<TYPE_SHORTHAND.length; ++i) { for (int i = 0; i < TYPE_SHORTHAND.length; ++i) {
if (name.equals(TYPE_SHORTHAND[i][0])) { if (name.equals(TYPE_SHORTHAND[i][0])) {
return TYPE_SHORTHAND[i][1]; return TYPE_SHORTHAND[i][1];
} }

View File

@ -61,3 +61,5 @@ log4j.logger.com.arsdigita.packaging.Loader=INFO
# For debugging all queries run by persistence # For debugging all queries run by persistence
#log4j.logger.com.redhat.persistence.engine.rdbms.RDBMSEngine=INFO #log4j.logger.com.redhat.persistence.engine.rdbms.RDBMSEngine=INFO
log4j.logger.com.arsdigita.cms.search.ContentPageMetadataProvider=DEBUG
log4j.logger.com.arsdigita.london.importer=DEBUG

View File

@ -28,6 +28,7 @@ import org.apache.log4j.Logger;
import com.arsdigita.cms.ContentBundle; import com.arsdigita.cms.ContentBundle;
import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.Folder; import com.arsdigita.cms.Folder;
import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.domain.DataObjectNotFoundException;
@ -152,6 +153,17 @@ public class ItemImportTool extends Program {
ContentItem item = ContentItem item =
(ContentItem) itemParser.getDomainObject(); (ContentItem) itemParser.getDomainObject();
if (item == null) {
s_log.warn("item is null.Igoring...");
return;
}
s_log.debug(String.format("Got item from ItemParser:"));
s_log.debug(String.format("OID : %s", item.getOID()));
s_log.debug(String.format("Name : %s", item.getName()));
s_log.debug(String.format("Title: %s", item.get("title")));
if (item instanceof ContentPage) {
s_log.debug("Item is a content page...");
}
/* /*
* Multi lang extension begin * Multi lang extension begin
*/ */
@ -160,8 +172,15 @@ public class ItemImportTool extends Program {
if (itemName.lastIndexOf('-') == -1) { if (itemName.lastIndexOf('-') == -1) {
bundleName = itemName; bundleName = itemName;
} else { } else {
if (itemName.substring((itemName.lastIndexOf('-') + 1)).
equals("de")
|| itemName.substring((itemName.lastIndexOf('-') + 1)).
equals("en")) {
bundleName = itemName.substring(0, itemName. bundleName = itemName.substring(0, itemName.
lastIndexOf('-')); lastIndexOf('-'));
} else {
bundleName = itemName;
}
} }
/* /*
* Multi lang extension end * Multi lang extension end
@ -177,19 +196,25 @@ public class ItemImportTool extends Program {
* Multi lang extension start * Multi lang extension start
*/ */
ContentBundle bundle; ContentBundle bundle;
s_log.debug(String.format("Bundle name: %s",
bundleName));
if (itemName.lastIndexOf('-') == -1) { if (itemName.lastIndexOf('-') == -1) {
s_log.debug("Item is not localized...");
bundle = new ContentBundle(item); bundle = new ContentBundle(item);
bundle.setParent(folder); bundle.setParent(folder);
bundle.setName(bundleName); bundle.setName(bundleName);
bundles.put(bundleName, bundle); bundles.put(bundleName, bundle);
} else { } else {
s_log.debug("Item is localized...");
bundle = bundles.get(bundleName); bundle = bundles.get(bundleName);
if (bundle == null) { if (bundle == null) {
s_log.debug("No content bundle found for item, creating new.");
bundle = new ContentBundle(item); bundle = new ContentBundle(item);
bundle.setParent(folder); bundle.setParent(folder);
bundle.setName(bundleName); bundle.setName(bundleName);
bundles.put(bundleName, bundle); bundles.put(bundleName, bundle);
} else { } else {
s_log.debug("Found content bundle for item, adding item as instance.");
bundle.addInstance(item); bundle.addInstance(item);
} }
} }

View File

@ -12,8 +12,20 @@
<xrd:associations rule="include"> <xrd:associations rule="include">
<xrd:property name="/object/addendum"/> <xrd:property name="/object/addendum"/>
<xrd:property name="/object/contacts"/> <xrd:property name="/object/contacts"/>
<xrd:property name="/object/orgaunit_children"/> <xrd:property name="/object/contacts/person"/>
<xrd:property name="/object/contacts/address"/>
<xrd:property name="/object/contacts/contactentries"/>
<xrd:property name="/object/subDepartments"/>
<xrd:property name="/object/subDepartments/projects"/>
<xrd:property name="/object/subDepartments/contacts"/>
<xrd:property name="/object/subDepartments/contacts/address"/>
<xrd:property name="/object/subDepartments/contacts/contactentries"/>
<xrd:property name="/object/projects"/>
<xrd:property name="/object/projects/persons"/>
<xrd:property name="/object/persons"/> <xrd:property name="/object/persons"/>
<xrd:property name="/object/persons/contacts"/>
<xrd:property name="/object/persons/contacts/address"/>
<xrd:property name="/object/persons/contacts/contactentries"/>
</xrd:associations> </xrd:associations>
</xrd:adapter> </xrd:adapter>
</xrd:context> </xrd:context>

View File

@ -16,12 +16,17 @@
<xrd:property name="/object/contacts/person"/> <xrd:property name="/object/contacts/person"/>
<xrd:property name="/object/contacts/address"/> <xrd:property name="/object/contacts/address"/>
<xrd:property name="/object/contacts/contactentries"/> <xrd:property name="/object/contacts/contactentries"/>
<xrd:property name="/object/contacts/person"/>
<xrd:property name="/object/departments"/> <xrd:property name="/object/departments"/>
<xrd:property name="/object/departments/persons"/> <xrd:property name="/object/departments/persons"/>
<xrd:property name="/object/departments/persons/contacts"/>
<xrd:property name="/object/departments/persons/contacts/address"/>
<xrd:property name="/object/departments/persons/contacts/contactentries"/>
<xrd:property name="/object/projects"/> <xrd:property name="/object/projects"/>
<xrd:property name="/object/projects/persons"/> <xrd:property name="/object/projects/persons"/>
<xrd:property name="/object/persons"/> <xrd:property name="/object/persons"/>
<xrd:property name="/object/persons/contacts"/>
<xrd:property name="/object/persons/contacts/address"/>
<xrd:property name="/object/persons/contacts/contactentries"/>
</xrd:associations> </xrd:associations>
</xrd:adapter> </xrd:adapter>
</xrd:context> </xrd:context>