chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dcaru...@apache.org
Subject svn commit: r936938 [4/29] - in /incubator/chemistry/opencmis/trunk/chemistry-opencmis-server: chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/ chemistry-opencmis-server-bindings/src/main/java/org/apache/chemi...
Date Thu, 22 Apr 2010 16:28:00 GMT
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/NavigationService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/NavigationService.java?rev=936938&r1=936937&r2=936938&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/NavigationService.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/NavigationService.java Thu Apr 22 16:27:57 2010
@@ -73,446 +73,446 @@ import org.apache.chemistry.opencmis.ser
  */
 public final class NavigationService {
 
-	/**
-	 * Children Collection GET.
-	 */
-	public static void getChildren(CallContext context, AbstractServicesFactory factory, String repositoryId,
-			HttpServletRequest request, HttpServletResponse response) throws Exception {
-		CmisNavigationService service = factory.getNavigationService();
-
-		// get parameters
-		String folderId = getStringParameter(request, Constants.PARAM_ID);
-		String filter = getStringParameter(request, Constants.PARAM_FILTER);
-		String orderBy = getStringParameter(request, Constants.PARAM_ORDER_BY);
-		Boolean includeAllowableActions = getBooleanParameter(request, Constants.PARAM_ALLOWABLE_ACTIONS);
-		IncludeRelationships includeRelationships = getEnumParameter(request, Constants.PARAM_RELATIONSHIPS,
-				IncludeRelationships.class);
-		String renditionFilter = getStringParameter(request, Constants.PARAM_RENDITION_FILTER);
-		Boolean includePathSegment = getBooleanParameter(request, Constants.PARAM_PATH_SEGMENT);
-		BigInteger maxItems = getBigIntegerParameter(request, Constants.PARAM_MAX_ITEMS);
-		BigInteger skipCount = getBigIntegerParameter(request, Constants.PARAM_SKIP_COUNT);
-
-		// execute
-		ObjectInfoHolder objectInfoHolder = new ObjectInfoHolderImpl();
-		ObjectInFolderList children = service.getChildren(context, repositoryId, folderId, filter, orderBy,
-				includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, maxItems,
-				skipCount, null, objectInfoHolder);
-
-		if (children == null) {
-			throw new CmisRuntimeException("Children are null!");
-		}
-
-		ObjectInfo folderInfo = objectInfoHolder.getObjectInfo(folderId);
-		if (folderInfo == null) {
-			throw new CmisRuntimeException("Folder 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(folderInfo.getId(), folderInfo.getCreatedBy(), folderInfo.getName(), folderInfo
-				.getLastModificationDate(), null, children.getNumItems());
-
-		// write links
-		UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
-
-		feed.writeServiceLink(baseUrl.toString(), repositoryId);
-
-		feed.writeSelfLink(compileUrl(baseUrl, RESOURCE_CHILDREN, folderInfo.getId()), null);
-
-		feed.writeDescribedByLink(compileUrl(baseUrl, RESOURCE_TYPE, folderInfo.getTypeId()));
-
-		feed.writeAllowableActionsLink(compileUrl(baseUrl, RESOURCE_ALLOWABLEACIONS, folderInfo.getId()));
-
-		feed.writeDownLink(compileUrl(baseUrl, RESOURCE_CHILDREN, folderInfo.getId()), Constants.MEDIATYPE_FEED);
-
-		if (folderInfo.supportsDescendants()) {
-			feed.writeDownLink(compileUrl(baseUrl, RESOURCE_DESCENDANTS, folderInfo.getId()),
-					Constants.MEDIATYPE_DESCENDANTS);
-		}
-
-		if (folderInfo.supportsFolderTree()) {
-			feed.writeFolderTreeLink(compileUrl(baseUrl, RESOURCE_FOLDERTREE, folderInfo.getId()));
-		}
-
-		if (folderInfo.hasParent()) {
-			feed.writeUpLink(compileUrl(baseUrl, RESOURCE_PARENTS, folderInfo.getId()), Constants.MEDIATYPE_FEED);
-		}
-
-		if (folderInfo.getRenditionInfos() != null) {
-			for (RenditionInfo ri : folderInfo.getRenditionInfos()) {
-				feed.writeAlternateLink(compileUrl(baseUrl, RESOURCE_CONTENT, ri.getId()), ri.getContenType(), ri
-						.getKind(), ri.getTitle(), ri.getLength());
-			}
-		}
-
-		if (folderInfo.hasAcl()) {
-			feed.writeAclLink(compileUrl(baseUrl, RESOURCE_ACL, folderInfo.getId()));
-		}
-
-		if (folderInfo.supportsPolicies()) {
-			feed.writeAclLink(compileUrl(baseUrl, RESOURCE_POLICIES, folderInfo.getId()));
-		}
-
-		if (folderInfo.supportsRelationships()) {
-			feed.writeRelationshipsLink(compileUrl(baseUrl, RESOURCE_RELATIONSHIPS, folderInfo.getId()));
-		}
-
-		UrlBuilder pagingUrl = new UrlBuilder(compileUrlBuilder(baseUrl, RESOURCE_CHILDREN, folderInfo.getId()));
-		pagingUrl.addParameter(Constants.PARAM_FILTER, filter);
-		pagingUrl.addParameter(Constants.PARAM_ORDER_BY, orderBy);
-		pagingUrl.addParameter(Constants.PARAM_ALLOWABLE_ACTIONS, includeAllowableActions);
-		pagingUrl.addParameter(Constants.PARAM_RELATIONSHIPS, includeRelationships);
-		pagingUrl.addParameter(Constants.PARAM_RENDITION_FILTER, renditionFilter);
-		pagingUrl.addParameter(Constants.PARAM_PATH_SEGMENT, includePathSegment);
-		feed.writePagingLinks(pagingUrl, maxItems, skipCount, children.getNumItems(), children.hasMoreItems(),
-				AtomPubUtils.PAGE_SIZE);
-
-		// write collection
-		feed.writeCollection(compileUrl(baseUrl, RESOURCE_CHILDREN, folderInfo.getId()), null, "Folder collection",
-				Constants.MEDIATYPE_CMISATOM);
-
-		// write entries
-		if (children.getObjects() != null) {
-			AtomEntry entry = new AtomEntry(feed.getWriter());
-			for (ObjectInFolderData object : children.getObjects()) {
-				if ((object == null) || (object.getObject() == null)) {
-					continue;
-				}
-				writeObjectEntry(entry, object.getObject(), objectInfoHolder, null, repositoryId, object
-						.getPathSegment(), null, baseUrl, false);
-			}
-		}
-
-		// we are done
-		feed.endFeed();
-		feed.endDocument();
-	}
-
-	/**
-	 * Descendants feed GET.
-	 */
-	public static void getDescendants(CallContext context, AbstractServicesFactory factory, String repositoryId,
-			HttpServletRequest request, HttpServletResponse response) throws Exception {
-		CmisNavigationService service = factory.getNavigationService();
-
-		// get parameters
-		String folderId = getStringParameter(request, Constants.PARAM_ID);
-		BigInteger depth = getBigIntegerParameter(request, Constants.PARAM_DEPTH);
-		String filter = getStringParameter(request, Constants.PARAM_FILTER);
-		Boolean includeAllowableActions = getBooleanParameter(request, Constants.PARAM_ALLOWABLE_ACTIONS);
-		IncludeRelationships includeRelationships = getEnumParameter(request, Constants.PARAM_RELATIONSHIPS,
-				IncludeRelationships.class);
-		String renditionFilter = getStringParameter(request, Constants.PARAM_RENDITION_FILTER);
-		Boolean includePathSegment = getBooleanParameter(request, Constants.PARAM_PATH_SEGMENT);
-
-		// execute
-		ObjectInfoHolder objectInfoHolder = new ObjectInfoHolderImpl();
-		List<ObjectInFolderContainer> descendants = service.getDescendants(context, repositoryId, folderId, depth,
-				filter, includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, null,
-				objectInfoHolder);
-
-		if (descendants == null) {
-			throw new CmisRuntimeException("Descendants are null!");
-		}
-
-		ObjectInfo folderInfo = objectInfoHolder.getObjectInfo(folderId);
-		if (folderInfo == null) {
-			throw new CmisRuntimeException("Folder 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(folderInfo.getId(), folderInfo.getCreatedBy(), folderInfo.getName(), folderInfo
-				.getLastModificationDate(), null, null);
-
-		// write links
-		UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
-
-		feed.writeServiceLink(baseUrl.toString(), repositoryId);
-
-		feed.writeSelfLink(compileUrl(baseUrl, RESOURCE_DESCENDANTS, folderInfo.getId()), null);
-
-		feed.writeViaLink(compileUrl(baseUrl, RESOURCE_ENTRY, folderInfo.getId()));
-
-		feed.writeDownLink(compileUrl(baseUrl, RESOURCE_CHILDREN, folderInfo.getId()), Constants.MEDIATYPE_FEED);
-
-		if (folderInfo.supportsFolderTree()) {
-			feed.writeFolderTreeLink(compileUrl(baseUrl, RESOURCE_FOLDERTREE, folderInfo.getId()));
-		}
-
-		if (folderInfo.hasParent()) {
-			feed.writeUpLink(compileUrl(baseUrl, RESOURCE_PARENTS, folderInfo.getId()), Constants.MEDIATYPE_FEED);
-		}
-
-		// write entries
-		AtomEntry entry = new AtomEntry(feed.getWriter());
-		for (ObjectInFolderContainer container : descendants) {
-			if ((container == null) || (container.getObject() == null) || (container.getObject().getObject() == null)) {
-				continue;
-			}
-			writeObjectEntry(entry, container.getObject().getObject(), objectInfoHolder, container.getChildren(),
-					repositoryId, container.getObject().getPathSegment(), null, baseUrl, false);
-		}
-
-		// we are done
-		feed.endFeed();
-		feed.endDocument();
-	}
-
-	/**
-	 * Folder tree feed GET.
-	 */
-	public static void getFolderTree(CallContext context, AbstractServicesFactory factory, String repositoryId,
-			HttpServletRequest request, HttpServletResponse response) throws Exception {
-		CmisNavigationService service = factory.getNavigationService();
-
-		// get parameters
-		String folderId = getStringParameter(request, Constants.PARAM_ID);
-		BigInteger depth = getBigIntegerParameter(request, Constants.PARAM_DEPTH);
-		String filter = getStringParameter(request, Constants.PARAM_FILTER);
-		Boolean includeAllowableActions = getBooleanParameter(request, Constants.PARAM_ALLOWABLE_ACTIONS);
-		IncludeRelationships includeRelationships = getEnumParameter(request, Constants.PARAM_RELATIONSHIPS,
-				IncludeRelationships.class);
-		String renditionFilter = getStringParameter(request, Constants.PARAM_RENDITION_FILTER);
-		Boolean includePathSegment = getBooleanParameter(request, Constants.PARAM_PATH_SEGMENT);
-
-		// execute
-		ObjectInfoHolder objectInfoHolder = new ObjectInfoHolderImpl();
-		List<ObjectInFolderContainer> folderTree = service.getFolderTree(context, repositoryId, folderId, depth,
-				filter, includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, null,
-				objectInfoHolder);
-
-		if (folderTree == null) {
-			throw new CmisRuntimeException("Folder tree is null!");
-		}
-
-		ObjectInfo folderInfo = objectInfoHolder.getObjectInfo(folderId);
-		if (folderInfo == null) {
-			throw new CmisRuntimeException("Folder 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(folderInfo.getId(), folderInfo.getCreatedBy(), folderInfo.getName(), folderInfo
-				.getLastModificationDate(), null, null);
-
-		// write links
-		UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
-
-		feed.writeServiceLink(baseUrl.toString(), repositoryId);
-
-		feed.writeSelfLink(compileUrl(baseUrl, RESOURCE_DESCENDANTS, folderInfo.getId()), null);
-
-		feed.writeViaLink(compileUrl(baseUrl, RESOURCE_ENTRY, folderInfo.getId()));
-
-		feed.writeDownLink(compileUrl(baseUrl, RESOURCE_CHILDREN, folderInfo.getId()), Constants.MEDIATYPE_FEED);
-
-		if (folderInfo.supportsDescendants()) {
-			feed.writeDownLink(compileUrl(baseUrl, RESOURCE_DESCENDANTS, folderInfo.getId()),
-					Constants.MEDIATYPE_DESCENDANTS);
-		}
-
-		if (folderInfo.hasParent()) {
-			feed.writeUpLink(compileUrl(baseUrl, RESOURCE_PARENTS, folderInfo.getId()), Constants.MEDIATYPE_FEED);
-		}
-
-		// write entries
-		AtomEntry entry = new AtomEntry(feed.getWriter());
-		for (ObjectInFolderContainer container : folderTree) {
-			if ((container == null) || (container.getObject() == null) || (container.getObject().getObject() == null)) {
-				continue;
-			}
-			writeObjectEntry(entry, container.getObject().getObject(), objectInfoHolder, container.getChildren(),
-					repositoryId, container.getObject().getPathSegment(), null, baseUrl, false);
-		}
-
-		// we are done
-		feed.endFeed();
-		feed.endDocument();
-	}
-
-	/**
-	 * Object parents feed GET.
-	 */
-	public static void getObjectParents(CallContext context, AbstractServicesFactory factory, String repositoryId,
-			HttpServletRequest request, HttpServletResponse response) throws Exception {
-		CmisNavigationService service = factory.getNavigationService();
-
-		// get parameters
-		String objectId = getStringParameter(request, Constants.PARAM_ID);
-		String filter = getStringParameter(request, Constants.PARAM_FILTER);
-		Boolean includeAllowableActions = getBooleanParameter(request, Constants.PARAM_ALLOWABLE_ACTIONS);
-		IncludeRelationships includeRelationships = getEnumParameter(request, Constants.PARAM_RELATIONSHIPS,
-				IncludeRelationships.class);
-		String renditionFilter = getStringParameter(request, Constants.PARAM_RENDITION_FILTER);
-		Boolean includeRelativePathSegment = getBooleanParameter(request, Constants.PARAM_RELATIVE_PATH_SEGMENT);
-
-		// execute
-		ObjectInfoHolder objectInfoHolder = new ObjectInfoHolderImpl();
-		List<ObjectParentData> parents = service.getObjectParents(context, repositoryId, objectId, filter,
-				includeAllowableActions, includeRelationships, renditionFilter, includeRelativePathSegment, null,
-				objectInfoHolder);
-
-		if (parents == null) {
-			throw new CmisRuntimeException("Parents 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_PARENTS, objectInfo.getId()), null);
-
-		// write entries
-		if (parents != null) {
-			AtomEntry entry = new AtomEntry(feed.getWriter());
-			for (ObjectParentData object : parents) {
-				if ((object == null) || (object.getObject() == null)) {
-					continue;
-				}
-				writeObjectEntry(entry, object.getObject(), objectInfoHolder, null, repositoryId, null, object
-						.getRelativePathSegment(), baseUrl, false);
-			}
-		}
-
-		// we are done
-		feed.endFeed();
-		feed.endDocument();
-	}
-
-	/**
-	 * Checked Out Collection GET.
-	 */
-	public static void getCheckedOutDocs(CallContext context, AbstractServicesFactory factory, String repositoryId,
-			HttpServletRequest request, HttpServletResponse response) throws Exception {
-		CmisNavigationService service = factory.getNavigationService();
-
-		// get parameters
-		String folderId = getStringParameter(request, Constants.PARAM_ID);
-		String filter = getStringParameter(request, Constants.PARAM_FILTER);
-		String orderBy = getStringParameter(request, Constants.PARAM_ORDER_BY);
-		Boolean includeAllowableActions = getBooleanParameter(request, Constants.PARAM_ALLOWABLE_ACTIONS);
-		IncludeRelationships includeRelationships = getEnumParameter(request, Constants.PARAM_RELATIONSHIPS,
-				IncludeRelationships.class);
-		String renditionFilter = getStringParameter(request, Constants.PARAM_RENDITION_FILTER);
-		BigInteger maxItems = getBigIntegerParameter(request, Constants.PARAM_MAX_ITEMS);
-		BigInteger skipCount = getBigIntegerParameter(request, Constants.PARAM_SKIP_COUNT);
-
-		// execute
-		ObjectInfoHolder objectInfoHolder = new ObjectInfoHolderImpl();
-		ObjectList checkedOut = service.getCheckedOutDocs(context, repositoryId, folderId, filter, orderBy,
-				includeAllowableActions, includeRelationships, renditionFilter, maxItems, skipCount, null,
-				objectInfoHolder);
-
-		if (checkedOut == null) {
-			throw new CmisRuntimeException("Checked Out list is null!");
-		}
-
-		ObjectInfo folderInfo = null;
-		if (folderId != null) {
-			folderInfo = objectInfoHolder.getObjectInfo(folderId);
-			if (folderInfo == null) {
-				throw new CmisRuntimeException("Folder Object Info is missing!");
-			}
-		} else {
-			folderInfo = new ObjectInfoImpl();
-			GregorianCalendar now = new GregorianCalendar();
-
-			((ObjectInfoImpl) folderInfo).setId("uri:x-checkedout");
-			((ObjectInfoImpl) folderInfo).setName("Checked Out");
-			((ObjectInfoImpl) folderInfo).setCreatedBy("");
-			((ObjectInfoImpl) folderInfo).setCreationDate(now);
-			((ObjectInfoImpl) folderInfo).setLastModificationDate(now);
-			((ObjectInfoImpl) folderInfo).setHasParent(false);
-			((ObjectInfoImpl) folderInfo).setSupportsDescendants(false);
-			((ObjectInfoImpl) folderInfo).setSupportsFolderTree(false);
-		}
-
-		// 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(folderInfo.getId(), folderInfo.getCreatedBy(), folderInfo.getName(), folderInfo
-				.getLastModificationDate(), null, checkedOut.getNumItems());
-
-		// write links
-		UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
-
-		feed.writeServiceLink(baseUrl.toString(), repositoryId);
-
-		feed.writeSelfLink(compileUrl(baseUrl, RESOURCE_CHECKEDOUT, folderInfo.getId()), null);
-
-		UrlBuilder pagingUrl = new UrlBuilder(compileUrlBuilder(baseUrl, RESOURCE_CHECKEDOUT, folderInfo.getId()));
-		pagingUrl.addParameter(Constants.PARAM_FILTER, filter);
-		pagingUrl.addParameter(Constants.PARAM_ORDER_BY, orderBy);
-		pagingUrl.addParameter(Constants.PARAM_ALLOWABLE_ACTIONS, includeAllowableActions);
-		pagingUrl.addParameter(Constants.PARAM_RELATIONSHIPS, includeRelationships);
-		pagingUrl.addParameter(Constants.PARAM_RENDITION_FILTER, renditionFilter);
-		feed.writePagingLinks(pagingUrl, maxItems, skipCount, checkedOut.getNumItems(), checkedOut.hasMoreItems(),
-				AtomPubUtils.PAGE_SIZE);
-
-		// write entries
-		if (checkedOut.getObjects() != null) {
-			AtomEntry entry = new AtomEntry(feed.getWriter());
-			for (ObjectData object : checkedOut.getObjects()) {
-				if (object == null) {
-					continue;
-				}
-				writeObjectEntry(entry, object, objectInfoHolder, null, repositoryId, null, null, baseUrl, false);
-			}
-		}
-
-		// we are done
-		feed.endFeed();
-		feed.endDocument();
-	}
+    /**
+     * Children Collection GET.
+     */
+    public static void getChildren(CallContext context, AbstractServicesFactory factory, String repositoryId,
+            HttpServletRequest request, HttpServletResponse response) throws Exception {
+        CmisNavigationService service = factory.getNavigationService();
+
+        // get parameters
+        String folderId = getStringParameter(request, Constants.PARAM_ID);
+        String filter = getStringParameter(request, Constants.PARAM_FILTER);
+        String orderBy = getStringParameter(request, Constants.PARAM_ORDER_BY);
+        Boolean includeAllowableActions = getBooleanParameter(request, Constants.PARAM_ALLOWABLE_ACTIONS);
+        IncludeRelationships includeRelationships = getEnumParameter(request, Constants.PARAM_RELATIONSHIPS,
+                IncludeRelationships.class);
+        String renditionFilter = getStringParameter(request, Constants.PARAM_RENDITION_FILTER);
+        Boolean includePathSegment = getBooleanParameter(request, Constants.PARAM_PATH_SEGMENT);
+        BigInteger maxItems = getBigIntegerParameter(request, Constants.PARAM_MAX_ITEMS);
+        BigInteger skipCount = getBigIntegerParameter(request, Constants.PARAM_SKIP_COUNT);
+
+        // execute
+        ObjectInfoHolder objectInfoHolder = new ObjectInfoHolderImpl();
+        ObjectInFolderList children = service.getChildren(context, repositoryId, folderId, filter, orderBy,
+                includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, maxItems,
+                skipCount, null, objectInfoHolder);
+
+        if (children == null) {
+            throw new CmisRuntimeException("Children are null!");
+        }
+
+        ObjectInfo folderInfo = objectInfoHolder.getObjectInfo(folderId);
+        if (folderInfo == null) {
+            throw new CmisRuntimeException("Folder 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(folderInfo.getId(), folderInfo.getCreatedBy(), folderInfo.getName(), folderInfo
+                .getLastModificationDate(), null, children.getNumItems());
+
+        // write links
+        UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
+
+        feed.writeServiceLink(baseUrl.toString(), repositoryId);
+
+        feed.writeSelfLink(compileUrl(baseUrl, RESOURCE_CHILDREN, folderInfo.getId()), null);
+
+        feed.writeDescribedByLink(compileUrl(baseUrl, RESOURCE_TYPE, folderInfo.getTypeId()));
+
+        feed.writeAllowableActionsLink(compileUrl(baseUrl, RESOURCE_ALLOWABLEACIONS, folderInfo.getId()));
+
+        feed.writeDownLink(compileUrl(baseUrl, RESOURCE_CHILDREN, folderInfo.getId()), Constants.MEDIATYPE_FEED);
+
+        if (folderInfo.supportsDescendants()) {
+            feed.writeDownLink(compileUrl(baseUrl, RESOURCE_DESCENDANTS, folderInfo.getId()),
+                    Constants.MEDIATYPE_DESCENDANTS);
+        }
+
+        if (folderInfo.supportsFolderTree()) {
+            feed.writeFolderTreeLink(compileUrl(baseUrl, RESOURCE_FOLDERTREE, folderInfo.getId()));
+        }
+
+        if (folderInfo.hasParent()) {
+            feed.writeUpLink(compileUrl(baseUrl, RESOURCE_PARENTS, folderInfo.getId()), Constants.MEDIATYPE_FEED);
+        }
+
+        if (folderInfo.getRenditionInfos() != null) {
+            for (RenditionInfo ri : folderInfo.getRenditionInfos()) {
+                feed.writeAlternateLink(compileUrl(baseUrl, RESOURCE_CONTENT, ri.getId()), ri.getContenType(), ri
+                        .getKind(), ri.getTitle(), ri.getLength());
+            }
+        }
+
+        if (folderInfo.hasAcl()) {
+            feed.writeAclLink(compileUrl(baseUrl, RESOURCE_ACL, folderInfo.getId()));
+        }
+
+        if (folderInfo.supportsPolicies()) {
+            feed.writeAclLink(compileUrl(baseUrl, RESOURCE_POLICIES, folderInfo.getId()));
+        }
+
+        if (folderInfo.supportsRelationships()) {
+            feed.writeRelationshipsLink(compileUrl(baseUrl, RESOURCE_RELATIONSHIPS, folderInfo.getId()));
+        }
+
+        UrlBuilder pagingUrl = new UrlBuilder(compileUrlBuilder(baseUrl, RESOURCE_CHILDREN, folderInfo.getId()));
+        pagingUrl.addParameter(Constants.PARAM_FILTER, filter);
+        pagingUrl.addParameter(Constants.PARAM_ORDER_BY, orderBy);
+        pagingUrl.addParameter(Constants.PARAM_ALLOWABLE_ACTIONS, includeAllowableActions);
+        pagingUrl.addParameter(Constants.PARAM_RELATIONSHIPS, includeRelationships);
+        pagingUrl.addParameter(Constants.PARAM_RENDITION_FILTER, renditionFilter);
+        pagingUrl.addParameter(Constants.PARAM_PATH_SEGMENT, includePathSegment);
+        feed.writePagingLinks(pagingUrl, maxItems, skipCount, children.getNumItems(), children.hasMoreItems(),
+                AtomPubUtils.PAGE_SIZE);
+
+        // write collection
+        feed.writeCollection(compileUrl(baseUrl, RESOURCE_CHILDREN, folderInfo.getId()), null, "Folder collection",
+                Constants.MEDIATYPE_CMISATOM);
+
+        // write entries
+        if (children.getObjects() != null) {
+            AtomEntry entry = new AtomEntry(feed.getWriter());
+            for (ObjectInFolderData object : children.getObjects()) {
+                if ((object == null) || (object.getObject() == null)) {
+                    continue;
+                }
+                writeObjectEntry(entry, object.getObject(), objectInfoHolder, null, repositoryId, object
+                        .getPathSegment(), null, baseUrl, false);
+            }
+        }
+
+        // we are done
+        feed.endFeed();
+        feed.endDocument();
+    }
+
+    /**
+     * Descendants feed GET.
+     */
+    public static void getDescendants(CallContext context, AbstractServicesFactory factory, String repositoryId,
+            HttpServletRequest request, HttpServletResponse response) throws Exception {
+        CmisNavigationService service = factory.getNavigationService();
+
+        // get parameters
+        String folderId = getStringParameter(request, Constants.PARAM_ID);
+        BigInteger depth = getBigIntegerParameter(request, Constants.PARAM_DEPTH);
+        String filter = getStringParameter(request, Constants.PARAM_FILTER);
+        Boolean includeAllowableActions = getBooleanParameter(request, Constants.PARAM_ALLOWABLE_ACTIONS);
+        IncludeRelationships includeRelationships = getEnumParameter(request, Constants.PARAM_RELATIONSHIPS,
+                IncludeRelationships.class);
+        String renditionFilter = getStringParameter(request, Constants.PARAM_RENDITION_FILTER);
+        Boolean includePathSegment = getBooleanParameter(request, Constants.PARAM_PATH_SEGMENT);
+
+        // execute
+        ObjectInfoHolder objectInfoHolder = new ObjectInfoHolderImpl();
+        List<ObjectInFolderContainer> descendants = service.getDescendants(context, repositoryId, folderId, depth,
+                filter, includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, null,
+                objectInfoHolder);
+
+        if (descendants == null) {
+            throw new CmisRuntimeException("Descendants are null!");
+        }
+
+        ObjectInfo folderInfo = objectInfoHolder.getObjectInfo(folderId);
+        if (folderInfo == null) {
+            throw new CmisRuntimeException("Folder 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(folderInfo.getId(), folderInfo.getCreatedBy(), folderInfo.getName(), folderInfo
+                .getLastModificationDate(), null, null);
+
+        // write links
+        UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
+
+        feed.writeServiceLink(baseUrl.toString(), repositoryId);
+
+        feed.writeSelfLink(compileUrl(baseUrl, RESOURCE_DESCENDANTS, folderInfo.getId()), null);
+
+        feed.writeViaLink(compileUrl(baseUrl, RESOURCE_ENTRY, folderInfo.getId()));
+
+        feed.writeDownLink(compileUrl(baseUrl, RESOURCE_CHILDREN, folderInfo.getId()), Constants.MEDIATYPE_FEED);
+
+        if (folderInfo.supportsFolderTree()) {
+            feed.writeFolderTreeLink(compileUrl(baseUrl, RESOURCE_FOLDERTREE, folderInfo.getId()));
+        }
+
+        if (folderInfo.hasParent()) {
+            feed.writeUpLink(compileUrl(baseUrl, RESOURCE_PARENTS, folderInfo.getId()), Constants.MEDIATYPE_FEED);
+        }
+
+        // write entries
+        AtomEntry entry = new AtomEntry(feed.getWriter());
+        for (ObjectInFolderContainer container : descendants) {
+            if ((container == null) || (container.getObject() == null) || (container.getObject().getObject() == null)) {
+                continue;
+            }
+            writeObjectEntry(entry, container.getObject().getObject(), objectInfoHolder, container.getChildren(),
+                    repositoryId, container.getObject().getPathSegment(), null, baseUrl, false);
+        }
+
+        // we are done
+        feed.endFeed();
+        feed.endDocument();
+    }
+
+    /**
+     * Folder tree feed GET.
+     */
+    public static void getFolderTree(CallContext context, AbstractServicesFactory factory, String repositoryId,
+            HttpServletRequest request, HttpServletResponse response) throws Exception {
+        CmisNavigationService service = factory.getNavigationService();
+
+        // get parameters
+        String folderId = getStringParameter(request, Constants.PARAM_ID);
+        BigInteger depth = getBigIntegerParameter(request, Constants.PARAM_DEPTH);
+        String filter = getStringParameter(request, Constants.PARAM_FILTER);
+        Boolean includeAllowableActions = getBooleanParameter(request, Constants.PARAM_ALLOWABLE_ACTIONS);
+        IncludeRelationships includeRelationships = getEnumParameter(request, Constants.PARAM_RELATIONSHIPS,
+                IncludeRelationships.class);
+        String renditionFilter = getStringParameter(request, Constants.PARAM_RENDITION_FILTER);
+        Boolean includePathSegment = getBooleanParameter(request, Constants.PARAM_PATH_SEGMENT);
+
+        // execute
+        ObjectInfoHolder objectInfoHolder = new ObjectInfoHolderImpl();
+        List<ObjectInFolderContainer> folderTree = service.getFolderTree(context, repositoryId, folderId, depth,
+                filter, includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, null,
+                objectInfoHolder);
+
+        if (folderTree == null) {
+            throw new CmisRuntimeException("Folder tree is null!");
+        }
+
+        ObjectInfo folderInfo = objectInfoHolder.getObjectInfo(folderId);
+        if (folderInfo == null) {
+            throw new CmisRuntimeException("Folder 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(folderInfo.getId(), folderInfo.getCreatedBy(), folderInfo.getName(), folderInfo
+                .getLastModificationDate(), null, null);
+
+        // write links
+        UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
+
+        feed.writeServiceLink(baseUrl.toString(), repositoryId);
+
+        feed.writeSelfLink(compileUrl(baseUrl, RESOURCE_DESCENDANTS, folderInfo.getId()), null);
+
+        feed.writeViaLink(compileUrl(baseUrl, RESOURCE_ENTRY, folderInfo.getId()));
+
+        feed.writeDownLink(compileUrl(baseUrl, RESOURCE_CHILDREN, folderInfo.getId()), Constants.MEDIATYPE_FEED);
+
+        if (folderInfo.supportsDescendants()) {
+            feed.writeDownLink(compileUrl(baseUrl, RESOURCE_DESCENDANTS, folderInfo.getId()),
+                    Constants.MEDIATYPE_DESCENDANTS);
+        }
+
+        if (folderInfo.hasParent()) {
+            feed.writeUpLink(compileUrl(baseUrl, RESOURCE_PARENTS, folderInfo.getId()), Constants.MEDIATYPE_FEED);
+        }
+
+        // write entries
+        AtomEntry entry = new AtomEntry(feed.getWriter());
+        for (ObjectInFolderContainer container : folderTree) {
+            if ((container == null) || (container.getObject() == null) || (container.getObject().getObject() == null)) {
+                continue;
+            }
+            writeObjectEntry(entry, container.getObject().getObject(), objectInfoHolder, container.getChildren(),
+                    repositoryId, container.getObject().getPathSegment(), null, baseUrl, false);
+        }
+
+        // we are done
+        feed.endFeed();
+        feed.endDocument();
+    }
+
+    /**
+     * Object parents feed GET.
+     */
+    public static void getObjectParents(CallContext context, AbstractServicesFactory factory, String repositoryId,
+            HttpServletRequest request, HttpServletResponse response) throws Exception {
+        CmisNavigationService service = factory.getNavigationService();
+
+        // get parameters
+        String objectId = getStringParameter(request, Constants.PARAM_ID);
+        String filter = getStringParameter(request, Constants.PARAM_FILTER);
+        Boolean includeAllowableActions = getBooleanParameter(request, Constants.PARAM_ALLOWABLE_ACTIONS);
+        IncludeRelationships includeRelationships = getEnumParameter(request, Constants.PARAM_RELATIONSHIPS,
+                IncludeRelationships.class);
+        String renditionFilter = getStringParameter(request, Constants.PARAM_RENDITION_FILTER);
+        Boolean includeRelativePathSegment = getBooleanParameter(request, Constants.PARAM_RELATIVE_PATH_SEGMENT);
+
+        // execute
+        ObjectInfoHolder objectInfoHolder = new ObjectInfoHolderImpl();
+        List<ObjectParentData> parents = service.getObjectParents(context, repositoryId, objectId, filter,
+                includeAllowableActions, includeRelationships, renditionFilter, includeRelativePathSegment, null,
+                objectInfoHolder);
+
+        if (parents == null) {
+            throw new CmisRuntimeException("Parents 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_PARENTS, objectInfo.getId()), null);
+
+        // write entries
+        if (parents != null) {
+            AtomEntry entry = new AtomEntry(feed.getWriter());
+            for (ObjectParentData object : parents) {
+                if ((object == null) || (object.getObject() == null)) {
+                    continue;
+                }
+                writeObjectEntry(entry, object.getObject(), objectInfoHolder, null, repositoryId, null, object
+                        .getRelativePathSegment(), baseUrl, false);
+            }
+        }
+
+        // we are done
+        feed.endFeed();
+        feed.endDocument();
+    }
+
+    /**
+     * Checked Out Collection GET.
+     */
+    public static void getCheckedOutDocs(CallContext context, AbstractServicesFactory factory, String repositoryId,
+            HttpServletRequest request, HttpServletResponse response) throws Exception {
+        CmisNavigationService service = factory.getNavigationService();
+
+        // get parameters
+        String folderId = getStringParameter(request, Constants.PARAM_ID);
+        String filter = getStringParameter(request, Constants.PARAM_FILTER);
+        String orderBy = getStringParameter(request, Constants.PARAM_ORDER_BY);
+        Boolean includeAllowableActions = getBooleanParameter(request, Constants.PARAM_ALLOWABLE_ACTIONS);
+        IncludeRelationships includeRelationships = getEnumParameter(request, Constants.PARAM_RELATIONSHIPS,
+                IncludeRelationships.class);
+        String renditionFilter = getStringParameter(request, Constants.PARAM_RENDITION_FILTER);
+        BigInteger maxItems = getBigIntegerParameter(request, Constants.PARAM_MAX_ITEMS);
+        BigInteger skipCount = getBigIntegerParameter(request, Constants.PARAM_SKIP_COUNT);
+
+        // execute
+        ObjectInfoHolder objectInfoHolder = new ObjectInfoHolderImpl();
+        ObjectList checkedOut = service.getCheckedOutDocs(context, repositoryId, folderId, filter, orderBy,
+                includeAllowableActions, includeRelationships, renditionFilter, maxItems, skipCount, null,
+                objectInfoHolder);
+
+        if (checkedOut == null) {
+            throw new CmisRuntimeException("Checked Out list is null!");
+        }
+
+        ObjectInfo folderInfo = null;
+        if (folderId != null) {
+            folderInfo = objectInfoHolder.getObjectInfo(folderId);
+            if (folderInfo == null) {
+                throw new CmisRuntimeException("Folder Object Info is missing!");
+            }
+        } else {
+            folderInfo = new ObjectInfoImpl();
+            GregorianCalendar now = new GregorianCalendar();
+
+            ((ObjectInfoImpl) folderInfo).setId("uri:x-checkedout");
+            ((ObjectInfoImpl) folderInfo).setName("Checked Out");
+            ((ObjectInfoImpl) folderInfo).setCreatedBy("");
+            ((ObjectInfoImpl) folderInfo).setCreationDate(now);
+            ((ObjectInfoImpl) folderInfo).setLastModificationDate(now);
+            ((ObjectInfoImpl) folderInfo).setHasParent(false);
+            ((ObjectInfoImpl) folderInfo).setSupportsDescendants(false);
+            ((ObjectInfoImpl) folderInfo).setSupportsFolderTree(false);
+        }
+
+        // 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(folderInfo.getId(), folderInfo.getCreatedBy(), folderInfo.getName(), folderInfo
+                .getLastModificationDate(), null, checkedOut.getNumItems());
+
+        // write links
+        UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
+
+        feed.writeServiceLink(baseUrl.toString(), repositoryId);
+
+        feed.writeSelfLink(compileUrl(baseUrl, RESOURCE_CHECKEDOUT, folderInfo.getId()), null);
+
+        UrlBuilder pagingUrl = new UrlBuilder(compileUrlBuilder(baseUrl, RESOURCE_CHECKEDOUT, folderInfo.getId()));
+        pagingUrl.addParameter(Constants.PARAM_FILTER, filter);
+        pagingUrl.addParameter(Constants.PARAM_ORDER_BY, orderBy);
+        pagingUrl.addParameter(Constants.PARAM_ALLOWABLE_ACTIONS, includeAllowableActions);
+        pagingUrl.addParameter(Constants.PARAM_RELATIONSHIPS, includeRelationships);
+        pagingUrl.addParameter(Constants.PARAM_RENDITION_FILTER, renditionFilter);
+        feed.writePagingLinks(pagingUrl, maxItems, skipCount, checkedOut.getNumItems(), checkedOut.hasMoreItems(),
+                AtomPubUtils.PAGE_SIZE);
+
+        // write entries
+        if (checkedOut.getObjects() != null) {
+            AtomEntry entry = new AtomEntry(feed.getWriter());
+            for (ObjectData object : checkedOut.getObjects()) {
+                if (object == null) {
+                    continue;
+                }
+                writeObjectEntry(entry, object, objectInfoHolder, null, repositoryId, null, null, baseUrl, false);
+            }
+        }
+
+        // we are done
+        feed.endFeed();
+        feed.endDocument();
+    }
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java?rev=936938&r1=936937&r2=936938&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java Thu Apr 22 16:27:57 2010
@@ -72,465 +72,465 @@ import org.apache.chemistry.opencmis.ser
  */
 public final class ObjectService {
 
-	private static final int BUFFER_SIZE = 64 * 1024;
+    private static final int BUFFER_SIZE = 64 * 1024;
 
-	/**
-	 * Create*.
-	 */
-	public static void create(CallContext context, AbstractServicesFactory factory, String repositoryId,
-			HttpServletRequest request, HttpServletResponse response) throws Exception {
-
-		// get parameters
-		String folderId = getStringParameter(request, Constants.PARAM_ID);
-		String sourceFolderId = getStringParameter(request, Constants.PARAM_SOURCE_FOLDER_ID);
-		VersioningState versioningState = getEnumParameter(request, Constants.PARAM_VERSIONIG_STATE,
-				VersioningState.class);
-
-		AtomEntryParser parser = new AtomEntryParser(request.getInputStream());
-		String objectId = parser.getId();
-
-		// execute
-		ObjectInfoHolder objectInfoHolder = new ObjectInfoHolderImpl();
-		ObjectData object = null;
-
-		if (objectId == null) {
-			// create
-			CmisObjectService service = factory.getObjectService();
-			object = service.create(context, repositoryId, parser.getProperties(), folderId, parser.getContentStream(),
-					versioningState, parser.getPolicyIds(), null, objectInfoHolder);
-		} else {
-			if ((sourceFolderId == null) || (sourceFolderId.trim().length() == 0)) {
-				// addObjectToFolder
-				CmisMultiFilingService service = factory.getMultiFilingService();
-				object = service.addObjectToFolder(context, repositoryId, objectId, sourceFolderId, null, null,
-						objectInfoHolder);
-			} else {
-				// move
-				CmisObjectService service = factory.getObjectService();
-				object = service.moveObject(context, repositoryId, new Holder<String>(objectId), folderId,
-						sourceFolderId, 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);
-
-		response.setStatus(HttpServletResponse.SC_CREATED);
-		response.setContentType(Constants.MEDIATYPE_ENTRY);
-		response.setHeader("Location", compileUrl(baseUrl, RESOURCE_ENTRY, object.getId()));
-
-		// write XML
-		AtomEntry entry = new AtomEntry();
-		entry.startDocument(response.getOutputStream());
-		writeObjectEntry(entry, object, objectInfoHolder, null, repositoryId, null, null, baseUrl, true);
-		entry.endDocument();
-	}
-
-	/**
-	 * Create relationship.
-	 */
-	public static void createRelationship(CallContext context, AbstractServicesFactory factory, String repositoryId,
-			HttpServletRequest request, HttpServletResponse response) throws Exception {
-		CmisObjectService service = factory.getObjectService();
-
-		// get parameters
-		AtomEntryParser parser = new AtomEntryParser(request.getInputStream());
-
-		// execute
-		ObjectInfoHolder objectInfoHolder = new ObjectInfoHolderImpl();
-		ObjectData object = service.create(context, repositoryId, parser.getProperties(), null, null, null, parser
-				.getPolicyIds(), null, objectInfoHolder);
-
-		// set headers
-		UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
-
-		response.setStatus(HttpServletResponse.SC_CREATED);
-		response.setContentType(Constants.MEDIATYPE_ENTRY);
-		response.setHeader("Location", compileUrl(baseUrl, RESOURCE_ENTRY, object.getId()));
-
-		// write XML
-		AtomEntry entry = new AtomEntry();
-		entry.startDocument(response.getOutputStream());
-		writeObjectEntry(entry, object, objectInfoHolder, null, repositoryId, null, null, baseUrl, true);
-		entry.endDocument();
-	}
-
-	/**
-	 * Delete object.
-	 */
-	public static void deleteObject(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);
-		Boolean allVersions = getBooleanParameter(request, Constants.PARAM_ALL_VERSIONS);
-
-		// execute
-		service.deleteObjectOrCancelCheckOut(context, repositoryId, objectId, allVersions, null);
-
-		// set headers
-		response.setStatus(HttpServletResponse.SC_NO_CONTENT);
-	}
-
-	/**
-	 * Delete content stream.
-	 */
-	public static void deleteContentStream(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);
-		String changeToken = getStringParameter(request, Constants.PARAM_CHANGE_TOKEN);
-
-		// execute
-		service.deleteContentStream(context, repositoryId, new Holder<String>(objectId), changeToken == null ? null
-				: new Holder<String>(changeToken), null);
-
-		// set headers
-		response.setStatus(HttpServletResponse.SC_NO_CONTENT);
-	}
-
-	/**
-	 * Set content stream.
-	 */
-	public static void setContentStream(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);
-		String changeToken = getStringParameter(request, Constants.PARAM_CHANGE_TOKEN);
-		Boolean overwriteFlag = getBooleanParameter(request, Constants.PARAM_OVERWRITE_FLAG);
-
-		ContentStreamImpl contentStream = new ContentStreamImpl();
-		contentStream.setStream(request.getInputStream());
-		contentStream.setMimeType(request.getHeader("Content-Type"));
-		String lengthStr = request.getHeader("Content-Length");
-		if (lengthStr != null) {
-			try {
-				contentStream.setLength(new BigInteger(lengthStr));
-			} catch (NumberFormatException e) {
-			}
-		}
-
-		// execute
-		Holder<String> objectIdHolder = new Holder<String>(objectId);
-		service.setContentStream(context, repositoryId, objectIdHolder, overwriteFlag, changeToken == null ? null
-				: new Holder<String>(changeToken), contentStream, null);
-
-		// set headers
-		String newObjectId = (objectIdHolder.getValue() == null ? objectId : objectIdHolder.getValue());
-		String location = compileUrl(compileBaseUrl(request, repositoryId), RESOURCE_CONTENT, newObjectId);
-
-		response.setStatus(HttpServletResponse.SC_CREATED);
-		response.setHeader("Content-Location", location);
-		response.setHeader("Location", location);
-	}
-
-	/**
-	 * Delete tree.
-	 */
-	public static void deleteTree(CallContext context, AbstractServicesFactory factory, String repositoryId,
-			HttpServletRequest request, HttpServletResponse response) throws Exception {
-		CmisObjectService service = factory.getObjectService();
-
-		// get parameters
-		String folderId = getStringParameter(request, Constants.PARAM_ID);
-		Boolean allVersions = getBooleanParameter(request, Constants.PARAM_ALL_VERSIONS);
-		UnfileObject unfileObjects = getEnumParameter(request, Constants.PARAM_UNFILE_OBJECTS, UnfileObject.class);
-		Boolean continueOnFailure = getBooleanParameter(request, Constants.PARAM_CONTINUE_ON_FAILURE);
-
-		// execute
-		FailedToDeleteData ftd = service.deleteTree(context, repositoryId, folderId, allVersions, unfileObjects,
-				continueOnFailure, null);
-
-		if ((ftd != null) && (ftd.getIds() != null) && (ftd.getIds().size() > 0)) {
-			// print ids that could not be deleted
-			response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
-			response.setContentType("text/plain");
-
-			PrintWriter pw = response.getWriter();
-
-			pw.println("Failed to delete the following objects:");
-			for (String id : ftd.getIds()) {
-				pw.println(id);
-			}
-
-			pw.flush();
-
-			return;
-		}
-
-		// set headers
-		response.setStatus(HttpServletResponse.SC_NO_CONTENT);
-	}
-
-	/**
-	 * getObject.
-	 */
-	public static void getObject(CallContext context, AbstractServicesFactory factory, String repositoryId,
-			HttpServletRequest request, HttpServletResponse response) throws Exception {
-
-		// get parameters
-		String objectId = getStringParameter(request, Constants.PARAM_ID);
-		ReturnVersion returnVersion = getEnumParameter(request, Constants.PARAM_RETURN_VERSION, ReturnVersion.class);
-		String filter = getStringParameter(request, Constants.PARAM_FILTER);
-		Boolean includeAllowableActions = getBooleanParameter(request, Constants.PARAM_ALLOWABLE_ACTIONS);
-		IncludeRelationships includeRelationships = getEnumParameter(request, Constants.PARAM_RELATIONSHIPS,
-				IncludeRelationships.class);
-		String renditionFilter = getStringParameter(request, Constants.PARAM_RENDITION_FILTER);
-		Boolean includePolicyIds = getBooleanParameter(request, Constants.PARAM_POLICY_IDS);
-		Boolean includeAcl = getBooleanParameter(request, Constants.PARAM_ACL);
-
-		// execute
-		ObjectInfoHolder objectInfoHolder = new ObjectInfoHolderImpl();
-		ObjectData object = null;
-
-		if ((returnVersion == ReturnVersion.LATEST) || (returnVersion == ReturnVersion.LASTESTMAJOR)) {
-			CmisVersioningService service = factory.getVersioningService();
-			object = service.getObjectOfLatestVersion(context, repositoryId, objectId,
-					returnVersion == ReturnVersion.LASTESTMAJOR, filter, includeAllowableActions, includeRelationships,
-					renditionFilter, includePolicyIds, includeAcl, null, objectInfoHolder);
-		} else {
-			CmisObjectService service = factory.getObjectService();
-			object = service.getObject(context, repositoryId, objectId, filter, includeAllowableActions,
-					includeRelationships, renditionFilter, includePolicyIds, includeAcl, null, objectInfoHolder);
-		}
-
-		if (object == null) {
-			throw new CmisRuntimeException("Object is null!");
-		}
-
-		ObjectInfo objectInfo = objectInfoHolder.getObjectInfo(object.getId());
-		if (objectInfo == null) {
-			throw new CmisRuntimeException("Object Info is missing!");
-		}
-
-		// set headers
-		response.setStatus(HttpServletResponse.SC_OK);
-		response.setContentType(Constants.MEDIATYPE_ENTRY);
-
-		// write XML
-		UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
-
-		AtomEntry entry = new AtomEntry();
-		entry.startDocument(response.getOutputStream());
-		writeObjectEntry(entry, object, objectInfoHolder, null, repositoryId, null, null, baseUrl, true);
-		entry.endDocument();
-	}
-
-	/**
-	 * objectByPath URI template.
-	 */
-	public static void getObjectByPath(CallContext context, AbstractServicesFactory factory, String repositoryId,
-			HttpServletRequest request, HttpServletResponse response) throws Exception {
-		CmisObjectService service = factory.getObjectService();
-
-		// get parameters
-		String path = getStringParameter(request, Constants.PARAM_PATH);
-		String filter = getStringParameter(request, Constants.PARAM_FILTER);
-		Boolean includeAllowableActions = getBooleanParameter(request, Constants.PARAM_ALLOWABLE_ACTIONS);
-		IncludeRelationships includeRelationships = getEnumParameter(request, Constants.PARAM_RELATIONSHIPS,
-				IncludeRelationships.class);
-		String renditionFilter = getStringParameter(request, Constants.PARAM_RENDITION_FILTER);
-		Boolean includePolicyIds = getBooleanParameter(request, Constants.PARAM_POLICY_IDS);
-		Boolean includeAcl = getBooleanParameter(request, Constants.PARAM_ACL);
-
-		// execute
-		ObjectInfoHolder objectInfoHolder = new ObjectInfoHolderImpl();
-		ObjectData object = service.getObjectByPath(context, repositoryId, path, filter, includeAllowableActions,
-				includeRelationships, renditionFilter, includePolicyIds, includeAcl, null, objectInfoHolder);
-
-		if (object == null) {
-			throw new CmisRuntimeException("Object is null!");
-		}
-
-		ObjectInfo objectInfo = objectInfoHolder.getObjectInfo(object.getId());
-		if (objectInfo == null) {
-			throw new CmisRuntimeException("Object Info is missing!");
-		}
-
-		// set headers
-		response.setStatus(HttpServletResponse.SC_OK);
-		response.setContentType(Constants.MEDIATYPE_ENTRY);
-
-		// write XML
-		UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
-
-		AtomEntry entry = new AtomEntry();
-		entry.startDocument(response.getOutputStream());
-		writeObjectEntry(entry, object, objectInfoHolder, null, repositoryId, null, null, baseUrl, true);
-		entry.endDocument();
-	}
-
-	/**
-	 * Allowable Actions.
-	 */
-	public static void getAllowableActions(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
-		AllowableActions allowableActions = service.getAllowableActions(context, repositoryId, objectId, null);
-
-		if (allowableActions == null) {
-			throw new CmisRuntimeException("Allowable Actions is null!");
-		}
-
-		// set headers
-		response.setStatus(HttpServletResponse.SC_OK);
-		response.setContentType(Constants.MEDIATYPE_ALLOWABLEACTION);
-
-		// write XML
-		AllowableActionsDocument allowableActionsDocument = new AllowableActionsDocument();
-		allowableActionsDocument.writeAllowableActions(allowableActions, response.getOutputStream());
-	}
-
-	/**
-	 * getContentStream.
-	 */
-	public static void getContentStream(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);
-		String streamId = getStringParameter(request, Constants.PARAM_STREAM_ID);
-
-		BigInteger offset = null;
-		String offsetStr = context.get(CallContext.OFFSET);
-		if (offsetStr != null) {
-			offset = new BigInteger(offsetStr);
-		}
-
-		BigInteger length = null;
-		String lengthStr = context.get(CallContext.LENGTH);
-		if (lengthStr != null) {
-			length = new BigInteger(offsetStr);
-		}
-
-		// execute
-		ContentStream content = service.getContentStream(context, repositoryId, objectId, streamId, offset, length,
-				null);
-
-		if ((content == null) || (content.getStream() == null)) {
-			throw new CmisRuntimeException("Content stream is null!");
-		}
-
-		String contentType = content.getMimeType();
-		if (contentType == null) {
-			contentType = Constants.MEDIATYPE_OCTETSTREAM;
-		}
-
-		// set headers
-		if ((offset == null) && (length == null)) {
-			response.setStatus(HttpServletResponse.SC_OK);
-		} else {
-			response.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT);
-		}
-		response.setContentType(contentType);
-
-		// send content
-		InputStream in = new BufferedInputStream(content.getStream(), BUFFER_SIZE);
-		OutputStream out = new BufferedOutputStream(response.getOutputStream());
-
-		byte[] buffer = new byte[BUFFER_SIZE];
-		int b;
-		while ((b = in.read(buffer)) > -1) {
-			out.write(buffer, 0, b);
-		}
-
-		in.close();
-		out.flush();
-	}
-
-	/**
-	 * UpdateProperties.
-	 */
-	public static void updateProperties(CallContext context, AbstractServicesFactory factory, String repositoryId,
-			HttpServletRequest request, HttpServletResponse response) throws Exception {
-
-		// get parameters
-		String objectId = getStringParameter(request, Constants.PARAM_ID);
-		Boolean checkin = getBooleanParameter(request, Constants.PARAM_CHECK_IN);
-		String checkinComment = getStringParameter(request, Constants.PARAM_CHECKIN_COMMENT);
-		Boolean major = getBooleanParameter(request, Constants.PARAM_MAJOR);
-
-		AtomEntryParser parser = new AtomEntryParser(request.getInputStream());
-
-		// execute
-		ObjectInfoHolder objectInfoHolder = new ObjectInfoHolderImpl();
-		ObjectData object = null;
-
-		if ((checkin != null) && (checkin.booleanValue())) {
-			CmisVersioningService service = factory.getVersioningService();
-			object = service.checkIn(context, repositoryId, new Holder<String>(objectId), major,
-					parser.getProperties(), parser.getContentStream(), checkinComment, parser.getPolicyIds(), null,
-					null, null, objectInfoHolder);
-		} else {
-			String changeToken = extractChangeToken(parser.getProperties());
-
-			CmisObjectService service = factory.getObjectService();
-			object = service.updateProperties(context, repositoryId, new Holder<String>(objectId),
-					changeToken == null ? null : new Holder<String>(changeToken), parser.getProperties(), parser
-							.getAcl(), 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();
-	}
-
-	/**
-	 * Gets the change token from a property set.
-	 */
-	private static String extractChangeToken(Properties properties) {
-		if (properties == null) {
-			return null;
-		}
-
-		Map<String, PropertyData<?>> propertiesMap = properties.getProperties();
-		if (propertiesMap == null) {
-			return null;
-		}
-
-		PropertyData<?> changeLogProperty = propertiesMap.get(PropertyIds.CHANGE_TOKEN);
-		if (!(changeLogProperty instanceof PropertyString)) {
-			return null;
-		}
+    /**
+     * Create*.
+     */
+    public static void create(CallContext context, AbstractServicesFactory factory, String repositoryId,
+            HttpServletRequest request, HttpServletResponse response) throws Exception {
+
+        // get parameters
+        String folderId = getStringParameter(request, Constants.PARAM_ID);
+        String sourceFolderId = getStringParameter(request, Constants.PARAM_SOURCE_FOLDER_ID);
+        VersioningState versioningState = getEnumParameter(request, Constants.PARAM_VERSIONIG_STATE,
+                VersioningState.class);
+
+        AtomEntryParser parser = new AtomEntryParser(request.getInputStream());
+        String objectId = parser.getId();
+
+        // execute
+        ObjectInfoHolder objectInfoHolder = new ObjectInfoHolderImpl();
+        ObjectData object = null;
+
+        if (objectId == null) {
+            // create
+            CmisObjectService service = factory.getObjectService();
+            object = service.create(context, repositoryId, parser.getProperties(), folderId, parser.getContentStream(),
+                    versioningState, parser.getPolicyIds(), null, objectInfoHolder);
+        } else {
+            if ((sourceFolderId == null) || (sourceFolderId.trim().length() == 0)) {
+                // addObjectToFolder
+                CmisMultiFilingService service = factory.getMultiFilingService();
+                object = service.addObjectToFolder(context, repositoryId, objectId, sourceFolderId, null, null,
+                        objectInfoHolder);
+            } else {
+                // move
+                CmisObjectService service = factory.getObjectService();
+                object = service.moveObject(context, repositoryId, new Holder<String>(objectId), folderId,
+                        sourceFolderId, 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);
+
+        response.setStatus(HttpServletResponse.SC_CREATED);
+        response.setContentType(Constants.MEDIATYPE_ENTRY);
+        response.setHeader("Location", compileUrl(baseUrl, RESOURCE_ENTRY, object.getId()));
+
+        // write XML
+        AtomEntry entry = new AtomEntry();
+        entry.startDocument(response.getOutputStream());
+        writeObjectEntry(entry, object, objectInfoHolder, null, repositoryId, null, null, baseUrl, true);
+        entry.endDocument();
+    }
+
+    /**
+     * Create relationship.
+     */
+    public static void createRelationship(CallContext context, AbstractServicesFactory factory, String repositoryId,
+            HttpServletRequest request, HttpServletResponse response) throws Exception {
+        CmisObjectService service = factory.getObjectService();
+
+        // get parameters
+        AtomEntryParser parser = new AtomEntryParser(request.getInputStream());
+
+        // execute
+        ObjectInfoHolder objectInfoHolder = new ObjectInfoHolderImpl();
+        ObjectData object = service.create(context, repositoryId, parser.getProperties(), null, null, null, parser
+                .getPolicyIds(), null, objectInfoHolder);
+
+        // set headers
+        UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
+
+        response.setStatus(HttpServletResponse.SC_CREATED);
+        response.setContentType(Constants.MEDIATYPE_ENTRY);
+        response.setHeader("Location", compileUrl(baseUrl, RESOURCE_ENTRY, object.getId()));
+
+        // write XML
+        AtomEntry entry = new AtomEntry();
+        entry.startDocument(response.getOutputStream());
+        writeObjectEntry(entry, object, objectInfoHolder, null, repositoryId, null, null, baseUrl, true);
+        entry.endDocument();
+    }
+
+    /**
+     * Delete object.
+     */
+    public static void deleteObject(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);
+        Boolean allVersions = getBooleanParameter(request, Constants.PARAM_ALL_VERSIONS);
+
+        // execute
+        service.deleteObjectOrCancelCheckOut(context, repositoryId, objectId, allVersions, null);
+
+        // set headers
+        response.setStatus(HttpServletResponse.SC_NO_CONTENT);
+    }
+
+    /**
+     * Delete content stream.
+     */
+    public static void deleteContentStream(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);
+        String changeToken = getStringParameter(request, Constants.PARAM_CHANGE_TOKEN);
+
+        // execute
+        service.deleteContentStream(context, repositoryId, new Holder<String>(objectId), changeToken == null ? null
+                : new Holder<String>(changeToken), null);
+
+        // set headers
+        response.setStatus(HttpServletResponse.SC_NO_CONTENT);
+    }
+
+    /**
+     * Set content stream.
+     */
+    public static void setContentStream(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);
+        String changeToken = getStringParameter(request, Constants.PARAM_CHANGE_TOKEN);
+        Boolean overwriteFlag = getBooleanParameter(request, Constants.PARAM_OVERWRITE_FLAG);
+
+        ContentStreamImpl contentStream = new ContentStreamImpl();
+        contentStream.setStream(request.getInputStream());
+        contentStream.setMimeType(request.getHeader("Content-Type"));
+        String lengthStr = request.getHeader("Content-Length");
+        if (lengthStr != null) {
+            try {
+                contentStream.setLength(new BigInteger(lengthStr));
+            } catch (NumberFormatException e) {
+            }
+        }
+
+        // execute
+        Holder<String> objectIdHolder = new Holder<String>(objectId);
+        service.setContentStream(context, repositoryId, objectIdHolder, overwriteFlag, changeToken == null ? null
+                : new Holder<String>(changeToken), contentStream, null);
+
+        // set headers
+        String newObjectId = (objectIdHolder.getValue() == null ? objectId : objectIdHolder.getValue());
+        String location = compileUrl(compileBaseUrl(request, repositoryId), RESOURCE_CONTENT, newObjectId);
+
+        response.setStatus(HttpServletResponse.SC_CREATED);
+        response.setHeader("Content-Location", location);
+        response.setHeader("Location", location);
+    }
+
+    /**
+     * Delete tree.
+     */
+    public static void deleteTree(CallContext context, AbstractServicesFactory factory, String repositoryId,
+            HttpServletRequest request, HttpServletResponse response) throws Exception {
+        CmisObjectService service = factory.getObjectService();
+
+        // get parameters
+        String folderId = getStringParameter(request, Constants.PARAM_ID);
+        Boolean allVersions = getBooleanParameter(request, Constants.PARAM_ALL_VERSIONS);
+        UnfileObject unfileObjects = getEnumParameter(request, Constants.PARAM_UNFILE_OBJECTS, UnfileObject.class);
+        Boolean continueOnFailure = getBooleanParameter(request, Constants.PARAM_CONTINUE_ON_FAILURE);
+
+        // execute
+        FailedToDeleteData ftd = service.deleteTree(context, repositoryId, folderId, allVersions, unfileObjects,
+                continueOnFailure, null);
+
+        if ((ftd != null) && (ftd.getIds() != null) && (ftd.getIds().size() > 0)) {
+            // print ids that could not be deleted
+            response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+            response.setContentType("text/plain");
+
+            PrintWriter pw = response.getWriter();
+
+            pw.println("Failed to delete the following objects:");
+            for (String id : ftd.getIds()) {
+                pw.println(id);
+            }
+
+            pw.flush();
+
+            return;
+        }
+
+        // set headers
+        response.setStatus(HttpServletResponse.SC_NO_CONTENT);
+    }
+
+    /**
+     * getObject.
+     */
+    public static void getObject(CallContext context, AbstractServicesFactory factory, String repositoryId,
+            HttpServletRequest request, HttpServletResponse response) throws Exception {
+
+        // get parameters
+        String objectId = getStringParameter(request, Constants.PARAM_ID);
+        ReturnVersion returnVersion = getEnumParameter(request, Constants.PARAM_RETURN_VERSION, ReturnVersion.class);
+        String filter = getStringParameter(request, Constants.PARAM_FILTER);
+        Boolean includeAllowableActions = getBooleanParameter(request, Constants.PARAM_ALLOWABLE_ACTIONS);
+        IncludeRelationships includeRelationships = getEnumParameter(request, Constants.PARAM_RELATIONSHIPS,
+                IncludeRelationships.class);
+        String renditionFilter = getStringParameter(request, Constants.PARAM_RENDITION_FILTER);
+        Boolean includePolicyIds = getBooleanParameter(request, Constants.PARAM_POLICY_IDS);
+        Boolean includeAcl = getBooleanParameter(request, Constants.PARAM_ACL);
+
+        // execute
+        ObjectInfoHolder objectInfoHolder = new ObjectInfoHolderImpl();
+        ObjectData object = null;
+
+        if ((returnVersion == ReturnVersion.LATEST) || (returnVersion == ReturnVersion.LASTESTMAJOR)) {
+            CmisVersioningService service = factory.getVersioningService();
+            object = service.getObjectOfLatestVersion(context, repositoryId, objectId,
+                    returnVersion == ReturnVersion.LASTESTMAJOR, filter, includeAllowableActions, includeRelationships,
+                    renditionFilter, includePolicyIds, includeAcl, null, objectInfoHolder);
+        } else {
+            CmisObjectService service = factory.getObjectService();
+            object = service.getObject(context, repositoryId, objectId, filter, includeAllowableActions,
+                    includeRelationships, renditionFilter, includePolicyIds, includeAcl, null, objectInfoHolder);
+        }
+
+        if (object == null) {
+            throw new CmisRuntimeException("Object is null!");
+        }
+
+        ObjectInfo objectInfo = objectInfoHolder.getObjectInfo(object.getId());
+        if (objectInfo == null) {
+            throw new CmisRuntimeException("Object Info is missing!");
+        }
+
+        // set headers
+        response.setStatus(HttpServletResponse.SC_OK);
+        response.setContentType(Constants.MEDIATYPE_ENTRY);
+
+        // write XML
+        UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
+
+        AtomEntry entry = new AtomEntry();
+        entry.startDocument(response.getOutputStream());
+        writeObjectEntry(entry, object, objectInfoHolder, null, repositoryId, null, null, baseUrl, true);
+        entry.endDocument();
+    }
+
+    /**
+     * objectByPath URI template.
+     */
+    public static void getObjectByPath(CallContext context, AbstractServicesFactory factory, String repositoryId,
+            HttpServletRequest request, HttpServletResponse response) throws Exception {
+        CmisObjectService service = factory.getObjectService();
+
+        // get parameters
+        String path = getStringParameter(request, Constants.PARAM_PATH);
+        String filter = getStringParameter(request, Constants.PARAM_FILTER);
+        Boolean includeAllowableActions = getBooleanParameter(request, Constants.PARAM_ALLOWABLE_ACTIONS);
+        IncludeRelationships includeRelationships = getEnumParameter(request, Constants.PARAM_RELATIONSHIPS,
+                IncludeRelationships.class);
+        String renditionFilter = getStringParameter(request, Constants.PARAM_RENDITION_FILTER);
+        Boolean includePolicyIds = getBooleanParameter(request, Constants.PARAM_POLICY_IDS);
+        Boolean includeAcl = getBooleanParameter(request, Constants.PARAM_ACL);
+
+        // execute
+        ObjectInfoHolder objectInfoHolder = new ObjectInfoHolderImpl();
+        ObjectData object = service.getObjectByPath(context, repositoryId, path, filter, includeAllowableActions,
+                includeRelationships, renditionFilter, includePolicyIds, includeAcl, null, objectInfoHolder);
+
+        if (object == null) {
+            throw new CmisRuntimeException("Object is null!");
+        }
+
+        ObjectInfo objectInfo = objectInfoHolder.getObjectInfo(object.getId());
+        if (objectInfo == null) {
+            throw new CmisRuntimeException("Object Info is missing!");
+        }
+
+        // set headers
+        response.setStatus(HttpServletResponse.SC_OK);
+        response.setContentType(Constants.MEDIATYPE_ENTRY);
+
+        // write XML
+        UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
+
+        AtomEntry entry = new AtomEntry();
+        entry.startDocument(response.getOutputStream());
+        writeObjectEntry(entry, object, objectInfoHolder, null, repositoryId, null, null, baseUrl, true);
+        entry.endDocument();
+    }
+
+    /**
+     * Allowable Actions.
+     */
+    public static void getAllowableActions(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
+        AllowableActions allowableActions = service.getAllowableActions(context, repositoryId, objectId, null);
+
+        if (allowableActions == null) {
+            throw new CmisRuntimeException("Allowable Actions is null!");
+        }
+
+        // set headers
+        response.setStatus(HttpServletResponse.SC_OK);
+        response.setContentType(Constants.MEDIATYPE_ALLOWABLEACTION);
+
+        // write XML
+        AllowableActionsDocument allowableActionsDocument = new AllowableActionsDocument();
+        allowableActionsDocument.writeAllowableActions(allowableActions, response.getOutputStream());
+    }
+
+    /**
+     * getContentStream.
+     */
+    public static void getContentStream(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);
+        String streamId = getStringParameter(request, Constants.PARAM_STREAM_ID);
+
+        BigInteger offset = null;
+        String offsetStr = context.get(CallContext.OFFSET);
+        if (offsetStr != null) {
+            offset = new BigInteger(offsetStr);
+        }
+
+        BigInteger length = null;
+        String lengthStr = context.get(CallContext.LENGTH);
+        if (lengthStr != null) {
+            length = new BigInteger(offsetStr);
+        }
+
+        // execute
+        ContentStream content = service.getContentStream(context, repositoryId, objectId, streamId, offset, length,
+                null);
+
+        if ((content == null) || (content.getStream() == null)) {
+            throw new CmisRuntimeException("Content stream is null!");
+        }
+
+        String contentType = content.getMimeType();
+        if (contentType == null) {
+            contentType = Constants.MEDIATYPE_OCTETSTREAM;
+        }
+
+        // set headers
+        if ((offset == null) && (length == null)) {
+            response.setStatus(HttpServletResponse.SC_OK);
+        } else {
+            response.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT);
+        }
+        response.setContentType(contentType);
+
+        // send content
+        InputStream in = new BufferedInputStream(content.getStream(), BUFFER_SIZE);
+        OutputStream out = new BufferedOutputStream(response.getOutputStream());
+
+        byte[] buffer = new byte[BUFFER_SIZE];
+        int b;
+        while ((b = in.read(buffer)) > -1) {
+            out.write(buffer, 0, b);
+        }
+
+        in.close();
+        out.flush();
+    }
+
+    /**
+     * UpdateProperties.
+     */
+    public static void updateProperties(CallContext context, AbstractServicesFactory factory, String repositoryId,
+            HttpServletRequest request, HttpServletResponse response) throws Exception {
+
+        // get parameters
+        String objectId = getStringParameter(request, Constants.PARAM_ID);
+        Boolean checkin = getBooleanParameter(request, Constants.PARAM_CHECK_IN);
+        String checkinComment = getStringParameter(request, Constants.PARAM_CHECKIN_COMMENT);
+        Boolean major = getBooleanParameter(request, Constants.PARAM_MAJOR);
+
+        AtomEntryParser parser = new AtomEntryParser(request.getInputStream());
+
+        // execute
+        ObjectInfoHolder objectInfoHolder = new ObjectInfoHolderImpl();
+        ObjectData object = null;
+
+        if ((checkin != null) && (checkin.booleanValue())) {
+            CmisVersioningService service = factory.getVersioningService();
+            object = service.checkIn(context, repositoryId, new Holder<String>(objectId), major,
+                    parser.getProperties(), parser.getContentStream(), checkinComment, parser.getPolicyIds(), null,
+                    null, null, objectInfoHolder);
+        } else {
+            String changeToken = extractChangeToken(parser.getProperties());
+
+            CmisObjectService service = factory.getObjectService();
+            object = service.updateProperties(context, repositoryId, new Holder<String>(objectId),
+                    changeToken == null ? null : new Holder<String>(changeToken), parser.getProperties(), parser
+                            .getAcl(), 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();
+    }
+
+    /**
+     * Gets the change token from a property set.
+     */
+    private static String extractChangeToken(Properties properties) {
+        if (properties == null) {
+            return null;
+        }
+
+        Map<String, PropertyData<?>> propertiesMap = properties.getProperties();
+        if (propertiesMap == null) {
+            return null;
+        }
+
+        PropertyData<?> changeLogProperty = propertiesMap.get(PropertyIds.CHANGE_TOKEN);
+        if (!(changeLogProperty instanceof PropertyString)) {
+            return null;
+        }
 
-		return ((PropertyString) changeLogProperty).getFirstValue();
-	}
+        return ((PropertyString) changeLogProperty).getFirstValue();
+    }
 }



Mime
View raw message