- 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
* the content item's primary adapter
*/
@Override
public boolean processProperty(DomainObject obj,
String path,
Property prop,

View File

@ -18,7 +18,6 @@
*/
package com.arsdigita.cms.dispatcher;
import com.arsdigita.bebop.PageState;
import com.arsdigita.cms.CMS;
import com.arsdigita.cms.ContentItem;
@ -45,7 +44,6 @@ import org.apache.log4j.Logger;
import java.util.Iterator;
/**
* <p>The default <tt>XMLGenerator</tt> implementation.</p>
*
@ -56,25 +54,25 @@ import java.util.Iterator;
public class SimpleXMLGenerator implements XMLGenerator {
private static Logger s_log =
Logger.getLogger(SimpleXMLGenerator.class);
public static final String ADAPTER_CONTEXT = SimpleXMLGenerator.class.getName();
Logger.getLogger(SimpleXMLGenerator.class);
public static final String ADAPTER_CONTEXT = SimpleXMLGenerator.class.
getName();
// Register general purpose adaptor for all content items
static {
SimpleDomainObjectTraversalAdapter adapter =
new SimpleDomainObjectTraversalAdapter();
new SimpleDomainObjectTraversalAdapter();
adapter.addAssociationProperty("/object/type");
adapter.addAssociationProperty("/object/categories");
DomainObjectTraversal.registerAdapter(
ContentItem.BASE_DATA_OBJECT_TYPE,
adapter,
ADAPTER_CONTEXT
);
ContentItem.BASE_DATA_OBJECT_TYPE,
adapter,
ADAPTER_CONTEXT);
}
public SimpleXMLGenerator() {}
public SimpleXMLGenerator() {
}
/**
* Generates the XML to render the content panel.
@ -90,61 +88,65 @@ public class SimpleXMLGenerator implements XMLGenerator {
s_log.info("Generate XML for item " + item.getOID());
Party currentParty = Kernel.getContext().getParty();
if (currentParty == null) {
currentParty = Kernel.getPublicUser();
}
// check if current user can edit the current item (nb privilege is granted on draft item, but live item
// has draft as its permission context
//
// Note that the xml that is generated is only of use if you DO NOT CACHE content pages.
// cg.
PermissionDescriptor edit = new PermissionDescriptor(PrivilegeDescriptor.get(SecurityManager.CMS_EDIT_ITEM), item, currentParty);
if (PermissionService.checkPermission(edit)) {
parent.addAttribute("canEdit", "true");
}
PermissionDescriptor publish = new PermissionDescriptor(PrivilegeDescriptor.get(SecurityManager.CMS_PUBLISH), item, currentParty);
if (PermissionService.checkPermission(publish)) {
parent.addAttribute("canPublish", "true");
}
Party currentParty = Kernel.getContext().getParty();
if (currentParty == null) {
currentParty = Kernel.getPublicUser();
}
// check if current user can edit the current item (nb privilege is granted on draft item, but live item
// has draft as its permission context
//
// Note that the xml that is generated is only of use if you DO NOT CACHE content pages.
// cg.
PermissionDescriptor edit = new PermissionDescriptor(PrivilegeDescriptor.
get(SecurityManager.CMS_EDIT_ITEM), item, currentParty);
if (PermissionService.checkPermission(edit)) {
parent.addAttribute("canEdit", "true");
}
PermissionDescriptor publish = new PermissionDescriptor(PrivilegeDescriptor.
get(SecurityManager.CMS_PUBLISH), item, currentParty);
if (PermissionService.checkPermission(publish)) {
parent.addAttribute("canPublish", "true");
}
String className = item.getDefaultDomainClass();
// Ensure correct subtype of ContentItem is instantiated
if (!item.getClass().getName().equals(className)) {
s_log.info("Specializing item");
try {
item = (ContentItem)DomainObjectFactory
.newInstance(new OID(item.getObjectType().getQualifiedName(),
item.getID()));
item = (ContentItem) DomainObjectFactory.newInstance(new OID(item.
getObjectType().getQualifiedName(),
item.
getID()));
} catch (DataObjectNotFoundException ex) {
throw new UncheckedWrapperException(
(String)GlobalizationUtil.globalize(
"cms.dispatcher.cannot_find_domain_object"
).localize(), ex);
throw new UncheckedWrapperException(
(String) GlobalizationUtil.globalize(
"cms.dispatcher.cannot_find_domain_object").localize(),
ex);
}
}
// Implementing XMLGenerator directly is now deprecated
if ( item instanceof XMLGenerator) {
if (item instanceof XMLGenerator) {
s_log.info("Item implements XMLGenerator interface");
XMLGenerator xitem = (XMLGenerator)item;
XMLGenerator xitem = (XMLGenerator) item;
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");
UserDefinedContentItem UDItem = (UserDefinedContentItem)item;
UserDefinedContentItem UDItem = (UserDefinedContentItem) item;
generateUDItemXML(UDItem, state, parent, useContext);
} else {
s_log.info("Item is using DomainObjectXMLRenderer");
// This is the preferred method
Element content = startElement(useContext);
ContentItemXMLRenderer renderer =
new ContentItemXMLRenderer(content);
new ContentItemXMLRenderer(content);
renderer.setWrapAttributes(true);
renderer.setWrapRoot(false);
@ -157,7 +159,6 @@ public class SimpleXMLGenerator implements XMLGenerator {
}
}
/**
* Fetches the current content item. This method can be overidden to
* 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());
DynamicObjectType dot = new DynamicObjectType(
UDItem.getSpecificObjectType()
);
Iterator declaredProperties = dot.getObjectType()
.getDeclaredProperties();
UDItem.getSpecificObjectType());
Iterator declaredProperties =
dot.getObjectType().getDeclaredProperties();
Property currentProperty = null;
Object value = null;
while (declaredProperties.hasNext()) {
@ -202,12 +202,12 @@ public class SimpleXMLGenerator implements XMLGenerator {
value = (Object) UDItem.get(currentProperty.getName());
if (value != null) {
element.addContent(
UDItemAttrElement(currentProperty.getName(),
value.toString()));
UDItemAttrElement(currentProperty.getName(),
value.toString()));
} else {
element.addContent(
UDItemAttrElement(currentProperty.getName(),
"none specified"));
UDItemAttrElement(currentProperty.getName(),
"none specified"));
}
}
@ -216,11 +216,9 @@ public class SimpleXMLGenerator implements XMLGenerator {
}
private Element startElement(String useContext) {
Element element = new Element("cms:item", CMS.CMS_XML_NS);
if ( useContext != null ) {
if (useContext != null) {
element.addAttribute("useContext", useContext);
}
return element;
@ -229,10 +227,10 @@ public class SimpleXMLGenerator implements XMLGenerator {
private Element UDItemElement(String useContext) {
Element element = new Element("cms:UDItemAttributes", CMS.CMS_XML_NS);
/*
if ( useContext != null ) {
element.addAttribute("useContext", useContext);
}
*/
if ( useContext != null ) {
element.addAttribute("useContext", useContext);
}
*/
return element;
}
@ -242,5 +240,4 @@ public class SimpleXMLGenerator implements XMLGenerator {
element.addAttribute("UDItemAttrValue", value);
return element;
}
}

