chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fguilla...@apache.org
Subject svn commit: r830674 - in /incubator/chemistry/trunk/chemistry: ./ chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/ chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/ chemistry-atompub/src/main/java/or...
Date Wed, 28 Oct 2009 17:10:50 GMT
Author: fguillaume
Date: Wed Oct 28 17:10:49 2009
New Revision: 830674

URL: http://svn.apache.org/viewvc?rev=830674&view=rev
Log:
Pass more of the TCK (RepositoryServiceTest,TypeDefinitionTest,CreateTest,GetTest)

Modified:
    incubator/chemistry/trunk/chemistry/README.txt
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPConnection.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPRepository.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISCollection.java
    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/main/java/org/apache/chemistry/atompub/server/CMISProvider.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISServiceResponse.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISTypesCollection.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISWorkspaceManager.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/AtomPubCMIS.java
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObject.java
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObjectEntry.java
    incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/pom.xml
    incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/BasicTestCase.java

Modified: incubator/chemistry/trunk/chemistry/README.txt
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/README.txt?rev=830674&r1=830673&r2=830674&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/README.txt (original)
+++ incubator/chemistry/trunk/chemistry/README.txt Wed Oct 28 17:10:49 2009
@@ -18,4 +18,4 @@
 
 A small in-memory demo AtomPub server can then be launched with:
 
-  java -jar chemistry-tests/target/chemistry-tests-0.1-SNAPSHOT-jar-with-dependencies.jar
+  java -jar chemistry-tests/target/chemistry-tests-1.0-SNAPSHOT-jar-with-dependencies.jar

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=830674&r1=830673&r2=830674&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
Wed Oct 28 17:10:49 2009
@@ -351,7 +351,7 @@
             // TODO do a search (maybe 4 searches as base type unknown)
 
             // XXX hardcoded Chemistry URL pattern
