You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fg...@apache.org on 2009/06/05 11:05:22 UTC

svn commit: r781949 [1/5] - in /incubator/chemistry/trunk/chemistry: ./ chemistry-atompub-client/ chemistry-atompub-client/src/ chemistry-atompub-client/src/main/ chemistry-atompub-client/src/main/java/ chemistry-atompub-client/src/main/java/org/ chemi...

Author: fguillaume
Date: Fri Jun  5 09:05:20 2009
New Revision: 781949

URL: http://svn.apache.org/viewvc?rev=781949&view=rev
Log:
Initial version of an AtomPub client binding, not functional yet

Added:
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/pom.xml   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/ContentManager.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/ContentManagerException.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/Credentials.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/CredentialsProvider.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/NoSuchRepositoryException.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/APPContentManager.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/Connector.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/DefaultCredentialsProvider.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/DefaultIOProvider.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/IOProvider.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/Request.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/Response.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/httpclient/
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/httpclient/HttpClientConnector.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/httpclient/HttpClientResponse.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/httpclient/ObjectRequestEntity.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPConnection.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPDocument.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPFolder.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPObject.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPObjectEntry.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPObjectEntryReader.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPObjectEntryWriter.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPObjectFeedReader.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPPropertyDefinition.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPRepository.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPRepositoryCapabilities.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPRepositoryInfo.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPServiceDocumentReader.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPType.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/TypeEntryReader.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/TypeFeedReader.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/service/
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/service/ExtensionService.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/service/ServiceContext.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/service/ServiceEntryReader.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/service/ServiceFeedReader.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/service/ServiceInfo.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/AdapterFactory.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/AdapterManager.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/ClassLookup.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/ClassNameRegistry.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/ClassRegistry.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/DateParser.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/Path.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/atom/
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/atom/ATOM.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/atom/AbstractEntryReader.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/atom/AbstractFeedReader.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/atom/AbstractObjectReader.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/atom/AbstractXmlObjectWriter.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/atom/DefaultEntryReader.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/atom/EntryReader.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/atom/FeedReader.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/atom/ListFeedReader.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/atom/ObjectEntryWriter.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/atom/PropertyIterator.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/atom/ReadContext.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/atom/ServiceDocumentReader.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/atom/ValueAdapter.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/atom/ValueIterator.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/atom/XmlObject.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/atom/XmlObjectWriter.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/atom/XmlProperty.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/xml/
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/xml/ChildrenIterator.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/xml/ChildrenNavigator.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/xml/ElementIterator.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/xml/FilteredChildrenNavigator.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/xml/ParseException.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/xml/SiblingsIterator.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/xml/StaxReader.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/xml/XMLWriter.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-parent/.project
Modified:
    incubator/chemistry/trunk/chemistry/chemistry-parent/pom.xml
    incubator/chemistry/trunk/chemistry/pom.xml

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Jun  5 09:05:20 2009
@@ -0,0 +1,7 @@
+bin
+target
+*.iws
+*.ipr
+*.iml
+.*
+

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/pom.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/pom.xml?rev=781949&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/pom.xml (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/pom.xml Fri Jun  5 09:05:20 2009
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+   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.
+  -->
+
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.chemistry</groupId>
+    <artifactId>chemistry-parent</artifactId>
+    <version>0.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>chemistry-atompub-client</artifactId>
+  <name>Chemistry AtomPub Client</name>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>org.apache.chemistry</groupId>
+      <artifactId>chemistry-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.chemistry</groupId>
+      <artifactId>chemistry-atompub</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.chemistry</groupId>
+      <artifactId>chemistry-commons</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>stax</groupId>
+      <artifactId>stax-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.woodstox</groupId>
+      <artifactId>wstx-asl</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>commons-httpclient</groupId>
+      <artifactId>commons-httpclient</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>commons-collections</groupId>
+      <artifactId>commons-collections</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.mortbay.jetty</groupId>
+      <artifactId>jetty</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.mortbay.jetty</groupId>
+      <artifactId>jetty-util</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+</project>

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/ContentManager.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/ContentManager.java?rev=781949&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/ContentManager.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/ContentManager.java Fri Jun  5 09:05:20 2009
@@ -0,0 +1,86 @@
+/*
+ * 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:
+ *     Bogdan Stefanescu, Nuxeo
+ */
+package org.apache.chemistry.atompub.client;
+
+import org.apache.chemistry.Repository;
+
+/**
+ * The entry point to CMIS repositories exposed by a server.
+ *
+ * An instance of this service can be used to enumerate available repositories,
+ * and fetch repository objects given they name. This interface doesn't define
+ * how to register new repositories.
+ * <p>
+ * There will be different implementations depending on how the repositories are
+ * accessed i.e. whether or not the ContentManager is used to access remote or
+ * local repositories.
+ * <p>
+ * The discovery mechanism used by the implementation to detect repositories is
+ * up to the implementors. Repositories connected through APP will use APP
+ * discovery, local repositories will use repository specific java API etc.
+ */
+public interface ContentManager {
+
+    Repository[] getRepositories() throws ContentManagerException;
+
+    Repository getDefaultRepository() throws ContentManagerException;
+
+    Repository getRepository(String id) throws NoSuchRepositoryException,
+            ContentManagerException;
+
+    void setCredentialsProvider(CredentialsProvider provider);
+
+    CredentialsProvider getCredentialsProvider();
+
+    /**
+     * Login as the given user. All the subsequent connections made by this
+     * content manager will use this login. If you want to temporary run some
+     * code using another login you should use {@link #loginAs(String, String)}
+     * and then {@link #logout()} to revert back to the previous login.
+     *
+     * @param username
+     * @param pass
+     */
+    void login(String username, String pass);
+
+    /**
+     * Login as the given user but only on the current thread. The other threads
+     * will not use this login. You can use to change the current login for the
+     * current thread. This is working like a stack stored in a thread local
+     * variable. You can call {@link #loginAs(String, String)} several times and
+     * then logout
+     *
+     * @param username
+     * @param pass
+     */
+    void pushLogin(String username, String pass);
+
+    void popLogin();
+
+    /**
+     * Remove global login
+     */
+    void logout();
+
+    /**
+     * Get the current login or null if none
+     *
+     * @return
+     */
+    Credentials getCurrentLogin();
+
+}

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

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

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/ContentManagerException.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/ContentManagerException.java?rev=781949&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/ContentManagerException.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/ContentManagerException.java Fri Jun  5 09:05:20 2009
@@ -0,0 +1,38 @@
+/*
+ * 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:
+ *     Stephane Lacoin, Nuxeo
+ */
+package org.apache.chemistry.atompub.client;
+
+/**
+ *
+ */
+public class ContentManagerException extends RuntimeException {
+
+    private static final long serialVersionUID = 1L;
+
+    public ContentManagerException(String message) {
+        super(message);
+    }
+
+    public ContentManagerException(String message, Exception e) {
+        super(message, e);
+    }
+
+    public ContentManagerException(Exception e) {
+        super(e);
+    }
+
+}

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

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

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/Credentials.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/Credentials.java?rev=781949&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/Credentials.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/Credentials.java Fri Jun  5 09:05:20 2009
@@ -0,0 +1,45 @@
+/*
+ * 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:
+ *     Bogdan Stefanescu, Nuxeo
+ */
+package org.apache.chemistry.atompub.client;
+
+/**
+ *
+ */
+public class Credentials {
+
+    protected String username;
+
+    protected char[] password;
+
+    public Credentials(String username, char[] password) {
+        this.username = username;
+        this.password = password;
+    }
+
+    public Credentials(String username, String password) {
+        this(username, password.toCharArray());
+    }
+
+    public String getUsername() {
+        return this.username;
+    }
+
+    public char[] getPassword() {
+        return this.password;
+    }
+
+}

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

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

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/CredentialsProvider.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/CredentialsProvider.java?rev=781949&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/CredentialsProvider.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/CredentialsProvider.java Fri Jun  5 09:05:20 2009
@@ -0,0 +1,26 @@
+/*
+ * 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:
+ *     Bogdan Stefanescu, Nuxeo
+ */
+package org.apache.chemistry.atompub.client;
+
+/**
+ *
+ */
+public interface CredentialsProvider {
+
+    public Credentials getCredentials();
+
+}

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

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

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/NoSuchRepositoryException.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/NoSuchRepositoryException.java?rev=781949&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/NoSuchRepositoryException.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/NoSuchRepositoryException.java Fri Jun  5 09:05:20 2009
@@ -0,0 +1,40 @@
+/*
+ * 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:
+ *     Stephane Lacoin, Nuxeo
+ */
+package org.apache.chemistry.atompub.client;
+
+/**
+ *
+ */
+public class NoSuchRepositoryException extends ContentManagerException {
+
+    private static final long serialVersionUID = -3017945902792388422L;
+
+    public final String baseURL;
+
+    public final String repositoryId;
+
+    public NoSuchRepositoryException(String baseURL, String id) {
+        super("no such repository " + id + " in " + baseURL);
+        this.baseURL = baseURL;
+        this.repositoryId = id;
+    }
+
+    public String getRepositoryId() {
+        return repositoryId;
+    }
+
+}

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

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

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/APPContentManager.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/APPContentManager.java?rev=781949&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/APPContentManager.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/APPContentManager.java Fri Jun  5 09:05:20 2009
@@ -0,0 +1,184 @@
+/*
+ * 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:
+ *     Bogdan Stefanescu, Nuxeo
+ */
+package org.apache.chemistry.atompub.client.app;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+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.Credentials;
+import org.apache.chemistry.atompub.client.CredentialsProvider;
+import org.apache.chemistry.atompub.client.NoSuchRepositoryException;
+import org.apache.chemistry.atompub.client.app.httpclient.HttpClientConnector;
+import org.apache.chemistry.atompub.client.common.AdapterManager;
+import org.apache.chemistry.atompub.client.common.atom.ReadContext;
+
+/**
+ *
+ */
+public class APPContentManager implements ContentManager {
+
+    protected String baseUrl;
+
+    protected Connector connector;
+
+    protected Repository[] repos;
+
+    protected CredentialsProvider login;
+
+    protected IOProvider ioProvider;
+
+    protected static ThreadLocal<List<CredentialsProvider>> loginStack = new ThreadLocal<List<CredentialsProvider>>();
+
+    protected static Map<Class<?>, Class<?>> services = new Hashtable<Class<?>, Class<?>>();
+
+    public APPContentManager(String url) {
+        this(url, null);
+    }
+
+    protected APPContentManager(String url, Connector connector) {
+        this.baseUrl = url;
+        this.connector = connector;
+        initialize();
+    }
+
+    protected void initialize() {
+        if (connector == null) {
+            connector = createConnector();
+        }
+    }
+
+    protected AdapterManager createAdapterManager() {
+        return new AdapterManager();
+    }
+
+    protected Connector createConnector() {
+        return new HttpClientConnector(this);
+    }
+
+    public String getBaseUrl() {
+        return baseUrl;
+    }
+
+    public Connector getConnector() {
+        return connector;
+    }
+
+    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();
+            ctx.put(APPContentManager.class, this);
+            repos = resp.getServiceDocument(ctx);
+        }
+        return repos;
+    }
+
+    public Repository getRepository(String id)
+            throws NoSuchRepositoryException, ContentManagerException {
+        for (Repository repository : getRepositories()) {
+            if (repository.getId().equals(id)) {
+                return repository;
+            }
+        }
+        throw new NoSuchRepositoryException(baseUrl, id);
+    }
+
+    public Repository getDefaultRepository() throws ContentManagerException {
+        Repository[] repos = getRepositories();
+        if (repos != null && repos.length > 0) {
+            return repos[0];
+        }
+        throw new NoSuchRepositoryException(baseUrl, "default");
+    }
+
+    public void refresh() {
+        repos = null;
+    }
+
+    public void login(String username, String pass) {
+        login = new DefaultCredentialsProvider(username, pass.toCharArray());
+    }
+
+    public void pushLogin(String username, String pass) {
+        List<CredentialsProvider> stack = loginStack.get();
+        if (stack == null) {
+            stack = new ArrayList<CredentialsProvider>();
+            loginStack.set(stack);
+        }
+        stack.add(new DefaultCredentialsProvider(username, pass.toCharArray()));
+    }
+
+    public void popLogin() {
+        List<CredentialsProvider> stack = loginStack.get();
+        if (stack != null && !stack.isEmpty()) {
+            stack.remove(stack.size() - 1);
+        }
+    }
+
+    public void logout() {
+        login = null;
+    }
+
+    public Credentials getCurrentLogin() {
+        List<CredentialsProvider> stack = loginStack.get();
+        return stack == null || stack.isEmpty() ? login.getCredentials()
+                : stack.get(stack.size() - 1).getCredentials();
+    }
+
+    public CredentialsProvider getCredentialsProvider() {
+        return login;
+    }
+
+    public void setCredentialsProvider(CredentialsProvider provider) {
+        login = provider;
+    }
+
+    public IOProvider getIO() {
+        if (ioProvider == null) {
+            ioProvider = new DefaultIOProvider();
+        }
+        return ioProvider;
+    }
+
+    public void setIO(IOProvider readers) {
+        this.ioProvider = readers;
+    }
+
+    public static void registerService(Class<?> itf, Class<?> impl) {
+        services.put(itf, impl);
+    }
+
+    public static void unregisterService(Class<?> itf) {
+        services.remove(itf);
+    }
+
+    public static Class<?> getServiceClass(Class<?> itf) {
+        return services.get(itf);
+    }
+
+}

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

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

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/Connector.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/Connector.java?rev=781949&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/Connector.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/Connector.java Fri Jun  5 09:05:20 2009
@@ -0,0 +1,72 @@
+/*
+ * 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:
+ *     Bogdan Stefanescu, Nuxeo
+ */
+package org.apache.chemistry.atompub.client.app;
+
+import java.util.List;
+
+import org.apache.chemistry.ObjectEntry;
+import org.apache.chemistry.Repository;
+import org.apache.chemistry.Type;
+import org.apache.chemistry.atompub.client.ContentManagerException;
+import org.apache.chemistry.atompub.client.common.atom.ReadContext;
+import org.apache.chemistry.atompub.client.common.atom.XmlObjectWriter;
+
+/**
+ * Invokes a remote content manager over HTTP protocols, such as AtomPub.
+ */
+public interface Connector {
+
+    APPContentManager getAPPContentManager();
+
+    <T> Response post(Request operation, XmlObjectWriter<T> writer, T object)
+            throws ContentManagerException;
+
+    <T> Response put(Request operation, XmlObjectWriter<T> writer, T object)
+            throws ContentManagerException;
+
+    Response get(Request operation) throws ContentManagerException;
+
+    Response head(Request operation) throws ContentManagerException;
+
+    Response delete(Request operation) throws ContentManagerException;
+
+    Type getType(ReadContext ctx, String href) throws ContentManagerException;
+
+    ObjectEntry getObject(ReadContext ctx, String href)
+            throws ContentManagerException;
+
+    List<ObjectEntry> getObjectFeed(ReadContext ctx, String href)
+            throws ContentManagerException;
+
+    List<ObjectEntry> getTypeFeed(ReadContext ctx, String href)
+            throws ContentManagerException;
+
+    Repository[] getServiceDocument(ReadContext ctx, String href)
+            throws ContentManagerException;
+
+    Response putObject(Request req, ObjectEntry entry)
+            throws ContentManagerException;
+
+    Response putQuery(Request req, String query) throws ContentManagerException;
+
+    Response postObject(Request req, ObjectEntry entry)
+            throws ContentManagerException;
+
+    Response postQuery(Request req, String query)
+            throws ContentManagerException;
+
+}

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

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

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/DefaultCredentialsProvider.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/DefaultCredentialsProvider.java?rev=781949&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/DefaultCredentialsProvider.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/DefaultCredentialsProvider.java Fri Jun  5 09:05:20 2009
@@ -0,0 +1,45 @@
+/*
+ * 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:
+ *     Bogdan Stefanescu, Nuxeo
+ */
+package org.apache.chemistry.atompub.client.app;
+
+import org.apache.chemistry.atompub.client.Credentials;
+import org.apache.chemistry.atompub.client.CredentialsProvider;
+
+/**
+ *
+ */
+public class DefaultCredentialsProvider implements CredentialsProvider {
+
+    protected Credentials credentials;
+
+    public DefaultCredentialsProvider(Credentials credentials) {
+        this.credentials = credentials;
+    }
+
+    public DefaultCredentialsProvider(String username, char[] password) {
+        this(new Credentials(username, password));
+    }
+
+    public DefaultCredentialsProvider(String username, String password) {
+        this(username, password.toCharArray());
+    }
+
+    public Credentials getCredentials() {
+        return credentials;
+    }
+
+}

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

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

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/DefaultIOProvider.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/DefaultIOProvider.java?rev=781949&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/DefaultIOProvider.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/DefaultIOProvider.java Fri Jun  5 09:05:20 2009
@@ -0,0 +1,81 @@
+/*
+ * 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:
+ *     Bogdan Stefanescu, Nuxeo
+ */
+package org.apache.chemistry.atompub.client.app;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.chemistry.ObjectEntry;
+import org.apache.chemistry.Type;
+import org.apache.chemistry.atompub.client.app.model.APPObjectEntryReader;
+import org.apache.chemistry.atompub.client.app.model.APPObjectEntryWriter;
+import org.apache.chemistry.atompub.client.app.model.APPObjectFeedReader;
+import org.apache.chemistry.atompub.client.app.model.APPServiceDocumentReader;
+import org.apache.chemistry.atompub.client.app.model.TypeEntryReader;
+import org.apache.chemistry.atompub.client.app.model.TypeFeedReader;
+import org.apache.chemistry.atompub.client.common.atom.EntryReader;
+import org.apache.chemistry.atompub.client.common.atom.FeedReader;
+import org.apache.chemistry.atompub.client.common.atom.ServiceDocumentReader;
+import org.apache.chemistry.atompub.client.common.atom.XmlObjectWriter;
+
+/**
+ *
+ */
+public class DefaultIOProvider implements IOProvider {
+
+    protected APPObjectEntryReader objectReader = new APPObjectEntryReader();
+
+    protected APPObjectFeedReader objectFeedReader = new APPObjectFeedReader(
+            objectReader);
+
+    protected TypeEntryReader typeReader = new TypeEntryReader();
+
+    protected TypeFeedReader typeFeedReader = new TypeFeedReader(typeReader);
+
+    protected APPServiceDocumentReader serviceDocumentReader = new APPServiceDocumentReader();
+
+    protected APPObjectEntryWriter objectWriter = new APPObjectEntryWriter();
+
+    public EntryReader<? extends ObjectEntry> getObjectEntryReader() {
+        return objectReader;
+    }
+
+    public FeedReader<List<ObjectEntry>> getObjectFeedReader() {
+        return objectFeedReader;
+    }
+
+    public ServiceDocumentReader<?> getServiceDocumentReader() {
+        return serviceDocumentReader;
+    }
+
+    public FeedReader<Map<String, Type>> getTypeFeedReader() {
+        return typeFeedReader;
+    }
+
+    public EntryReader<? extends Type> getTypeEntryReader() {
+        return typeReader;
+    }
+
+    public XmlObjectWriter<ObjectEntry> getObjectEntryWriter() {
+        return objectWriter;
+    }
+
+    public XmlObjectWriter<String> getQueryWriter() {
+        throw new UnsupportedOperationException("Not yet implemented");
+    }
+
+}

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

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

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/IOProvider.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/IOProvider.java?rev=781949&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/IOProvider.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/IOProvider.java Fri Jun  5 09:05:20 2009
@@ -0,0 +1,48 @@
+/*
+ * 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:
+ *     Bogdan Stefanescu, Nuxeo
+ */
+package org.apache.chemistry.atompub.client.app;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.chemistry.ObjectEntry;
+import org.apache.chemistry.Type;
+import org.apache.chemistry.atompub.client.common.atom.EntryReader;
+import org.apache.chemistry.atompub.client.common.atom.FeedReader;
+import org.apache.chemistry.atompub.client.common.atom.ServiceDocumentReader;
+import org.apache.chemistry.atompub.client.common.atom.XmlObjectWriter;
+
+/**
+ *
+ */
+public interface IOProvider {
+
+    EntryReader<? extends ObjectEntry> getObjectEntryReader();
+
+    EntryReader<? extends Type> getTypeEntryReader();
+
+    ServiceDocumentReader<?> getServiceDocumentReader();
+
+    FeedReader<List<ObjectEntry>> getObjectFeedReader();
+
+    FeedReader<Map<String, Type>> getTypeFeedReader();
+
+    XmlObjectWriter<ObjectEntry> getObjectEntryWriter();
+
+    XmlObjectWriter<String> getQueryWriter();
+
+}

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

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

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/Request.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/Request.java?rev=781949&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/Request.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/Request.java Fri Jun  5 09:05:20 2009
@@ -0,0 +1,65 @@
+/*
+ * 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:
+ *     Bogdan Stefanescu, Nuxeo
+ */
+package org.apache.chemistry.atompub.client.app;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * An HTTP operation.
+ */
+public class Request {
+
+    protected String url;
+
+    protected List<String> headers;
+
+    protected List<String> params;
+
+    public Request(String url) {
+        this.url = url;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setHeader(String key, String value) {
+        if (headers == null) {
+            headers = new ArrayList<String>();
+        }
+        headers.add(key);
+        headers.add(value);
+    }
+
+    public void setParameter(String key, String value) {
+        if (params == null) {
+            params = new ArrayList<String>();
+        }
+        params.add(key);
+        params.add(value);
+    }
+
+    public List<String> getHeaders() {
+        return headers;
+    }
+
+    public List<String> getParameters() {
+        return params;
+    }
+
+}

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

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

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/Response.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/Response.java?rev=781949&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/Response.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/Response.java Fri Jun  5 09:05:20 2009
@@ -0,0 +1,59 @@
+/*
+ * 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:
+ *     Bogdan Stefanescu, Nuxeo
+ */
+package org.apache.chemistry.atompub.client.app;
+
+import java.io.InputStream;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.chemistry.ObjectEntry;
+import org.apache.chemistry.Repository;
+import org.apache.chemistry.Type;
+import org.apache.chemistry.atompub.client.ContentManagerException;
+import org.apache.chemistry.atompub.client.common.atom.ReadContext;
+
+/**
+ *
+ */
+public interface Response {
+
+    int getStatusCode();
+
+    String getHeader(String key);
+
+    InputStream getStream() throws ContentManagerException;
+
+    byte[] getBytes() throws ContentManagerException;
+
+    String getString() throws ContentManagerException;
+
+    List<ObjectEntry> getObjectFeed(ReadContext ctx)
+            throws ContentManagerException;
+
+    Map<String, Type> getTypeFeed(ReadContext ctx)
+            throws ContentManagerException;
+
+    ObjectEntry getObject(ReadContext ctx) throws ContentManagerException;
+
+    Type getType(ReadContext ctx) throws ContentManagerException;
+
+    Repository[] getServiceDocument(ReadContext ctx)
+            throws ContentManagerException;
+
+    boolean isOk();
+
+}

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

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

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/httpclient/HttpClientConnector.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/httpclient/HttpClientConnector.java?rev=781949&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/httpclient/HttpClientConnector.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/httpclient/HttpClientConnector.java Fri Jun  5 09:05:20 2009
@@ -0,0 +1,249 @@
+/*
+ * 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:
+ *     Bogdan Stefanescu, Nuxeo
+ */
+package org.apache.chemistry.atompub.client.app.httpclient;
+
+import java.util.List;
+
+import org.apache.chemistry.ObjectEntry;
+import org.apache.chemistry.Repository;
+import org.apache.chemistry.Type;
+import org.apache.chemistry.atompub.client.ContentManagerException;
+import org.apache.chemistry.atompub.client.app.APPContentManager;
+import org.apache.chemistry.atompub.client.app.Connector;
+import org.apache.chemistry.atompub.client.app.Request;
+import org.apache.chemistry.atompub.client.app.Response;
+import org.apache.chemistry.atompub.client.common.atom.ReadContext;
+import org.apache.chemistry.atompub.client.common.atom.XmlObjectWriter;
+import org.apache.commons.httpclient.Credentials;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.NameValuePair;
+import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.commons.httpclient.auth.AuthScheme;
+import org.apache.commons.httpclient.auth.CredentialsNotAvailableException;
+import org.apache.commons.httpclient.auth.CredentialsProvider;
+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.PostMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+
+/**
+ *
+ */
+public class HttpClientConnector implements Connector {
+
+    protected HttpClient client;
+
+    protected APPContentManager cm;
+
+    public HttpClientConnector(APPContentManager cm) {
+        this.cm = cm;
+        this.client = new HttpClient();
+        this.client.getParams().setAuthenticationPreemptive(true);
+        this.client.getParams().setParameter(CredentialsProvider.PROVIDER,
+                new MyCredentialsProvider());
+    }
+
+    public APPContentManager getAPPContentManager() {
+        return cm;
+    }
+
+    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);
+            }
+        }
+    }
+
+    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 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(this, method);
+        } catch (Exception e) {
+            throw new ContentManagerException("GET request failed", e);
+        }
+    }
+
+    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(this, method);
+        } catch (Exception e) {
+            throw new ContentManagerException("DELETE request failed", e);
+        }
+    }
+
+    public Response head(Request request) throws ContentManagerException {
+        try {
+            HeadMethod method = new HeadMethod(request.getUrl());
+            setMethodParams(method, request);
+            setMethodHeaders(method, request);
+            client.executeMethod(method);
+            return new HttpClientResponse(this, method);
+        } catch (Exception e) {
+            throw new ContentManagerException("HEAD request failed", e);
+        }
+    }
+
+    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 ObjectRequestEntity<T>(writer, object));
+            client.executeMethod(method);
+            return new HttpClientResponse(this, method);
+        } catch (Exception e) {
+            throw new ContentManagerException("POST request failed", e);
+        }
+    }
+
+    public <T> Response put(Request request, XmlObjectWriter<T> writer, T object)
+            throws ContentManagerException {
+        try {
+            PutMethod method = new PutMethod(request.getUrl());
+            setMethodParams(method, request);
+            setMethodHeaders(method, request);
+            method.setRequestEntity(new ObjectRequestEntity<T>(writer, object));
+            client.executeMethod(method);
+            return new HttpClientResponse(this, method);
+        } catch (Exception e) {
+            throw new ContentManagerException("PUT request failed", e);
+        }
+    }
+
+    public Type getType(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.getType(ctx);
+    }
+
+    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 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 List<ObjectEntry> getTypeFeed(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 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());
+        }
+        return resp.getServiceDocument(ctx);
+    }
+
+    public Response putObject(Request req, ObjectEntry entry)
+            throws ContentManagerException {
+        return put(req, cm.getIO().getObjectEntryWriter(), entry);
+    }
+
+    public Response putQuery(Request req, String query)
+            throws ContentManagerException {
+        return put(req, cm.getIO().getQueryWriter(), query);
+    }
+
+    public Response postObject(Request req, ObjectEntry entry)
+            throws ContentManagerException {
+        return post(req, cm.getIO().getObjectEntryWriter(), entry);
+    }
+
+    public Response postQuery(Request req, String query)
+            throws ContentManagerException {
+        return post(req, cm.getIO().getQueryWriter(), query);
+    }
+
+    protected class MyCredentialsProvider implements CredentialsProvider {
+        public Credentials getCredentials(AuthScheme scheme, String host,
+                int port, boolean proxy)
+                throws CredentialsNotAvailableException {
+            org.apache.chemistry.atompub.client.CredentialsProvider login = (org.apache.chemistry.atompub.client.CredentialsProvider) cm.getCurrentLogin();
+            if (login == null) {
+                return null;
+            }
+            org.apache.chemistry.atompub.client.Credentials credentials = login.getCredentials();
+            if (credentials == null) {
+                return null;
+            }
+            return new UsernamePasswordCredentials(credentials.getUsername(),
+                    new String(credentials.getPassword()));
+        }
+    }
+
+}

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

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

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/httpclient/HttpClientResponse.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/httpclient/HttpClientResponse.java?rev=781949&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/httpclient/HttpClientResponse.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/httpclient/HttpClientResponse.java Fri Jun  5 09:05:20 2009
@@ -0,0 +1,165 @@
+/*
+ * 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:
+ *     Bogdan Stefanescu, Nuxeo
+ */
+package org.apache.chemistry.atompub.client.app.httpclient;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.chemistry.ObjectEntry;
+import org.apache.chemistry.Repository;
+import org.apache.chemistry.Type;
+import org.apache.chemistry.atompub.client.ContentManagerException;
+import org.apache.chemistry.atompub.client.app.Connector;
+import org.apache.chemistry.atompub.client.app.Response;
+import org.apache.chemistry.atompub.client.common.atom.ReadContext;
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpMethod;
+
+/**
+ *
+ */
+public class HttpClientResponse implements Response {
+
+    final static int MIN_BUF_LEN = 32 * 1024;
+
+    final static int MAX_BUF_LEN = 128 * 1024;
+
+    protected HttpMethod method;
+
+    protected Connector connector;
+
+    public HttpClientResponse(Connector connector, HttpMethod method) {
+        this.method = method;
+        this.connector = connector;
+    }
+
+    public String getHeader(String key) {
+        Header h = method.getResponseHeader(key);
+        return h == null ? null : h.getValue();
+    }
+
+    public int getStatusCode() {
+        return method.getStatusCode();
+    }
+
+    public boolean isOk() {
+        return method.getStatusCode() < 400;
+    }
+
+    public InputStream getStream() throws ContentManagerException {
+        try {
+            return method.getResponseBodyAsStream();
+        } catch (IOException e) {
+            throw new ContentManagerException("Failed to get response stream",
+                    e);
+        }
+    }
+
+    public String getString() throws ContentManagerException {
+        try {
+            return method.getResponseBodyAsString();
+        } catch (IOException e) {
+            throw new ContentManagerException("Failed to get response stream",
+                    e);
+        }
+    }
+
+    public byte[] getBytes() throws ContentManagerException {
+        InputStream in = null;
+        try {
+            in = getStream();
+            int len = in.available();
+            if (len < MIN_BUF_LEN) {
+                len = MIN_BUF_LEN;
+            } else {
+                len = MAX_BUF_LEN;
+            }
+            byte[] buffer = new byte[len];
+            int read;
+            ByteArrayOutputStream baos = new ByteArrayOutputStream(len);
+            while ((read = in.read(buffer)) != -1) {
+                baos.write(buffer, 0, read);
+            }
+            return baos.toByteArray();
+        } catch (IOException e) {
+            throw new ContentManagerException("Failed to get response", e);
+        } finally {
+            if (in != null) {
+                try {
+                    in.close();
+                } catch (Exception ee) {
+                    ee.printStackTrace();
+                }
+            }
+        }
+    }
+
+    public ObjectEntry getObject(ReadContext ctx)
+            throws ContentManagerException {
+        try {
+            return connector.getAPPContentManager().getIO().getObjectEntryReader().read(
+                    ctx, getStream());
+        } catch (XMLStreamException e) {
+            throw new ContentManagerException(e);
+        }
+    }
+
+    public Type getType(ReadContext ctx) throws ContentManagerException {
+        try {
+            return connector.getAPPContentManager().getIO().getTypeEntryReader().read(
+                    ctx, getStream());
+        } catch (XMLStreamException e) {
+            throw new ContentManagerException(e);
+        }
+    }
+
+    public Map<String, Type> getTypeFeed(ReadContext ctx)
+            throws ContentManagerException {
+        try {
+            return connector.getAPPContentManager().getIO().getTypeFeedReader().read(
+                    ctx, getStream());
+        } catch (XMLStreamException e) {
+            throw new ContentManagerException(e);
+        }
+    }
+
+    public List<ObjectEntry> getObjectFeed(ReadContext ctx)
+            throws ContentManagerException {
+        try {
+            return connector.getAPPContentManager().getIO().getObjectFeedReader().read(
+                    ctx, getStream());
+        } catch (XMLStreamException e) {
+            throw new ContentManagerException(e);
+        }
+    }
+
+    public Repository[] getServiceDocument(ReadContext ctx)
+            throws ContentManagerException {
+        try {
+            return connector.getAPPContentManager().getIO().getServiceDocumentReader().read(
+                    ctx, getStream());
+        } catch (IOException e) {
+            throw new ContentManagerException(e);
+        }
+    }
+
+}

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

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

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/httpclient/ObjectRequestEntity.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/httpclient/ObjectRequestEntity.java?rev=781949&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/httpclient/ObjectRequestEntity.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/httpclient/ObjectRequestEntity.java Fri Jun  5 09:05:20 2009
@@ -0,0 +1,55 @@
+/*
+ * 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:
+ *     Bogdan Stefanescu, Nuxeo
+ */
+package org.apache.chemistry.atompub.client.app.httpclient;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.chemistry.atompub.client.common.atom.XmlObjectWriter;
+import org.apache.commons.httpclient.methods.RequestEntity;
+
+/**
+ *
+ */
+public class ObjectRequestEntity<T> implements RequestEntity {
+
+    protected XmlObjectWriter<T> writer;
+
+    protected T obj;
+
+    public ObjectRequestEntity(XmlObjectWriter<T> writer, T obj) {
+        this.writer = writer;
+        this.obj = obj;
+    }
+
+    public long getContentLength() {
+        return -1;
+    }
+
+    public String getContentType() {
+        return writer.getContentType();
+    }
+
+    public boolean isRepeatable() {
+        return false;
+    }
+
+    public void writeRequest(OutputStream out) throws IOException {
+        writer.write(obj, out);
+    }
+
+}

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

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