chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fguilla...@apache.org
Subject svn commit: r899577 - in /incubator/chemistry/trunk/chemistry: chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/ chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/ chemistry-atompub-server/src/test/res...
Date Fri, 15 Jan 2010 09:50:51 GMT
Author: fguillaume
Date: Fri Jan 15 09:50:50 2010
New Revision: 899577

URL: http://svn.apache.org/viewvc?rev=899577&view=rev
Log:
Fix update case when cmis:objectTypeId is omitted

Added:
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/resources/templates/updatedocument2.atomentry.xml
  (with props)
Modified:
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/AtomPubServerTestCase.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/ObjectElement.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=899577&r1=899576&r2=899577&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
Fri Jan 15 09:50:50 2010
@@ -372,7 +372,7 @@
         } else {
             ObjectElement objectElement = new ObjectElement(obb, repository);
             try {
-                properties = objectElement.getProperties();
+                properties = objectElement.getProperties(typeId);
             } catch (Exception e) { // TODO proper exception
                 throw new ResponseContextException(500, e);
             }
@@ -381,7 +381,7 @@
             if (isNew) {
                 // post
                 typeId = tid;
-            } else if (!typeId.equals(tid)) {
+            } else if (tid != null && !tid.equals(typeId)) {
                 // mismatched types during put
                 throw new ResponseContextException("Invalid type: " + tid, 500);
             }

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/AtomPubServerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/AtomPubServerTestCase.java?rev=899577&r1=899576&r2=899577&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/AtomPubServerTestCase.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/AtomPubServerTestCase.java
Fri Jan 15 09:50:50 2010
@@ -281,7 +281,7 @@
         assertNotNull(ob);
         resp.release();
 
-        // update
+        // update content
         RequestOptions options = new RequestOptions();
         options.setContentType(AtomPub.MEDIA_TYPE_ATOM_ENTRY);
         resp = client.put(base + "/object/" + doc3id,
@@ -290,6 +290,16 @@
         ob = resp.getDocument().getRoot();
         assertNotNull(ob);
         resp.release();
+
+        // update single prop without cmis:objectTypeId
+        options = new RequestOptions();
+        options.setContentType(AtomPub.MEDIA_TYPE_ATOM_ENTRY);
+        resp = client.put(base + "/object/" + doc3id,
+                load("templates/updatedocument2.atomentry.xml"), options);
+        assertEquals(HttpStatus.SC_OK, resp.getStatus());
+        ob = resp.getDocument().getRoot();
+        assertNotNull(ob);
+        resp.release();
     }
 
     public void testGetObjectByPath() {

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/resources/templates/updatedocument2.atomentry.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/resources/templates/updatedocument2.atomentry.xml?rev=899577&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/resources/templates/updatedocument2.atomentry.xml
(added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/resources/templates/updatedocument2.atomentry.xml
Fri Jan 15 09:50:50 2010
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<entry xmlns="http://www.w3.org/2005/Atom"
+  xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/"
+  xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/">
+  <id>urn:uuid:00000000-0000-0000-0000-000000000000</id>
+  <title>testFolder2</title>
+  <updated>2009-01-01T00:00:00Z</updated>
+  <cmisra:object>
+    <cmis:properties>
+      <cmis:propertyString propertyDefinitionId="cmis:name">
+        <cmis:value>testFolder2</cmis:value>
+      </cmis:propertyString>
+    </cmis:properties>
+  </cmisra:object>
+</entry>

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/resources/templates/updatedocument2.atomentry.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/resources/templates/updatedocument2.atomentry.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/ObjectElement.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/ObjectElement.java?rev=899577&r1=899576&r2=899577&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/ObjectElement.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/abdera/ObjectElement.java
Fri Jan 15 09:50:50 2010
@@ -56,11 +56,11 @@
         setProperties(object.getValues(), type);
     }
 
-    public Map<String, Serializable> getProperties() {
+    public Map<String, Serializable> getProperties(String typeId) {
         if (properties == null) {
             return Collections.emptyMap();
         }
-        return properties.getProperties();
+        return properties.getProperties(typeId);
     }
 
     public void setProperties(Map<String, Serializable> values, Type type) {

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=899577&r1=899576&r2=899577&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
Fri Jan 15 09:50:50 2010
@@ -36,6 +36,7 @@
 import org.apache.abdera.model.ExtensibleElementWrapper;
 import org.apache.chemistry.BaseType;
 import org.apache.chemistry.CMIS;
+import org.apache.chemistry.CMISRuntimeException;
 import org.apache.chemistry.Property;
 import org.apache.chemistry.PropertyDefinition;
 import org.apache.chemistry.PropertyType;
@@ -66,11 +67,10 @@
         repository = null;
     }
 
-    public Map<String, Serializable> getProperties() {
+    public Map<String, Serializable> getProperties(String typeId) {
         // collector raw values
         Map<String, List<Serializable>> raw = new HashMap<String, List<Serializable>>();
         Map<String, ValueAdapter> adapters = new HashMap<String, ValueAdapter>();
-        String typeId = null;
         for (Element element : getElements()) {
             ValueAdapter va = ValueAdapter.getAdapter(element.getQName());
             if (va == null) {
@@ -99,7 +99,12 @@
                 }
                 list.add(value);
                 if (pdid.equals(Property.TYPE_ID)) {
-                    typeId = (String) value;
+                    String tid = (String) value;
+                    if (tid == null || !(typeId == null || tid.equals(typeId))) {
+                        // mismatched types during put
+                        throw new CMISRuntimeException("Invalid type: " + tid);
+                    }
+                    typeId = tid;
                 }
             }
             raw.put(pdid, list);



Mime
View raw message