chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fguilla...@apache.org
Subject svn commit: r781949 [2/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...
Date Fri, 05 Jun 2009 09:05:22 GMT
Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPConnection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPConnection.java?rev=781949&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPConnection.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPConnection.java Fri Jun  5 09:05:20 2009
@@ -0,0 +1,483 @@
+/*
+ * 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
+ *     Florent Guillaume, Nuxeo
+ */
+package org.apache.chemistry.atompub.client.app.model;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.chemistry.BaseType;
+import org.apache.chemistry.CMISObject;
+import org.apache.chemistry.Connection;
+import org.apache.chemistry.ContentStream;
+import org.apache.chemistry.Document;
+import org.apache.chemistry.Folder;
+import org.apache.chemistry.ObjectEntry;
+import org.apache.chemistry.ObjectId;
+import org.apache.chemistry.Policy;
+import org.apache.chemistry.Property;
+import org.apache.chemistry.Relationship;
+import org.apache.chemistry.RelationshipDirection;
+import org.apache.chemistry.Repository;
+import org.apache.chemistry.ReturnVersion;
+import org.apache.chemistry.SPI;
+import org.apache.chemistry.Type;
+import org.apache.chemistry.Unfiling;
+import org.apache.chemistry.VersioningState;
+import org.apache.chemistry.atompub.CMIS;
+import org.apache.chemistry.atompub.client.ContentManagerException;
+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.app.service.ServiceContext;
+import org.apache.chemistry.atompub.client.app.service.ServiceInfo;
+import org.apache.chemistry.atompub.client.common.atom.ReadContext;
+import org.apache.chemistry.atompub.client.common.atom.XmlProperty;
+
+/**
+ *
+ */
+public class APPConnection implements Connection, SPI {
+
+    protected APPFolder root;
+
+    protected Connector connector;
+
+    protected APPRepository repository;
+
+    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 Connection getConnection() {
+        return this;
+    }
+
+    public SPI getSPI() {
+        return this;
+    }
+
+    public void close() {
+        // do nothing? or clear login?
+        // throw new UnsupportedOperationException("Not yet implemented");
+    }
+
+    public Repository getRepository() {
+        return repository;
+    }
+
+    public Folder getRootFolder() {
+        if (root == null) {
+            root = (APPFolder) getObject(repository.info.getRootFolderId(),
+                    ReturnVersion.THIS);
+        }
+        return root;
+    }
+
+    // not in API
+
+    public Connector getConnector() {
+        return connector;
+    }
+
+    public String getBaseUrl() {
+        return repository.cm.getBaseUrl();
+    }
+
+    /*
+     * ----- Factories -----
+     */
+
+    public Document newDocument(String typeId, Folder folder) {
+        Type type = repository.getType(typeId);
+        if (type == null || type.getBaseType() != BaseType.DOCUMENT) {
+            throw new IllegalArgumentException(typeId);
+        }
+        APPObjectEntry entry = newObjectEntry(typeId);
+        if (folder != null) {
+            entry.setValue(Property.PARENT_ID, folder.getId());
+            entry.addLink(CMIS.LINK_PARENTS,
+                    ((APPFolder) folder).entry.getEditLink());
+        }
+        return new APPDocument(entry, type);
+    }
+
+    public Folder newFolder(String typeId, Folder folder) {
+        Type type = repository.getType(typeId);
+        if (type == null || type.getBaseType() != BaseType.DOCUMENT) {
+            throw new IllegalArgumentException(typeId);
+        }
+        APPObjectEntry entry = newObjectEntry(typeId);
+        if (folder != null) {
+            entry.setValue(Property.PARENT_ID, folder.getId());
+            entry.addLink(CMIS.LINK_PARENTS,
+                    ((APPFolder) folder).entry.getEditLink());
+        }
+        return new APPFolder(entry, type);
+    }
+
+    public Relationship newRelationship(String typeId) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public Policy newPolicy(String typeId, Folder folder) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public APPObjectEntry newObjectEntry(String typeId) {
+        Map<String, XmlProperty> map = new HashMap<String, XmlProperty>();
+        Type type = getRepository().getType(typeId);
+        XmlProperty p = new XmlProperty(
+                type.getPropertyDefinition(Property.TYPE_ID), typeId);
+        map.put(p.getName(), p);
+        return new APPObjectEntry(this, map, null);
+    }
+
+    public ObjectId newObjectId(String id) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    /*
+     * ----- Navigation Services -----
+     */
+
+    public List<ObjectEntry> getDescendants(ObjectId folder, BaseType type,
+            int depth, String filter, boolean includeAllowableActions,
+            boolean includeRelationships, String orderBy) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public List<ObjectEntry> getChildren(ObjectId folder, BaseType type,
+            String filter, boolean includeAllowableActions,
+            boolean includeRelationships, int maxItems, int skipCount,
+            String orderBy, boolean[] hasMoreItems) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public List<ObjectEntry> getFolderParent(ObjectId folder, String filter,
+            boolean includeAllowableActions, boolean includeRelationships,
+            boolean returnToRoot) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public Collection<ObjectEntry> getObjectParents(ObjectId object,
+            String filter, boolean includeAllowableActions,
+            boolean includeRelationships) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public Collection<ObjectEntry> getCheckedoutDocuments(ObjectId folder,
+            String filter, boolean includeAllowableActions,
+            boolean includeRelationships, int maxItems, int skipCount,
+            boolean[] hasMoreItems) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    /*
+     * ----- Object Services -----
+     */
+
+    /**
+     * TODO temporary implementation to have something working until search is
+     * implemented Versions not yet supported
+     */
+    public CMISObject getObject(ObjectId object, ReturnVersion returnVersion) {
+        String objectId = object.getId();
+        if (returnVersion == null) {
+            returnVersion = ReturnVersion.THIS;
+        }
+        String href = repository.getCollectionHref("root-children");
+        int p = href.lastIndexOf("/");
+        if (p == href.length() - 1) {
+            p = href.lastIndexOf("/", href.length() - 1);
+        }
+        if (p > -1) {
+            href = href.substring(0, p + 1);
+        }
+        href += "objects/" + objectId;
+        Request req = new Request(href);
+        Response resp = connector.get(req);
+        if (!resp.isOk()) {
+            throw new ContentManagerException(
+                    "Remote server returned error code: "
+                            + resp.getStatusCode());
+        }
+
+        APPObjectEntry entry = (APPObjectEntry) resp.getObject(new ReadContext(
+                this));
+        Type type = getRepository().getType(entry.getTypeId());
+        switch (type.getBaseType()) {
+        case DOCUMENT:
+            return new APPDocument(entry, type);
+        case FOLDER:
+            return new APPFolder(entry, type);
+        case POLICY:
+            throw new UnsupportedOperationException("Not yet implemented");
+        case RELATIONSHIP:
+            throw new UnsupportedOperationException("Not yet implemented");
+        default:
+            throw new AssertionError(type.getBaseType());
+        }
+
+        // throw new UnsupportedOperationException("Not yet implemented");
+    }
+
+    public ObjectId createDocument(String typeId,
+            Map<String, Serializable> properties, ObjectId folder,
+            ContentStream contentStream, VersioningState versioningState) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public ObjectId createFolder(String typeId,
+            Map<String, Serializable> properties, ObjectId folder) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public ObjectId createRelationship(String typeId,
+            Map<String, Serializable> properties, ObjectId source,
+            ObjectId target) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public ObjectId createPolicy(String typeId,
+            Map<String, Serializable> properties, ObjectId folder) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public Collection<String> getAllowableActions(ObjectId object, String asUser) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public ObjectEntry getProperties(ObjectId object,
+            ReturnVersion returnVersion, String filter,
+            boolean includeAllowableActions, boolean includeRelationships) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public boolean hasContentStream(ObjectId document) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public InputStream getContentStream(ObjectId document, int offset,
+            int length) throws IOException {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public ObjectId setContentStream(ObjectId document, boolean overwrite,
+            ContentStream contentStream) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public void deleteContentStream(ObjectId document) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public ObjectId updateProperties(ObjectId object, String changeToken,
+            Map<String, Serializable> properties) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public void moveObject(ObjectId object, ObjectId targetFolder,
+            ObjectId sourceFolder) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public void deleteObject(ObjectId object) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public Collection<ObjectId> deleteTree(ObjectId folder, Unfiling unfiling,
+            boolean continueOnFailure) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public void addObjectToFolder(ObjectId object, ObjectId folder) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public void removeObjectFromFolder(ObjectId object, ObjectId folder) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    /*
+     * ----- Discovery Services -----
+     */
+
+    public Collection<ObjectEntry> query(String statement,
+            boolean searchAllVersions, boolean includeAllowableActions,
+            boolean includeRelationships, int maxItems, int skipCount,
+            boolean[] hasMoreItems) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public Collection<CMISObject> query(String statement,
+            boolean searchAllVersions) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    /*
+     * ----- Versioning Services -----
+     */
+
+    public ObjectId checkOut(ObjectId document, boolean[] contentCopied) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public void cancelCheckOut(ObjectId document) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public ObjectId checkIn(ObjectId document, boolean major,
+            Map<String, Serializable> properties, ContentStream contentStream,
+            String comment) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public Map<String, Serializable> getPropertiesOfLatestVersion(
+            String versionSeriesId, boolean majorVersion, String filter) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public Collection<ObjectEntry> getAllVersions(String versionSeriesId,
+            String filter) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public void deleteAllVersions(String versionSeriesId) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    /*
+     * ----- Relationship Services -----
+     */
+
+    public List<ObjectEntry> getRelationships(ObjectId object,
+            RelationshipDirection direction, String typeId,
+            boolean includeSubRelationshipTypes, String filter,
+            String includeAllowableActions, int maxItems, int skipCount,
+            boolean[] hasMoreItems) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    /*
+     * ----- Policy Services -----
+     */
+
+    public void applyPolicy(ObjectId policy, ObjectId object) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public void removePolicy(ObjectId policy, ObjectId object) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public Collection<ObjectEntry> getAppliedPolicies(ObjectId object,
+            String filter) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    /*
+     * ----- Extensions -----
+     */
+
+    /**
+     * Get an extension service in connection scope
+     *
+     * @param <T>
+     * @param clazz service interface class
+     * @param connection the connection to bound the service on
+     * @return the service instance or null if none
+     */
+    public <T> T getExtension(Class<T> clazz) {
+        repository.loadServices(); // be sure services information is loaded
+        ServiceInfo info = repository.services.get(clazz);
+        if (info != null) {
+            if (info.isSingleton()) {
+                Object service = getSingletonService(clazz);
+                if (service != null) {
+                    return (T) service;
+                }
+            }
+            ServiceContext ctx = new ServiceContext(info, this);
+            try {
+                Object service = info.newInstance(ctx);
+                if (info.isSingleton()) {
+                    putSingletonService(clazz, service);
+                }
+                return (T) service;
+            } catch (Exception e) {
+                // do nothing
+            }
+        }
+        return null;
+    }
+
+    protected void putSingletonService(Class<?> clazz, Object service) {
+        singletons.put(clazz, service);
+    }
+
+    protected Object getSingletonService(Class<?> clazz) {
+        return singletons.get(clazz);
+    }
+
+}

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

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

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPDocument.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPDocument.java?rev=781949&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPDocument.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPDocument.java Fri Jun  5 09:05:20 2009
@@ -0,0 +1,79 @@
+/*
+ * 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.model;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collection;
+
+import org.apache.chemistry.ContentStream;
+import org.apache.chemistry.Document;
+import org.apache.chemistry.Type;
+
+/**
+ *
+ */
+public class APPDocument extends APPObject implements Document {
+
+    public APPDocument(APPObjectEntry entry, Type type) {
+        super(entry, type);
+    }
+
+    public ContentStream getContentStream() {
+        throw new UnsupportedOperationException("Not yet implemented");
+    }
+
+    public InputStream getStream() throws IOException {
+        throw new UnsupportedOperationException("Not yet implemented");
+    }
+
+    public void setContentStream(ContentStream contentStream)
+            throws IOException {
+        throw new UnsupportedOperationException("Not yet implemented");
+    }
+
+    public void cancelCheckOut() {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public Document checkIn(boolean major, String comment) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public Document checkOut() {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public void deleteAllVersions() {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public Collection<Document> getAllVersions() {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public Document getLatestVersion(boolean major) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+}

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

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

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPFolder.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPFolder.java?rev=781949&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPFolder.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPFolder.java Fri Jun  5 09:05:20 2009
@@ -0,0 +1,92 @@
+/*
+ * 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.model;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.chemistry.BaseType;
+import org.apache.chemistry.CMISObject;
+import org.apache.chemistry.Document;
+import org.apache.chemistry.Folder;
+import org.apache.chemistry.ObjectEntry;
+import org.apache.chemistry.ObjectId;
+import org.apache.chemistry.Type;
+import org.apache.chemistry.Unfiling;
+import org.apache.chemistry.atompub.CMIS;
+import org.apache.chemistry.atompub.client.ContentManagerException;
+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;
+
+/**
+ *
+ */
+public class APPFolder extends APPDocument implements Folder {
+
+    public APPFolder(APPObjectEntry entry, Type type) {
+        super(entry, type);
+    }
+
+    public void add(CMISObject object) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public void remove(CMISObject object) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public Collection<ObjectId> deleteTree(Unfiling unfiling) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public List<Folder> getAncestors() {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public List<CMISObject> getChildren(BaseType type) {
+        // TODO type
+        String href = entry.getLink(CMIS.LINK_CHILDREN);
+        Response resp = entry.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<CMISObject> children = new ArrayList<CMISObject>(feed.size());
+        for (ObjectEntry e : feed) {
+            children.add(APPObject.construct((APPObjectEntry) e));
+        }
+        return children;
+    }
+
+    public Document newDocument(String typeId) {
+        return entry.connection.newDocument(typeId, this);
+    }
+
+    public Folder newFolder(String typeId) {
+        return entry.connection.newFolder(typeId, this);
+    }
+
+}

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

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

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPObject.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPObject.java?rev=781949&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPObject.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPObject.java Fri Jun  5 09:05:20 2009
@@ -0,0 +1,233 @@
+/*
+ * 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
+ *     Florent Guillaume, Nuxeo
+ */
+package org.apache.chemistry.atompub.client.app.model;
+
+import java.io.Serializable;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.chemistry.BaseType;
+import org.apache.chemistry.Folder;
+import org.apache.chemistry.Policy;
+import org.apache.chemistry.Property;
+import org.apache.chemistry.Relationship;
+import org.apache.chemistry.RelationshipDirection;
+import org.apache.chemistry.Type;
+import org.apache.chemistry.atompub.CMIS;
+import org.apache.chemistry.atompub.client.ContentManagerException;
+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.impl.base.BaseObject;
+
+/**
+ *
+ */
+public abstract class APPObject extends BaseObject {
+
+    protected final APPObjectEntry entry;
+
+    private final Type type;
+
+    public APPObject(APPObjectEntry entry, Type type) {
+        this.entry = entry;
+        this.type = type;
+    }
+
+    protected static APPObject construct(APPObjectEntry entry) {
+        Type type = entry.connection.repository.getType(entry.getTypeId());
+        BaseType baseType = type.getBaseType();
+        switch (baseType) {
+        case DOCUMENT:
+            return new APPDocument(entry, type);
+        case FOLDER:
+            return new APPFolder(entry, type);
+        case POLICY:
+            // return new APPPolicy(entry, type);
+        case RELATIONSHIP:
+            // return new APPRelationship(entry, type);
+        default:
+            throw new AssertionError(baseType.toString());
+        }
+    }
+
+    public Connector getConnector() {
+        return entry.getConnector();
+    }
+
+    /*
+     * ----- Object Services -----
+     */
+
+    public void move(Folder targetFolder, Folder sourceFolder) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public void delete() {
+        Request req = new Request(entry.getEditLink());
+        Response resp = getConnector().delete(req);
+        if (!resp.isOk()) {
+            throw new ContentManagerException(
+                    "Remote server returned error code: "
+                            + resp.getStatusCode());
+        }
+    }
+
+    public void unfile() {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    /*
+     * ----- Navigation Services -----
+     */
+    public Folder getParent() {
+        String href = entry.getLink(CMIS.LINK_PARENTS); // TODO check this
+        if (href == null) {
+            return null;
+        }
+        APPObjectEntry e = (APPObjectEntry) getConnector().getObject(
+                new ReadContext(entry.getConnection()), href);
+        Type t = entry.getConnection().getRepository().getType(e.getTypeId());
+        APPFolder f = new APPFolder(e, t);
+        return f;
+    }
+
+    public Collection<Folder> getParents() {
+        // TODO
+        return Collections.singleton(getParent());
+    }
+
+    /*
+     * ----- Relationship Services -----
+     */
+
+    public List<Relationship> getRelationships(RelationshipDirection direction,
+            String typeId, boolean includeSubRelationshipTypes) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    /*
+     * ----- Policy Services -----
+     */
+
+    public void applyPolicy(Policy policy) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public void removePolicy(Policy policy) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public Collection<Policy> getPolicies() {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    /*
+     * ----- data access -----
+     */
+
+    public Type getType() {
+        return type;
+    }
+
+    public Property getProperty(String name) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public Serializable getValue(String name) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public void save() {
+        try {
+            if (getId() == null) {
+                create();
+            } else {
+                update();
+            }
+        } catch (ContentManagerException e) { // TODO
+            throw new RuntimeException(e);
+        }
+    }
+
+    protected void create() throws ContentManagerException {
+        String href = entry.getLink(CMIS.LINK_PARENTS); // TODO check this
+        if (href == null) {
+            throw new IllegalArgumentException(
+                    "Cannot create entry: no 'cmis-parents' link is present");
+        }
+        Request req = new Request(href);
+        req.setHeader("Content-Type", "application/atom+xml;type=entry");
+        Response resp = getConnector().postObject(req, entry);
+        if (!resp.isOk()) {
+            throw new ContentManagerException(
+                    "Remote server returned error code: "
+                            + resp.getStatusCode());
+        }
+        // TODO get the response to update the content of the posted document
+        // resp.getEntity(get, APPDocument.class);
+    }
+
+    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", "application/atom+xml;type=entry");
+        Response resp = getConnector().putObject(req, entry);
+        if (!resp.isOk()) {
+            throw new ContentManagerException(
+                    "Remote server returned error code: "
+                            + resp.getStatusCode());
+        }
+    }
+
+    // ----- overriden from base class -----
+
+    // TODO make sure getProperties returns that too
+    @Override
+    public URI getURI() {
+        String value = entry.getEditLink();
+        if (value == null) {
+            value = entry.getLink("self");
+            if (value == null) {
+                value = entry.getLink("alternate");
+            }
+        }
+        try {
+            return new URI(value);
+        } catch (URISyntaxException e) {
+            throw new IllegalArgumentException("Not an URI: " + value);
+        }
+    }
+
+}

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

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

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPObjectEntry.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPObjectEntry.java?rev=781949&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPObjectEntry.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPObjectEntry.java Fri Jun  5 09:05:20 2009
@@ -0,0 +1,215 @@
+/*
+ * 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
+ *     Florent Guillaume, Nuxeo
+ */
+package org.apache.chemistry.atompub.client.app.model;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import org.apache.chemistry.ObjectEntry;
+import org.apache.chemistry.Property;
+import org.apache.chemistry.PropertyDefinition;
+import org.apache.chemistry.atompub.CMIS;
+import org.apache.chemistry.atompub.client.app.Connector;
+import org.apache.chemistry.atompub.client.common.atom.ValueAdapter;
+import org.apache.chemistry.atompub.client.common.atom.XmlProperty;
+import org.apache.chemistry.atompub.client.common.xml.XMLWriter;
+
+/**
+ *
+ */
+public class APPObjectEntry implements ObjectEntry {
+
+    protected APPConnection connection;
+
+    protected Map<String, XmlProperty> properties;
+
+    protected Set<String> allowableActions; // TODO use set?
+
+    protected String id;
+
+    protected String name;
+
+    protected String typeId;
+
+    protected final List<String> links;
+
+    public APPObjectEntry(APPConnection connection,
+            Map<String, XmlProperty> properties, Set<String> allowableActions) {
+        this.connection = connection;
+        this.properties = properties;
+        if (allowableActions == null) {
+            allowableActions = new HashSet<String>();
+        }
+        this.allowableActions = allowableActions;
+        links = new ArrayList<String>();
+    }
+
+    public void addLink(String rel, String href) {
+        links.add(rel == null ? "" : rel);
+        links.add(href);
+    }
+
+    public String[] getLinks() {
+        return links.toArray(new String[links.size()]);
+    }
+
+    public String getLink(String rel) {
+        for (int i = 0, len = links.size(); i < len; i += 2) {
+            if (rel.equals(links.get(i))) {
+                return links.get(i + 1);
+            }
+        }
+        return null;
+    }
+
+    public String getEditLink() {
+        String href = getLink("edit");
+        return href == null ? getLink("self") : href;
+    }
+
+    public Connector getConnector() {
+        return connection.getConnector();
+    }
+
+    // -----
+
+    public APPConnection getConnection() {
+        return connection;
+    }
+
+    public String getId() {
+        return (String) getValue(Property.ID);
+    }
+
+    public String getTypeId() {
+        return (String) getValue(Property.TYPE_ID);
+    }
+
+    public Serializable getValue(String name) {
+        XmlProperty p = properties.get(name);
+        return p == null ? null : p.getValue();
+    }
+
+    public Map<String, Serializable> getValues() {
+        Map<String, Serializable> map = new HashMap<String, Serializable>();
+        for (Entry<String, XmlProperty> e : properties.entrySet()) {
+            String key = e.getKey();
+            XmlProperty p = properties.get(key);
+            map.put(key, p == null ? null : p.getValue());
+        }
+        return map;
+    }
+
+    public void setValue(String name, Serializable value) {
+        XmlProperty p = properties.get(name);
+        if (p != null) {
+            p.setValue(value);
+        } else {
+            PropertyDefinition pd = connection.getRepository().getType(
+                    getTypeId()).getPropertyDefinition(name);
+            if (pd == null) {
+                throw new IllegalArgumentException("No such property: " + name);
+            }
+            p = new XmlProperty(pd);
+            p.setValue(value);
+            properties.put(name, p);
+        }
+    }
+
+    public void setValues(Map<String, Serializable> values) {
+        for (Map.Entry<String, Serializable> entry : values.entrySet()) {
+            setValue(entry.getKey(), entry.getValue());
+        }
+    }
+
+    // public Document getDocument() {
+    // return (APPDocument) getConnector().getObject(
+    // new ReadContext(getConnection(), getType()), getEditLink());
+    // }
+    //
+    // public Folder getFolder() {
+    // if (getType().getBaseType() == BaseType.FOLDER) {
+    // return (APPFolder) getConnector().getObject(
+    // new ReadContext(getConnection(), getType()), getEditLink());
+    // }
+    // return null;
+    // }
+
+    public Collection<String> getAllowableActions() {
+        return allowableActions;
+    }
+
+    public Collection<ObjectEntry> getRelationships() {
+        throw new UnsupportedOperationException("Not yet implemented");
+    }
+
+    @Override
+    public String toString() {
+        return getId();
+    }
+
+    public void writeObjectTo(XMLWriter xw) throws IOException {
+        xw.element(CMIS.OBJECT);
+        xw.start();
+        xw.element(CMIS.PROPERTIES);
+        xw.start();
+        for (XmlProperty p : properties.values()) {
+            ValueAdapter va = p.getAdapter();
+            xw.element(va.getPropertyName()).attr(CMIS.NAME, p.getName());
+            xw.start();
+            if (p.isValueLoaded()) {
+                Serializable v = p.getValue();
+                if (v != null) {
+                    if (v.getClass().isArray()) {
+                        Serializable[] ar = (Serializable[]) v;
+                        for (Serializable val : ar) {
+                            xw.element(CMIS.VALUE).content(va.writeValue(val));
+                        }
+                    } else {
+                        xw.element(CMIS.VALUE).content(va.writeValue(v));
+                    }
+                }
+            } else {
+                Object v = p.getXmlValue();
+                if (v != null) {
+                    if (v.getClass() == String.class) {
+                        xw.element(CMIS.VALUE).content((String) v);
+                    } else {
+                        @SuppressWarnings("unchecked")
+                        List<String> list = (List<String>) v;
+                        for (String val : list) {
+                            xw.element(CMIS.VALUE).content(val);
+                        }
+                    }
+                }
+            }
+            xw.end();
+        }
+        xw.end();
+        xw.end();
+    }
+
+}

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

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

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPObjectEntryReader.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPObjectEntryReader.java?rev=781949&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPObjectEntryReader.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPObjectEntryReader.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
+ *     Florent Guillaume, Nuxeo
+ */
+package org.apache.chemistry.atompub.client.app.model;
+
+import java.util.HashMap;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.chemistry.Type;
+import org.apache.chemistry.atompub.client.common.atom.AbstractObjectReader;
+import org.apache.chemistry.atompub.client.common.atom.ReadContext;
+import org.apache.chemistry.atompub.client.common.atom.XmlProperty;
+import org.apache.chemistry.atompub.client.common.xml.StaxReader;
+
+/**
+ *
+ */
+public class APPObjectEntryReader extends AbstractObjectReader<APPObjectEntry> {
+
+    private static APPObjectEntryReader builder = new APPObjectEntryReader();
+
+    public static APPObjectEntryReader getBuilder() {
+        return builder;
+    }
+
+    @Override
+    protected APPObjectEntry createObject(ReadContext ctx) {
+        Type type = ctx.getType();
+        APPConnection connection = (APPConnection) ctx.getConnection();
+        if (type == null) {
+            return new APPObjectEntry(connection,
+                    new HashMap<String, XmlProperty>(), null);
+        } else {
+            return connection.newObjectEntry(type.getId());
+        }
+    }
+
+    @Override
+    protected void readProperty(ReadContext ctx, StaxReader reader,
+            APPObjectEntry object, XmlProperty p) {
+        object.properties.put(p.getName(), p);
+    }
+
+    @Override
+    protected void readAtomElement(ReadContext ctx, StaxReader reader,
+            APPObjectEntry object) throws XMLStreamException {
+        String name = reader.getLocalName();
+        if ("link".equals(name)) {
+            String rel = reader.getAttributeValue(ATOM_NS, "rel");
+            String href = reader.getAttributeValue(ATOM_NS, "href");
+            object.addLink(rel, href);
+            // } else if ("id".equals(name)) {
+            // object.id = new URI(id);
+        }
+    }
+
+}

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

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

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPObjectEntryWriter.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPObjectEntryWriter.java?rev=781949&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPObjectEntryWriter.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPObjectEntryWriter.java Fri Jun  5 09:05:20 2009
@@ -0,0 +1,36 @@
+/*
+ * 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.model;
+
+import java.io.IOException;
+
+import org.apache.chemistry.ObjectEntry;
+import org.apache.chemistry.atompub.client.common.atom.ObjectEntryWriter;
+import org.apache.chemistry.atompub.client.common.xml.XMLWriter;
+
+/**
+ *
+ */
+public class APPObjectEntryWriter extends ObjectEntryWriter {
+
+    @Override
+    protected void writeCmisObject(ObjectEntry object, XMLWriter xw)
+            throws IOException {
+        ((APPObjectEntry) object).writeObjectTo(xw);
+    }
+
+}

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

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

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPObjectFeedReader.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPObjectFeedReader.java?rev=781949&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPObjectFeedReader.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPObjectFeedReader.java Fri Jun  5 09:05:20 2009
@@ -0,0 +1,58 @@
+/*
+ * 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.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.chemistry.ObjectEntry;
+import org.apache.chemistry.atompub.client.common.atom.AbstractFeedReader;
+import org.apache.chemistry.atompub.client.common.atom.EntryReader;
+import org.apache.chemistry.atompub.client.common.xml.StaxReader;
+
+/**
+ *
+ */
+public class APPObjectFeedReader extends
+        AbstractFeedReader<List<ObjectEntry>, APPObjectEntry> {
+
+    private static APPObjectFeedReader builder = new APPObjectFeedReader();
+
+    public static APPObjectFeedReader getBuilder() {
+        return builder;
+    }
+
+    public APPObjectFeedReader(EntryReader<APPObjectEntry> entryBuilder) {
+        super(entryBuilder);
+
+    }
+
+    public APPObjectFeedReader() {
+        this(APPObjectEntryReader.getBuilder());
+    }
+
+    @Override
+    protected List<ObjectEntry> createFeed(StaxReader reader) {
+        return new ArrayList<ObjectEntry>();
+    }
+
+    @Override
+    protected void addEntry(List<ObjectEntry> feed, APPObjectEntry entry) {
+        feed.add(entry);
+    }
+
+}

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

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

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPPropertyDefinition.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPPropertyDefinition.java?rev=781949&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPPropertyDefinition.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPPropertyDefinition.java Fri Jun  5 09:05:20 2009
@@ -0,0 +1,298 @@
+/*
+ * 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.model;
+
+import java.io.Serializable;
+import java.lang.reflect.Array;
+import java.math.BigDecimal;
+import java.net.URI;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.chemistry.Choice;
+import org.apache.chemistry.PropertyDefinition;
+import org.apache.chemistry.PropertyType;
+import org.apache.chemistry.Updatability;
+import org.apache.chemistry.atompub.client.common.atom.ValueAdapter;
+import org.apache.chemistry.atompub.client.common.xml.ChildrenNavigator;
+import org.apache.chemistry.atompub.client.common.xml.StaxReader;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ */
+public class APPPropertyDefinition implements PropertyDefinition {
+
+    public final static Log log = LogFactory.getLog(APPPropertyDefinition.class);
+
+    protected Map<String, Object> map;
+
+    protected String name;
+
+    protected PropertyType type;
+
+    protected boolean multiValued;
+
+    protected Updatability updatability;
+
+    protected APPPropertyDefinition(Map<String, Object> map) {
+        this.map = map;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getId() {
+        return (String) map.get("id");
+    }
+
+    public String getDisplayName() {
+        return (String) map.get("displayName");
+    }
+
+    public String getDescription() {
+        return (String) map.get("description");
+    }
+
+    public boolean isInherited() {
+        Boolean v = (Boolean) map.get("inherited");
+        return v == null ? false : v.booleanValue();
+    }
+
+    public PropertyType getType() {
+        String t = (String) map.get("propertyType");
+        if (t != null) {
+            type = types.get(t);
+            if (type == null) {
+                type = PropertyType.STRING;
+            }
+        }
+        return type;
+    }
+
+    public boolean isMultiValued() {
+        return multiValued;
+    }
+
+    public List<Choice> getChoices() {
+        throw new UnsupportedOperationException("Not yet implemented");
+    }
+
+    protected final boolean getBooleanValue(String name) {
+        Boolean v = (Boolean) map.get(name);
+        return v == null ? false : v.booleanValue();
+    }
+
+    public boolean isOpenChoice() {
+        return getBooleanValue("openChoice");
+    }
+
+    public boolean isRequired() {
+        return getBooleanValue("required");
+    }
+
+    public Serializable getDefaultValue() {
+        throw new UnsupportedOperationException("Not yet implemented");
+    }
+
+    public Updatability getUpdatability() {
+        if (updatability == null) {
+            String text = (String) map.get("updateability");
+            if ("readonly".equals(text)) {
+                updatability = Updatability.READ_ONLY;
+            } else if ("whencheckedout".equals(text)) {
+                updatability = Updatability.WHEN_CHECKED_OUT;
+            } else {
+                updatability = Updatability.READ_WRITE;
+            }
+        }
+        return updatability;
+    }
+
+    public boolean isQueryable() {
+        return getBooleanValue("queryable");
+    }
+
+    public boolean isOrderable() {
+        return getBooleanValue("orderable");
+    }
+
+    public int getPrecision() {
+        Integer v = (Integer) map.get("precision");
+        return v != null ? v.intValue() : 32;
+    }
+
+    public Integer getMinValue() {
+        return (Integer) map.get("minValue");
+    }
+
+    public Integer getMaxValue() {
+        return (Integer) map.get("maxValue");
+    }
+
+    public int getMaxLength() {
+        Integer v = (Integer) map.get("maxLength");
+        return v != null ? v.intValue() : -1;
+    }
+
+    public URI getSchemaURI() {
+        throw new UnsupportedOperationException("Not yet implemented");
+    }
+
+    public String getEncoding() {
+        return (String) map.get("encoding");
+    }
+
+    public boolean validates(Serializable value) {
+        return validationError(value) == null;
+    }
+
+    public String validationError(Serializable value) {
+        if (getUpdatability() == Updatability.READ_ONLY) {
+            // TODO Updatability.WHEN_CHECKED_OUT
+            return "Property is read-only";
+        }
+        if (value == null) {
+            if (isRequired()) {
+                return "Property is required";
+            }
+            return null;
+        }
+        boolean multi = isMultiValued();
+        if (multi != value.getClass().isArray()) {
+            return multi ? "Property is multi-valued"
+                    : "Property is single-valued";
+        }
+        Class<?> klass;
+        switch (getType().ordinal()) {
+        case PropertyType.STRING_ORD:
+        case PropertyType.ID_ORD:
+            klass = String.class;
+            break;
+        case PropertyType.DECIMAL_ORD:
+            klass = BigDecimal.class;
+            break;
+        case PropertyType.INTEGER_ORD:
+            klass = Integer.class; // TODO Long
+            break;
+        case PropertyType.BOOLEAN_ORD:
+            klass = Boolean.class;
+            break;
+        case PropertyType.DATETIME_ORD:
+            klass = Calendar.class;
+            break;
+        case PropertyType.URI_ORD:
+            klass = URI.class;
+            break;
+        case PropertyType.XML_ORD:
+            klass = String.class; // TODO
+            break;
+        case PropertyType.HTML_ORD:
+            klass = String.class; // TODO
+            break;
+        default:
+            throw new UnsupportedOperationException(type.toString());
+        }
+        if (multi) {
+            for (int i = 0; i < Array.getLength(value); i++) {
+                Object v = Array.get(value, i);
+                if (v == null) {
+                    return "Array value cannot contain null elements";
+                }
+                if (!klass.isInstance(v)) {
+                    return "Array value has type " + v.getClass()
+                            + " instead of " + klass.getName();
+                }
+            }
+        } else {
+            if (!klass.isInstance(value)) {
+                return "Value has type " + value.getClass() + " instead of "
+                        + klass.getName();
+            }
+        }
+        return null;
+    }
+
+    public static APPPropertyDefinition fromXml(StaxReader reader)
+            throws XMLStreamException {
+        HashMap<String, Object> map = new HashMap<String, Object>();
+        APPPropertyDefinition pd = new APPPropertyDefinition(map);
+        ChildrenNavigator nav = reader.getChildren();
+        while (nav.next()) {
+            String tag = reader.getLocalName();
+            if ("name".equals(tag)) {
+                pd.name = reader.getElementText();
+            } else if ("cardinality".equals(tag)) {
+                String text = reader.getElementText();
+                pd.multiValued = isMultiValued(text);
+            } else if ("defaultValue".equals(tag)) {
+                // TODO not yet implemented
+            } else if (tag.startsWith("choice")) {
+                // TODO not yet implemented
+            } else {
+                ValueAdapter adapter = adapters.get(tag);
+                Object val = null;
+                if (adapter == null) {
+                    val = reader.getElementText();
+                } else {
+                    val = adapter.readValue(reader.getElementText());
+                }
+                map.put(tag, val);
+            }
+        }
+        return pd;
+    }
+
+    public static boolean isMultiValued(String text) {
+        return "multi".equals(text);
+    }
+
+    static abstract class Setter {
+        public abstract void set(APPPropertyDefinition pd, StaxReader reader)
+                throws XMLStreamException;
+    }
+
+    static Map<String, ValueAdapter> adapters = new HashMap<String, ValueAdapter>();
+
+    static Map<String, PropertyType> types = new HashMap<String, PropertyType>();
+
+    static {
+        adapters.put("inherited", ValueAdapter.BOOLEAN);
+        adapters.put("required", ValueAdapter.BOOLEAN);
+        adapters.put("queryable", ValueAdapter.BOOLEAN);
+        adapters.put("orderable", ValueAdapter.BOOLEAN);
+        adapters.put("openChoice", ValueAdapter.BOOLEAN);
+        adapters.put("maxLength", ValueAdapter.INTEGER);
+
+        types.put("string", PropertyType.STRING);
+        types.put("boolean", PropertyType.BOOLEAN);
+        types.put("integer", PropertyType.INTEGER);
+        types.put("decimal", PropertyType.DECIMAL);
+        types.put("id", PropertyType.ID);
+        types.put("datetime", PropertyType.DATETIME);
+        types.put("uri", PropertyType.URI);
+        types.put("xml", PropertyType.XML);
+        types.put("html", PropertyType.HTML);
+    }
+
+}

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

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

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPRepository.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPRepository.java?rev=781949&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPRepository.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPRepository.java Fri Jun  5 09:05:20 2009
@@ -0,0 +1,253 @@
+/*
+ * 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.model;
+
+import java.io.InputStream;
+import java.io.Serializable;
+import java.net.URI;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.chemistry.Connection;
+import org.apache.chemistry.Repository;
+import org.apache.chemistry.RepositoryInfo;
+import org.apache.chemistry.SPI;
+import org.apache.chemistry.Type;
+import org.apache.chemistry.atompub.CMIS;
+import org.apache.chemistry.atompub.client.ContentManager;
+import org.apache.chemistry.atompub.client.ContentManagerException;
+import org.apache.chemistry.atompub.client.app.APPContentManager;
+import org.apache.chemistry.atompub.client.app.Request;
+import org.apache.chemistry.atompub.client.app.Response;
+import org.apache.chemistry.atompub.client.app.service.ServiceContext;
+import org.apache.chemistry.atompub.client.app.service.ServiceFeedReader;
+import org.apache.chemistry.atompub.client.app.service.ServiceInfo;
+import org.apache.chemistry.atompub.client.common.atom.ReadContext;
+
+/**
+ * An APP client repository proxy
+ */
+public class APPRepository implements Repository {
+
+    protected APPContentManager cm;
+
+    protected RepositoryInfo info;
+
+    protected String id;
+
+    protected Map<String, ServiceInfo> services;
+
+    protected Map<String, Type> typeRegistry;
+
+    protected Map<String, String> collections = new HashMap<String, String>();
+
+    protected Map<Class<?>, Object> singletons = new Hashtable<Class<?>, Object>();
+
+    public APPRepository(APPContentManager cm) {
+        this(cm, null);
+    }
+
+    public APPRepository(APPContentManager cm, RepositoryInfo info) {
+        this.cm = cm;
+        this.info = info;
+    }
+
+    public void setInfo(RepositoryInfo info) {
+        this.info = info;
+    }
+
+    public ContentManager getContentManager() {
+        return cm;
+    }
+
+    public String getId() {
+        if (id == null) {
+            id = info.getId();
+        }
+        return id;
+    }
+
+    public String getName() {
+        return info.getName();
+    }
+
+    public URI getURI() {
+        throw new UnsupportedOperationException("Not yet implemented");
+    }
+
+    public SPI getSPI() {
+        loadTypes();
+        return new APPConnection(this);
+    }
+
+    public Connection getConnection(Map<String, Serializable> parameters) {
+        loadTypes();
+        return new APPConnection(this);
+    }
+
+    public void addCollection(String type, String href) {
+        collections.put(type, href);
+    }
+
+    public RepositoryInfo getInfo() {
+        return info;
+    }
+
+    public Type getType(String typeId) {
+        loadTypes();
+        return typeRegistry.get(typeId);
+    }
+
+    public List<Type> getTypes(String typeId,
+            boolean returnPropertyDefinitions, int maxItems, int skipCount,
+            boolean[] hasMoreItems) {
+        loadTypes();
+        throw new UnsupportedOperationException("Not yet Implemented");
+    }
+
+    public Collection<Type> getTypes(String typeId,
+            boolean returnPropertyDefinitions) {
+        loadTypes();
+        throw new UnsupportedOperationException("Not yet Implemented");
+    }
+
+    public String getRelationshipName() {
+        return info.getRelationshipName();
+    }
+
+    public String getCollectionHref(String type) {
+        return collections.get(type);
+    }
+
+    /** type API */
+
+    public void addType(APPType type) {
+        typeRegistry.put(type.getId(), type);
+    }
+
+    protected void loadTypes() {
+        if (typeRegistry == null) {
+            try {
+                String href = getCollectionHref(CMIS.COL_TYPES_CHILDREN);
+                if (href == null) {
+                    throw new IllegalArgumentException(
+                            "Invalid CMIS repository. No types children collection defined");
+                }
+                Request req = new Request(href);
+                // TODO lazy load property definition
+                req.setHeader("CMIS-includePropertyDefinitions", "true");
+                Response resp = cm.getConnector().get(req);
+                if (!resp.isOk()) {
+                    throw new ContentManagerException(
+                            "Remote server returned error code: "
+                                    + resp.getStatusCode());
+                }
+                InputStream in = resp.getStream();
+                try {
+                    typeRegistry = TypeFeedReader.INSTANCE.read(
+                            new ReadContext(this), in);
+                } finally {
+                    in.close();
+                }
+            } catch (Exception e) { // TODO how to handle exceptions?
+                throw new RuntimeException(
+                        "Failed to load repository types for " + getName(), e);
+            }
+        }
+    }
+
+    protected void loadServices() {
+        if (services == null) {
+            String href = getCollectionHref("services");
+            if (href != null) {
+                Request req = new Request(href);
+                Response resp = cm.getConnector().get(req);
+                if (!resp.isOk()) {
+                    throw new ContentManagerException(
+                            "Remote server returned error code: "
+                                    + resp.getStatusCode());
+                }
+                InputStream in = resp.getStream();
+                try {
+                    try {
+                        services = ServiceFeedReader.getBuilder().read(
+                                new ReadContext(this), in);
+                    } finally {
+                        in.close();
+                    }
+                } catch (Exception e) {
+                    throw new ContentManagerException("Failed to read response");
+                }
+            }
+            if (services == null) {
+                services = new HashMap<String, ServiceInfo>();
+            }
+        }
+    }
+
+    protected void putSingletonService(Class<?> clazz, Object service) {
+        singletons.put(clazz, service);
+    }
+
+    protected Object getSingletonService(Class<?> clazz) {
+        return singletons.get(clazz);
+    }
+
+    /**
+     * Get an extension service in repository scope
+     *
+     * @param <T>
+     * @param clazz service interface class
+     * @param repository the repository to bound the service on
+     * @return the service instance or null if none
+     */
+    public <T> T getExtension(Class<T> clazz) {
+        loadServices(); // be sure services information is loaded
+        ServiceInfo info = services.get(clazz.getName());
+        if (info != null) {
+            if (info.requiresConnection()) {
+                return null;
+            }
+            if (info.isSingleton()) {
+                Object service = getSingletonService(clazz);
+                if (service != null) {
+                    return (T) service;
+                }
+            }
+            ServiceContext ctx = new ServiceContext(info, this);
+            try {
+                Object service = info.newInstance(ctx);
+                if (info.isSingleton()) {
+                    putSingletonService(clazz, service);
+                }
+                return (T) service;
+            } catch (Exception e) {
+                // do nothing
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public String toString() {
+        return getName();
+    }
+
+}

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

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

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPRepositoryCapabilities.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPRepositoryCapabilities.java?rev=781949&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPRepositoryCapabilities.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPRepositoryCapabilities.java Fri Jun  5 09:05:20 2009
@@ -0,0 +1,107 @@
+/*
+ * 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.model;
+
+import org.apache.chemistry.JoinCapability;
+import org.apache.chemistry.QueryCapability;
+import org.apache.chemistry.RepositoryCapabilities;
+
+/**
+ *
+ */
+public class APPRepositoryCapabilities implements RepositoryCapabilities {
+
+    protected JoinCapability joinCapability;
+
+    protected QueryCapability queryCapability;
+
+    protected boolean hasUnfiling;
+
+    protected boolean hasMultifiling;
+
+    protected boolean hasVersionSpecificFiling;
+
+    protected boolean isAllVersionsSearchable;
+
+    protected boolean isPWCSearchable;
+
+    protected boolean isPWCUpdatable;
+
+    public JoinCapability getJoinCapability() {
+        return joinCapability;
+    }
+
+    public QueryCapability getQueryCapability() {
+        return queryCapability;
+    }
+
+    public boolean hasMultifiling() {
+        return hasMultifiling;
+    }
+
+    public boolean hasUnfiling() {
+        return hasUnfiling;
+    }
+
+    public boolean hasVersionSpecificFiling() {
+        return hasVersionSpecificFiling;
+    }
+
+    public boolean isAllVersionsSearchable() {
+        return isAllVersionsSearchable;
+    }
+
+    public boolean isPWCSearchable() {
+        return isPWCSearchable;
+    }
+
+    public boolean isPWCUpdatable() {
+        return isPWCUpdatable;
+    }
+
+    public void setAllVersionsSearchable(boolean isAllVersionsSearchable) {
+        this.isAllVersionsSearchable = isAllVersionsSearchable;
+    }
+
+    public void setHasMultifiling(boolean hasMultifiling) {
+        this.hasMultifiling = hasMultifiling;
+    }
+
+    public void setHasUnfiling(boolean hasUnfiling) {
+        this.hasUnfiling = hasUnfiling;
+    }
+
+    public void setHasVersionSpecificFiling(boolean hasVersionSpecificFiling) {
+        this.hasVersionSpecificFiling = hasVersionSpecificFiling;
+    }
+
+    public void setJoinCapability(JoinCapability joinCapability) {
+        this.joinCapability = joinCapability;
+    }
+
+    public void setPWCSearchable(boolean isPWCSearchable) {
+        this.isPWCSearchable = isPWCSearchable;
+    }
+
+    public void setPWCUpdatable(boolean isPWCUpdatable) {
+        this.isPWCUpdatable = isPWCUpdatable;
+    }
+
+    public void setQueryCapability(QueryCapability queryCapability) {
+        this.queryCapability = queryCapability;
+    }
+}

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

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

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPRepositoryInfo.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPRepositoryInfo.java?rev=781949&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPRepositoryInfo.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPRepositoryInfo.java Fri Jun  5 09:05:20 2009
@@ -0,0 +1,108 @@
+/*
+ * 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.model;
+
+import java.net.URI;
+import java.util.Collection;
+import java.util.Map;
+
+import org.apache.chemistry.ObjectId;
+import org.apache.chemistry.RepositoryCapabilities;
+import org.apache.chemistry.RepositoryEntry;
+import org.apache.chemistry.RepositoryInfo;
+import org.apache.chemistry.atompub.CMIS;
+import org.apache.chemistry.impl.simple.SimpleObjectId;
+import org.w3c.dom.Document;
+
+/**
+ *
+ */
+public class APPRepositoryInfo implements RepositoryInfo {
+
+    protected Map<String, Object> map;
+
+    protected RepositoryCapabilities caps;
+
+    public APPRepositoryInfo(RepositoryCapabilities caps,
+            Map<String, Object> map) {
+        this.map = map;
+        this.caps = caps;
+    }
+
+    public URI getURI() {
+        // TODO: what for?
+        throw new UnsupportedOperationException("Not yet implemented");
+    }
+
+    public String getString(String name) {
+        return (String) map.get(name);
+    }
+
+    public String getId() {
+        return getString(CMIS.REPOSITORY_ID.getLocalPart());
+    }
+
+    public String getName() {
+        return getString(CMIS.REPOSITORY_NAME.getLocalPart());
+    }
+
+    public String getRelationshipName() {
+        return getString(CMIS.REPOSITORY_RELATIONSHIP.getLocalPart());
+    }
+
+    public String getDescription() {
+        return getString(CMIS.REPOSITORY_DESCRIPTION.getLocalPart());
+    }
+
+    public String getProductName() {
+        return getString(CMIS.PRODUCT_NAME.getLocalPart());
+    }
+
+    public String getProductVersion() {
+        return getString(CMIS.PRODUCT_VERSION.getLocalPart());
+    }
+
+    public ObjectId getRootFolderId() {
+        String id = getString(CMIS.ROOT_FOLDER_ID.getLocalPart());
+        return new SimpleObjectId(id);
+    }
+
+    public String getVendorName() {
+        return getString(CMIS.VENDOR_NAME.getLocalPart());
+    }
+
+    public String getVersionSupported() {
+        return getString(CMIS.VERSION_SUPPORTED.getLocalPart());
+    }
+
+    public Document getRepositorySpecificInformation() {
+        return (Document) map.get(CMIS.REPOSITORY_SPECIFIC_INFORMATION.getLocalPart());
+    }
+
+    public RepositoryCapabilities getCapabilities() {
+        return caps;
+    }
+
+    public Collection<RepositoryEntry> getRelatedRepositories() {
+        throw new UnsupportedOperationException("Not yet implemented");
+    }
+
+    @Override
+    public String toString() {
+        return getName() + " - " + getURI();
+    }
+}

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

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

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPServiceDocumentReader.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPServiceDocumentReader.java?rev=781949&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPServiceDocumentReader.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPServiceDocumentReader.java Fri Jun  5 09:05:20 2009
@@ -0,0 +1,46 @@
+/*
+ * 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.model;
+
+import org.apache.chemistry.RepositoryInfo;
+import org.apache.chemistry.atompub.client.app.APPContentManager;
+import org.apache.chemistry.atompub.client.common.atom.ReadContext;
+import org.apache.chemistry.atompub.client.common.atom.ServiceDocumentReader;
+
+/**
+ *
+ */
+public class APPServiceDocumentReader extends
+        ServiceDocumentReader<APPRepository> {
+
+    @Override
+    protected void addCollection(APPRepository repo, String href, String type) {
+        repo.addCollection(type, href);
+    }
+
+    @Override
+    protected APPRepository createRepository(ReadContext ctx) {
+        return new APPRepository(
+                (APPContentManager) ctx.get(APPContentManager.class));
+    }
+
+    @Override
+    protected void setInfo(APPRepository repo, RepositoryInfo info) {
+        repo.setInfo(info);
+    }
+
+}

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

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

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPType.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPType.java?rev=781949&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPType.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPType.java Fri Jun  5 09:05:20 2009
@@ -0,0 +1,158 @@
+/*
+ * 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
+ *     Florent Guillaume, Nuxeo
+ */
+package org.apache.chemistry.atompub.client.app.model;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+
+import org.apache.chemistry.BaseType;
+import org.apache.chemistry.ContentStreamPresence;
+import org.apache.chemistry.PropertyDefinition;
+import org.apache.chemistry.Type;
+import org.apache.chemistry.atompub.CMIS;
+import org.apache.chemistry.atompub.client.common.atom.ReadContext;
+import org.apache.chemistry.atompub.client.common.atom.XmlProperty;
+
+/**
+ *
+ */
+public class APPType extends APPObjectEntry implements Type {
+
+    protected Map<String, String> map;
+
+    protected BaseType baseType;
+
+    protected String parentId;
+
+    protected Map<String, PropertyDefinition> propertyDefs;
+
+    public APPType(APPConnection connection) {
+        super(connection, new HashMap<String, XmlProperty>(), null);
+    }
+
+    public void init(Map<String, String> properties,
+            Map<String, PropertyDefinition> props) {
+        if (map != null) {
+            throw new IllegalStateException("Type is already intialized");
+        }
+        map = properties;
+        propertyDefs = props;
+    }
+
+    // should be added to API
+    public boolean isFolder() {
+        return getBaseType() == BaseType.FOLDER;
+    }
+
+    public BaseType getBaseType() {
+        if (baseType == null) {
+            baseType = BaseType.valueOf(map.get(CMIS.BASE_TYPE.getLocalPart()));
+        }
+        return baseType;
+    }
+
+    public String getBaseTypeQueryName() {
+        return map.get(CMIS.BASE_TYPE_QUERY_NAME.getLocalPart());
+    }
+
+    public String getDescription() {
+        return map.get(CMIS.DESCRIPTION.getLocalPart());
+    }
+
+    public String getDisplayName() {
+        return map.get(CMIS.DISPLAY_NAME.getLocalPart());
+    }
+
+    @Override
+    public String getId() {
+        return getTypeId();
+    }
+
+    public String getParentId() {
+        if (parentId == null) {
+            parentId = map.get(CMIS.TYPE_ID.getLocalPart());
+        }
+        return parentId;
+    }
+
+    public PropertyDefinition getPropertyDefinition(String name) {
+        loadPropertyDef();
+        return propertyDefs.get(name);
+    }
+
+    public Collection<PropertyDefinition> getPropertyDefinitions() {
+        loadPropertyDef();
+        return Collections.unmodifiableCollection(propertyDefs.values());
+    }
+
+    public String getQueryName() {
+        return map.get(CMIS.QUERY_NAME);
+    }
+
+    public boolean isControllable() {
+        return "true".equals(map.get(CMIS.CONTROLLABLE));
+    }
+
+    public boolean isCreatable() {
+        return "true".equals(map.get(CMIS.CREATABLE));
+    }
+
+    public boolean isFileable() {
+        return "true".equals(map.get(CMIS.FILEABLE));
+    }
+
+    public boolean isQueryable() {
+        return "true".equals(map.get(CMIS.QUERYABLE));
+    }
+
+    public boolean isVersionable() {
+        return "true".equals(map.get(CMIS.VERSIONABLE));
+    }
+
+    public boolean isIncludedInSuperTypeQuery() {
+        throw new UnsupportedOperationException("Not yet implemented");
+    }
+
+    public String[] getAllowedSourceTypes() {
+        throw new UnsupportedOperationException("Not yet implemented");
+    }
+
+    public String[] getAllowedTargetTypes() {
+        throw new UnsupportedOperationException("Not yet implemented");
+    }
+
+    public ContentStreamPresence getContentStreamAllowed() {
+        throw new UnsupportedOperationException("Not yet implemented");
+    }
+
+    protected void loadPropertyDef() {
+        if (propertyDefs == null) {
+            APPType typeDef = (APPType) getConnector().getType(
+                    new ReadContext(connection), getEditLink());
+            propertyDefs = typeDef.propertyDefs;
+        }
+    }
+
+    @Override
+    public String toString() {
+        return getId();
+    }
+}



Mime
View raw message