From ff1f223578e6a16d237ebd7f126bab9ab85eb7f4 Mon Sep 17 00:00:00 2001 From: jensp Date: Wed, 10 Aug 2011 14:01:31 +0000 Subject: [PATCH] Formatierungen git-svn-id: https://svn.libreccm.org/ccm/trunk@1056 8810af33-2d31-482b-a856-94f89814c4df --- .../arsdigita/cms/ContentItemXMLRenderer.java | 70 ++++++++++++------- .../ui/GenericPersonContactTable.java | 2 +- .../com/arsdigita/runtime/ConfigRegistry.java | 4 +- 3 files changed, 48 insertions(+), 28 deletions(-) diff --git a/ccm-cms/src/com/arsdigita/cms/ContentItemXMLRenderer.java b/ccm-cms/src/com/arsdigita/cms/ContentItemXMLRenderer.java index deb3d690a..a188ab126 100644 --- a/ccm-cms/src/com/arsdigita/cms/ContentItemXMLRenderer.java +++ b/ccm-cms/src/com/arsdigita/cms/ContentItemXMLRenderer.java @@ -27,7 +27,8 @@ import org.apache.log4j.Logger; */ public class ContentItemXMLRenderer extends DomainObjectXMLRenderer { - private static final Logger logger = Logger.getLogger(ContentItemXMLRenderer.class); + private static final Logger logger = + Logger.getLogger(ContentItemXMLRenderer.class); private String m_propertyName = ""; private String m_keyName = ""; private String m_relationAttribute = ""; @@ -42,16 +43,17 @@ public class ContentItemXMLRenderer extends DomainObjectXMLRenderer { // Otherwise this methd will do nothing. @Override protected void walk(final DomainObjectTraversalAdapter adapter, - final DomainObject obj, - final String path, - final String context, - final DomainObject linkObject) { + final DomainObject obj, + final String path, + final String context, + final DomainObject linkObject) { DomainObject nObj = obj; if (nObj instanceof ContentBundle) { - nObj = ((ContentBundle) obj).negotiate(DispatcherHelper.getRequest().getLocales()); + nObj = ((ContentBundle) obj).negotiate(DispatcherHelper.getRequest(). + getLocales()); } super.walk(adapter, nObj, path, context, linkObject); @@ -59,8 +61,8 @@ public class ContentItemXMLRenderer extends DomainObjectXMLRenderer { @Override protected void handleAttribute(DomainObject obj, - String path, - Property property) { + String path, + Property property) { String propertyName = property.getName(); @@ -70,7 +72,8 @@ public class ContentItemXMLRenderer extends DomainObjectXMLRenderer { super.handleAttribute(obj, path, property); Element element = newElement(m_element, "country"); - element.setText(GenericAddress.getCountryNameFromIsoCode(((GenericAddress) obj).getIsoCountryCode())); + element.setText(GenericAddress.getCountryNameFromIsoCode(((GenericAddress) obj). + getIsoCountryCode())); return; } } @@ -81,16 +84,19 @@ public class ContentItemXMLRenderer extends DomainObjectXMLRenderer { // The RelationAttribute is part of this domain object as field if (obj instanceof RelationAttributeInterface - && ((RelationAttributeInterface) obj).hasRelationAttributeProperty(propertyName)) { + && ((RelationAttributeInterface) obj). + hasRelationAttributeProperty(propertyName)) { - RelationAttributeInterface relationAttributeObject = (RelationAttributeInterface) obj; - key = relationAttributeObject.getRelationAttributeKey(propertyName); + RelationAttributeInterface relationAttributeObject = + (RelationAttributeInterface) obj; + key = relationAttributeObject.getRelationAttributeKey( + propertyName); } // This RelationAttribute is part of an n:m association as link attribute if (obj instanceof LinkDomainObject - && propertyName.equals(m_keyName)) { + && propertyName.equals(m_keyName)) { key = (String) ((LinkDomainObject) obj).get(m_keyName); } @@ -98,12 +104,20 @@ public class ContentItemXMLRenderer extends DomainObjectXMLRenderer { // Replace value of the property defined in RELATION_ATTRIBUTES string // of the primary domain object with the localized String. if (!key.isEmpty()) { - logger.debug(String.format("Getting relation attribute value for key '%s' of relation attribute '%s'", key, m_relationAttribute)); - RelationAttributeCollection relationAttributeCollection = new RelationAttributeCollection(m_relationAttribute, key); - relationAttributeCollection.addLanguageFilter(DispatcherHelper.getNegotiatedLocale().getLanguage()); - Element element = newElement(m_element, m_keyName); - element.setText(relationAttributeCollection.getName()); - relationAttributeCollection.close(); + logger.debug(String.format( + "Getting relation attribute value for key '%s' of relation attribute '%s'", + key, m_relationAttribute)); + RelationAttributeCollection relationAttributeCollection = + new RelationAttributeCollection( + m_relationAttribute, key); + relationAttributeCollection.addLanguageFilter(DispatcherHelper. + getNegotiatedLocale().getLanguage()); + if (relationAttributeCollection.size() > 0) { + relationAttributeCollection.next(); + Element element = newElement(m_element, m_keyName); + element.setText(relationAttributeCollection.getName()); + relationAttributeCollection.close(); + } return; } } @@ -112,25 +126,31 @@ public class ContentItemXMLRenderer extends DomainObjectXMLRenderer { } @Override - protected void beginAssociation(DomainObject obj, String path, Property property) { + protected void beginAssociation(DomainObject obj, String path, + Property property) { super.beginAssociation(obj, path, property); String propertyName = property.getName(); if (obj instanceof RelationAttributeInterface - && ((RelationAttributeInterface) obj).hasRelationAttributeProperty(propertyName)) { + && ((RelationAttributeInterface) obj).hasRelationAttributeProperty( + propertyName)) { - RelationAttributeInterface relationAttributeObject = (RelationAttributeInterface) obj; + RelationAttributeInterface relationAttributeObject = + (RelationAttributeInterface) obj; m_propertyName = propertyName; - m_keyName = relationAttributeObject.getRelationAttributeKeyName(propertyName); - m_relationAttribute = relationAttributeObject.getRelationAttributeName(propertyName); + m_keyName = relationAttributeObject.getRelationAttributeKeyName( + propertyName); + m_relationAttribute = relationAttributeObject. + getRelationAttributeName(propertyName); } } @Override - protected void endAssociation(DomainObject obj, String path, Property property) { + protected void endAssociation(DomainObject obj, String path, + Property property) { m_propertyName = ""; m_keyName = ""; diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericPersonContactTable.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericPersonContactTable.java index 465beff14..f950aab04 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericPersonContactTable.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericPersonContactTable.java @@ -211,7 +211,7 @@ public class GenericPersonContactTable extends Table implements lang).getName(); // Close collection to prevent open ResultSet - contacttypes.close(); + //contacttypes.close(); return name; case 1: diff --git a/ccm-core/src/com/arsdigita/runtime/ConfigRegistry.java b/ccm-core/src/com/arsdigita/runtime/ConfigRegistry.java index 4c9fcf281..3f63061db 100755 --- a/ccm-core/src/com/arsdigita/runtime/ConfigRegistry.java +++ b/ccm-core/src/com/arsdigita/runtime/ConfigRegistry.java @@ -251,7 +251,7 @@ public class ConfigRegistry { * @param context a subclass of {@link * com.arsdigita.runtime.AbstractConfig} * - * @return true iff this ConfigRegistry contains a mapping for + * @return true if this ConfigRegistry contains a mapping for * context **/ public boolean isConfigured(Class context) { @@ -337,7 +337,7 @@ public class ConfigRegistry { String storage = attrs.getValue(uri, "storage"); // XXX: Is there a better way to handle errors that // includes line number information? - if (klass == null || storage == null) { + if ((klass == null) || (storage == null)) { throw new IllegalArgumentException( "class and storage attributes are required"); }