chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fguilla...@apache.org
Subject svn commit: r901263 - in /incubator/chemistry/trunk/chemistry: chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/ chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/ chemistry-atompub-client/sr...
Date Wed, 20 Jan 2010 16:30:23 GMT
Author: fguillaume
Date: Wed Jan 20 16:30:22 2010
New Revision: 901263

URL: http://svn.apache.org/viewvc?rev=901263&view=rev
Log:
Refactored to get rid of useless abstraction layers (YAGNI)

Added:
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPContentManager.java
      - copied, changed from r901135, incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/APPContentManager.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/Connector.java
      - copied, changed from r901135, incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/HttpClientConnector.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/NameValuePairs.java   (with props)
Removed:
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/APPContentManager.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/Connector.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/DefaultIOProvider.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/HttpClientConnector.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/HttpClientResponse.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/IOProvider.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/Request.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/Response.java
Modified:
    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/APPFolder.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObject.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectEntryReader.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectFeedReader.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPRepository.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPServiceDocumentReader.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPType.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/QueryWriter.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/ServiceDocumentReaderTest.java
    incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/app/ChemistryApp.java
    incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/app/ChemistryContext.java
    incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/app/ChemistryRootContext.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=901263&r1=901262&r2=901263&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 Jan 20 16:30:22 2010
@@ -19,13 +19,11 @@
 package org.apache.chemistry.atompub.client;
 
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -38,7 +36,6 @@
 import org.apache.chemistry.CMISObject;
 import org.apache.chemistry.CMISRuntimeException;
 import org.apache.chemistry.Connection;
-import org.apache.chemistry.ConstraintViolationException;
 import org.apache.chemistry.ContentStream;
 import org.apache.chemistry.Document;
 import org.apache.chemistry.Folder;
@@ -61,35 +58,28 @@
 import org.apache.chemistry.atompub.AtomPub;
 import org.apache.chemistry.atompub.AtomPubCMIS;
 import org.apache.chemistry.atompub.URITemplate;
-import org.apache.chemistry.atompub.client.connector.Connector;
-import org.apache.chemistry.atompub.client.connector.Request;
-import org.apache.chemistry.atompub.client.connector.Response;
 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.SimpleListPage;
 import org.apache.chemistry.impl.simple.SimpleObjectId;