-            href = repository.getCollectionHref(AtomPubCMIS.COL_ROOT_CHILDREN);
+            href = repository.getCollectionHref(AtomPubCMIS.COL_ROOT);
             if (href.matches(".*/children/[0-9a-f-]{36}")) {
                 href = href.substring(0, href.length() - "/children/".length()
                         - 36);

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPRepository.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPRepository.java?rev=830674&r1=830673&r2=830674&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPRepository.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPRepository.java
Wed Oct 28 17:10:49 2009
@@ -147,7 +147,7 @@
             return;
         }
         try {
-            String href = getCollectionHref(AtomPubCMIS.COL_TYPES_CHILDREN);
+            String href = getCollectionHref(AtomPubCMIS.COL_TYPES);
             if (href == null) {
                 throw new IllegalArgumentException(
                         "Invalid CMIS repository. No types children collection defined");

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISCollection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISCollection.java?rev=830674&r1=830673&r2=830674&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISCollection.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISCollection.java
Wed Oct 28 17:10:49 2009
@@ -125,6 +125,13 @@
         return request.absoluteUrlFor(TargetType.TYPE_ENTRY, params);
     }
 
+    public String getDescendantsLink(String fid, RequestContext request) {
+        Map<String, String> params = new HashMap<String, String>();
+        params.put("collection", "descendants");
+        params.put("id", fid);
+        return request.absoluteUrlFor(TargetType.TYPE_COLLECTION, params);
+    }
+
     public String getParentsLink(String fid, RequestContext request) {
         Map<String, String> params = new HashMap<String, String>();
         params.put("entrytype", "parents");

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=830674&r1=830673&r2=830674&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
Wed Oct 28 17:10:49 2009
@@ -23,6 +23,7 @@
 import java.util.Calendar;
 import java.util.Collections;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -61,6 +62,7 @@
 import org.apache.chemistry.atompub.abdera.ObjectElement;
 import org.apache.chemistry.impl.simple.SimpleContentStream;
 import org.apache.chemistry.util.GregorianCalendar;
+import org.apache.commons.codec.binary.Base64;
 
 /**
  * CMIS Collection for object entries.
@@ -173,7 +175,8 @@
             // TODO don't add links if no children/decendants
             entry.addLink(getChildrenLink(oid, request), AtomPub.LINK_DOWN,
                     AtomPub.MEDIA_TYPE_ATOM_FEED, null, null, -1);
-            // TODO children descendants and folder tree
+            entry.addLink(getDescendantsLink(oid, request), AtomPub.LINK_DOWN,
+                    AtomPubCMIS.MEDIA_TYPE_CMIS_TREE, null, null, -1);
         } else if (baseType == BaseType.DOCUMENT) {
             // TODO don't add link if no parents
             entry.addLink(getParentsLink(oid, request), AtomPub.LINK_UP,
@@ -207,54 +210,84 @@
         if (entry == null /* || !ProviderHelper.isValidEntry(entry) TODO XXX TCK */) {
             return new EmptyResponseContext(400);
         }
+
         InputStream stream;
         String mimeType;
-        try {
-            org.apache.abdera.model.Content.Type ct = entry.getContentType();
-            switch (ct) {
-            case TEXT:
-                mimeType = "text/plain";
-                break;
-            case HTML:
-                mimeType = "text/html";
-                break;
-            case XHTML:
-                mimeType = "application/xhtml+xml";
-                break;
-            case XML:
-                mimeType = "application/xml";
-                break;
-            case MEDIA:
-                mimeType = entry.getContentMimeType().toString();
-                break;
-            default:
-                throw new AssertionError(ct.toString());
+
+        Element cmisContent = entry.getFirstChild(AtomPubCMIS.CONTENT);
+        if (cmisContent != null) {
+            Element el = cmisContent.getFirstChild(AtomPubCMIS.MEDIA_TYPE);
+            if (el == null) {
+                return createErrorResponse(new ResponseContextException(
+                        "missing cmisra:mediatype", 500));
             }
-            if (ct == org.apache.abdera.model.Content.Type.MEDIA) {
-                stream = entry.getContentStream();
+            mimeType = el.getText();
+            el = cmisContent.getFirstChild(AtomPubCMIS.BASE64);
+            if (el == null) {
+                return createErrorResponse(new ResponseContextException(
+                        "missing cmisra:base64", 500));
+            }
+            byte[] b64 = el.getText().getBytes(); // no charset, pure ASCII
+            stream = new ByteArrayInputStream(Base64.decodeBase64(b64));
+        } else {
+            Content content = entry.getContentElement();
+            if (content != null) {
+                org.apache.abdera.model.Content.Type ct = content.getContentType();
+                switch (ct) {
+                case TEXT:
+                    mimeType = "text/plain;charset=UTF-8";
+                    break;
+                case HTML:
+                    mimeType = "text/html;charset=UTF-8";
+                    break;
+                case XHTML:
+                    mimeType = "application/xhtml+xml";
+                    break;
+                case XML:
+                    mimeType = "application/xml";
+                    break;
+                case MEDIA:
+                    mimeType = content.getMimeType().toString();
+                    break;
+                default:
+                    throw new AssertionError(ct.toString());
+                }
+                try {
+                    if (ct == org.apache.abdera.model.Content.Type.MEDIA) {
+                        stream = content.getDataHandler().getInputStream();
+                    } else {
+                        stream = new ByteArrayInputStream(
+                                content.getValue().getBytes("UTF-8"));
+                    }
+                } catch (IOException e1) {
+                    return createErrorResponse(new ResponseContextException(
+                            "cannot get stream", 500));
+                }
             } else {
-                stream = new ByteArrayInputStream(entry.getContent().getBytes(
-                        "UTF-8"));
+                stream = null;
+                mimeType = null;
             }
-        } catch (IOException e1) {
-            return createErrorResponse(new ResponseContextException(
-                    "cannot get stream", 500));
         }
 
-        Element obb = entry.getFirstChild(AtomPubCMIS.OBJECT);
-        ObjectElement objectElement = new ObjectElement(obb, repository);
         Map<String, Serializable> properties;
-        try {
-            properties = objectElement.getProperties();
-        } catch (Exception e) { // TODO proper exception
-            return createErrorResponse(new ResponseContextException(500, e));
-        }
-
-        String typeId = (String) properties.get(Property.TYPE_ID);
-        Type type = repository.getType(typeId);
-        if (type == null) {
-            return createErrorResponse(new ResponseContextException(
-                    "Unknown type: " + typeId, 500));
+        Type type;
+        Element obb = entry.getFirstChild(AtomPubCMIS.OBJECT);
+        if (obb != null) {
+            ObjectElement objectElement = new ObjectElement(obb, repository);
+            try {
+                properties = objectElement.getProperties();
+            } catch (Exception e) { // TODO proper exception
+                return createErrorResponse(new ResponseContextException(500, e));
+            }
+            String typeId = (String) properties.get(Property.TYPE_ID);
+            type = repository.getType(typeId);
+            if (type == null) {
+                return createErrorResponse(new ResponseContextException(
+                        "Unknown type: " + typeId, 500));
+            }
+        } else {
+            properties = new HashMap<String, Serializable>();
+            type = repository.getType(BaseType.DOCUMENT.getId());
         }
 
         // set Atom-defined properties into entry
@@ -286,11 +319,16 @@
         case DOCUMENT:
             String filename = (String) properties.get(Property.CONTENT_STREAM_FILE_NAME);
             ContentStream contentStream;
-            try {
-                contentStream = new SimpleContentStream(stream, mimeType,
-                        filename);
-            } catch (IOException e) {
-                return createErrorResponse(new ResponseContextException(500, e));
+            if (stream == null) {
+                contentStream = null;
+            } else {
+                try {
+                    contentStream = new SimpleContentStream(stream, mimeType,
+                            filename);
+                } catch (IOException e) {
+                    return createErrorResponse(new ResponseContextException(
+                            500, e));
+                }
             }
             VersioningState versioningState = null; // TODO
             objectId = spi.createDocument(properties, folderId, contentStream,
@@ -413,7 +451,10 @@
             throws ResponseContextException {
         SPI spi = repository.getSPI(); // TODO XXX connection leak
         if ("path".equals(getType())) {
-            String path = "/" + resourceName;
+            String path = resourceName;
+            if (!path.startsWith("/")) {
+                path = "/" + path;
+            }
             return spi.getObjectByPath(path, null, false, false);
         } else { // object
             String id = resourceName;
@@ -434,6 +475,8 @@
         resourceName = resourceName.replace("%3a", ":");
         resourceName = resourceName.replace("%3A", ":");
         resourceName = resourceName.replace("%20", " ");
+        resourceName = resourceName.replace("%2f", "/");
+        resourceName = resourceName.replace("%2F", "/");
         return resourceName;
     }
 

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISProvider.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISProvider.java?rev=830674&r1=830673&r2=830674&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISProvider.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISProvider.java
Wed Oct 28 17:10:49 2009
@@ -105,10 +105,6 @@
                 TargetType.TYPE_COLLECTION, "objectid");
         targetResolver.setPattern("/types/([^/?]+)",
                 TargetType.TYPE_COLLECTION, "typeid");
-        targetResolver.setPattern("/typesdescendants(\\?.*)?",
-                TargetType.TYPE_COLLECTION);
-        targetResolver.setPattern("/typesdescendants/([^/?]*)(\\?.*)?",
-                TargetType.TYPE_COLLECTION, "typeid");
 
         // CMIS workspaces available
 
@@ -116,11 +112,7 @@
         workspaceInfo.setTitle(repository.getInfo().getName());
 
         workspaceInfo.addCollection(new CMISChildrenCollection(
-                AtomPubCMIS.COL_ROOT_CHILDREN,
-                repository.getInfo().getRootFolderId().getId(), repository));
-
-        workspaceInfo.addCollection(new CMISCollectionForOther(
-                AtomPubCMIS.COL_ROOT_DESCENDANTS, "descendants",
+                AtomPubCMIS.COL_ROOT,
                 repository.getInfo().getRootFolderId().getId(), repository));
 
         workspaceInfo.addCollection(new CMISCollectionForOther(
@@ -130,10 +122,7 @@
                 AtomPubCMIS.COL_CHECKED_OUT, "checkedout", null, repository));
 
         workspaceInfo.addCollection(new CMISTypesCollection(
-                AtomPubCMIS.COL_TYPES_CHILDREN, null, repository));
-
-        workspaceInfo.addCollection(new CMISTypesCollection(
-                AtomPubCMIS.COL_TYPES_DESCENDANTS, null, repository));
+                AtomPubCMIS.COL_TYPES, null, repository));
 
         workspaceInfo.addCollection(new CMISQueryFeed(repository));
 
@@ -156,7 +145,7 @@
                 base + "object/{id}"));
         list.add(new URITemplate(AtomPubCMIS.URITMPL_OBJECT_BY_PATH, //
                 AtomPub.MEDIA_TYPE_ATOM_ENTRY, //
-                base + "path{path}"));
+                base + "path/{path}"));
         list.add(new URITemplate(AtomPubCMIS.URITMPL_TYPE_BY_ID, //
                 AtomPub.MEDIA_TYPE_ATOM_FEED, //
                 base + "type/{id}"));

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISServiceResponse.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISServiceResponse.java?rev=830674&r1=830673&r2=830674&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISServiceResponse.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISServiceResponse.java
Wed Oct 28 17:10:49 2009
@@ -80,13 +80,14 @@
                 sw.endCollection();
             }
             // CMIS links