View File

@ -37,33 +37,36 @@ import org.apache.log4j.Logger;
public class ContentPageMetadataProvider extends ContentItemMetadataProvider {
public static final String ADAPTER_CONTEXT =
ContentPageMetadataProvider.class.getName();
private static final Logger s_log =
Logger.getLogger(ContentPageMetadataProvider.class);
ContentPageMetadataProvider.class.getName();
private static final Logger s_log =
Logger.getLogger(
ContentPageMetadataProvider.class);
public String getTitle(DomainObject dobj) {
if (dobj instanceof ContentPage) {
ContentPage item = (ContentPage)dobj;
String title = item.getTitle();
if (StringUtils.emptyString(title)) {
throw new IllegalArgumentException(
"ContentPage must have non-blank title!"
);
}
return title;
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();
if (StringUtils.emptyString(title)) {
throw new IllegalArgumentException(
"ContentPage must have non-blank title!");
}
return title;
} else {
// this is not pretty,
// but fails more gracefully for items which are not contentpages
s_log.warn("Item is not a ContentPage.");
s_log.warn("Item is not a ContentPage.");
return "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
}
}
public String getSummary(DomainObject dobj) {
if (dobj instanceof ContentPage) {
ContentPage item = (ContentPage)dobj;
return item.getSearchSummary();
ContentPage item = (ContentPage) dobj;
return item.getSearchSummary();
} else {
return "";
}
@ -72,11 +75,11 @@ public class ContentPageMetadataProvider extends ContentItemMetadataProvider {
public String getContentSection(DomainObject dobj) {
String sectionName = "";
if (dobj instanceof ContentPage) {
ContentPage item = (ContentPage)dobj;
ContentSection section = item.getContentSection();
if (section != null) {
sectionName = section.getName();
}
ContentPage item = (ContentPage) dobj;
ContentSection section = item.getContentSection();
if (section != null) {
sectionName = section.getName();
}
}
return sectionName;
}

View File

@ -104,21 +104,39 @@ public class SimpleDomainObjectTraversalAdapter
/**
* 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) {
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.
*
* @param path the full path to the property
* @param prop the full path to the property
*/
public void addAssociationProperty(String 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
* of a property, based on the property set and

View File

@ -59,32 +59,28 @@ public class OID {
private ObjectType m_type;
private Map m_values = new HashMap();
/** some shorthand names for common content-types */
private final static String[][] TYPE_SHORTHAND = {
{"Article", "com.arsdigita.cms.contenttypes.Article"},
{"MultiPartArticle", "com.arsdigita.cms.contenttypes.MultiPartArticle"},
{"PressRelease", "com.arsdigita.cms.contenttypes.PressRelease"},
{"NewsItem", "com.arsdigita.cms.contenttypes.NewsItem"},
{"Bookmark", "com.arsdigita.cms.contenttypes.Bookmark"},
{"ESDService", "com.arsdigita.cms.contenttypes.ESDService"},
{"SiteProxy", "com.arsdigita.cms.contenttypes.SiteProxy"},
{"RelatedLink", "com.arsdigita.cms.contentassets.RelatedLink"},
{"FileAttachment", "com.arsdigita.cms.contentassets.FileAttachment"},
{"Category", "com.arsdigita.categorization.Category"},
};
{"Article", "com.arsdigita.cms.contenttypes.Article"},
{"MultiPartArticle", "com.arsdigita.cms.contenttypes.MultiPartArticle"},
{"PressRelease", "com.arsdigita.cms.contenttypes.PressRelease"},
{"NewsItem", "com.arsdigita.cms.contenttypes.NewsItem"},
{"Bookmark", "com.arsdigita.cms.contenttypes.Bookmark"},
{"ESDService", "com.arsdigita.cms.contenttypes.ESDService"},
{"SiteProxy", "com.arsdigita.cms.contenttypes.SiteProxy"},
{"RelatedLink", "com.arsdigita.cms.contentassets.RelatedLink"},
{"FileAttachment", "com.arsdigita.cms.contentassets.FileAttachment"},
{"Category", "com.arsdigita.categorization.Category"},};
/** the separator character to be used in the new OID formatting scheme */
private final static char OID_SEPARATOR_CHAR = '-';
/** A Format used for formatting/parsing OIDs */
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 */
private static final Logger m_log = Logger.getLogger(OID.class);
/**
* Creates an OID for the Object type. An example of an object
* type would be "com.arsdigita.kernel.ACSObject." Using this
@ -148,8 +144,7 @@ public class OID {
if (it.hasNext()) {
throw new PersistenceException(
"This object type has a compound key."
);
"This object type has a compound key.");
}
String attr = prop.getName();
@ -165,14 +160,13 @@ public class OID {
*/
private static final ObjectType lookup(String typeName) {
ObjectType type =
MetadataRoot.getMetadataRoot().getObjectType(typeName);
MetadataRoot.getMetadataRoot().getObjectType(typeName);
if (type == null) {
throw new PersistenceException("No such type " + typeName);
}
return type;
}
/**
* Creates an OID for the named ObjectType. The typename of the
* ObjectType must be defined in the MetadataRoot. An example
@ -197,7 +191,6 @@ public class OID {
this(lookup(typeName));
}
/**
* Creates an OID with a single attribute for the key. To create a
* multi-valued OID, use a single arg OID constructor, and add
@ -229,7 +222,6 @@ public class OID {
this(lookup(typeName), value);
}
/**
* Creates an OID with a single attribute for the key. To create a
* multi-valued OID, use a single arg OID constructor, and add
@ -258,7 +250,6 @@ public class OID {
this(typeName, new BigDecimal(value));
}
/**
* Creates an OID with a single attribute for the key. To create a
* multi-valued OID, use a single arg OID constructor, and add
@ -300,9 +291,8 @@ public class OID {
// We do some type-checking here, to ensure that OIDs are being
// created with legit types of values.
if (prop == null) {
throw new PersistenceException
("no such property: " + propertyName
+ " for type " + m_type.getName());
throw new PersistenceException("no such property: " + propertyName
+ " for type " + m_type.getName());
}
// null has no type
@ -310,12 +300,12 @@ public class OID {
if (prop.isAttribute() && value != null) {
// we can be sure this is a simpletype because
// isAttribute was true.
SimpleType expectedType = (SimpleType)prop.getType();
if (!expectedType.getJavaClass()
.isAssignableFrom(value.getClass())) {
throw new PersistenceException
("expected " + expectedType.getJavaClass()
+ "actual type " + value.getClass());
SimpleType expectedType = (SimpleType) prop.getType();
if (!expectedType.getJavaClass().isAssignableFrom(value.getClass())) {
throw new PersistenceException("expected " + expectedType.
getJavaClass()
+ "actual type "
+ value.getClass());
}
} else if (value != null) {
if (value instanceof DataObject) {
@ -323,15 +313,15 @@ public class OID {
DataObject dobj = (DataObject) value;
ObjectType.verifySubtype(ot, dobj.getObjectType());
} else {
throw new PersistenceException
("expected DataObject for property " + propertyName
+ " but got " + value.getClass());
throw new PersistenceException("expected DataObject for property "
+ propertyName
+ " but got " + value.getClass());
}
}
if (hasProperty(propertyName)) {
throw new PersistenceException
(propertyName + " is already set to " + get(propertyName));
throw new PersistenceException(propertyName + " is already set to " + get(
propertyName));
}
m_values.put(propertyName, value);
@ -365,7 +355,7 @@ public class OID {
}
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())) {
return false;
}
@ -405,7 +395,6 @@ public class OID {
return getObjectType();
}
/**
* @return The ObjectType.
**/
@ -418,7 +407,6 @@ public class OID {
m_type = subtype;
}
/**
* Serializes the OID.
*/
@ -426,60 +414,60 @@ public class OID {
String fullType = m_type.getQualifiedName();
Map props = getProperties();
StringBuffer sb = new StringBuffer();
for(Iterator it = props.keySet().iterator(); it.hasNext(); ) {
Object key = it.next();
Object value = props.get(key);
/*if ((key == null) || (value == null)) {
m_log.warn("key or value in OID.toString() are null");
m_log.warn(String.format("key = %s", key));
m_log.warn(String.format("value = %s", value));
}*/
/*
* Changed by Jens Pelzetter 2010-09-14. For unknown reasons
* the value is null for some properties, which causes
* a NPE in the line below the if.
*/
if (null == value) {
m_log.info(String.format("The value for prop \"%s\" " +
"is null. Ignoring.", key));
continue;
}
/*
* Changed by Jens Pelzetter 2010-09-14.
*
* The old method (see below) is very slow, because of this
* has been changed.
*/
sb.append(key.toString());
for (Iterator it = props.keySet().iterator(); it.hasNext();) {
Object key = it.next();
Object value = props.get(key);
/*if ((key == null) || (value == null)) {
m_log.warn("key or value in OID.toString() are null");
m_log.warn(String.format("key = %s", key));
m_log.warn(String.format("value = %s", value));
}*/
/*
* Changed by Jens Pelzetter 2010-09-14. For unknown reasons
* the value is null for some properties, which causes
* a NPE in the line below the if.
*/
if (null == value) {
m_log.info(String.format("The value for prop \"%s\" "
+ "is null. Ignoring.", key));
continue;
}
/*
* Changed by Jens Pelzetter 2010-09-14.
*
* The old method (see below) is very slow, because of this
* has been changed.
*/
sb.append(key.toString());
sb.append(OID_SEPARATOR_CHAR);
sb.append(value.toString());
//sb.append(key.toString() + OID_SEPARATOR_CHAR + value.toString());
if (it.hasNext()) {
sb.append(OID_SEPARATOR_CHAR);
sb.append(value.toString());
//sb.append(key.toString() + OID_SEPARATOR_CHAR + value.toString());
if (it.hasNext()) {
sb.append(OID_SEPARATOR_CHAR);
}
}
}
Object[] args = {convertTypeShorthand(fullType), sb.toString()};
return m_format_new.format(args);
}
/** Parse the oid string. If it contains a left-square-bracket,
* use the old parsing scheme. Otherwise, use the new parser.
*/
public static OID valueOf(String s) throws IllegalArgumentException {
if (s.indexOf("[") >= 0 || s.indexOf("%5B") >= 0) {
return valueOfOld(s);
} else {
return valueOfNew(s);
}
if (s.indexOf("[") >= 0 || s.indexOf("%5B") >= 0) {
return valueOfOld(s);
} else {
return valueOfNew(s);
}
}
/** new way to parse the OID string */
public static OID valueOfNew(String s) throws IllegalArgumentException {
StringTokenizer st = new StringTokenizer(s, "" + OID_SEPARATOR_CHAR);
if (st.countTokens() < 2) {
throw new IllegalArgumentException
("Invalid OID '" + s + "'. It must have at least the object type and the value");
throw new IllegalArgumentException(
"Invalid OID '" + s
+ "'. It must have at least the object type and the value");
// } else if (st.countTokens() % 2 != 1) {
// throw new IllegalArgumentException
// ("Invalid OID '" + s + "'. It must have type followed by name-value pairs");
@ -488,49 +476,50 @@ public class OID {
String type = convertTypeLonghand(st.nextToken());
try {
OID oid = new OID(type);
OID oid = new OID(type);
if (st.hasMoreTokens()) {
String key = st.nextToken();
String value = st.nextToken();
while (st.hasMoreTokens()) {
value = value + OID_SEPARATOR_CHAR + st.nextToken();
}
// if it can be a BigDecimal, that is what we make it
boolean bigDecimal = true;
for (int i = 0; i < value.length(); i++) {
char c = value.charAt(i);
if (!('0' <= c && c <= '9') && !((i == 0) && (c == '-'))) {
bigDecimal = false;
break;
}
}
if (bigDecimal) {
oid.set(key, new BigDecimal(value));
} else {
oid.set(key, value);
}
}
if (st.hasMoreTokens()) {
String key = st.nextToken();
String value = st.nextToken();
while (st.hasMoreTokens()) {
value = value + OID_SEPARATOR_CHAR + st.nextToken();
}
// if it can be a BigDecimal, that is what we make it
boolean bigDecimal = true;
for (int i = 0; i < value.length(); i++) {
char c = value.charAt(i);
if (!('0' <= c && c <= '9') && !((i == 0) && (c == '-'))) {
bigDecimal = false;
break;
}
}
if (bigDecimal) {
oid.set(key, new BigDecimal(value));
} else {
oid.set(key, value);
}
}
return oid;
} catch (PersistenceException e) {
throw new IllegalArgumentException
("Invalid OID '" + s + "'. The type specified [" + type +
"] is not defined");
}
} catch (PersistenceException e) {
throw new IllegalArgumentException("Invalid OID '" + s
+ "'. The type specified ["
+ type + "] is not defined");
}
}
// Couldn't get MessageFormat to work, so I cheated
public static OID valueOfOld(String s) throws IllegalArgumentException {
m_log.debug(String.format("Trying to parse OID '%s'...", s));
StringTokenizer st = new StringTokenizer(s, "[:{}],");
if (st.countTokens() < 2) {
st = new StringTokenizer(java.net.URLDecoder.decode(s), "[:{}],");
if (st.countTokens() < 2) {
throw new IllegalArgumentException
("Invalid OID '" + s + "'. It must have at least the object " +
"type and the value");
throw new IllegalArgumentException("Invalid OID '" + s
+ "'. It must have at least the object "
+ "type and the value");
}
}
@ -547,6 +536,15 @@ public class OID {
while (st.hasMoreTokens()) {
String nextToken = st.nextToken();
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 value = nextToken.substring(index + 1);
@ -561,8 +559,7 @@ public class OID {
boolean bigDecimal = true;
for (int i = 0; i < value.length(); i++) {
char c = value.charAt(i);
if (!('0' <= c && c <= '9') &&
!((i == 0) && (c == '-'))) {
if (!('0' <= c && c <= '9') && !((i == 0) && (c == '-'))) {
bigDecimal = false;
break;
}
@ -577,9 +574,9 @@ public class OID {
}
return oid;
} catch (PersistenceException e) {
throw new IllegalArgumentException
("Invalid OID '" + s + "'. The type specified [" + type +
"] is not defined");
throw new IllegalArgumentException("Invalid OID '" + s
+ "'. The type specified ["
+ type + "] is not defined");
}
}
@ -591,11 +588,11 @@ public class OID {
* for an example). */
public boolean equals(Object obj) {
if (obj instanceof OID) {
OID oid = (OID)obj;
OID oid = (OID) obj;
// we rely on the toString ecause the HashMap.equals does not
// give us what we need
return m_type.getBasetype().equals(oid.m_type.getBasetype()) &&
m_values.equals(oid.m_values);
return m_type.getBasetype().equals(oid.m_type.getBasetype()) && m_values.
equals(oid.m_values);
}
return false;
}
@ -610,24 +607,24 @@ public class OID {
// to base its hashcode on the hashcodes of the contained values.
return (m_type.getBasetype().hashCode() + m_values.hashCode());
}
/** create shorthand names for some common types */
private static String convertTypeShorthand(String name) {
for (int i=0; i<TYPE_SHORTHAND.length; ++i) {
if (name.equals(TYPE_SHORTHAND[i][1])) {
return TYPE_SHORTHAND[i][0];
}
}
return name;
for (int i = 0; i < TYPE_SHORTHAND.length; ++i) {
if (name.equals(TYPE_SHORTHAND[i][1])) {
return TYPE_SHORTHAND[i][0];
}
}
return name;
}
/** create longhand name for some common types */
private static String convertTypeLonghand(String name) {
for (int i=0; i<TYPE_SHORTHAND.length; ++i) {
if (name.equals(TYPE_SHORTHAND[i][0])) {
return TYPE_SHORTHAND[i][1];
}
}
return name;
for (int i = 0; i < TYPE_SHORTHAND.length; ++i) {
if (name.equals(TYPE_SHORTHAND[i][0])) {
return TYPE_SHORTHAND[i][1];
}
}
return name;
}
}

View File

@ -61,3 +61,5 @@ log4j.logger.com.arsdigita.packaging.Loader=INFO
# For debugging all queries run by persistence
#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.ContentItem;
import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.Folder;
import com.arsdigita.domain.DataObjectNotFoundException;
@ -152,6 +153,17 @@ public class ItemImportTool extends Program {
ContentItem item =
(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
*/
@ -160,8 +172,15 @@ public class ItemImportTool extends Program {
if (itemName.lastIndexOf('-') == -1) {
bundleName = itemName;
} else {
bundleName = itemName.substring(0, itemName.
lastIndexOf('-'));
if (itemName.substring((itemName.lastIndexOf('-') + 1)).
equals("de")
|| itemName.substring((itemName.lastIndexOf('-') + 1)).
equals("en")) {
bundleName = itemName.substring(0, itemName.
lastIndexOf('-'));
} else {
bundleName = itemName;
}
}
/*
* Multi lang extension end
@ -177,19 +196,25 @@ public class ItemImportTool extends Program {
* Multi lang extension start
*/
ContentBundle bundle;
s_log.debug(String.format("Bundle name: %s",
bundleName));
if (itemName.lastIndexOf('-') == -1) {
s_log.debug("Item is not localized...");
bundle = new ContentBundle(item);
bundle.setParent(folder);
bundle.setName(bundleName);
bundles.put(bundleName, bundle);
} else {
s_log.debug("Item is localized...");
bundle = bundles.get(bundleName);
if (bundle == null) {
s_log.debug("No content bundle found for item, creating new.");
bundle = new ContentBundle(item);
bundle.setParent(folder);
bundle.setName(bundleName);
bundles.put(bundleName, bundle);
} else {
s_log.debug("Found content bundle for item, adding item as instance.");
bundle.addInstance(item);
}
}

View File

@ -11,9 +11,21 @@
<xrd:adapter objectType="com.arsdigita.cms.contenttypes.SciDepartment" extends="com.arsdigita.cms.ContentPage">
<xrd:associations rule="include">
<xrd:property name="/object/addendum"/>
<xrd:property name="/object/contacts"/>
<xrd:property name="/object/orgaunit_children"/>
<xrd:property name="/object/persons"/>
<xrd:property name="/object/contacts"/>
<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/contacts"/>
<xrd:property name="/object/persons/contacts/address"/>
<xrd:property name="/object/persons/contacts/contactentries"/>
</xrd:associations>
</xrd:adapter>
</xrd:context>

View File

@ -16,12 +16,17 @@
<xrd:property name="/object/contacts/person"/>
<xrd:property name="/object/contacts/address"/>
<xrd:property name="/object/contacts/contactentries"/>
<xrd:property name="/object/contacts/person"/>
<xrd:property name="/object/departments"/>
<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/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:adapter>
</xrd:context>