-import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.Header;
 
 /**
- *
+ * A {@link Connection} and {@link SPI} using the AtomPub protocol to talk to a
+ * CMIS server.
  */
 public class APPConnection implements Connection, SPI {
 
-    public static final int DEFAULT_MAX_CHILDREN = 20;
+    protected final APPRepository repository;
 
     protected final Connector connector;
 
-    protected final APPRepository repository;
-
     protected APPFolder root;
 
-    protected Map<Class<?>, Object> singletons = new Hashtable<Class<?>, Object>();
-
-    public APPConnection(APPRepository repo) {
-        this.repository = repo;
-        this.connector = repo.cm.getConnector(); // TODO clone connector to be
-        // able to use different logins
+    public APPConnection(APPRepository repository) {
+        this.repository = repository;
+        connector = new Connector(repository.getContentManager().getClient(),
+                new ReadContext(this));
     }
 
     public Connection getConnection() {
@@ -109,6 +99,10 @@
         return repository;
     }
 
+    public Connector getConnector() {
+        return connector;
+    }
+
     public Folder getRootFolder() {
         if (root == null) {
             root = (APPFolder) getObject(repository.info.getRootFolderId());
@@ -116,12 +110,6 @@
         return root;
     }
 
-    // not in API
-
-    public Connector getConnector() {
-        return connector;
-    }
-
     public String getBaseUrl() {
         return repository.cm.getBaseUrl();
     }
@@ -196,31 +184,25 @@
         if (href == null) {
             throw new CMISRuntimeException("Missing foldertree link");
         }
-        Request req = new Request(href);
-        req.setParameter(AtomPubCMIS.PARAM_DEPTH, Integer.toString(depth));
+        NameValuePairs params = new NameValuePairs();
+        params.add(AtomPubCMIS.PARAM_DEPTH, Integer.toString(depth));
         if (inclusion != null) {
             if (inclusion.properties != null) {
-                req.setParameter(AtomPubCMIS.PARAM_FILTER, inclusion.properties);
+                params.add(AtomPubCMIS.PARAM_FILTER, inclusion.properties);
             }
             if (inclusion.renditions != null) {
-                req.setParameter(AtomPubCMIS.PARAM_RENDITION_FILTER,
+                params.add(AtomPubCMIS.PARAM_RENDITION_FILTER,
                         inclusion.renditions);
             }
             if (inclusion.relationships != null) {
-                req.setParameter(
+                params.add(
                         AtomPubCMIS.PARAM_INCLUDE_RELATIONSHIPS,
                         RelationshipDirection.toInclusion(inclusion.relationships));
             }
-            req.setParameter(AtomPubCMIS.PARAM_INCLUDE_ALLOWABLE_ACTIONS,
+            params.add(AtomPubCMIS.PARAM_INCLUDE_ALLOWABLE_ACTIONS,
                     Boolean.toString(inclusion.allowableActions));
         }
-        Response resp = connector.get(req);
-        if (!resp.isOk()) {
-            throw new ContentManagerException(
-                    "Remote server returned error code: "
-                            + resp.getStatusCode());
-        }
-        return resp.getObjectFeed(new ReadContext(this));
+        return connector.getEntryFeed(href, params);
     }
 
     public List<ObjectEntry> getDescendants(ObjectId folder, int depth,
@@ -230,38 +212,32 @@
         if (href == null) {
             throw new CMISRuntimeException("Missing down tree link");
         }
-        Request req = new Request(href);
-        req.setParameter(AtomPubCMIS.PARAM_DEPTH, Integer.toString(depth));
+        NameValuePairs params = new NameValuePairs();
+        params.add(AtomPubCMIS.PARAM_DEPTH, Integer.toString(depth));
         if (orderBy != null) {
-            req.setParameter(AtomPubCMIS.PARAM_ORDER_BY, orderBy);
+            params.add(AtomPubCMIS.PARAM_ORDER_BY, orderBy);
         }
         if (inclusion != null) {
             if (inclusion.properties != null) {
-                req.setParameter(AtomPubCMIS.PARAM_FILTER, inclusion.properties);
+                params.add(AtomPubCMIS.PARAM_FILTER, inclusion.properties);
             }
             if (inclusion.renditions != null) {
-                req.setParameter(AtomPubCMIS.PARAM_RENDITION_FILTER,
+                params.add(AtomPubCMIS.PARAM_RENDITION_FILTER,
                         inclusion.renditions);
             }
             if (inclusion.relationships != null) {
-                req.setParameter(
+                params.add(
                         AtomPubCMIS.PARAM_INCLUDE_RELATIONSHIPS,
                         RelationshipDirection.toInclusion(inclusion.relationships));
             }
-            req.setParameter(AtomPubCMIS.PARAM_INCLUDE_ALLOWABLE_ACTIONS,
+            params.add(AtomPubCMIS.PARAM_INCLUDE_ALLOWABLE_ACTIONS,
                     Boolean.toString(inclusion.allowableActions));
-            req.setParameter(AtomPubCMIS.PARAM_INCLUDE_POLICY_IDS,
+            params.add(AtomPubCMIS.PARAM_INCLUDE_POLICY_IDS,
                     Boolean.toString(inclusion.policies));
-            req.setParameter(AtomPubCMIS.PARAM_INCLUDE_ACL,
+            params.add(AtomPubCMIS.PARAM_INCLUDE_ACL,
                     Boolean.toString(inclusion.acls));
         }
-        Response resp = connector.get(req);
-        if (!resp.isOk()) {
-            throw new ContentManagerException(
-                    "Remote server returned error code: "
-                            + resp.getStatusCode());
-        }
-        return resp.getObjectFeed(new ReadContext(this));
+        return connector.getEntryFeed(href, params);
     }
 
     public ListPage<ObjectEntry> getChildren(ObjectId folder,
@@ -269,20 +245,17 @@
         // TODO filter, includeRelationship, includeAllowableActions, orderBy
         String href = getFolderEntry(folder).getLink(AtomPub.LINK_DOWN,
                 AtomPub.MEDIA_TYPE_ATOM_FEED);
-        Request req = new Request(href);
+        if (href == null) {
+            throw new CMISRuntimeException("Missing down link");
+        }
+        NameValuePairs params = new NameValuePairs();
         if (paging != null) {
-            req.setParameter(AtomPubCMIS.PARAM_MAX_ITEMS,
+            params.add(AtomPubCMIS.PARAM_MAX_ITEMS,
                     Integer.toString(paging.maxItems));
-            req.setParameter(AtomPubCMIS.PARAM_SKIP_COUNT,
+            params.add(AtomPubCMIS.PARAM_SKIP_COUNT,
                     Integer.toString(paging.skipCount));
         }
-        Response resp = connector.get(req);
-        if (!resp.isOk()) {
-            throw new ContentManagerException(
-                    "Remote server returned error code: "
-                            + resp.getStatusCode());
-        }
-        return resp.getObjectFeed(new ReadContext(this));
+        return connector.getEntryFeed(href, params);
     }
 
     public ObjectEntry getFolderParent(ObjectId folder, String filter) {
@@ -297,13 +270,7 @@
         if (href == null) {
             return null;
         }
-        Response resp = connector.get(new Request(href));
-        if (!resp.isOk()) {
-            throw new ContentManagerException(
-                    "Remote server returned error code: "
-                            + resp.getStatusCode());
-        }
-        return (APPObjectEntry) resp.getObject(new ReadContext(this));
+        return connector.getEntry(href, folder.getId());
     }
 
     public Collection<ObjectEntry> getObjectParents(ObjectId object,
@@ -311,13 +278,10 @@
         // TODO filter
         APPObjectEntry current = getObjectEntry(object);
         String href = current.getLink(AtomPub.LINK_UP);
-        Response resp = connector.get(new Request(href));
-        if (!resp.isOk()) {
-            throw new ContentManagerException(
-                    "Remote server returned error code: "
-                            + resp.getStatusCode());
+        if (href == null) {
+            throw new CMISRuntimeException("Missing up link");
         }
-        return resp.getObjectFeed(new ReadContext(this));
+        return connector.getEntryFeed(href, null);
     }
 
     public ListPage<ObjectEntry> getCheckedOutDocuments(ObjectId folder,
@@ -345,16 +309,7 @@
         href = replace(href, AtomPubCMIS.PARAM_INCLUDE_ALLOWABLE_ACTIONS, "");
         href = replace(href, AtomPubCMIS.PARAM_INCLUDE_POLICY_IDS, "");
         href = replace(href, AtomPubCMIS.PARAM_INCLUDE_ACL, "");
-        Response resp = connector.get(new Request(href));
-        if (resp.getStatusCode() == HttpStatus.SC_NOT_FOUND) {
-            throw new ObjectNotFoundException(objectId.getId());
-        }
-        if (!resp.isOk()) {
-            throw new ContentManagerException(
-                    "Remote server returned error code: "
-                            + resp.getStatusCode());
-        }
-        return (APPObjectEntry) resp.getObject(new ReadContext(this));
+        return connector.getEntry(href, objectId.getId());
     }
 
     protected APPObjectEntry getFolderEntry(ObjectId objectId) {
@@ -401,7 +356,7 @@
         return href;
     }
 
-    protected APPObjectEntry createObject(String postHref,
+    protected APPObjectEntry createObject(String href,
             Map<String, Serializable> properties, ContentStream contentStream,
             BaseType baseType) {
         String typeId = (String) properties.get(Property.TYPE_ID);
@@ -412,6 +367,7 @@
         if (type == null || type.getBaseType() != baseType) {
             throw new IllegalArgumentException(typeId);
         }
+
         APPObjectEntry entry = newObjectEntry(typeId);
         for (Entry<String, Serializable> en : properties.entrySet()) {
             entry._setValue(en.getKey(), en.getValue());
@@ -419,35 +375,7 @@
         if (contentStream != null) {
             entry.setContentStream(contentStream);
         }
-
-        Request req = new Request(postHref);
-        req.setHeader("Content-Type", AtomPub.MEDIA_TYPE_ATOM_ENTRY);
-        Response resp = connector.postObject(req, entry);
-        if (resp.getStatusCode() != 201) { // Created
-            throw new ContentManagerException(
-                    "Remote server returned error code: "
-                            + resp.getStatusCode());
-        }
-        ReadContext ctx = new ReadContext(this);
-        APPObjectEntry newEntry = (APPObjectEntry) resp.getObject(ctx);
-        // newEntry SHOULD be returned (AtomPub 9.2)...
-        String loc = resp.getHeader("Location");
-        if (loc == null) {
-            throw new ContentManagerException(
-                    "Remote server failed to return a Location header");
-        }
-        if (newEntry == null || !loc.equals(resp.getHeader("Content-Location"))) {
-            // (Content-Location defined by AtomPub 9.2)
-            // fetch actual new entry from Location header
-            // TODO could fetch only a subset of the properties, if deemed ok
-            newEntry = (APPObjectEntry) connector.getObject(ctx, loc);
-            if (newEntry == null) {
-                throw new ContentManagerException(
-                        "Remote server failed to return an entry for Location: "
-                                + loc);
-            }
-        }
-        return newEntry;
+        return connector.postEntry(href, null, entry);
     }
 
     public ObjectId createDocument(Map<String, Serializable> properties,
@@ -484,18 +412,13 @@
         // TODO inclusion
         APPObjectEntry current = getObjectEntry(object);
         String href = current.getLink(AtomPub.LINK_SELF);
-        Response resp = connector.get(new Request(href));
-        if (!resp.isOk()) {
-            if (resp.getStatusCode() == 404) {
-                // object not found, signature says return null
-                return null;
-            }
-            throw new ContentManagerException(
-                    "Remote server returned error code: "
-                            + resp.getStatusCode());
+        try {
+            return connector.getEntry(href, object.getId());
+            // TODO fill current
+        } catch (ObjectNotFoundException e) {
+            // object not found, signature says return null
+            return null;
         }
-        // TODO fill current
-        return (APPObjectEntry) resp.getObject(new ReadContext(this));
     }
 
     public ObjectEntry getObjectByPath(String path, Inclusion inclusion) {
@@ -522,17 +445,13 @@
         href = replace(href, AtomPubCMIS.PARAM_INCLUDE_ALLOWABLE_ACTIONS, "");
         href = replace(href, AtomPubCMIS.PARAM_INCLUDE_POLICY_IDS, "");
         href = replace(href, AtomPubCMIS.PARAM_INCLUDE_ACL, "");
-        Response resp = connector.get(new Request(href));
-        if (!resp.isOk()) {
-            if (resp.getStatusCode() == 404) {
-                // object not found, signature says return null
-                return null;
-            }
-            throw new ContentManagerException(
-                    "Remote server returned error code: "
-                            + resp.getStatusCode());
+        try {
+            return connector.getEntry(href, path);
+            // TODO fill current
+        } catch (ObjectNotFoundException e) {
+            // object not found, signature says return null
+            return null;
         }
-        return (APPObjectEntry) resp.getObject(new ReadContext(this));
     }
 
     public Folder getFolder(String path) {
@@ -577,29 +496,13 @@
             return cs;
         }
 
-        // must fetch the content stream
         String href = current.getContentHref();
         if (href == null) {
-            throw new RuntimeException("Object is missing content src");
+            throw new RuntimeException("Missing content src");
         }
-        Request req = new Request(href);
-        Response resp = connector.get(req);
-        int status = resp.getStatusCode();
-        if (status == 404 || status == 409) {
-            throw new ConstraintViolationException("No content stream");
-        }
-        if (!resp.isOk()) {
-            // TODO exceptions
-            throw new ContentManagerException(
-                    "Remote server returned error code: "
-                            + resp.getStatusCode());
-        }
-        // get MIME type and filename from entry
-        InputStream stream = resp.getStream();
-        // String mimeType = resp.getHeader("Content-Type");
         String mimeType = (String) current.getValue(Property.CONTENT_STREAM_MIME_TYPE);
         String filename = (String) current.getValue(Property.CONTENT_STREAM_FILE_NAME);
-        cs = new SimpleContentStream(stream, mimeType, filename);
+        cs = connector.getContentStream(href, mimeType, filename);
         // current.localContentStream = cs; // problem reusing the stream
         return cs;
     }
@@ -609,23 +512,10 @@
         APPObjectEntry current = getObjectEntry(document);
         String href = current.getLink(AtomPub.LINK_EDIT_MEDIA);
         if (href == null) {
-            throw new RuntimeException("Document is missing link "
+            throw new RuntimeException("Missing link "
                     + AtomPub.LINK_EDIT_MEDIA);
         }
-        Request req = new Request(href);
-        String filename = cs.getFileName();
-        if (filename != null) {
-            // Use Slug: header for filename
-            req.setHeader(AtomPub.HEADER_SLUG, filename);
-        }
-        Response resp = connector.put(req, cs.getStream(), cs.getLength(),
-                cs.getMimeType());
-        if (!resp.isOk()) {
-            // TODO exceptions
-            throw new ContentManagerException(
-                    "Remote server returned error code: "
-                            + resp.getStatusCode());
-        }
+        connector.putStream(href, cs);
         // TODO AtomPub cannot return a new id... (autoversioning)
         return new SimpleObjectId(document.getId());
     }
@@ -634,17 +524,10 @@
         APPObjectEntry current = getObjectEntry(document);
         String href = current.getLink(AtomPub.LINK_EDIT_MEDIA);
         if (href == null) {
-            throw new RuntimeException("Document is missing link "
+            throw new RuntimeException("Missing link "
                     + AtomPub.LINK_EDIT_MEDIA);
         }
-        Response resp = connector.delete(new Request(href));
-        if (!resp.isOk()) {
-            // TODO exceptions
-            throw new ContentManagerException(
-                    "Remote server returned error code: "
-                            + resp.getStatusCode());
-        }
-
+        connector.delete(href, null, document.getId());
         // TODO AtomPub cannot return a new id... (autoversioning)
         return new SimpleObjectId(document.getId());
     }
@@ -653,6 +536,11 @@
             Map<String, Serializable> properties) {
         // make properties into an entry for putObject
         APPObjectEntry current = getObjectEntry(object);
+        String href = current.getLink(AtomPub.LINK_EDIT);
+        if (href == null) {
+            throw new RuntimeException("Missing link " + AtomPub.LINK_EDIT);
+        }
+
         APPObjectEntry update = newObjectEntry(current.getTypeId());
         for (String key : properties.keySet()) {
             update._setValue(key, properties.get(key));
@@ -661,77 +549,28 @@
         // TODO proper title
         update._setValue(Property.NAME, current.getValue(Property.NAME));
 
-        String href = current.getLink(AtomPub.LINK_EDIT);
-        if (href == null) {
-            throw new RuntimeException("Object is missing link "
-                    + AtomPub.LINK_EDIT);
-        }
-        Request req = new Request(href);
-        req.setHeader("Content-Type", AtomPub.MEDIA_TYPE_ATOM_ENTRY);
-        Response resp = connector.putObject(req, update);
-        if (!resp.isOk()) {
-            throw new ContentManagerException(
-                    "Remote server returned error code: "
-                            + resp.getStatusCode());
-        }
-        return (APPObjectEntry) resp.getObject(new ReadContext(this));
+        Header header = new Header("Content-Type",
+                AtomPub.MEDIA_TYPE_ATOM_ENTRY);
+        return connector.putEntry(href, header, update);
     }
 
     public ObjectId moveObject(ObjectId object, ObjectId targetFolder,
             ObjectId sourceFolder) {
         APPObjectEntry entry = getObjectEntry(object);
-        Request req = new Request(getPostHref(targetFolder));
-        req.setHeader("Content-Type", AtomPub.MEDIA_TYPE_ATOM_ENTRY);
-        req.setParameter(AtomPubCMIS.PARAM_SOURCE_FOLDER_ID,
+        NameValuePairs params = new NameValuePairs();
+        params.add(AtomPubCMIS.PARAM_SOURCE_FOLDER_ID,
                 sourceFolder == null ? "" : sourceFolder.getId());
-        Response resp = connector.postObject(req, entry);
-        if (resp.getStatusCode() != 201) { // Created
-            throw new ContentManagerException(
-                    "Remote server returned error code: "
-                            + resp.getStatusCode());
-        }
-        ReadContext ctx = new ReadContext(this);
-        APPObjectEntry newEntry = (APPObjectEntry) resp.getObject(ctx);
-        // newEntry SHOULD be returned (AtomPub 9.2)...
-        String loc = resp.getHeader("Location");
-        if (loc == null) {
-            throw new ContentManagerException(
-                    "Remote server failed to return a Location header");
-        }
-        if (newEntry == null || !loc.equals(resp.getHeader("Content-Location"))) {
-            // (Content-Location defined by AtomPub 9.2)
-            // fetch actual new entry from Location header
-            // TODO could fetch only a subset of the properties, if deemed ok
-            newEntry = (APPObjectEntry) connector.getObject(ctx, loc);
-            if (newEntry == null) {
-                throw new ContentManagerException(
-                        "Remote server failed to return an entry for Location: "
-                                + loc);
-            }
-        }
-        return newEntry;
+        return connector.postEntry(getPostHref(targetFolder), params,
+                entry);
     }
 
     public void deleteObject(ObjectId object, boolean allVersions) {
         APPObjectEntry current = getObjectEntry(object);
         String href = current.getLink(AtomPub.LINK_SELF);
-        Request req = new Request(href);
+        NameValuePairs params = new NameValuePairs();
         // TODO XXX allVersions not in spec
-        req.setParameter("allVersions", String.valueOf(allVersions));
-        Response resp = connector.delete(req);
-        int status = resp.getStatusCode();
-        if (status == HttpStatus.SC_NOT_FOUND) {
-            throw new ObjectNotFoundException(object.getId());
-        }
-        if (status == HttpStatus.SC_CONFLICT) {
-            throw new ConstraintViolationException(resp.getStatusReasonPhrase());
-        }
-        if (!resp.isOk()) {
-            // TODO exceptions
-            throw new ContentManagerException(
-                    "Remote server returned error code: "
-                            + resp.getStatusCode());
-        }
+        params.add("allVersions", String.valueOf(allVersions));
+        connector.delete(href, params, object.getId());
     }
 
     public Collection<ObjectId> deleteTree(ObjectId folder, Unfiling unfiling,
@@ -740,31 +579,16 @@
         String href = current.getLink(AtomPub.LINK_DOWN,
                 AtomPubCMIS.MEDIA_TYPE_CMIS_TREE);
         if (href == null) {
-            throw new CMISRuntimeException("Document is missing link "
-                    + AtomPub.LINK_DOWN + " "
-                    + AtomPubCMIS.MEDIA_TYPE_CMIS_TREE);
+            throw new CMISRuntimeException("Missing link " + AtomPub.LINK_DOWN
+                    + " " + AtomPubCMIS.MEDIA_TYPE_CMIS_TREE);
         }
-        Request req = new Request(href);
+        NameValuePairs params = new NameValuePairs();
         if (unfiling != null) {
-            req.setParameter(AtomPubCMIS.PARAM_UNFILE_OBJECTS,
-                    unfiling.toString());
+            params.add(AtomPubCMIS.PARAM_UNFILE_OBJECTS, unfiling.toString());
         }
-        req.setParameter(AtomPubCMIS.PARAM_CONTINUE_ON_FAILURE,
+        params.add(AtomPubCMIS.PARAM_CONTINUE_ON_FAILURE,
                 Boolean.toString(continueOnFailure));
-        Response resp = connector.delete(req);
-        int status = resp.getStatusCode();
-        if (status == HttpStatus.SC_NOT_FOUND) {
-            throw new ObjectNotFoundException(folder.getId());
-        }
-        if (status == HttpStatus.SC_CONFLICT) {
-            throw new ConstraintViolationException(resp.getStatusReasonPhrase());
-        }
-        if (!resp.isOk()) {
-            // TODO exceptions
-            throw new ContentManagerException(
-                    "Remote server returned error code: "
-                            + resp.getStatusCode());
-        }
+        connector.delete(href, params, folder.getId());
         // AtomPub bindings cannot return the objects that could not be deleted
         return Collections.emptyList();
     }
@@ -786,15 +610,12 @@
     public ListPage<ObjectEntry> query(String statement,
             boolean searchAllVersions, Inclusion inclusion, Paging paging) {
         String href = repository.getCollectionHref(AtomPubCMIS.COL_QUERY);
-        Response resp = connector.postQuery(new Request(href), statement,
-                searchAllVersions, inclusion, paging);
-        if (!resp.isOk()) {
-            throw new ContentManagerException(
-                    "Remote server returned error code: "
-                            + resp.getStatusCode());
+        if (href == null) {
+            throw new CMISRuntimeException("Missing collection "
+                    + AtomPubCMIS.COL_QUERY);
         }
-        ListPage<ObjectEntry> objects = resp.getObjectFeed(new ReadContext(this));
-        return objects;
+        return connector.postQuery(href, statement, searchAllVersions,
+                inclusion, paging);
     }
 
     public Collection<CMISObject> query(String statement,

Copied: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPContentManager.java (from r901135, incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/APPContentManager.java)
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPContentManager.java?p2=incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPContentManager.java&p1=incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/APPContentManager.java&r1=901135&r2=901263&rev=901263&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/APPContentManager.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPContentManager.java Wed Jan 20 16:30:22 2010
@@ -15,13 +15,12 @@
  *     Bogdan Stefanescu, Nuxeo
  *     Florent Guillaume, Nuxeo
  */
-package org.apache.chemistry.atompub.client.connector;
+package org.apache.chemistry.atompub.client;
 
 import org.apache.chemistry.Repository;
-import org.apache.chemistry.atompub.client.ContentManager;
-import org.apache.chemistry.atompub.client.ContentManagerException;
 import org.apache.chemistry.atompub.client.stax.ReadContext;
 import org.apache.commons.httpclient.Credentials;
+import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.UsernamePasswordCredentials;
 import org.apache.commons.httpclient.auth.AuthScheme;
 import org.apache.commons.httpclient.auth.CredentialsProvider;
@@ -33,40 +32,31 @@
 
     protected final String baseUrl;
 
-    protected final Connector connector;
+    protected final HttpClient client;
 
     protected Repository[] repos;
 
     protected String username;
 
-    protected APPContentManager(String url, Connector connector) {
-        this.baseUrl = url;
-        this.connector = connector;
-    }
-
     public APPContentManager(String url) {
-        this(url, new HttpClientConnector(new DefaultIOProvider()));
+        this.baseUrl = url;
+        client = new HttpClient();
+        // client.setHttpConnectionManager(new
+        // MultiThreadedHttpConnectionManager());
     }
 
     public String getBaseUrl() {
         return baseUrl;
     }
 
-    public Connector getConnector() {
-        return connector;
+    public HttpClient getClient() {
+        return client;
     }
 
     public Repository[] getRepositories() throws ContentManagerException {
         if (repos == null) {
-            Request req = new Request(getBaseUrl());
-            Response resp = connector.get(req);
-            if (!resp.isOk()) {
-                throw new ContentManagerException(
-                        "Remote server returned error code: "
-                                + resp.getStatusCode());
-            }
-            ReadContext ctx = new ReadContext(this);
-            repos = resp.getServiceDocument(ctx);
+            Connector connector = new Connector(client, new ReadContext(this));
+            repos = connector.getServiceDocument(getBaseUrl());
         }
         return repos;
     }
@@ -99,12 +89,14 @@
         this.username = username;
         CredentialsProvider cp = new UsernamePasswordCredentialsProvider(
                 username, password);
-        connector.setCredentialsProvider(cp);
+        client.getParams().setAuthenticationPreemptive(true);
+        client.getParams().setParameter(CredentialsProvider.PROVIDER, cp);
     }
 
     public void logout() {
         username = null;
-        connector.setCredentialsProvider(null);
+        client.getParams().setAuthenticationPreemptive(true);
+        client.getParams().setParameter(CredentialsProvider.PROVIDER, null);
     }
 
     public String getCurrentLogin() {

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPFolder.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPFolder.java?rev=901263&r1=901262&r2=901263&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPFolder.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPFolder.java Wed Jan 20 16:30:22 2010
@@ -27,10 +27,6 @@
 import org.apache.chemistry.ObjectId;
 import org.apache.chemistry.Type;
 import org.apache.chemistry.Unfiling;
-import org.apache.chemistry.atompub.AtomPub;
-import org.apache.chemistry.atompub.client.connector.Request;
-import org.apache.chemistry.atompub.client.connector.Response;
-import org.apache.chemistry.atompub.client.stax.ReadContext;
 
 /**
  *
@@ -57,15 +53,7 @@
     }
 
     public List<CMISObject> getChildren() {
-        String href = entry.getLink(AtomPub.LINK_DOWN);
-        Response resp = entry.connection.getConnector().get(new Request(href));
-        if (!resp.isOk()) {
-            throw new ContentManagerException(
-                    "Remote server returned error code: "
-                            + resp.getStatusCode());
-        }
-        List<ObjectEntry> feed = resp.getObjectFeed(new ReadContext(
-                entry.connection));
+        List<ObjectEntry> feed = entry.connection.getChildren(this, null, null, null);
         List<CMISObject> children = new ArrayList<CMISObject>(feed.size());
         for (ObjectEntry child : feed) {
             children.add(APPObject.construct((APPObjectEntry) child));

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObject.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObject.java?rev=901263&r1=901262&r2=901263&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObject.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObject.java Wed Jan 20 16:30:22 2010
@@ -27,8 +27,10 @@
 import java.util.List;
 
 import org.apache.chemistry.BaseType;
+import org.apache.chemistry.CMISRuntimeException;
 import org.apache.chemistry.ContentStream;
 import org.apache.chemistry.Folder;
+import org.apache.chemistry.ObjectEntry;
 import org.apache.chemistry.Policy;
 import org.apache.chemistry.Property;
 import org.apache.chemistry.PropertyDefinition;
@@ -36,11 +38,8 @@
 import org.apache.chemistry.RelationshipDirection;
 import org.apache.chemistry.Type;
 import org.apache.chemistry.atompub.AtomPub;
-import org.apache.chemistry.atompub.client.connector.Connector;
-import org.apache.chemistry.atompub.client.connector.Request;
-import org.apache.chemistry.atompub.client.connector.Response;
-import org.apache.chemistry.atompub.client.stax.ReadContext;
 import org.apache.chemistry.impl.base.BaseObject;
+import org.apache.commons.httpclient.Header;
 
 /**
  *
@@ -114,19 +113,26 @@
      */
 
     public Folder getParent() {
-        String href = entry.getLink(AtomPub.LINK_UP); // usually a feed entry
-        if (href == null) {
-            return null;
+        APPObjectEntry parentEntry;
+        if (getBaseType() == BaseType.FOLDER) {
+            parentEntry = (APPObjectEntry) entry.connection.getFolderParent(
+                    this, null);
+            if (parentEntry == null) {
+                return null;
+            }
+        } else {
+            String href = entry.getLink(AtomPub.LINK_UP); // feed or entry
+            if (href == null) {
+                return null;
+            }
+            Collection<ObjectEntry> parents = entry.connection.getObjectParents(
+                    this, null);
+            if (parents.isEmpty()) {
+                return null;
+            }
+            parentEntry = (APPObjectEntry) parents.iterator().next();
         }
-        // can read an entry directly, or the first one from a feed
-        APPObjectEntry e = (APPObjectEntry) entry.connection.getConnector().getObject(
-                new ReadContext(entry.connection), href);
-        if (e == null) {
-            return null; // no parent
-        }
-        Type t = entry.connection.getRepository().getType(e.getTypeId());
-        APPFolder f = new APPFolder(e, t);
-        return f;
+        return (Folder) construct(parentEntry);
     }
 
     public Collection<Folder> getParents() {
@@ -219,60 +225,25 @@
     }
 
     protected void create() throws ContentManagerException {
-        Connector connector = entry.connection.getConnector();
-        ReadContext ctx = new ReadContext(entry.connection);
-
         // this link value is local, set by APPConnection#newDocument
         String href = entry.getLink(AtomPub.LINK_UP);
         if (href == null) {
-            throw new IllegalArgumentException(
-                    "Cannot create entry: no 'cmis-parents' link is present");
+            throw new CMISRuntimeException("Missing up link");
         }
         // TODO hardcoded Chemistry URL pattern here...
         href = href.replaceAll("/object/([0-9a-f-]{36}$)", "/children/$1");
-        Request req = new Request(href);
-        req.setHeader("Content-Type", AtomPub.MEDIA_TYPE_ATOM_ENTRY);
-        Response resp = connector.postObject(req, entry);
-        if (resp.getStatusCode() != 201) { // Created
-            throw new ContentManagerException(
-                    "Remote server returned error code: "
-                            + resp.getStatusCode());
-        }
-        APPObjectEntry newEntry = (APPObjectEntry) resp.getObject(ctx);
-        // newEntry SHOULD be returned (AtomPub 9.2)...
-        String loc = resp.getHeader("Location");
-        if (loc == null) {
-            throw new ContentManagerException(
-                    "Remote server failed to return a Location header");
-        }
-        if (newEntry == null || !loc.equals(resp.getHeader("Content-Location"))) {
-            // (Content-Location defined by AtomPub 9.2)
-            // fetch actual new entry from Location header
-            // TODO could fetch only a subset of the properties, if deemed ok
-            newEntry = (APPObjectEntry) connector.getObject(ctx, loc);
-            if (newEntry == null) {
-                throw new ContentManagerException(
-                        "Remote server failed to return an entry for Location: "
-                                + loc);
-            }
-        }
-        entry = newEntry;
+
+        entry = entry.connection.connector.postEntry(href, null, entry);
     }
 
     protected void update() throws ContentManagerException {
         String href = entry.getEditLink();
         if (href == null) {
-            throw new IllegalArgumentException(
-                    "Cannot edit entry: no 'edit' link is present");
-        }
-        Request req = new Request(href);
-        req.setHeader("Content-Type", AtomPub.MEDIA_TYPE_ATOM_ENTRY);
-        Response resp = entry.connection.getConnector().putObject(req, entry);
-        if (!resp.isOk()) {
-            throw new ContentManagerException(
-                    "Remote server returned error code: "
-                            + resp.getStatusCode());
+            throw new CMISRuntimeException("Missing edit link");
         }
+        Header header = new Header("Content-Type",
+                AtomPub.MEDIA_TYPE_ATOM_ENTRY);
+        entry = entry.connection.connector.putEntry(href, header, entry);
     }
 
     /**
@@ -319,21 +290,13 @@
         // TODO this could save the stream in a side object and put it back in
         // the entry's local content stream when done, to allow reuse
         public InputStream getStream() throws IOException {
-            try {
-                Response resp = entry.connection.connector.get(new Request(url));
-                if (!resp.isOk()) {
-                    throw new IOException("Error: " + resp.getStatusCode()
-                            + " fetching: " + url);
-                }
-                if (length == -1) {
-                    // get the "official" length if available
-                    length = resp.getStreamLength();
-                }
-                return resp.getStream();
-            } catch (ContentManagerException e) {
-                throw (IOException) (new IOException(
-                        "Could not fetch stream from: " + url).initCause(e));
+            ContentStream cs = entry.connection.connector.getContentStream(url,
+                    null, null);
+            if (length == -1) {
+                // ((HttpMethodBase) method).getResponseContentLength();
+                length = cs.getLength();
             }
+            return cs.getStream();
         }
     }
 

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectEntryReader.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectEntryReader.java?rev=901263&r1=901262&r2=901263&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectEntryReader.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectEntryReader.java Wed Jan 20 16:30:22 2010
@@ -35,12 +35,6 @@
  */
 public class APPObjectEntryReader extends AbstractObjectReader<APPObjectEntry> {
 
-    private static final APPObjectEntryReader builder = new APPObjectEntryReader();
-
-    public static APPObjectEntryReader getBuilder() {
-        return builder;
-    }
-
     @Override
     protected APPObjectEntry createObject(ReadContext ctx) {
         APPConnection connection = (APPConnection) ctx.getConnection();

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectFeedReader.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectFeedReader.java?rev=901263&r1=901262&r2=901263&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectFeedReader.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObjectFeedReader.java Wed Jan 20 16:30:22 2010
@@ -19,7 +19,6 @@
 import org.apache.chemistry.ListPage;
 import org.apache.chemistry.ObjectEntry;
 import org.apache.chemistry.atompub.client.stax.AbstractFeedReader;
-import org.apache.chemistry.atompub.client.stax.EntryReader;
 import org.apache.chemistry.impl.simple.SimpleListPage;
 import org.apache.chemistry.xml.stax.StaxReader;
 
@@ -29,18 +28,8 @@
 public class APPObjectFeedReader extends
         AbstractFeedReader<ListPage<ObjectEntry>, APPObjectEntry> {
 
-    private static final APPObjectFeedReader builder = new APPObjectFeedReader();
-
-    public static APPObjectFeedReader getBuilder() {
-        return builder;
-    }
-
-    public APPObjectFeedReader(EntryReader<APPObjectEntry> entryBuilder) {
-        super(entryBuilder);
-    }
-
     public APPObjectFeedReader() {
-        this(APPObjectEntryReader.getBuilder());
+        super(new APPObjectEntryReader());
     }
 
     @Override

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=901263&r1=901262&r2=901263&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 Jan 20 16:30:22 2010
@@ -36,9 +36,9 @@
 import org.apache.chemistry.atompub.AtomPub;
 import org.apache.chemistry.atompub.AtomPubCMIS;
 import org.apache.chemistry.atompub.URITemplate;
-import org.apache.chemistry.atompub.client.connector.APPContentManager;
 import org.apache.chemistry.atompub.client.stax.ReadContext;
 import org.apache.chemistry.impl.simple.SimpleTypeManager;
+import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -51,6 +51,8 @@
 
     protected final APPContentManager cm;
 
+    protected final Connector connector;
+
     protected RepositoryInfo info;
 
     protected String id;
@@ -67,6 +69,7 @@
 
     public APPRepository(APPContentManager cm, RepositoryInfo info) {
         this.cm = cm;
+        connector = new Connector(cm.getClient(), new ReadContext(this));
         this.info = info;
     }
 
@@ -78,6 +81,10 @@
         return cm;
     }
 
+    public HttpClient client() {
+        return cm.getClient();
+    }
+
     public String getId() {
         if (id == null) {
             id = info.getId();
@@ -209,7 +216,7 @@
 
     protected TypeManager readTypes(String href) throws Exception {
         href = includePropertyDefinitionsInURI(href);
-        return cm.getConnector().getTypeFeed(new ReadContext(this), href, true);
+        return connector.getTypeFeed(href, true);
     }
 
     protected static String includePropertyDefinitionsInURI(String href) {

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPServiceDocumentReader.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPServiceDocumentReader.java?rev=901263&r1=901262&r2=901263&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPServiceDocumentReader.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPServiceDocumentReader.java Wed Jan 20 16:30:22 2010
@@ -18,7 +18,6 @@
 
 import org.apache.chemistry.RepositoryInfo;
 import org.apache.chemistry.atompub.URITemplate;
-import org.apache.chemistry.atompub.client.connector.APPContentManager;
 import org.apache.chemistry.atompub.client.stax.ReadContext;
 import org.apache.chemistry.atompub.client.stax.ServiceDocumentReader;
 

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPType.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPType.java?rev=901263&r1=901262&r2=901263&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPType.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPType.java Wed Jan 20 16:30:22 2010
@@ -29,8 +29,6 @@
 import org.apache.chemistry.ContentStreamPresence;
 import org.apache.chemistry.PropertyDefinition;
 import org.apache.chemistry.Type;
-import org.apache.chemistry.atompub.client.connector.Connector;
-import org.apache.chemistry.atompub.client.stax.ReadContext;
 
 /**
  *
@@ -176,10 +174,8 @@
 
     protected void loadPropertyDef() {
         if (propertyDefs == null) {
-            Connector connector = repository.getContentManager().getConnector();
             String href = APPRepository.includePropertyDefinitionsInURI(getEditLink());
-            APPType typeDef = (APPType) connector.getType(new ReadContext(
-                    repository), href, true);
+            APPType typeDef = repository.connector.getType(href, true, getId());
             propertyDefs = typeDef.propertyDefs == null ? new HashMap<String, PropertyDefinition>()
                     : typeDef.propertyDefs;
         }

Copied: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/Connector.java (from r901135, incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/HttpClientConnector.java)
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/Connector.java?p2=incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/Connector.java&p1=incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/HttpClientConnector.java&r1=901135&r2=901263&rev=901263&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/connector/HttpClientConnector.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/Connector.java Wed Jan 20 16:30:22 2010
@@ -14,245 +14,323 @@
  * Authors:
  *     Bogdan Stefanescu, Nuxeo
  *     Ugo Cei, Sourcesense
+ *     Florent Guillaume, Nuxeo
  */
-package org.apache.chemistry.atompub.client.connector;
+package org.apache.chemistry.atompub.client;
 
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.util.List;
 
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.chemistry.ConstraintViolationException;
+import org.apache.chemistry.ContentStream;
 import org.apache.chemistry.Inclusion;
+import org.apache.chemistry.ListPage;
 import org.apache.chemistry.ObjectEntry;
+import org.apache.chemistry.ObjectNotFoundException;
 import org.apache.chemistry.Paging;
-import org.apache.chemistry.Repository;
-import org.apache.chemistry.Type;
 import org.apache.chemistry.TypeManager;
+import org.apache.chemistry.atompub.AtomPub;
+import org.apache.chemistry.atompub.client.APPObjectEntry;
+import org.apache.chemistry.atompub.client.APPObjectEntryReader;
+import org.apache.chemistry.atompub.client.APPObjectEntryWriter;
+import org.apache.chemistry.atompub.client.APPObjectFeedReader;
+import org.apache.chemistry.atompub.client.APPRepository;
+import org.apache.chemistry.atompub.client.APPServiceDocumentReader;
+import org.apache.chemistry.atompub.client.APPType;
 import org.apache.chemistry.atompub.client.ContentManagerException;
+import org.apache.chemistry.atompub.client.TypeEntryReader;
+import org.apache.chemistry.atompub.client.TypeFeedReader;
+import org.apache.chemistry.atompub.client.stax.EntryReader;
+import org.apache.chemistry.atompub.client.stax.FeedReader;
+import org.apache.chemistry.atompub.client.stax.QueryWriter;
 import org.apache.chemistry.atompub.client.stax.ReadContext;
 import org.apache.chemistry.atompub.client.stax.XmlObjectWriter;
+import org.apache.chemistry.impl.simple.SimpleContentStream;
+import org.apache.commons.httpclient.Header;
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.NameValuePair;
-import org.apache.commons.httpclient.auth.CredentialsProvider;
+import org.apache.commons.httpclient.HttpStatus;
 import org.apache.commons.httpclient.methods.DeleteMethod;
 import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.HeadMethod;
 import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
 import org.apache.commons.httpclient.methods.PostMethod;
 import org.apache.commons.httpclient.methods.PutMethod;
 import org.apache.commons.httpclient.methods.RequestEntity;
 
 /**
- *
+ * A Connector abstracts the HTTP or AtomPub operations.
  */
-public class HttpClientConnector implements Connector {
+public class Connector {
 
     protected final HttpClient client;
 
-    protected final IOProvider io;
+    protected final ReadContext ctx;
 
-    public HttpClientConnector(IOProvider io) {
-        this.io = io;
-        client = new HttpClient();
-        // use a multi-threaded connection manager because we need reentrancy
-        // when reading some property definition
-        // client.setHttpConnectionManager(new
-        // MultiThreadedHttpConnectionManager());
-    }
-
-    public void setCredentialsProvider(CredentialsProvider cp) {
-        client.getParams().setAuthenticationPreemptive(true);
-        client.getParams().setParameter(CredentialsProvider.PROVIDER, cp);
-    }
-
-    protected void setMethodParams(HttpMethod method, Request request) {
-        List<String> params = request.getParameters();
-        if (params != null) {
-            int len = params.size() >> 1;
-            if (len > 0) {
-                NameValuePair[] qs = new NameValuePair[len];
-                for (int i = 0, k = 0; i < len; i++, k += 2) {
-                    qs[i] = new NameValuePair(params.get(k), params.get(k + 1));
-                }
-                method.setQueryString(qs);
-            }
-        }
+    public Connector(HttpClient client, ReadContext ctx) {
+        this.client = client;
+        this.ctx = ctx;
     }
 
-    protected void setMethodHeaders(HttpMethod method, Request request) {
-        List<String> headers = request.getHeaders();
-        if (headers != null) {
-            int len = headers.size();
-            for (int k = 0; k < len; k += 2) {
-                method.addRequestHeader(headers.get(k), headers.get(k + 1));
+    public APPRepository[] getServiceDocument(String href) {
+        GetMethod method = new GetMethod(href);
+        try {
+            client.executeMethod(method);
+            int status = method.getStatusCode();
+            if (status >= HttpStatus.SC_BAD_REQUEST) {
+                throw new ContentManagerException(
+                        "Remote server returned error code: " + status);
             }
+            return new APPServiceDocumentReader().read(ctx,
+                    method.getResponseBodyAsStream());
+        } catch (IOException e) {
+            throw new ContentManagerException(e);
+        } finally {
+            method.releaseConnection();
         }
     }
 
-    public Response get(Request request) throws ContentManagerException {
-        try {
-            GetMethod method = new GetMethod(request.getUrl());
-            setMethodParams(method, request);
-            setMethodHeaders(method, request);
-            client.executeMethod(method);
-            return new HttpClientResponse(method, io);
-        } catch (Exception e) {
-            throw new ContentManagerException("GET request failed", e);
-        }
+    public ListPage<ObjectEntry> getEntryFeed(String href, NameValuePairs params) {
+        return getObjectFeed(href, params, new APPObjectFeedReader());
     }
 
-    public Response delete(Request request) throws ContentManagerException {
-        try {
-            DeleteMethod method = new DeleteMethod(request.getUrl());
-            setMethodParams(method, request);
-            setMethodHeaders(method, request);
-            client.executeMethod(method);
-            return new HttpClientResponse(method, io);
-        } catch (Exception e) {
-            throw new ContentManagerException("DELETE request failed", e);
-        }
+    public TypeManager getTypeFeed(String href,
+            boolean includePropertyDefinitions) {
+        return getObjectFeed(href, null, new TypeFeedReader(
+                includePropertyDefinitions));
     }
 
-    public Response head(Request request) throws ContentManagerException {
+    protected <T> T getObjectFeed(String href, NameValuePairs params,
+            FeedReader<T> reader) {
+        HttpMethod method = new GetMethod(href);
         try {
-            HeadMethod method = new HeadMethod(request.getUrl());
-            setMethodParams(method, request);
-            setMethodHeaders(method, request);
+            if (params != null) {
+                method.setQueryString(params.toArray());
+            }
             client.executeMethod(method);
-            return new HttpClientResponse(method, io);
-        } catch (Exception e) {
-            throw new ContentManagerException("HEAD request failed", e);
+            int status = method.getStatusCode();
+            if (status >= HttpStatus.SC_BAD_REQUEST) {
+                throw new ContentManagerException(
+                        "Remote server returned error code: " + status);
+            }
+            return reader.read(ctx, method.getResponseBodyAsStream());
+        } catch (IOException e) {
+            throw new ContentManagerException(e);
+        } catch (XMLStreamException e) {
+            throw new ContentManagerException(e);
+        } finally {
+            method.releaseConnection();
         }
     }
 
-    public <T> Response post(Request request, XmlObjectWriter<T> writer,
-            T object) throws ContentManagerException {
-        try {
-            PostMethod method = new PostMethod(request.getUrl());
-            setMethodParams(method, request);
-            setMethodHeaders(method, request);
-            method.setRequestEntity(new XmlObjectWriterRequestEntity<T>(writer,
-                    object));
-            method.setContentChunked(true);
-            client.executeMethod(method);
-            return new HttpClientResponse(method, io);
-        } catch (Exception e) {
-            throw new ContentManagerException("POST request failed", e);
-        }
+    public APPObjectEntry getEntry(String href, String msg) {
+        return getObject(href, msg, new APPObjectEntryReader());
+    }
+
+    public APPType getType(String href, boolean includePropertyDefinitions,
+            String msg) {
+        return getObject(href, msg, new TypeEntryReader(
+                includePropertyDefinitions));
     }
 
-    public <T> Response put(Request request, XmlObjectWriter<T> writer, T object)
-            throws ContentManagerException {
+    protected <T> T getObject(String href, String msg, EntryReader<T> reader) {
+        HttpMethod method = new GetMethod(href);
         try {
-            PutMethod method = new PutMethod(request.getUrl());
-            setMethodParams(method, request);
-            setMethodHeaders(method, request);
-            method.setRequestEntity(new XmlObjectWriterRequestEntity<T>(writer,
-                    object));
             client.executeMethod(method);
-            return new HttpClientResponse(method, io);
-        } catch (Exception e) {
-            throw new ContentManagerException("PUT request failed", e);
+            int status = method.getStatusCode();
+            if (status == HttpStatus.SC_NOT_FOUND) {
+                throw new ObjectNotFoundException(msg);
+            }
+            if (status == HttpStatus.SC_CONFLICT) {
+                throw new ConstraintViolationException(msg);
+            }
+            if (status >= HttpStatus.SC_BAD_REQUEST) {
+                throw new ContentManagerException(
+                        "Remote server returned error code: " + status);
+            }
+            return reader.read(ctx, method.getResponseBodyAsStream());
+        } catch (IOException e) {
+            throw new ContentManagerException(e);
+        } catch (XMLStreamException e) {
+            throw new ContentManagerException(e);
+        } finally {
+            method.releaseConnection();
         }
     }
 
-    public Response put(Request request, InputStream in, long length,
-            String type) throws ContentManagerException {
+    public ContentStream getContentStream(String href, String mimeType,
+            String filename) throws IOException {
+        HttpMethod method = new GetMethod(href);
         try {
-            PutMethod method = new PutMethod(request.getUrl());
-            setMethodParams(method, request);
-            setMethodHeaders(method, request);
-            method.setRequestEntity(new InputStreamRequestEntity(in, length,
-                    type));
             client.executeMethod(method);
-            return new HttpClientResponse(method, io);
-        } catch (Exception e) {
-            throw new ContentManagerException("PUT request failed", e);
+            int status = method.getStatusCode();
+            if (status == HttpStatus.SC_NOT_FOUND
+                    || status == HttpStatus.SC_CONFLICT) {
+                throw new ConstraintViolationException("No content stream");
+            }
+            if (status >= HttpStatus.SC_BAD_REQUEST) {
+                throw new ContentManagerException(
+                        "Remote server returned error code: " + status);
+            }
+            InputStream is = method.getResponseBodyAsStream();
+            return new SimpleContentStream(is, mimeType, filename);
+        } finally {
+            // because of this, we have to consume the stream completely
+            // therefore we must copy it (SimpleContentStream does it)
+            method.releaseConnection();
         }
-    }
 
-    public Type getType(ReadContext ctx, String href,
-            boolean includePropertyDefinitions) {
-        Request req = new Request(href);
-        Response resp = get(req);
-        if (!resp.isOk()) {
-            throw new ContentManagerException(
-                    "Remote server returned error code: "
-                            + resp.getStatusCode() + "\n\n" + resp.getString());
-        }
-        return resp.getType(ctx, includePropertyDefinitions);
     }
 
-    public ObjectEntry getObject(ReadContext ctx, String href) {
-        Request req = new Request(href);
-        Response resp = get(req);
-        if (!resp.isOk()) {
-            throw new ContentManagerException(
-                    "Remote server returned error code: "
-                            + resp.getStatusCode() + "\n\n" + resp.getString());
-        }
-        return resp.getObject(ctx);
+    public APPObjectEntry putEntry(String href, Header header,
+            APPObjectEntry entry) {
+        RequestEntity requestEntity = new XmlObjectWriterRequestEntity<ObjectEntry>(
+                new APPObjectEntryWriter(), entry);
+        return put(href, header, requestEntity);
     }
 
-    public List<ObjectEntry> getObjectFeed(ReadContext ctx, String href)
-            throws ContentManagerException {
-        Request req = new Request(href);
-        Response resp = get(req);
-        if (!resp.isOk()) {
-            throw new ContentManagerException(
-                    "Remote server returned error code: "
-                            + resp.getStatusCode() + "\n\n" + resp.getString());
-        }
-        return resp.getObjectFeed(ctx);
+    public APPObjectEntry putStream(String href, ContentStream cs)
+            throws IOException {
+        RequestEntity requestEntity = new InputStreamRequestEntity(
+                cs.getStream(), cs.getLength(), cs.getMimeType());
+        // Use Slug: header for filename
+        String filename = cs.getFileName();
+        Header header = filename == null ? null : new Header(
+                AtomPub.HEADER_SLUG, filename);
+        return put(href, header, requestEntity);
     }
 
-    public TypeManager getTypeFeed(ReadContext ctx, String href,
-            boolean includePropertyDefinitions) throws ContentManagerException {
-        Request req = new Request(href);
-        Response resp = get(req);
-        if (!resp.isOk()) {
-            throw new ContentManagerException(
-                    "Remote server returned error code: "
-                            + resp.getStatusCode() + "\n\n" + resp.getString());
+    protected APPObjectEntry put(String href, Header header,
+            RequestEntity requestEntity) {
+        PutMethod method = new PutMethod(href);
+        try {
+            if (header != null) {
+                method.addRequestHeader(header);
+            }
+            method.setRequestEntity(requestEntity);
+            method.setContentChunked(true);
+            client.executeMethod(method);
+            int status = method.getStatusCode();
+            if (status >= HttpStatus.SC_BAD_REQUEST) {
+                throw new ContentManagerException(
+                        "Remote server returned error code: " + status);
+            }
+            if (requestEntity instanceof InputStreamRequestEntity) {
+                // no answer expected for stream put
+                return null;
+            } else {
+                return new APPObjectEntryReader().read(ctx,
+                        method.getResponseBodyAsStream());
+            }
+        } catch (IOException e) {
+            throw new ContentManagerException(e);
+        } catch (XMLStreamException e) {
+            throw new ContentManagerException(e);
+        } finally {
+            method.releaseConnection();
         }
-        return resp.getTypeFeed(ctx, includePropertyDefinitions);
     }
 
-    public Repository[] getServiceDocument(ReadContext ctx, String href)
-            throws ContentManagerException {
-        Request req = new Request(href);
-        Response resp = get(req);
-        if (!resp.isOk()) {
-            throw new ContentManagerException(
-                    "Remote server returned error code: "
-                            + resp.getStatusCode() + "\n\n" + resp.getString());
+    public APPObjectEntry postEntry(String href, NameValuePairs params,
+            APPObjectEntry entry) {
+        PostMethod method = new PostMethod(href);
+        try {
+            if (params != null) {
+                method.setQueryString(params.toArray());
+            }
+            method.addRequestHeader("Content-Type",
+                    AtomPub.MEDIA_TYPE_ATOM_ENTRY);
+            method.setRequestEntity(new XmlObjectWriterRequestEntity<ObjectEntry>(
+                    new APPObjectEntryWriter(), entry));
+            method.setContentChunked(true);
+            client.executeMethod(method);
+            int status = method.getStatusCode();
+            if (status != HttpStatus.SC_CREATED) {
+                throw new ContentManagerException(
+                        "Remote server returned error code: " + status);
+            }
+            APPObjectEntry newEntry = new APPObjectEntryReader().read(ctx,
+                    method.getResponseBodyAsStream());
+            // newEntry SHOULD be returned (AtomPub 9.2)...
+            Header loc = method.getResponseHeader("Location");
+            Header cloc = method.getResponseHeader("Content-Location");
+            if (loc == null) {
+                throw new ContentManagerException(
+                        "Remote server failed to return a Location header");
+            }
+            if (newEntry == null || !loc.equals(cloc)) {
+                // (Content-Location defined by AtomPub 9.2)
+                // fetch actual new entry from Location header
+                // TODO could fetch only a subset of the properties, if deemed
+                // ok
+                newEntry = getEntry(loc.getValue(), loc.getValue());
+                if (newEntry == null) {
+                    throw new ContentManagerException(
+                            "Remote server failed to return an entry for Location: "
+                                    + loc);
+                }
+            }
+            return newEntry;
+        } catch (IOException e) {
+            throw new ContentManagerException(e);
+        } catch (XMLStreamException e) {
+            throw new ContentManagerException(e);
+        } finally {
+            method.releaseConnection();
         }
-        return resp.getServiceDocument(ctx);
-    }
-
-    public Response putObject(Request req, ObjectEntry entry)
-            throws ContentManagerException {
-        return put(req, io.getObjectEntryWriter(), entry);
-    }
-
-    public Response putQuery(Request req, String query,
-            boolean searchAllVersions, Inclusion inclusion, Paging paging)
-            throws ContentManagerException {
-        return put(req,
-                io.getQueryWriter(searchAllVersions, inclusion, paging), query);
     }
 
-    public Response postObject(Request req, ObjectEntry entry)
-            throws ContentManagerException {
-        return post(req, io.getObjectEntryWriter(), entry);
+    public ListPage<ObjectEntry> postQuery(String href, String statement,
+            boolean searchAllVersions, Inclusion inclusion, Paging paging) {
+        PostMethod method = new PostMethod(href);
+        try {
+            method.setRequestEntity(new XmlObjectWriterRequestEntity<String>(
+                    new QueryWriter(searchAllVersions, inclusion, paging),
+                    statement));
+            method.setContentChunked(true);
+            client.executeMethod(method);
+            int status = method.getStatusCode();
+            if (status >= HttpStatus.SC_BAD_REQUEST) {
+                throw new ContentManagerException(
+                        "Remote server returned error code: " + status);
+            }
+            return new APPObjectFeedReader().read(ctx,
+                    method.getResponseBodyAsStream());
+        } catch (IOException e) {
+            throw new ContentManagerException(e);
+        } catch (XMLStreamException e) {
+            throw new ContentManagerException(e);
+        } finally {
+            method.releaseConnection();
+        }
     }
 
-    public Response postQuery(Request req, String query,
-            boolean searchAllVersions, Inclusion inclusion, Paging paging)
-            throws ContentManagerException {
-        return post(req,
-                io.getQueryWriter(searchAllVersions, inclusion, paging), query);
+    public void delete(String href, NameValuePairs params, String msg) {
+        HttpMethod method = new DeleteMethod(href);
+        try {
+            if (params != null) {
+                method.setQueryString(params.toArray());
+            }
+            client.executeMethod(method);
+            int status = method.getStatusCode();
+            if (status == HttpStatus.SC_NOT_FOUND) {
+                throw new ObjectNotFoundException(msg);
+            }
+            if (status == HttpStatus.SC_CONFLICT) {
+                throw new ConstraintViolationException(
+                        method.getStatusLine().getReasonPhrase());
+            }
+            if (status >= HttpStatus.SC_BAD_REQUEST) {
+                throw new ContentManagerException(
+                        "Remote server returned error code: " + status);
+            }
+        } catch (IOException e) {
+            throw new ContentManagerException(e);
+        } finally {
+            method.releaseConnection();
+        }
     }
 
     public static class XmlObjectWriterRequestEntity<T> implements

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/NameValuePairs.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/NameValuePairs.java?rev=901263&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/NameValuePairs.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/NameValuePairs.java Wed Jan 20 16:30:22 2010
@@ -0,0 +1,39 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Authors:
+ *     Florent Guillaume, Nuxeo
+ */
+package org.apache.chemistry.atompub.client;
+
+import java.util.LinkedList;
+
+import org.apache.commons.httpclient.NameValuePair;
+
+/**
+ * A list of {@link NameValuePair}s that can easily be turned into an array.
+ */
+public class NameValuePairs extends LinkedList<NameValuePair> {
+
+    private static final long serialVersionUID = 1L;
+
+    public void add(String name, String value) {
+        add(new NameValuePair(name, value));
+    }
+
+    @Override
+    public NameValuePair[] toArray() {
+        return super.toArray(new NameValuePair[size()]);
+    }
+
+}

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/NameValuePairs.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/NameValuePairs.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/QueryWriter.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/QueryWriter.java?rev=901263&r1=901262&r2=901263&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/QueryWriter.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/QueryWriter.java Wed Jan 20 16:30:22 2010
@@ -31,21 +31,16 @@
  */
 public class QueryWriter extends AbstractXmlObjectWriter<String> {
 
-    protected boolean searchAllVersions;
+    protected final boolean searchAllVersions;
 
-    protected Inclusion inclusion;
+    protected final Inclusion inclusion;
 
-    protected Paging paging;
+    protected final Paging paging;
 
-    public void setSearchAllVersions(boolean searchAllVersions) {
+    public QueryWriter(boolean searchAllVersions, Inclusion inclusion,
+            Paging paging) {
         this.searchAllVersions = searchAllVersions;
-    }
-
-    public void setInclusion(Inclusion inclusion) {
         this.inclusion = inclusion;
-    }
-
-    public void setPaging(Paging paging) {
         this.paging = paging;
     }
 

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/ServiceDocumentReaderTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/ServiceDocumentReaderTest.java?rev=901263&r1=901262&r2=901263&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/ServiceDocumentReaderTest.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/ServiceDocumentReaderTest.java Wed Jan 20 16:30:22 2010
@@ -41,7 +41,8 @@
     public void testReadServiceDocument() throws Exception {
         InputStream is = getClass().getResourceAsStream("/service-document.xml");
         ServiceDocumentReader<APPRepository> reader = new APPServiceDocumentReader();
-        Repository[] repos = reader.read(new ReadContext((Repository) null), is);
+        ReadContext ctx = new ReadContext(new APPContentManager(""));
+        Repository[] repos = reader.read(ctx, is);
         assertEquals(1, repos.length);
         Repository repo = repos[0];
         assertEquals("test", repo.getId());
@@ -62,7 +63,8 @@
         RepositoryCapabilities cap = info.getCapabilities();
         assertEquals(CapabilityACL.MANAGE, cap.getACLCapability());
         assertFalse(cap.isAllVersionsSearchable());
-        assertEquals(CapabilityChange.OBJECT_IDS_ONLY, cap.getChangeCapability());
+        assertEquals(CapabilityChange.OBJECT_IDS_ONLY,
+                cap.getChangeCapability());
         assertTrue(cap.isContentStreamUpdatableAnytime());
         assertTrue(cap.hasGetDescendants());
         assertTrue(cap.hasGetFolderTree());

Modified: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/app/ChemistryApp.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/app/ChemistryApp.java?rev=901263&r1=901262&r2=901263&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/app/ChemistryApp.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/app/ChemistryApp.java Wed Jan 20 16:30:22 2010
@@ -24,7 +24,7 @@
 
 package org.apache.chemistry.shell.app;
 
-import org.apache.chemistry.atompub.client.connector.APPContentManager;
+import org.apache.chemistry.atompub.client.APPContentManager;
 import org.apache.chemistry.shell.cmds.cmis.Cat;
 import org.apache.chemistry.shell.cmds.cmis.CreateFile;
 import org.apache.chemistry.shell.cmds.cmis.CreateFolder;

Modified: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/app/ChemistryContext.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/app/ChemistryContext.java?rev=901263&r1=901262&r2=901263&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/app/ChemistryContext.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/app/ChemistryContext.java Wed Jan 20 16:30:22 2010
@@ -33,7 +33,7 @@
 import org.apache.chemistry.ObjectEntry;
 import org.apache.chemistry.Repository;
 import org.apache.chemistry.atompub.client.APPConnection;
-import org.apache.chemistry.atompub.client.connector.APPContentManager;
+import org.apache.chemistry.atompub.client.APPContentManager;
 import org.apache.chemistry.shell.util.ColorHelper;
 import org.apache.chemistry.shell.util.Path;
 

Modified: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/app/ChemistryRootContext.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/app/ChemistryRootContext.java?rev=901263&r1=901262&r2=901263&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/app/ChemistryRootContext.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/app/ChemistryRootContext.java Wed Jan 20 16:30:22 2010
@@ -30,8 +30,8 @@
 import org.apache.chemistry.CMISObject;
 import org.apache.chemistry.Repository;
 import org.apache.chemistry.atompub.client.APPConnection;
+import org.apache.chemistry.atompub.client.APPContentManager;
 import org.apache.chemistry.atompub.client.ContentManager;
-import org.apache.chemistry.atompub.client.connector.APPContentManager;
 import org.apache.chemistry.shell.util.ColorHelper;
 import org.apache.chemistry.shell.util.Path;
 

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=901263&r1=901262&r2=901263&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 Wed Jan 20 16:30:22 2010
@@ -19,8 +19,8 @@
 import javax.servlet.Servlet;
 
 import org.apache.chemistry.Repository;
+import org.apache.chemistry.atompub.client.APPContentManager;
 import org.apache.chemistry.atompub.client.ContentManager;
-import org.apache.chemistry.atompub.client.connector.APPContentManager;
 import org.apache.chemistry.atompub.server.servlet.CMISServlet;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;



Mime
View raw message