chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fguilla...@apache.org
Subject svn commit: r893355 - in /incubator/chemistry/trunk/chemistry: chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/ chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/ chemistry-tests/src/main/java/org/apache/chemis...
Date Tue, 22 Dec 2009 23:57:45 GMT
Author: fguillaume
Date: Tue Dec 22 23:57:45 2009
New Revision: 893355

URL: http://svn.apache.org/viewvc?rev=893355&view=rev
Log:
Implement API.getFolder in AtomPub and Simple

Modified:
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPConnection.java
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java
    incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/BasicTestCase.java
    incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/TestAtomPubClientServer.java

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPConnection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPConnection.java?rev=893355&r1=893354&r2=893355&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPConnection.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPConnection.java
Tue Dec 22 23:57:45 2009
@@ -63,7 +63,9 @@
 import org.apache.chemistry.atompub.client.stax.ReadContext;
 import org.apache.chemistry.atompub.client.stax.XmlProperty;
 import org.apache.chemistry.impl.simple.SimpleContentStream;
+import org.apache.chemistry.impl.simple.SimpleFolder;
 import org.apache.chemistry.impl.simple.SimpleListPage;
+import org.apache.chemistry.impl.simple.SimpleObjectEntry;
 import org.apache.chemistry.impl.simple.SimpleObjectId;
 
 /**
@@ -408,8 +410,15 @@
     }
 
     public Folder getFolder(String path) {
-        // TODO Auto-generated method stub
-        throw new UnsupportedOperationException();
+        APPObjectEntry entry = (APPObjectEntry) getObjectByPath(path, null);
+        if (entry == null) {
+            return null;
+        }
+        if (entry.getBaseType() != BaseType.FOLDER) {
+            throw new IllegalArgumentException("Not a folder: " + path);
+        }
+        Type type = getRepository().getType(entry.getTypeId());
+        return new APPFolder(entry, type);
     }
 
     public List<Rendition> getRenditions(ObjectId object, Inclusion inclusion,

Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java?rev=893355&r1=893354&r2=893355&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java
Tue Dec 22 23:57:45 2009
@@ -521,8 +521,15 @@
     }
 
     public Folder getFolder(String path) {
-        // TODO Auto-generated method stub
-        throw new UnsupportedOperationException();
+        SimpleObjectEntry entry = (SimpleObjectEntry) getObjectByPath(path,
+                null);
+        if (entry == null) {
+            return null;
+        }
+        if (entry.getBaseType() != BaseType.FOLDER) {
+            throw new IllegalArgumentException("Not a folder: " + path);
+        }
+        return new SimpleFolder(entry);
     }
 
     public CMISObject getObject(ObjectId object) {
@@ -570,8 +577,8 @@
         return new SimpleContentStream(bytes, mimeType, filename);
     }
 
-    public ObjectId setContentStream(ObjectId document, ContentStream contentStream,
-            boolean overwrite) {
+    public ObjectId setContentStream(ObjectId document,
+            ContentStream contentStream, boolean overwrite) {
         SimpleData data = repository.datas.get(document.getId());
         if (contentStream == null) {
             data.remove(SimpleProperty.CONTENT_BYTES_KEY);

Modified: incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/BasicTestCase.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/BasicTestCase.java?rev=893355&r1=893354&r2=893355&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/BasicTestCase.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/BasicTestCase.java
Tue Dec 22 23:57:45 2009
@@ -241,6 +241,17 @@
         assertNotNull(spi.getObjectByPath("/folder 1/folder 2/doc 2", null));
         assertNotNull(spi.getObjectByPath("/folder 1/folder 2/doc 3", null));
         assertNull(spi.getObjectByPath("/notsuchname", null));
+
+        assertNotNull(conn.getFolder("/"));
+        assertNotNull(conn.getFolder("/folder 1"));
+        assertNotNull(conn.getFolder("/folder 1/folder 2"));
+        try {
+            conn.getFolder("/folder 1/doc 1");
+            fail();
+        } catch (IllegalArgumentException e) {
+            // ok
+        }
+        assertNull(conn.getFolder("/notsuchname"));
     }
 
     public void testGetChildren() {

Modified: incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/TestAtomPubClientServer.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/TestAtomPubClientServer.java?rev=893355&r1=893354&r2=893355&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/TestAtomPubClientServer.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/TestAtomPubClientServer.java
Tue Dec 22 23:57:45 2009
@@ -35,7 +35,7 @@
  */
 public class TestAtomPubClientServer extends BasicTestCase {
 
-    private static final Log log = LogFactory.getLog(MainServlet.class);
+    private static final Log log = LogFactory.getLog(TestAtomPubClientServer.class);
 
     public static final String HOST = "0.0.0.0";
 



Mime
View raw message