-            sw.startElement(AtomPub.ATOM_LINK);
-            sw.writeAttribute("type", "application/cmistree+xml");
-            sw.writeAttribute("rel", AtomPubCMIS.LINK_TYPES_DESCENDANTS);
-            String tdurl = request.absoluteUrlFor(TargetType.TYPE_SERVICE, null);
-            tdurl = tdurl.replaceFirst("/repository$", "/typesdescendants"); // XXX
-            sw.writeAttribute("href", tdurl);
-            sw.endElement();
+            // sw.startElement(AtomPub.ATOM_LINK);
+            // sw.writeAttribute("type", "application/cmistree+xml");
+            // sw.writeAttribute("rel", AtomPubCMIS.LINK_TYPES_DESCENDANTS);
+            // String tdurl = request.absoluteUrlFor(TargetType.TYPE_SERVICE,
+            // null);
+            // tdurl = tdurl.replaceFirst("/repository$", "/typesdescendants");
+            // sw.writeAttribute("href", tdurl);
+            // sw.endElement();
             // URI templates
             for (URITemplate info : provider.getURITemplates(request)) {
                 sw.startElement(AtomPubCMIS.URI_TEMPLATE);

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISTypesCollection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISTypesCollection.java?rev=830674&r1=830673&r2=830674&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISTypesCollection.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISTypesCollection.java
Wed Oct 28 17:10:49 2009
@@ -18,8 +18,6 @@
 
 import java.io.Serializable;
 import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Date;
 import java.util.List;
 
@@ -34,7 +32,6 @@
 import org.apache.abdera.model.Person;
 import org.apache.abdera.protocol.server.RequestContext;
 import org.apache.abdera.protocol.server.context.ResponseContextException;
-import org.apache.chemistry.BaseType;
 import org.apache.chemistry.CMIS;
 import org.apache.chemistry.PropertyDefinition;
 import org.apache.chemistry.PropertyType;
@@ -256,29 +253,6 @@
             }
         }
         // end property definitions
