You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by dc...@apache.org on 2010/02/16 17:04:07 UTC

svn commit: r910572 [25/36] - in /incubator/chemistry/trunk/opencmis: ./ _dev/ opencmis-client/ opencmis-client/opencmis-client-api/ opencmis-client/opencmis-client-api/src/ opencmis-client/opencmis-client-api/src/main/ opencmis-client/opencmis-client-...

Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/PolicyService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/PolicyService.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/PolicyService.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/PolicyService.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,202 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.opencmis.server.impl.atompub;
+
+import static org.apache.opencmis.commons.impl.Converter.convert;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.RESOURCE_POLICIES;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.compileBaseUrl;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.compileUrl;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.compileUrlBuilder;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.getStringParameter;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.opencmis.commons.exceptions.CmisRuntimeException;
+import org.apache.opencmis.commons.impl.Constants;
+import org.apache.opencmis.commons.impl.UrlBuilder;
+import org.apache.opencmis.commons.impl.jaxb.CmisObjectType;
+import org.apache.opencmis.commons.provider.ObjectData;
+import org.apache.opencmis.server.impl.ObjectInfoHolderImpl;
+import org.apache.opencmis.server.spi.AbstractServicesFactory;
+import org.apache.opencmis.server.spi.CallContext;
+import org.apache.opencmis.server.spi.CmisPolicyService;
+import org.apache.opencmis.server.spi.ObjectInfo;
+import org.apache.opencmis.server.spi.ObjectInfoHolder;
+
+/**
+ * Policy Service operations.
+ * 
+ * @author <a href="mailto:fmueller@opentext.com">Florian M&uuml;ller</a>
+ * 
+ */
+public class PolicyService {
+
+  /**
+   * Get applied policies.
+   */
+  public static void getAppliedPolicies(CallContext context, AbstractServicesFactory factory,
+      String repositoryId, HttpServletRequest request, HttpServletResponse response)
+      throws Exception {
+    CmisPolicyService service = factory.getPolicyService();
+
+    // get parameters
+    String objectId = getStringParameter(request, Constants.PARAM_ID);
+    String filter = getStringParameter(request, Constants.PARAM_FILTER);
+
+    // execute
+    ObjectInfoHolder objectInfoHolder = new ObjectInfoHolderImpl();
+    List<ObjectData> policies = service.getAppliedPolicies(context, repositoryId, objectId, filter,
+        null, objectInfoHolder);
+
+    if (policies == null) {
+      throw new CmisRuntimeException("Policies are null!");
+    }
+
+    ObjectInfo objectInfo = objectInfoHolder.getObjectInfo(objectId);
+    if (objectInfo == null) {
+      throw new CmisRuntimeException("Object Info is missing!");
+    }
+
+    // set headers
+    response.setStatus(HttpServletResponse.SC_OK);
+    response.setContentType(Constants.MEDIATYPE_FEED);
+
+    // write XML
+    AtomFeed feed = new AtomFeed();
+    feed.startDocument(response.getOutputStream());
+    feed.startFeed(true);
+
+    // write basic Atom feed elements
+    feed.writeFeedElements(objectInfo.getId(), objectInfo.getCreatedBy(), objectInfo.getName(),
+        objectInfo.getLastModificationDate(), null, null);
+
+    // write links
+    UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
+
+    feed.writeServiceLink(baseUrl.toString(), repositoryId);
+
+    feed.writeSelfLink(compileUrl(baseUrl, RESOURCE_POLICIES, objectInfo.getId()), null);
+
+    // write entries
+    if (policies != null) {
+      AtomEntry entry = new AtomEntry(feed.getWriter());
+      for (ObjectData policy : policies) {
+        if (policy == null) {
+          continue;
+        }
+        writePolicyEntry(entry, objectInfo.getId(), policy, objectInfoHolder, baseUrl);
+      }
+    }
+
+    // we are done
+    feed.endFeed();
+    feed.endDocument();
+  }
+
+  /**
+   * Apply policy.
+   */
+  public static void applyPolicy(CallContext context, AbstractServicesFactory factory,
+      String repositoryId, HttpServletRequest request, HttpServletResponse response)
+      throws Exception {
+    CmisPolicyService service = factory.getPolicyService();
+
+    // get parameters
+    String objectId = getStringParameter(request, Constants.PARAM_ID);
+
+    AtomEntryParser parser = new AtomEntryParser(request.getInputStream());
+
+    // execute
+    ObjectInfoHolder objectInfoHolder = new ObjectInfoHolderImpl();
+    ObjectData policy = service.applyPolicy(context, repositoryId, parser.getId(), objectId, null,
+        objectInfoHolder);
+
+    if (policy == null) {
+      throw new CmisRuntimeException("Policy is null!");
+    }
+
+    // set headers
+    UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
+    UrlBuilder location = compileUrlBuilder(baseUrl, RESOURCE_POLICIES, objectId);
+    location.addParameter(Constants.PARAM_POLICY_ID, policy.getId());
+
+    response.setStatus(HttpServletResponse.SC_CREATED);
+    response.setContentType(Constants.MEDIATYPE_ENTRY);
+    response.setHeader("Content-Location", location.toString());
+    response.setHeader("Location", location.toString());
+
+    // write XML
+    AtomEntry entry = new AtomEntry();
+    entry.startDocument(response.getOutputStream());
+    writePolicyEntry(entry, objectId, policy, objectInfoHolder, baseUrl);
+    entry.endDocument();
+  }
+
+  /**
+   * Remove policy.
+   */
+  public static void removePolicy(CallContext context, AbstractServicesFactory factory,
+      String repositoryId, HttpServletRequest request, HttpServletResponse response)
+      throws Exception {
+    CmisPolicyService service = factory.getPolicyService();
+
+    // get parameters
+    String objectId = getStringParameter(request, Constants.PARAM_ID);
+    String policyId = getStringParameter(request, Constants.PARAM_POLICY_ID);
+
+    // execute
+    service.removePolicy(context, repositoryId, policyId, objectId, null);
+
+    // set headers
+    response.setStatus(HttpServletResponse.SC_NO_CONTENT);
+  }
+
+  /**
+   * Writes an entry that is attached to an object.
+   */
+  private static void writePolicyEntry(AtomEntry entry, String objectId, ObjectData policy,
+      ObjectInfoHolder infoHolder, UrlBuilder baseUrl) throws Exception {
+    CmisObjectType resultJaxb = convert(policy);
+    if (resultJaxb == null) {
+      return;
+    }
+
+    ObjectInfo info = infoHolder.getObjectInfo(policy.getId());
+    if (info == null) {
+      throw new CmisRuntimeException("Object Info not found!");
+    }
+
+    // start
+    entry.startEntry(false);
+
+    // write the object
+    entry.writeObject(policy, info, null, null, null, null);
+
+    // write links
+    UrlBuilder selfLink = compileUrlBuilder(baseUrl, RESOURCE_POLICIES, objectId);
+    selfLink.addParameter(Constants.PARAM_POLICY_ID, info.getId());
+    entry.writeSelfLink(selfLink.toString(), null);
+
+    // we are done
+    entry.endEntry();
+  }
+}

Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/PolicyService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/RelationshipService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/RelationshipService.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/RelationshipService.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/RelationshipService.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.opencmis.server.impl.atompub;
+
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.RESOURCE_RELATIONSHIPS;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.compileBaseUrl;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.compileUrl;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.compileUrlBuilder;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.getBigIntegerParameter;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.getBooleanParameter;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.getEnumParameter;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.getStringParameter;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.writeObjectEntry;
+
+import java.math.BigInteger;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.opencmis.commons.enums.RelationshipDirection;
+import org.apache.opencmis.commons.exceptions.CmisRuntimeException;
+import org.apache.opencmis.commons.impl.Constants;
+import org.apache.opencmis.commons.impl.UrlBuilder;
+import org.apache.opencmis.commons.provider.ObjectData;
+import org.apache.opencmis.commons.provider.ObjectList;
+import org.apache.opencmis.server.impl.ObjectInfoHolderImpl;
+import org.apache.opencmis.server.spi.AbstractServicesFactory;
+import org.apache.opencmis.server.spi.CallContext;
+import org.apache.opencmis.server.spi.CmisRelationshipService;
+import org.apache.opencmis.server.spi.ObjectInfo;
+import org.apache.opencmis.server.spi.ObjectInfoHolder;
+
+/**
+ * Relationship Service operations.
+ * 
+ * @author <a href="mailto:fmueller@opentext.com">Florian M&uuml;ller</a>
+ * 
+ */
+public class RelationshipService {
+
+  /**
+   * Get object relationships.
+   */
+  public static void getObjectRelationships(CallContext context, AbstractServicesFactory factory,
+      String repositoryId, HttpServletRequest request, HttpServletResponse response)
+      throws Exception {
+    CmisRelationshipService service = factory.getRelationshipService();
+
+    // get parameters
+    String objectId = getStringParameter(request, Constants.PARAM_ID);
+    Boolean includeSubRelationshipTypes = getBooleanParameter(request,
+        Constants.PARAM_SUB_RELATIONSHIP_TYPES);
+    RelationshipDirection relationshipDirection = getEnumParameter(request,
+        Constants.PARAM_RELATIONSHIP_DIRECTION, RelationshipDirection.class);
+    String typeId = getStringParameter(request, Constants.PARAM_TYPE_ID);
+    String filter = getStringParameter(request, Constants.PARAM_FILTER);
+    Boolean includeAllowableActions = getBooleanParameter(request,
+        Constants.PARAM_ALLOWABLE_ACTIONS);
+    BigInteger maxItems = getBigIntegerParameter(request, Constants.PARAM_MAX_ITEMS);
+    BigInteger skipCount = getBigIntegerParameter(request, Constants.PARAM_SKIP_COUNT);
+
+    // execute
+    ObjectInfoHolder objectInfoHolder = new ObjectInfoHolderImpl();
+    ObjectList relationships = service.getObjectRelationships(context, repositoryId, objectId,
+        includeSubRelationshipTypes, relationshipDirection, typeId, filter,
+        includeAllowableActions, maxItems, skipCount, null, objectInfoHolder);
+
+    if (relationships == null) {
+      throw new CmisRuntimeException("Relationships are null!");
+    }
+
+    ObjectInfo objectInfo = objectInfoHolder.getObjectInfo(objectId);
+    if (objectInfo == null) {
+      throw new CmisRuntimeException("Object Info is missing!");
+    }
+
+    // set headers
+    response.setStatus(HttpServletResponse.SC_OK);
+    response.setContentType(Constants.MEDIATYPE_FEED);
+
+    // write XML
+    AtomFeed feed = new AtomFeed();
+    feed.startDocument(response.getOutputStream());
+    feed.startFeed(true);
+
+    // write basic Atom feed elements
+    feed.writeFeedElements(objectInfo.getId(), objectInfo.getCreatedBy(), objectInfo.getName(),
+        objectInfo.getLastModificationDate(), null, relationships.getNumItems());
+
+    // write links
+    UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
+
+    feed.writeServiceLink(baseUrl.toString(), repositoryId);
+
+    feed.writeSelfLink(compileUrl(baseUrl, RESOURCE_RELATIONSHIPS, objectInfo.getId()), null);
+
+    UrlBuilder pagingUrl = new UrlBuilder(compileUrlBuilder(baseUrl, RESOURCE_RELATIONSHIPS,
+        objectInfo.getId()));
+    pagingUrl.addParameter(Constants.PARAM_SUB_RELATIONSHIP_TYPES, includeSubRelationshipTypes);
+    pagingUrl.addParameter(Constants.PARAM_RELATIONSHIP_DIRECTION, relationshipDirection);
+    pagingUrl.addParameter(Constants.PARAM_TYPE_ID, typeId);
+    pagingUrl.addParameter(Constants.PARAM_FILTER, filter);
+    pagingUrl.addParameter(Constants.PARAM_ALLOWABLE_ACTIONS, includeAllowableActions);
+    feed.writePagingLinks(pagingUrl, maxItems, skipCount, relationships.getNumItems(),
+        relationships.hasMoreItems(), AtomPubUtils.PAGE_SIZE);
+
+    // write entries
+    if (relationships != null) {
+      AtomEntry entry = new AtomEntry(feed.getWriter());
+      for (ObjectData object : relationships.getObjects()) {
+        if (object == null) {
+          continue;
+        }
+        writeObjectEntry(entry, object, objectInfoHolder, null, repositoryId, null, null, baseUrl,
+            false);
+      }
+    }
+
+    // we are done
+    feed.endFeed();
+    feed.endDocument();
+  }
+}

Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/RelationshipService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/RepositoryService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/RepositoryService.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/RepositoryService.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/RepositoryService.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,438 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.opencmis.server.impl.atompub;
+
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.PAGE_SIZE;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.RESOURCE_CHANGES;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.RESOURCE_CHECKEDOUT;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.RESOURCE_CHILDREN;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.RESOURCE_DESCENDANTS;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.RESOURCE_FOLDERTREE;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.RESOURCE_OBJECTBYID;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.RESOURCE_OBJECTBYPATH;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.RESOURCE_QUERY;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.RESOURCE_TYPE;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.RESOURCE_TYPES;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.RESOURCE_TYPESDESC;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.RESOURCE_UNFILED;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.TYPE_AUTHOR;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.compileBaseUrl;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.compileUrl;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.compileUrlBuilder;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.getBigIntegerParameter;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.getBooleanParameter;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.getStringParameter;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.writeTypeEntry;
+
+import java.math.BigInteger;
+import java.util.Collections;
+import java.util.GregorianCalendar;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.opencmis.commons.api.TypeDefinition;
+import org.apache.opencmis.commons.api.TypeDefinitionContainer;
+import org.apache.opencmis.commons.api.TypeDefinitionList;
+import org.apache.opencmis.commons.enums.CapabilityChanges;
+import org.apache.opencmis.commons.enums.CapabilityQuery;
+import org.apache.opencmis.commons.impl.Constants;
+import org.apache.opencmis.commons.impl.UrlBuilder;
+import org.apache.opencmis.commons.provider.RepositoryCapabilitiesData;
+import org.apache.opencmis.commons.provider.RepositoryInfoData;
+import org.apache.opencmis.server.spi.AbstractServicesFactory;
+import org.apache.opencmis.server.spi.CallContext;
+import org.apache.opencmis.server.spi.CmisRepositoryService;
+
+/**
+ * Repository Service operations.
+ * 
+ * @author <a href="mailto:fmueller@opentext.com">Florian M&uuml;ller</a>
+ * 
+ */
+public final class RepositoryService {
+
+  /**
+   * Private constructor.
+   */
+  private RepositoryService() {
+  }
+
+  /**
+   * Renders the service document.
+   */
+  public static void getRepositories(CallContext context, AbstractServicesFactory factory,
+      HttpServletRequest request, HttpServletResponse response) throws Exception {
+    CmisRepositoryService service = factory.getRepositoryService();
+
+    // get parameters
+    String repositoryId = getStringParameter(request, Constants.PARAM_REPOSITORY_ID);
+
+    // execute
+    List<RepositoryInfoData> infoDataList = null;
+
+    if (repositoryId == null) {
+      infoDataList = service.getRepositoryInfos(context, null);
+    }
+    else {
+      infoDataList = Collections.singletonList(service.getRepositoryInfo(context, repositoryId,
+          null));
+    }
+
+    // set headers
+    response.setStatus(HttpServletResponse.SC_OK);
+    response.setContentType(Constants.MEDIATYPE_SERVICE);
+
+    // write XML
+    ServiceDocument serviceDoc = new ServiceDocument();
+
+    serviceDoc.startDocument(response.getOutputStream());
+    serviceDoc.startServiceDocument();
+
+    if (infoDataList != null) {
+      for (RepositoryInfoData infoData : infoDataList) {
+        if (infoData == null) {
+          continue;
+        }
+
+        String repId = infoData.getRepositoryId();
+        UrlBuilder baseUrl = compileBaseUrl(request, repId);
+
+        boolean supportsQuery = false;
+        boolean supportsUnFiling = false;
+        boolean supportsMultifiling = false;
+        boolean supportsFolderTree = false;
+        boolean supportsRootDescendants = false;
+        boolean supportsChanges = false;
+
+        if (infoData.getRepositoryCapabilities() != null) {
+          RepositoryCapabilitiesData cap = infoData.getRepositoryCapabilities();
+
+          if (cap.getCapabilityQuery() != null) {
+            supportsQuery = (cap.getCapabilityQuery() != CapabilityQuery.NONE);
+          }
+
+          if (cap.supportsUnfiling() != null) {
+            supportsUnFiling = cap.supportsUnfiling();
+          }
+
+          if (cap.supportsMultifiling() != null) {
+            supportsMultifiling = cap.supportsMultifiling();
+          }
+
+          if (cap.supportsGetFolderTree() != null) {
+            supportsFolderTree = cap.supportsGetFolderTree();
+          }
+
+          if (cap.supportsGetDescendants() != null) {
+            supportsRootDescendants = cap.supportsGetDescendants();
+          }
+
+          if (cap.getCapabilityChanges() != null) {
+            supportsChanges = (cap.getCapabilityChanges() != CapabilityChanges.NONE);
+          }
+        }
+
+        serviceDoc.startWorkspace(infoData.getRepositoryId());
+
+        // add collections
+
+        // - root collection
+        serviceDoc.writeCollection(compileUrl(baseUrl, RESOURCE_CHILDREN, infoData
+            .getRootFolderId()), Constants.COLLECTION_ROOT, "Root Collection",
+            Constants.MEDIATYPE_ENTRY, Constants.MEDIATYPE_CMISATOM);
+
+        // - types collection
+        serviceDoc.writeCollection(compileUrl(baseUrl, RESOURCE_TYPES, null),
+            Constants.COLLECTION_TYPES, "Types Collection", "");
+
+        // - query collection
+        if (supportsQuery) {
+          serviceDoc.writeCollection(compileUrl(baseUrl, RESOURCE_QUERY, null),
+              Constants.COLLECTION_QUERY, "Query Collection", Constants.MEDIATYPE_QUERY);
+        }
+
+        // - checked out collection collection
+        serviceDoc
+            .writeCollection(compileUrl(baseUrl, RESOURCE_CHECKEDOUT, null),
+                Constants.COLLECTION_CHECKEDOUT, "Checked Out Collection",
+                Constants.MEDIATYPE_CMISATOM);
+
+        // - unfiled collection collection
+        if (supportsUnFiling || supportsMultifiling) {
+          serviceDoc.writeCollection(compileUrl(baseUrl, RESOURCE_UNFILED, null),
+              Constants.COLLECTION_UNFILED, "Unfiled Collection", Constants.MEDIATYPE_CMISATOM);
+
+        }
+
+        // add repository info
+        serviceDoc.writeRepositoryInfo(infoData);
+
+        // add links
+
+        // - types descendants
+        serviceDoc.writeLink(Constants.REP_REL_TYPEDESC, compileUrl(baseUrl, RESOURCE_TYPESDESC,
+            null), Constants.MEDIATYPE_FEED, null);
+
+        // - folder tree
+        if (supportsFolderTree) {
+          serviceDoc.writeLink(Constants.REP_REL_FOLDERTREE, compileUrl(baseUrl,
+              RESOURCE_FOLDERTREE, infoData.getRootFolderId()), Constants.MEDIATYPE_DESCENDANTS,
+              null);
+        }
+
+        // - root descendants
+        if (supportsRootDescendants) {
+          serviceDoc.writeLink(Constants.REP_REL_ROOTDESC, compileUrl(baseUrl,
+              RESOURCE_DESCENDANTS, infoData.getRootFolderId()), Constants.MEDIATYPE_DESCENDANTS,
+              infoData.getRootFolderId());
+        }
+
+        // - changes
+        if (supportsChanges) {
+          serviceDoc.writeLink(Constants.REP_REL_CHANGES, compileUrl(baseUrl, RESOURCE_CHANGES,
+              null), Constants.MEDIATYPE_FEED, null);
+        }
+
+        // add URI templates
+
+        // - object by id
+        String url = compileUrl(baseUrl, RESOURCE_OBJECTBYID, null)
+            + "?id={id}&filter={filter}&includeAllowableActions={includeAllowableActions}&includeACL={includeACL}";
+        serviceDoc
+            .writeUriTemplate(url, Constants.TEMPLATE_OBJECT_BY_ID, Constants.MEDIATYPE_ENTRY);
+
+        // - object by path
+        url = compileUrl(baseUrl, RESOURCE_OBJECTBYPATH, null)
+            + "?path={path}&filter={filter}&includeAllowableActions={includeAllowableActions}&includeACL={includeACL}";
+        serviceDoc.writeUriTemplate(url, Constants.TEMPLATE_OBJECT_BY_PATH,
+            Constants.MEDIATYPE_ENTRY);
+
+        // - type by id
+        url = compileUrl(baseUrl, RESOURCE_TYPE, null) + "?id={id}";
+        serviceDoc.writeUriTemplate(url, Constants.TEMPLATE_TYPE_BY_ID, Constants.MEDIATYPE_ENTRY);
+
+        // - query
+        if (supportsQuery) {
+          url = compileUrl(baseUrl, RESOURCE_QUERY, null)
+              + "?q={q}&searchAllVersions={searchAllVersions}&includeAllowableActions={includeAllowableActions}&includeRelationships={includeRelationships}&maxItems={maxItems}&skipCount={skipCount}";
+          serviceDoc.writeUriTemplate(url, Constants.TEMPLATE_QUERY, Constants.MEDIATYPE_FEED);
+        }
+
+        serviceDoc.endWorkspace();
+      }
+    }
+
+    serviceDoc.endServiceDocument();
+    serviceDoc.endDocument();
+  }
+
+  /**
+   * Renders a type children collection.
+   */
+  public static void getTypeChildren(CallContext context, AbstractServicesFactory factory,
+      String repositoryId, HttpServletRequest request, HttpServletResponse response)
+      throws Exception {
+    CmisRepositoryService service = factory.getRepositoryService();
+
+    // get parameters
+    String typeId = getStringParameter(request, Constants.PARAM_TYPE_ID);
+    boolean includePropertyDefinitions = getBooleanParameter(request,
+        Constants.PARAM_PROPERTY_DEFINITIONS, false);
+    BigInteger maxItems = getBigIntegerParameter(request, Constants.PARAM_MAX_ITEMS);
+    BigInteger skipCount = getBigIntegerParameter(request, Constants.PARAM_SKIP_COUNT);
+
+    // execute
+    TypeDefinitionList typeList = service.getTypeChildren(context, repositoryId, typeId,
+        includePropertyDefinitions, maxItems, skipCount, null);
+
+    BigInteger numItems = (typeList == null ? null : typeList.getNumItems());
+    Boolean hasMoreItems = (typeList == null ? null : typeList.hasMoreItems());
+
+    String parentTypeId = null;
+    String typeName = "Type Children";
+
+    // in order to get the parent type, we need the type definition of this type as well
+    if (typeId != null) {
+      TypeDefinition typeDefinition = service
+          .getTypeDefinition(context, repositoryId, typeId, null);
+
+      parentTypeId = (typeDefinition == null ? null : typeDefinition.getParentId());
+      typeName = (typeDefinition == null ? typeId : typeDefinition.getDisplayName());
+    }
+
+    // write XML
+    response.setStatus(HttpServletResponse.SC_OK);
+    response.setContentType(Constants.MEDIATYPE_FEED);
+
+    AtomFeed feed = new AtomFeed();
+    feed.startDocument(response.getOutputStream());
+    feed.startFeed(true);
+
+    // write basic Atom feed elements
+    feed.writeFeedElements(typeId, TYPE_AUTHOR, typeName, new GregorianCalendar(), null, numItems);
+
+    // write links
+    UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
+
+    feed.writeServiceLink(baseUrl.toString(), repositoryId);
+
+    UrlBuilder selfLink = compileUrlBuilder(baseUrl, RESOURCE_TYPES, null);
+    selfLink.addParameter(Constants.PARAM_TYPE_ID, typeId);
+    selfLink.addParameter(Constants.PARAM_PROPERTY_DEFINITIONS, includePropertyDefinitions);
+    feed.writeSelfLink(selfLink.toString(), typeId);
+
+    feed.writeViaLink(compileUrl(baseUrl, RESOURCE_TYPE, typeId));
+
+    UrlBuilder downLink = compileUrlBuilder(baseUrl, RESOURCE_TYPESDESC, null);
+    downLink.addParameter(Constants.PARAM_TYPE_ID, typeId);
+    feed.writeDownLink(downLink.toString(), Constants.MEDIATYPE_DESCENDANTS);
+
+    if (parentTypeId != null) {
+      feed.writeUpLink(compileUrl(baseUrl, RESOURCE_TYPE, parentTypeId), Constants.MEDIATYPE_ENTRY);
+    }
+
+    // write paging links
+    UrlBuilder pagingUrl = compileUrlBuilder(baseUrl, RESOURCE_TYPES, null);
+    pagingUrl.addParameter(Constants.PARAM_TYPE_ID, typeId);
+    pagingUrl.addParameter(Constants.PARAM_PROPERTY_DEFINITIONS, includePropertyDefinitions);
+    feed.writePagingLinks(pagingUrl, maxItems, skipCount, numItems, hasMoreItems, PAGE_SIZE);
+
+    // write collection
+    UrlBuilder collectionUrl = compileUrlBuilder(baseUrl, RESOURCE_TYPES, null);
+    collectionUrl.addParameter(Constants.PARAM_TYPE_ID, typeId);
+    feed.writeCollection(collectionUrl.toString(), null, "Types Collection", "");
+
+    // write type entries
+    if ((typeList != null) && (typeList.getList() != null)) {
+      AtomEntry entry = new AtomEntry(feed.getWriter());
+      for (TypeDefinition type : typeList.getList()) {
+        writeTypeEntry(entry, type, null, repositoryId, baseUrl, false);
+      }
+    }
+
+    // we are done
+    feed.endFeed();
+    feed.endDocument();
+  }
+
+  /**
+   * Renders a type descendants feed.
+   */
+  public static void getTypeDescendants(CallContext context, AbstractServicesFactory factory,
+      String repositoryId, HttpServletRequest request, HttpServletResponse response)
+      throws Exception {
+    CmisRepositoryService service = factory.getRepositoryService();
+
+    // get parameters
+    String typeId = getStringParameter(request, Constants.PARAM_TYPE_ID);
+    BigInteger depth = getBigIntegerParameter(request, Constants.PARAM_DEPTH);
+    boolean includePropertyDefinitions = getBooleanParameter(request,
+        Constants.PARAM_PROPERTY_DEFINITIONS, false);
+
+    // execute
+    List<TypeDefinitionContainer> typeTree = service.getTypeDescendants(context, repositoryId,
+        typeId, depth, includePropertyDefinitions, null);
+
+    String parentTypeId = null;
+    String typeName = "Type Children";
+
+    // in order to get the parent type, we need the type definition of this type as well
+    if (typeId != null) {
+      TypeDefinition typeDefinition = service
+          .getTypeDefinition(context, repositoryId, typeId, null);
+
+      parentTypeId = (typeDefinition == null ? null : typeDefinition.getParentId());
+      typeName = (typeDefinition == null ? typeId : typeDefinition.getDisplayName());
+    }
+
+    // write XML
+    response.setStatus(HttpServletResponse.SC_OK);
+    response.setContentType(Constants.MEDIATYPE_FEED);
+
+    AtomFeed feed = new AtomFeed();
+    feed.startDocument(response.getOutputStream());
+    feed.startFeed(true);
+
+    // write basic Atom feed elements
+    feed.writeFeedElements(typeId, TYPE_AUTHOR, typeName, new GregorianCalendar(), null, null);
+
+    // write links
+    UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
+
+    feed.writeServiceLink(baseUrl.toString(), repositoryId);
+
+    UrlBuilder selfLink = compileUrlBuilder(baseUrl, RESOURCE_TYPESDESC, null);
+    selfLink.addParameter(Constants.PARAM_TYPE_ID, typeId);
+    selfLink.addParameter(Constants.PARAM_DEPTH, depth);
+    selfLink.addParameter(Constants.PARAM_PROPERTY_DEFINITIONS, includePropertyDefinitions);
+    feed.writeSelfLink(selfLink.toString(), typeId);
+
+    feed.writeViaLink(compileUrl(baseUrl, RESOURCE_TYPE, typeId));
+
+    UrlBuilder downLink = compileUrlBuilder(baseUrl, RESOURCE_TYPES, null);
+    downLink.addParameter(Constants.PARAM_TYPE_ID, typeId);
+    feed.writeDownLink(downLink.toString(), Constants.MEDIATYPE_FEED);
+
+    if (parentTypeId != null) {
+      feed.writeUpLink(compileUrl(baseUrl, RESOURCE_TYPE, parentTypeId), Constants.MEDIATYPE_ENTRY);
+    }
+
+    // write tree
+    if (typeTree != null) {
+      AtomEntry entry = new AtomEntry(feed.getWriter());
+
+      for (TypeDefinitionContainer container : typeTree) {
+        if ((container != null) && (container.getTypeDefinition() != null)) {
+          writeTypeEntry(entry, container.getTypeDefinition(), container.getChildren(),
+              repositoryId, baseUrl, false);
+        }
+      }
+    }
+
+    // we are done
+    feed.endFeed();
+    feed.endDocument();
+  }
+
+  /**
+   * Renders a type definition.
+   */
+  public static void getTypeDefinition(CallContext context, AbstractServicesFactory factory,
+      String repositoryId, HttpServletRequest request, HttpServletResponse response)
+      throws Exception {
+    CmisRepositoryService service = factory.getRepositoryService();
+
+    // get parameters
+    String typeId = getStringParameter(request, Constants.PARAM_ID);
+
+    // execute
+    TypeDefinition type = service.getTypeDefinition(context, repositoryId, typeId, null);
+
+    // write XML
+    response.setStatus(HttpServletResponse.SC_OK);
+    response.setContentType(Constants.MEDIATYPE_ENTRY);
+
+    AtomEntry entry = new AtomEntry();
+    entry.startDocument(response.getOutputStream());
+    writeTypeEntry(entry, type, null, repositoryId, compileBaseUrl(request, repositoryId), true);
+    entry.endDocument();
+  }
+}

Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/RepositoryService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/ServiceDocument.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/ServiceDocument.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/ServiceDocument.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/ServiceDocument.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.opencmis.server.impl.atompub;
+
+import static org.apache.opencmis.commons.impl.Converter.convert;
+
+import javax.xml.bind.JAXBException;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.opencmis.commons.impl.Constants;
+import org.apache.opencmis.commons.impl.JaxBHelper;
+import org.apache.opencmis.commons.impl.jaxb.CmisRepositoryInfoType;
+import org.apache.opencmis.commons.provider.RepositoryInfoData;
+
+/**
+ * Service document class.
+ * 
+ * @author <a href="mailto:fmueller@opentext.com">Florian M&uuml;ller</a>
+ * 
+ */
+public class ServiceDocument extends AtomDocumentBase {
+
+  public ServiceDocument() {
+  }
+
+  public void startServiceDocument() throws XMLStreamException {
+    XMLStreamWriter xsw = getWriter();
+    xsw.writeStartElement(Constants.NAMESPACE_APP, "service");
+    writeNamespace(Constants.NAMESPACE_APP);
+    writeNamespace(Constants.NAMESPACE_ATOM);
+    writeNamespace(Constants.NAMESPACE_CMIS);
+    writeNamespace(Constants.NAMESPACE_RESTATOM);
+  }
+
+  public void endServiceDocument() throws XMLStreamException {
+    getWriter().writeEndElement();
+  }
+
+  public void startWorkspace(String title) throws XMLStreamException {
+    getWriter().writeStartElement(Constants.NAMESPACE_APP, "workspace");
+    writeSimpleTag(Constants.NAMESPACE_ATOM, "title", title);
+  }
+
+  public void endWorkspace() throws XMLStreamException {
+    getWriter().writeEndElement();
+  }
+
+  public void writeRepositoryInfo(RepositoryInfoData repInfo) throws XMLStreamException,
+      JAXBException {
+    CmisRepositoryInfoType repInfoJaxb = convert(repInfo);
+    if (repInfoJaxb == null) {
+      return;
+    }
+
+    JaxBHelper.marshal(JaxBHelper.CMIS_EXTRA_OBJECT_FACTORY.createRepositoryInfo(repInfoJaxb),
+        getWriter(), true);
+  }
+
+  public void writeUriTemplate(String template, String type, String mediatype)
+      throws XMLStreamException {
+    XMLStreamWriter xsw = getWriter();
+
+    xsw.writeStartElement(Constants.NAMESPACE_RESTATOM, "uritemplate");
+    writeSimpleTag(Constants.NAMESPACE_RESTATOM, "template", template);
+    writeSimpleTag(Constants.NAMESPACE_RESTATOM, "type", type);
+    writeSimpleTag(Constants.NAMESPACE_RESTATOM, "mediatype", mediatype);
+    xsw.writeEndElement();
+  }
+}

Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/ServiceDocument.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/VersioningService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/VersioningService.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/VersioningService.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/VersioningService.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.opencmis.server.impl.atompub;
+
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.RESOURCE_ENTRY;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.RESOURCE_VERSIONS;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.compileBaseUrl;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.compileUrl;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.getBooleanParameter;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.getStringParameter;
+import static org.apache.opencmis.server.impl.atompub.AtomPubUtils.writeObjectEntry;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.opencmis.commons.exceptions.CmisRuntimeException;
+import org.apache.opencmis.commons.impl.Constants;
+import org.apache.opencmis.commons.impl.UrlBuilder;
+import org.apache.opencmis.commons.provider.Holder;
+import org.apache.opencmis.commons.provider.ObjectData;
+import org.apache.opencmis.server.impl.ObjectInfoHolderImpl;
+import org.apache.opencmis.server.spi.AbstractServicesFactory;
+import org.apache.opencmis.server.spi.CallContext;
+import org.apache.opencmis.server.spi.CmisObjectService;
+import org.apache.opencmis.server.spi.CmisVersioningService;
+import org.apache.opencmis.server.spi.ObjectInfo;
+import org.apache.opencmis.server.spi.ObjectInfoHolder;
+
+/**
+ * Versioning Service operations.
+ * 
+ * @author <a href="mailto:fmueller@opentext.com">Florian M&uuml;ller</a>
+ * 
+ */
+public class VersioningService {
+
+  /**
+   * Check Out.
+   */
+  public static void checkOut(CallContext context, AbstractServicesFactory factory,
+      String repositoryId, HttpServletRequest request, HttpServletResponse response)
+      throws Exception {
+    CmisVersioningService service = factory.getVersioningService();
+
+    // get parameters
+    AtomEntryParser parser = new AtomEntryParser(request.getInputStream());
+
+    // execute
+    ObjectInfoHolder objectInfoHolder = new ObjectInfoHolderImpl();
+    ObjectData object = service.checkOut(context, repositoryId, new Holder<String>(parser.getId()),
+        null, null, objectInfoHolder);
+
+    if (object == null) {
+      throw new CmisRuntimeException("Object is null!");
+    }
+
+    if (object.getId() == null) {
+      throw new CmisRuntimeException("Object Id is null!");
+    }
+
+    // set headers
+    UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
+    String location = compileUrl(baseUrl, RESOURCE_ENTRY, object.getId());
+
+    response.setStatus(HttpServletResponse.SC_CREATED);
+    response.setContentType(Constants.MEDIATYPE_ENTRY);
+    response.setHeader("Content-Location", location);
+    response.setHeader("Location", location);
+
+    // write XML
+    AtomEntry entry = new AtomEntry();
+    entry.startDocument(response.getOutputStream());
+    writeObjectEntry(entry, object, objectInfoHolder, null, repositoryId, null, null, baseUrl, true);
+    entry.endDocument();
+  }
+
+  /**
+   * Get all versions.
+   */
+  public static void getAllVersions(CallContext context, AbstractServicesFactory factory,
+      String repositoryId, HttpServletRequest request, HttpServletResponse response)
+      throws Exception {
+    CmisVersioningService service = factory.getVersioningService();
+
+    // get parameters
+    String objectId = getStringParameter(request, Constants.PARAM_ID);
+    String filter = getStringParameter(request, Constants.PARAM_FILTER);
+    Boolean includeAllowableActions = getBooleanParameter(request,
+        Constants.PARAM_ALLOWABLE_ACTIONS);
+
+    // execute
+    ObjectInfoHolder objectInfoHolder = new ObjectInfoHolderImpl();
+    List<ObjectData> versions = service.getAllVersions(context, repositoryId, objectId, filter,
+        includeAllowableActions, null, objectInfoHolder);
+
+    if (versions == null) {
+      throw new CmisRuntimeException("Versions are null!");
+    }
+
+    ObjectInfo objectInfo = objectInfoHolder.getObjectInfo(objectId);
+    if (objectInfo == null) {
+      throw new CmisRuntimeException("Object Info is missing!");
+    }
+
+    // set headers
+    response.setStatus(HttpServletResponse.SC_OK);
+    response.setContentType(Constants.MEDIATYPE_FEED);
+
+    // write XML
+    AtomFeed feed = new AtomFeed();
+    feed.startDocument(response.getOutputStream());
+    feed.startFeed(true);
+
+    // write basic Atom feed elements
+    feed.writeFeedElements(objectInfo.getId(), objectInfo.getCreatedBy(), objectInfo.getName(),
+        objectInfo.getLastModificationDate(), null, null);
+
+    // write links
+    UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
+
+    feed.writeServiceLink(baseUrl.toString(), repositoryId);
+
+    feed.writeSelfLink(compileUrl(baseUrl, RESOURCE_VERSIONS, objectInfo.getId()), null);
+
+    feed.writeViaLink(compileUrl(baseUrl, RESOURCE_ENTRY, objectId));
+
+    // write entries
+    AtomEntry entry = new AtomEntry(feed.getWriter());
+    for (ObjectData object : versions) {
+      if (object == null) {
+        continue;
+      }
+      writeObjectEntry(entry, object, objectInfoHolder, null, repositoryId, null, null, baseUrl,
+          false);
+    }
+
+    // we are done
+    feed.endFeed();
+    feed.endDocument();
+  }
+
+  /**
+   * Delete object.
+   */
+  public static void deleteAllVersions(CallContext context, AbstractServicesFactory factory,
+      String repositoryId, HttpServletRequest request, HttpServletResponse response)
+      throws Exception {
+    CmisObjectService service = factory.getObjectService();
+
+    // get parameters
+    String objectId = getStringParameter(request, Constants.PARAM_ID);
+
+    // execute
+    service.deleteObjectOrCancelCheckOut(context, repositoryId, objectId, Boolean.TRUE, null);
+
+    // set headers
+    response.setStatus(HttpServletResponse.SC_NO_CONTENT);
+  }
+}

Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/VersioningService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/XMLDocumentBase.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/XMLDocumentBase.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/XMLDocumentBase.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/XMLDocumentBase.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.opencmis.server.impl.atompub;
+
+import java.io.OutputStream;
+
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.opencmis.commons.impl.Constants;
+
+/**
+ * Base class for XML documents.
+ * 
+ * @author <a href="mailto:fmueller@opentext.com">Florian M&uuml;ller</a>
+ * 
+ */
+public abstract class XMLDocumentBase {
+
+  public static final String PREFIX_ATOM = "atom";
+  public static final String PREFIX_CMIS = "cmis";
+  public static final String PREFIX_RESTATOM = "cmisra";
+  public static final String PREFIX_APP = "app";
+  public static final String PREFIX_XSI = "xsi";
+
+  private XMLStreamWriter fWriter;
+
+  /**
+   * Sets the namespaces for the document.
+   */
+  public void setNamespaces() throws XMLStreamException {
+    fWriter.setPrefix(PREFIX_ATOM, Constants.NAMESPACE_ATOM);
+    fWriter.setPrefix(PREFIX_CMIS, Constants.NAMESPACE_CMIS);
+    fWriter.setPrefix(PREFIX_RESTATOM, Constants.NAMESPACE_RESTATOM);
+    fWriter.setPrefix(PREFIX_APP, Constants.NAMESPACE_APP);
+    fWriter.setPrefix(PREFIX_XSI, Constants.NAMESPACE_XSI);
+  }
+
+  /**
+   * Writes the namespace declaration of the given URI to the current tag.
+   */
+  public void writeNamespace(String namespaceUri) throws XMLStreamException {
+    fWriter.writeNamespace(fWriter.getPrefix(namespaceUri), namespaceUri);
+  }
+
+  /**
+   * Starts the document and sets the namespaces.
+   */
+  public void startDocument(OutputStream out) throws XMLStreamException {
+    // create a writer
+    XMLOutputFactory factory = XMLOutputFactory.newInstance();
+    fWriter = factory.createXMLStreamWriter(out);
+
+    // start the document
+    fWriter.writeStartDocument();
+    setNamespaces();
+  }
+
+  /**
+   * Finishes the document.
+   */
+  public void endDocument() throws XMLStreamException {
+    if (fWriter == null) {
+      return;
+    }
+
+    // end the document
+    fWriter.writeEndDocument();
+
+    // we are done.
+    fWriter.close();
+  }
+
+  /**
+   * Returns the writer object.
+   */
+  public XMLStreamWriter getWriter() {
+    return fWriter;
+  }
+
+  /**
+   * Sets the writer object.
+   */
+  protected void setWriter(XMLStreamWriter writer) {
+    fWriter = writer;
+  }
+}

Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/XMLDocumentBase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/dummy/DummyRepositoryService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/dummy/DummyRepositoryService.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/dummy/DummyRepositoryService.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/dummy/DummyRepositoryService.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.opencmis.server.impl.dummy;
+
+import java.math.BigInteger;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.opencmis.commons.api.ExtensionsData;
+import org.apache.opencmis.commons.api.TypeDefinition;
+import org.apache.opencmis.commons.api.TypeDefinitionContainer;
+import org.apache.opencmis.commons.api.TypeDefinitionList;
+import org.apache.opencmis.commons.exceptions.CmisNotSupportedException;
+import org.apache.opencmis.commons.exceptions.CmisObjectNotFoundException;
+import org.apache.opencmis.commons.impl.dataobjects.RepositoryInfoDataImpl;
+import org.apache.opencmis.commons.provider.RepositoryInfoData;
+import org.apache.opencmis.server.spi.CallContext;
+import org.apache.opencmis.server.spi.CmisRepositoryService;
+
+/**
+ * Simplest Repository Service implementation.
+ * 
+ * @author <a href="mailto:fmueller@opentext.com">Florian M&uuml;ller</a>
+ * 
+ */
+public class DummyRepositoryService implements CmisRepositoryService {
+
+  private RepositoryInfoDataImpl fRepInfo;
+
+  public DummyRepositoryService(String id, String name) {
+    fRepInfo = new RepositoryInfoDataImpl();
+
+    fRepInfo.setRepositoryId(id);
+    fRepInfo.setRepositoryName(name);
+    fRepInfo.setRepositoryDescription(name);
+    fRepInfo.setCmisVersionSupported("1.0");
+    fRepInfo.setRootFolder("root");
+
+    fRepInfo.setVendorName("OpenCMIS");
+    fRepInfo.setProductName("OpenCMIS Server");
+    fRepInfo.setProductVersion("1.0");
+  }
+
+  public RepositoryInfoData getRepositoryInfo(CallContext context, String repositoryId,
+      ExtensionsData extension) {
+
+    if (!fRepInfo.getRepositoryId().equals(repositoryId)) {
+      throw new CmisObjectNotFoundException("A repository with repository id '" + repositoryId
+          + "' does not exist!");
+    }
+
+    return fRepInfo;
+  }
+
+  public List<RepositoryInfoData> getRepositoryInfos(CallContext context, ExtensionsData extension) {
+    return Collections.singletonList((RepositoryInfoData) fRepInfo);
+  }
+
+  public TypeDefinitionList getTypeChildren(CallContext context, String repositoryId,
+      String typeId, Boolean includePropertyDefinitions, BigInteger maxItems, BigInteger skipCount,
+      ExtensionsData extension) {
+    throw new CmisNotSupportedException();
+  }
+
+  public TypeDefinition getTypeDefinition(CallContext context, String repositoryId, String typeId,
+      ExtensionsData extension) {
+    throw new CmisNotSupportedException();
+  }
+
+  public List<TypeDefinitionContainer> getTypeDescendants(CallContext context, String repositoryId,
+      String typeId, BigInteger depth, Boolean includePropertyDefinitions, ExtensionsData extension) {
+    throw new CmisNotSupportedException();
+  }
+
+}

Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/dummy/DummyRepositoryService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/dummy/DummyServicesFactory.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/dummy/DummyServicesFactory.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/dummy/DummyServicesFactory.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/dummy/DummyServicesFactory.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.opencmis.server.impl.dummy;
+
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.opencmis.server.spi.AbstractServicesFactory;
+import org.apache.opencmis.server.spi.CmisRepositoryService;
+
+/**
+ * Implementation of a repository factory without back-end for test purposes.
+ * 
+ * @author <a href="mailto:fmueller@opentext.com">Florian M&uuml;ller</a>
+ * 
+ */
+public class DummyServicesFactory extends AbstractServicesFactory {
+
+  private static final String REPOSITORY_ID = "repository.id";
+  private static final String REPOSITORY_ID_DEFAULT = "test-rep";
+
+  private static final String REPOSITORY_NAME = "repository.name";
+  private static final String REPOSITORY_NAME_DEFAULT = "Test Repository";
+
+  private static final Log LOG = LogFactory.getLog(DummyServicesFactory.class.getName());
+
+  private DummyRepositoryService fRepositoryService;
+  private String fId;
+  private String fName;
+
+  @Override
+  public void init(Map<String, String> parameters) {
+    // get the id
+    fId = parameters.get(REPOSITORY_ID);
+    if ((fId == null) || (fId.trim().length() == 0)) {
+      fId = REPOSITORY_ID_DEFAULT;
+    }
+
+    // get the name
+    fName = parameters.get(REPOSITORY_NAME);
+    if ((fName == null) || (fName.trim().length() == 0)) {
+      fName = REPOSITORY_NAME_DEFAULT;
+    }
+
+    // create a repository service
+    fRepositoryService = new DummyRepositoryService(fId, fName);
+
+    LOG.info("Initialized dummy repository '" + fName + "' (" + fId + ")");
+  }
+
+  @Override
+  public void destroy() {
+    LOG.info("Destroyed dummy repository '" + fName + "' (" + fId + ")");
+  }
+
+  @Override
+  public CmisRepositoryService getRepositoryService() {
+    return fRepositoryService;
+  }
+
+}

Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/dummy/DummyServicesFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/webservices/AbstractService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/webservices/AbstractService.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/webservices/AbstractService.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/webservices/AbstractService.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.opencmis.server.impl.webservices;
+
+import java.math.BigInteger;
+import java.util.Map;
+
+import javax.servlet.ServletContext;
+import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.handler.MessageContext;
+
+import org.apache.opencmis.commons.exceptions.CmisBaseException;
+import org.apache.opencmis.commons.exceptions.CmisConstraintException;
+import org.apache.opencmis.commons.exceptions.CmisContentAlreadyExistsException;
+import org.apache.opencmis.commons.exceptions.CmisFilterNotValidException;
+import org.apache.opencmis.commons.exceptions.CmisInvalidArgumentException;
+import org.apache.opencmis.commons.exceptions.CmisNameConstraintViolationException;
+import org.apache.opencmis.commons.exceptions.CmisNotSupportedException;
+import org.apache.opencmis.commons.exceptions.CmisObjectNotFoundException;
+import org.apache.opencmis.commons.exceptions.CmisPermissionDeniedException;
+import org.apache.opencmis.commons.exceptions.CmisStorageException;
+import org.apache.opencmis.commons.exceptions.CmisStreamNotSupportedException;
+import org.apache.opencmis.commons.exceptions.CmisUpdateConflictException;
+import org.apache.opencmis.commons.exceptions.CmisVersioningException;
+import org.apache.opencmis.commons.impl.jaxb.CmisException;
+import org.apache.opencmis.commons.impl.jaxb.CmisFaultType;
+import org.apache.opencmis.commons.impl.jaxb.EnumServiceException;
+import org.apache.opencmis.server.impl.CallContextImpl;
+import org.apache.opencmis.server.impl.CmisRepositoryContextListener;
+import org.apache.opencmis.server.spi.AbstractServicesFactory;
+import org.apache.opencmis.server.spi.CallContext;
+
+/**
+ * This class contains operations used by all services.
+ * 
+ * @author <a href="mailto:fmueller@opentext.com">Florian M&uuml;ller</a>
+ * 
+ */
+public abstract class AbstractService {
+
+  public static final String CALL_CONTEXT_MAP = "org.apache.opencmis.callcontext";
+
+  /**
+   * Returns the services factory.
+   */
+  protected AbstractServicesFactory getServicesFactory(WebServiceContext wsContext) {
+    ServletContext servletContext = (ServletContext) wsContext.getMessageContext().get(
+        MessageContext.SERVLET_CONTEXT);
+
+    return (AbstractServicesFactory) servletContext
+        .getAttribute(CmisRepositoryContextListener.SERVICES_FACTORY);
+  }
+
+  /**
+   * Creates a CallContext object for the Web Service context.
+   */
+  @SuppressWarnings("unchecked")
+  protected CallContext createContext(WebServiceContext wsContext) {
+    CallContextImpl context = new CallContextImpl(CallContext.BINDING_WEBSERVICES);
+
+    MessageContext mc = wsContext.getMessageContext();
+    Map<String, String> callContextMap = (Map<String, String>) mc.get(CALL_CONTEXT_MAP);
+    if (callContextMap != null) {
+      for (Map.Entry<String, String> e : callContextMap.entrySet()) {
+        context.put(e.getKey(), e.getValue());
+      }
+    }
+
+    return context;
+  }
+
+  /**
+   * Converts a CMIS exception to the appropriate Web Service exception.
+   */
+  protected CmisException convertException(Exception ex) {
+    CmisFaultType fault = new CmisFaultType();
+    fault.setMessage("Unknown exception");
+    fault.setCode(BigInteger.ZERO);
+    fault.setType(EnumServiceException.RUNTIME);
+
+    if (ex != null) {
+      fault.setMessage(ex.getMessage());
+
+      if (ex instanceof CmisBaseException) {
+        fault.setCode(((CmisBaseException) ex).getCode());
+      }
+
+      if (ex instanceof CmisConstraintException) {
+        fault.setType(EnumServiceException.CONSTRAINT);
+      }
+      else if (ex instanceof CmisContentAlreadyExistsException) {
+        fault.setType(EnumServiceException.CONTENT_ALREADY_EXISTS);
+      }
+      else if (ex instanceof CmisFilterNotValidException) {
+        fault.setType(EnumServiceException.FILTER_NOT_VALID);
+      }
+      else if (ex instanceof CmisInvalidArgumentException) {
+        fault.setType(EnumServiceException.INVALID_ARGUMENT);
+      }
+      else if (ex instanceof CmisNameConstraintViolationException) {
+        fault.setType(EnumServiceException.NAME_CONSTRAINT_VIOLATION);
+      }
+      else if (ex instanceof CmisNotSupportedException) {
+        fault.setType(EnumServiceException.NOT_SUPPORTED);
+      }
+      else if (ex instanceof CmisObjectNotFoundException) {
+        fault.setType(EnumServiceException.OBJECT_NOT_FOUND);
+      }
+      else if (ex instanceof CmisPermissionDeniedException) {
+        fault.setType(EnumServiceException.PERMISSION_DENIED);
+      }
+      else if (ex instanceof CmisStorageException) {
+        fault.setType(EnumServiceException.STORAGE);
+      }
+      else if (ex instanceof CmisStreamNotSupportedException) {
+        fault.setType(EnumServiceException.STREAM_NOT_SUPPORTED);
+      }
+      else if (ex instanceof CmisUpdateConflictException) {
+        fault.setType(EnumServiceException.UPDATE_CONFLICT);
+      }
+      else if (ex instanceof CmisVersioningException) {
+        fault.setType(EnumServiceException.VERSIONING);
+      }
+    }
+
+    return new CmisException(fault.getMessage(), fault, ex);
+  }
+}

Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/webservices/AbstractService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/webservices/AclService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/webservices/AclService.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/webservices/AclService.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/webservices/AclService.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.opencmis.server.impl.webservices;
+
+import static org.apache.opencmis.commons.impl.Converter.convert;
+
+import javax.annotation.Resource;
+import javax.jws.WebService;
+import javax.xml.ws.WebServiceContext;
+
+import org.apache.opencmis.commons.enums.AclPropagation;
+import org.apache.opencmis.commons.impl.jaxb.ACLServicePort;
+import org.apache.opencmis.commons.impl.jaxb.CmisACLType;
+import org.apache.opencmis.commons.impl.jaxb.CmisAccessControlListType;
+import org.apache.opencmis.commons.impl.jaxb.CmisException;
+import org.apache.opencmis.commons.impl.jaxb.CmisExtensionType;
+import org.apache.opencmis.commons.impl.jaxb.EnumACLPropagation;
+import org.apache.opencmis.commons.provider.AccessControlList;
+import org.apache.opencmis.server.spi.AbstractServicesFactory;
+import org.apache.opencmis.server.spi.CallContext;
+import org.apache.opencmis.server.spi.CmisAclService;
+
+/**
+ * CMIS ACL Service.
+ * 
+ * @author <a href="mailto:fmueller@opentext.com">Florian M&uuml;ller</a>
+ * 
+ */
+@WebService(endpointInterface = "org.apache.opencmis.commons.impl.jaxb.ACLServicePort")
+public class AclService extends AbstractService implements ACLServicePort {
+  @Resource
+  WebServiceContext fContext;
+
+  public CmisACLType applyACL(String repositoryId, String objectId,
+      CmisAccessControlListType addAces, CmisAccessControlListType removeAces,
+      EnumACLPropagation aclPropagation, CmisExtensionType extension) throws CmisException {
+    try {
+      AbstractServicesFactory factory = getServicesFactory(fContext);
+      CmisAclService service = factory.getAclService();
+      CallContext context = createContext(fContext);
+
+      AccessControlList acl = service.applyAcl(context, repositoryId, objectId, convert(addAces,
+          null), convert(removeAces, null), convert(AclPropagation.class, aclPropagation),
+          convert(extension));
+
+      if (acl == null) {
+        return null;
+      }
+
+      CmisACLType result = new CmisACLType();
+      result.setACL(convert(acl));
+      result.setExact(acl.isExact());
+
+      return result;
+    }
+    catch (Exception e) {
+      throw convertException(e);
+    }
+  }
+
+  public CmisACLType getACL(String repositoryId, String objectId, Boolean onlyBasicPermissions,
+      CmisExtensionType extension) throws CmisException {
+    try {
+      AbstractServicesFactory factory = getServicesFactory(fContext);
+      CmisAclService service = factory.getAclService();
+      CallContext context = createContext(fContext);
+
+      AccessControlList acl = service.getAcl(context, repositoryId, objectId, onlyBasicPermissions,
+          convert(extension));
+
+      if (acl == null) {
+        return null;
+      }
+
+      CmisACLType result = new CmisACLType();
+      result.setACL(convert(acl));
+      result.setExact(acl.isExact());
+
+      return result;
+    }
+    catch (Exception e) {
+      throw convertException(e);
+    }
+  }
+
+}

Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/webservices/AclService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/webservices/AuthHandler.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/webservices/AuthHandler.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/webservices/AuthHandler.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/webservices/AuthHandler.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.opencmis.server.impl.webservices;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPHeader;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.MessageContext.Scope;
+import javax.xml.ws.handler.soap.SOAPHandler;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import org.apache.opencmis.server.spi.CallContext;
+
+/**
+ * This class tries to extract a user name and a password from a UsernameToken.
+ * 
+ * @author <a href="mailto:fmueller@opentext.com">Florian M&uuml;ller</a>
+ * 
+ */
+public class AuthHandler implements SOAPHandler<SOAPMessageContext> {
+
+  private static final String WSSE_NS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
+  private static final QName WSSE_SECURITY = new QName(WSSE_NS, "Security");
+  private static final QName WSSE_USERNAME_TOKEN = new QName(WSSE_NS, "UsernameToken");
+  private static final QName WSSE_USERNAME = new QName(WSSE_NS, "Username");
+  private static final QName WSSE_PASSWORD = new QName(WSSE_NS, "Password");
+
+  private static final Set<QName> HEADERS = new HashSet<QName>();
+  static {
+    HEADERS.add(WSSE_SECURITY);
+  }
+
+  public Set<QName> getHeaders() {
+    return HEADERS;
+  }
+
+  public void close(MessageContext context) {
+  }
+
+  public boolean handleFault(SOAPMessageContext context) {
+    return true;
+  }
+
+  public boolean handleMessage(SOAPMessageContext context) {
+    Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+    if (outboundProperty.booleanValue()) {
+      // we are only looking at inbound messages
+      return true;
+    }
+
+    try {
+      // read the header
+      SOAPMessage msg = context.getMessage();
+      SOAPHeader sh = msg.getSOAPHeader();
+      SOAPElement securityElement = (SOAPElement) sh.getChildElements(WSSE_SECURITY).next();
+      SOAPElement tokenElement = (SOAPElement) securityElement
+          .getChildElements(WSSE_USERNAME_TOKEN).next();
+      SOAPElement userElement = (SOAPElement) tokenElement.getChildElements(WSSE_USERNAME).next();
+      SOAPElement passwordElement = (SOAPElement) tokenElement.getChildElements(WSSE_PASSWORD)
+          .next();
+
+      // add user and password to context
+      Map<String, String> callContextMap = new HashMap<String, String>();
+      callContextMap.put(CallContext.USERNAME, userElement.getValue());
+      callContextMap.put(CallContext.PASSWORD, passwordElement.getValue());
+
+      context.put(AbstractService.CALL_CONTEXT_MAP, callContextMap);
+      context.setScope(AbstractService.CALL_CONTEXT_MAP, Scope.APPLICATION);
+    }
+    catch (Exception e) {
+      // something went wrong, e.g. a part of the SOAP header wasn't set
+      throw new RuntimeException("UsernameToken not set!", e);
+    }
+
+    return true;
+  }
+}

Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/webservices/AuthHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/webservices/DiscoveryService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/webservices/DiscoveryService.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/webservices/DiscoveryService.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/webservices/DiscoveryService.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.opencmis.server.impl.webservices;
+
+import static org.apache.opencmis.commons.impl.Converter.convert;
+import static org.apache.opencmis.commons.impl.Converter.convertHolder;
+import static org.apache.opencmis.commons.impl.Converter.setHolderValue;
+
+import java.math.BigInteger;
+
+import javax.annotation.Resource;
+import javax.jws.WebService;
+import javax.xml.ws.Holder;
+import javax.xml.ws.WebServiceContext;
+
+import org.apache.opencmis.commons.enums.IncludeRelationships;
+import org.apache.opencmis.commons.impl.jaxb.CmisException;
+import org.apache.opencmis.commons.impl.jaxb.CmisExtensionType;
+import org.apache.opencmis.commons.impl.jaxb.CmisObjectListType;
+import org.apache.opencmis.commons.impl.jaxb.DiscoveryServicePort;
+import org.apache.opencmis.commons.impl.jaxb.EnumIncludeRelationships;
+import org.apache.opencmis.commons.provider.ObjectList;
+import org.apache.opencmis.server.spi.AbstractServicesFactory;
+import org.apache.opencmis.server.spi.CallContext;
+import org.apache.opencmis.server.spi.CmisDiscoveryService;
+
+/**
+ * CMIS Discovery Service.
+ * 
+ * @author <a href="mailto:fmueller@opentext.com">Florian M&uuml;ller</a>
+ * 
+ */
+@WebService(endpointInterface = "org.apache.opencmis.commons.impl.jaxb.DiscoveryServicePort")
+public class DiscoveryService extends AbstractService implements DiscoveryServicePort {
+  @Resource
+  WebServiceContext fContext;
+
+  public void getContentChanges(String repositoryId, Holder<String> changeLogToken,
+      Boolean includeProperties, String filter, Boolean includePolicyIds, Boolean includeAcl,
+      BigInteger maxItems, CmisExtensionType extension, Holder<CmisObjectListType> objects)
+      throws CmisException {
+    try {
+      AbstractServicesFactory factory = getServicesFactory(fContext);
+      CmisDiscoveryService service = factory.getDiscoveryService();
+      CallContext context = createContext(fContext);
+
+      org.apache.opencmis.commons.provider.Holder<String> changeLogTokenHolder = convertHolder(changeLogToken);
+
+      ObjectList changesList = service.getContentChanges(context, repositoryId,
+          changeLogTokenHolder, includeProperties, filter, includePolicyIds, includeAcl, maxItems,
+          convert(extension), null);
+
+      if (objects != null) {
+        objects.value = convert(changesList);
+      }
+
+      setHolderValue(changeLogTokenHolder, changeLogToken);
+    }
+    catch (Exception e) {
+      throw convertException(e);
+    }
+  }
+
+  public CmisObjectListType query(String repositoryId, String statement, Boolean searchAllVersions,
+      Boolean includeAllowableActions, EnumIncludeRelationships includeRelationships,
+      String renditionFilter, BigInteger maxItems, BigInteger skipCount, CmisExtensionType extension)
+      throws CmisException {
+    try {
+      AbstractServicesFactory factory = getServicesFactory(fContext);
+      CmisDiscoveryService service = factory.getDiscoveryService();
+      CallContext context = createContext(fContext);
+
+      return convert(service.query(context, repositoryId, statement, searchAllVersions,
+          includeAllowableActions, convert(IncludeRelationships.class, includeRelationships),
+          renditionFilter, maxItems, skipCount, convert(extension)));
+    }
+    catch (Exception e) {
+      throw convertException(e);
+    }
+  }
+
+}

Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/webservices/DiscoveryService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/webservices/MultiFilingService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/webservices/MultiFilingService.java?rev=910572&view=auto
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/webservices/MultiFilingService.java (added)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/webservices/MultiFilingService.java Tue Feb 16 16:03:38 2010
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.opencmis.server.impl.webservices;
+
+import static org.apache.opencmis.commons.impl.Converter.convertExtensionHolder;
+import static org.apache.opencmis.commons.impl.Converter.setExtensionValues;
+
+import javax.annotation.Resource;
+import javax.jws.WebService;
+import javax.xml.ws.Holder;
+import javax.xml.ws.WebServiceContext;
+
+import org.apache.opencmis.commons.api.ExtensionsData;
+import org.apache.opencmis.commons.impl.jaxb.CmisException;
+import org.apache.opencmis.commons.impl.jaxb.CmisExtensionType;
+import org.apache.opencmis.commons.impl.jaxb.MultiFilingServicePort;
+import org.apache.opencmis.server.spi.AbstractServicesFactory;
+import org.apache.opencmis.server.spi.CallContext;
+import org.apache.opencmis.server.spi.CmisMultiFilingService;
+
+/**
+ * CMIS MultiFiling Service.
+ * 
+ * @author <a href="mailto:fmueller@opentext.com">Florian M&uuml;ller</a>
+ * 
+ */
+@WebService(endpointInterface = "org.apache.opencmis.commons.impl.jaxb.MultiFilingServicePort")
+public class MultiFilingService extends AbstractService implements MultiFilingServicePort {
+  @Resource
+  WebServiceContext fContext;
+
+  public void addObjectToFolder(String repositoryId, String objectId, String folderId,
+      Boolean allVersions, Holder<CmisExtensionType> extension) throws CmisException {
+    try {
+      AbstractServicesFactory factory = getServicesFactory(fContext);
+      CmisMultiFilingService service = factory.getMultiFilingService();
+      CallContext context = createContext(fContext);
+
+      ExtensionsData extData = convertExtensionHolder(extension);
+
+      service.addObjectToFolder(context, repositoryId, objectId, folderId, allVersions, extData,
+          null);
+
+      setExtensionValues(extData, extension);
+    }
+    catch (Exception e) {
+      throw convertException(e);
+    }
+  }
+
+  public void removeObjectFromFolder(String repositoryId, String objectId, String folderId,
+      Holder<CmisExtensionType> extension) throws CmisException {
+    try {
+      AbstractServicesFactory factory = getServicesFactory(fContext);
+      CmisMultiFilingService service = factory.getMultiFilingService();
+      CallContext context = createContext(fContext);
+
+      ExtensionsData extData = convertExtensionHolder(extension);
+
+      service.removeObjectFromFolder(context, repositoryId, objectId, folderId, extData, null);
+
+      setExtensionValues(extData, extension);
+    }
+    catch (Exception e) {
+      throw convertException(e);
+    }
+  }
+
+}

Propchange: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/webservices/MultiFilingService.java
------------------------------------------------------------------------------
    svn:eol-style = native