Author: fguillaume
Date: Thu Dec 31 17:29:16 2009
New Revision: 894902
URL: http://svn.apache.org/viewvc?rev=894902&view=rev
Log:
Work around bugs in CMISSpacesAir build 12
Modified:
incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java
incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/PropertiesElement.java
Modified:
incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java?rev=894902&r1=894901&r2=894902&view=diff
==============================================================================
---
incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java
(original)
+++
incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java
Thu Dec 31 17:29:16 2009
@@ -31,6 +31,8 @@
import java.util.List;
import java.util.Map;
+import javax.xml.namespace.QName;
+
import org.apache.abdera.factory.Factory;
import org.apache.abdera.i18n.iri.IRI;
import org.apache.abdera.i18n.text.UrlEncoding;
@@ -319,6 +321,10 @@
Map<String, Serializable> properties;
Element obb = entry.getFirstChild(AtomPubCMIS.OBJECT);
if (obb == null) {
+ // compat with buggy CMISSpacesAir
+ obb = entry.getFirstChild(new QName(CMIS.CMIS_NS, "object"));
+ }
+ if (obb == null) {
// no CMIS object, basic AtomPub post/put
properties = new HashMap<String, Serializable>();
if (isNew) {
@@ -449,6 +455,9 @@
switch (baseType) {
case DOCUMENT:
String filename = (String)
posted.properties.get(Property.CONTENT_STREAM_FILE_NAME);
+ if (filename == null) {
+ filename = (String) posted.properties.get(Property.NAME);
+ }
ContentStream contentStream = posted.stream == null ? null
: new SimpleContentStream(posted.stream,
posted.mimeType, filename);
@@ -670,15 +679,19 @@
}
public long getContentSize(ObjectEntry object) {
- Integer value = (Integer)
object.getValue(Property.CONTENT_STREAM_LENGTH);
- return value == null ? -1 : value.longValue();
+ try {
+ Integer value = (Integer)
object.getValue(Property.CONTENT_STREAM_LENGTH);
+ return value == null ? -1 : value.longValue();
+ } catch (IllegalArgumentException e) {
+ return -1;
+ }
}
@Override
public String getContentType(ObjectEntry object) {
try {
return (String) object.getValue(Property.CONTENT_STREAM_MIME_TYPE);
- } catch (Exception e) {
+ } catch (IllegalArgumentException e) {
return null;
}
}
Modified:
incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/PropertiesElement.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/PropertiesElement.java?rev=894902&r1=894901&r2=894902&view=diff
==============================================================================
---
incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/PropertiesElement.java
(original)
+++
incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/PropertiesElement.java
Thu Dec 31 17:29:16 2009
@@ -34,6 +34,7 @@
import org.apache.abdera.model.Element;
import org.apache.abdera.model.ExtensibleElement;
import org.apache.abdera.model.ExtensibleElementWrapper;
+import org.apache.chemistry.BaseType;
import org.apache.chemistry.CMIS;
import org.apache.chemistry.Property;
import org.apache.chemistry.PropertyDefinition;
@@ -76,6 +77,16 @@
continue;
}
String pdid = element.getAttributeValue(CMIS.PDID);
+ boolean buggyCompat = false;
+ if (pdid == null) {
+ // compat with buggy CMISSpacesAir
+ String name = element.getAttributeValue(new QName(CMIS.CMIS_NS,
+ "name"));
+ if ("ObjectTypeId".equals(name)) {
+ pdid = Property.TYPE_ID;
+ buggyCompat = true;
+ }
+ }
adapters.put(pdid, va);
List<Serializable> list = new LinkedList<Serializable>();
for (Element el : element.getElements()) {
@@ -83,6 +94,9 @@
continue;
}
Serializable value = va.readValue(el.getText());
+ if (buggyCompat && "document".equals(value)) {
+ value = BaseType.DOCUMENT.getId();
+ }
list.add(value);
if (pdid.equals(Property.TYPE_ID)) {
typeId = (String) value;