-        if (AtomPubCMIS.COL_TYPES_DESCENDANTS.equals(getType())) {
-            Collection<Type> subTypes = repository.getTypes(type.getId(), 1,
-                    includePropertyDefinitions);
-            if (!subTypes.isEmpty()) {
-                Element che = factory.newElement(AtomPubCMIS.CHILDREN, entry);
-                // TODO basic feed info
-                // AbstractCollectionAdapter.createFeedBase:
-                factory.newID(che).setValue(
-                        "urn:x-id:typesdecendants-" + type.getId());
-                // che.setTitle(getTitle(request));
-                // che.addLink("");
-                // che.addLink("", "self");
-                // che.addAuthor(getAuthor(request));
-                // che.setUpdated(new Date());
-                // AbstractEntityCollectionAdapter.addFeedDetails
-                // che.setUpdated(new Date());
-                for (Type subType : subTypes) {
-                    Entry subEntry = factory.newEntry(che);
-                    addEntryDetails(request, subEntry, null, subType);
-                }
-                // end children entry
-            }
-        }
         return link;
     }
 
@@ -289,16 +263,7 @@
     @Override
     public Iterable<Type> getEntries(RequestContext request)
             throws ResponseContextException {
-        if (id == null && AtomPubCMIS.COL_TYPES_DESCENDANTS.equals(getType())) {
-            // descendants needs only the first level, it will then recurse
-            List<Type> list = new ArrayList<Type>(4);
-            for (String tid : BaseType.ALL_IDS) {
-                list.add(repository.getType(tid));
-            }
-            return list;
-        } else {
-            return repository.getTypes(id);
-        }
+        return repository.getTypes(id);
     }
 
     @Override

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISWorkspaceManager.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISWorkspaceManager.java?rev=830674&r1=830673&r2=830674&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISWorkspaceManager.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISWorkspaceManager.java
Wed Oct 28 17:10:49 2009
@@ -46,22 +46,18 @@
         if (paths.startsWith("/types/")) {
             return new CMISTypesCollection(null, null, repository);
         }
