Author: fmui
Date: Tue Oct  7 14:57:47 2014
New Revision: 1629905

URL: http://svn.apache.org/r1629905
Log:
AtomPub client: added workaround for repositories that send invalid property 
values

Modified:
    
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConverter.java

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConverter.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConverter.java?rev=1629905&r1=1629904&r2=1629905&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConverter.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConverter.java
 Tue Oct  7 14:57:47 2014
@@ -2151,7 +2151,14 @@ public final class XMLConverter {
         protected boolean read(XMLStreamReader parser, QName name, 
ChoiceImpl<T> target) throws XMLStreamException {
             if (isCmisNamespace(name)) {
                 if (isTag(name, TAG_PROPERTY_TYPE_CHOICE_VALUE)) {
-                    addValue(parser, target);
+                    try {
+                        addValue(parser, target);
+                    } catch (CmisInvalidArgumentException e) {
+                        // a few repositories send invalid values here
+                        if (LOG.isWarnEnabled()) {
+                            LOG.warn("Found invalid choice value for choice 
entry \"{}\"!", target.getDisplayName(), e);
+                        }
+                    }
                     return true;
                 }
 
@@ -2591,7 +2598,19 @@ public final class XMLConverter {
         protected boolean read(XMLStreamReader parser, QName name, T target) 
throws XMLStreamException {
             if (isCmisNamespace(name)) {
                 if (isTag(name, TAG_PROPERTY_VALUE)) {
-                    addValue(parser, target);
+                    try {
+                        addValue(parser, target);
+                    } catch (CmisInvalidArgumentException e) {
+                        // a few repositories send invalid values here
+                        // for example, in some cases SharePoint sends an empty
+                        // "value" tag instead of omitting the "value" tag to
+                        // indicate a "not set" value
+                        // -> being tolerant is better than breaking an
+                        // application because of this
+                        if (LOG.isWarnEnabled()) {
+                            LOG.warn("Found invalid property value for 
property {}!", target.getId(), e);
+                        }
+                    }
                     return true;
                 }
             }


Reply via email to