-        if (paths.startsWith("/typesdescendants/")) {
-            String id = request.getTarget().getParameter("typeid");
-            if ("".equals(id)) {
-                id = null;
-            }
-            return new CMISTypesCollection(AtomPubCMIS.COL_TYPES_DESCENDANTS,
-                    id, repository);
-        }
         if (paths.startsWith("/type/")) {
-            return new CMISTypesCollection(AtomPubCMIS.COL_TYPES_CHILDREN,
+            return new CMISTypesCollection(AtomPubCMIS.COL_TYPES,
                     null, repository);
         }
         if (paths.startsWith("/children/")) {
             String id = request.getTarget().getParameter("objectid");
             return new CMISChildrenCollection(null, id, repository);
         }
+        if (paths.startsWith("/descendants/")) {
+            String id = request.getTarget().getParameter("objectid");
+            return new CMISChildrenCollection(null, id, repository);
+        }
         if (paths.startsWith("/parents/")) {
             String id = request.getTarget().getParameter("objectid");
             return new CMISParentsCollection(null, id, repository);

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/AtomPubCMIS.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/AtomPubCMIS.java?rev=830674&r1=830673&r2=830674&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/AtomPubCMIS.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/AtomPubCMIS.java
Wed Oct 28 17:10:49 2009
@@ -64,24 +64,24 @@
 
     public static final QName CHILDREN = CMISRAName("children");
 
+    public static final QName CONTENT = CMISRAName("content");
+
+    public static final QName BASE64 = CMISRAName("base64");
+
     /*
      * ----- AtomPub Collection Types -----
      */
 
-    public static final String COL_ROOT_CHILDREN = "root";
+    public static final String COL_ROOT = "root";
 
-    public static final String COL_ROOT_DESCENDANTS = "rootdescendants"; // TODO
-
-    public static final String COL_UNFILED = "unfiled";
+    public static final String COL_TYPES = "types";
 
     public static final String COL_CHECKED_OUT = "checkedout";
 
-    public static final String COL_TYPES_CHILDREN = "types";
-
-    public static final String COL_TYPES_DESCENDANTS = "typesdescendants"; // TODO
-
     public static final String COL_QUERY = "query";
 
+    public static final String COL_UNFILED = "unfiled";
+
     /*
      * ----- AtomPub Link Types -----
      */
@@ -108,9 +108,6 @@
     public static final String LINK_FOLDER_TREE = CMIS_LINK_NS_BASE
             + "foldertree";
 
-    public static final String LINK_TYPES_DESCENDANTS = CMIS_LINK_NS_BASE
-            + "typesdescendants";
-
     public static final String LINK_ROOT_DESCENDANTS = CMIS_LINK_NS_BASE
             + "rootdescendants";
 

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=830674&r1=830673&r2=830674&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
Wed Oct 28 17:10:49 2009
@@ -405,7 +405,10 @@
         // TODO contentStream, versioningState
         String typeId = (String) properties.get(Property.TYPE_ID);
         if (typeId == null) {
-            throw new IllegalArgumentException("Missing obejct type id");
+            // use a default type, useful for pure AtomPub POST
+            typeId = BaseType.DOCUMENT.getId();
+            properties.put(Property.TYPE_ID, typeId);
+            // throw new IllegalArgumentException("Missing obejct type id");
         }
         Type type = repository.getType(typeId);
         if (type == null || type.getBaseType() != BaseType.DOCUMENT) {

Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObject.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObject.java?rev=830674&r1=830673&r2=830674&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObject.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObject.java
Wed Oct 28 17:10:49 2009
@@ -131,7 +131,7 @@
         if (pd == null) {
             throw new IllegalArgumentException(id);
         }
-        Serializable value = entry.data.get(id);
+        Serializable value = entry.getValue(id);
         if (value == null) {
             value = pd.getDefaultValue();
         }

Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObjectEntry.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObjectEntry.java?rev=830674&r1=830673&r2=830674&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObjectEntry.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObjectEntry.java
Wed Oct 28 17:10:49 2009
@@ -69,13 +69,55 @@
     }
 
     public Map<String, Serializable> getValues() {
-        return new HashMap<String, Serializable>(data);
+        HashMap<String, Serializable> map = new HashMap<String, Serializable>(
+                data);
+        if (map.containsKey(Property.PATH)) {
+            map.put(Property.PATH, getValue(Property.PATH));
+        }
+        return map;
     }
 
     public Serializable getValue(String id) {
+        if (id.equals(Property.PATH)) {
+            // non-local value
+            return getPath();
+        }
         return data.get(id);
     }
 
+    // TODO add a getPath method to the SPI
+    protected String getPath() {
+        ObjectEntry parent;
+        if (getBaseType() == BaseType.FOLDER) {
+            parent = connection.getSPI().getFolderParent(this, null);
+        } else {
+            Collection<ObjectEntry> parents = connection.getSPI().getObjectParents(
+                    this, null);
+            if (parents.size() == 0) {
+                parent = null;
+            } else if (parents.size() > 1) {
+                // several parents -> no path TODO error?
+                return null;
+            } else {
+                parent = parents.iterator().next();
+            }
+        }
+        String parentPath;
+        if (parent == null) {
+            parentPath = "";
+        } else {
+            parentPath = (String) parent.getValue(Property.PATH);
+            if (parentPath == null) {
+                return null;
+            }
+            if (parentPath.equals("/")) {
+                parentPath = "";
+            }
+        }
+        String name = (String) getValue(Property.NAME);
+        return parentPath + "/" + name;
+    }
+
     public void setValue(String id, Serializable value) {
         if (value == null) {
             data.remove(id);

Modified: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/pom.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/pom.xml?rev=830674&r1=830673&r2=830674&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/pom.xml (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/pom.xml Wed Oct 28 17:10:49
2009
@@ -109,6 +109,49 @@
   </reporting>
   <profiles>
     <profile>
+      <id>chemistry-local</id>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <systemProperties>
+                <property>
+                  <name>chemistry.tck.tests</name>
+                  <value>*</value>
+                </property>
+                <property>
+                  <name>chemistry.tck.serviceUrl</name>
+                  <value>http://localhost:8080/cmis/repository</value>
+                </property>
+                <property>
+                  <name>chemistry.tck.user</name>
+                  <value>admin</value>
+                </property>
+                <property>
+                  <name>chemistry.tck.password</name>
+                  <value>admin</value>
+                </property>
+                <property>
+                  <name>chemistry.tck.validate</name>
+                  <value>true</value>
+                </property>
+                <property>
+                  <name>chemistry.tck.failOnValidationError</name>
+                  <value>false</value>
+                </property>
+                <property>
+                  <name>chemistry.tck.traceRequests</name>
+                  <value>false</value>
+                </property>
+              </systemProperties>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+    <profile>
       <id>example</id>
       <build>
         <plugins>

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=830674&r1=830673&r2=830674&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
Wed Oct 28 17:10:49 2009
@@ -321,8 +321,8 @@
         // content stream
         String blobText = "Another file...\n";
         byte[] blobBytes = blobText.getBytes("UTF-8");
-        ContentStream cs = new SimpleContentStream(blobBytes, "text/plain",
-                "mydoc.txt");
+        ContentStream cs = new SimpleContentStream(blobBytes,
+                "text/plain;charset=UTF-8", "mydoc.txt");
         doc.setContentStream(cs);
         assertNull(doc.getId()); // not yet saved
         doc.save();
@@ -344,7 +344,7 @@
         assertNotNull(cs);
         assertTrue(cs.getLength() != 0);
         assertEquals("mydoc.txt", cs.getFileName());
-        assertEquals("text/plain", cs.getMimeType());
+        assertEquals("text/plain;charset=UTF-8", cs.getMimeType());
         assertNotNull(cs.getStream());
         InputStream in = doc.getContentStream().getStream();
         assertNotNull(in);



Mime
View raw message