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/04/22 18:28:00 UTC
svn commit: r936938 [5/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...
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/PolicyService.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/PolicyService.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/PolicyService.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/PolicyService.java Thu Apr 22 16:27:57 2010
@@ -50,150 +50,150 @@ import org.apache.chemistry.opencmis.ser
*/
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();
- }
+ /**
+ * 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();
+ }
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/RelationshipService.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/RelationshipService.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/RelationshipService.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/RelationshipService.java Thu Apr 22 16:27:57 2010
@@ -54,81 +54,81 @@ import org.apache.chemistry.opencmis.ser
*/
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();
- }
+ /**
+ * 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();
+ }
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/RepositoryService.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/RepositoryService.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/RepositoryService.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/RepositoryService.java Thu Apr 22 16:27:57 2010
@@ -69,357 +69,357 @@ import org.apache.chemistry.opencmis.ser
*/
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<RepositoryInfo> 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 (RepositoryInfo infoData : infoDataList) {
- if (infoData == null) {
- continue;
- }
-
- String repId = infoData.getId();
- 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.getCapabilities() != null) {
- RepositoryCapabilities cap = infoData.getCapabilities();
-
- if (cap.getQueryCapability() != null) {
- supportsQuery = (cap.getQueryCapability() != CapabilityQuery.NONE);
- }
-
- if (cap.isUnfilingSupported() != null) {
- supportsUnFiling = cap.isUnfilingSupported();
- }
-
- if (cap.isMultifilingSupported() != null) {
- supportsMultifiling = cap.isMultifilingSupported();
- }
-
- if (cap.isGetFolderTreeSupported() != null) {
- supportsFolderTree = cap.isGetFolderTreeSupported();
- }
-
- if (cap.isGetDescendantsSupported() != null) {
- supportsRootDescendants = cap.isGetDescendantsSupported();
- }
-
- if (cap.getChangesCapability() != null) {
- supportsChanges = (cap.getChangesCapability() != CapabilityChanges.NONE);
- }
- }
-
- serviceDoc.startWorkspace(infoData.getId());
-
- // 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.getParentTypeId());
- 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.getParentTypeId());
- 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();
- }
+ /**
+ * 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<RepositoryInfo> 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 (RepositoryInfo infoData : infoDataList) {
+ if (infoData == null) {
+ continue;
+ }
+
+ String repId = infoData.getId();
+ 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.getCapabilities() != null) {
+ RepositoryCapabilities cap = infoData.getCapabilities();
+
+ if (cap.getQueryCapability() != null) {
+ supportsQuery = (cap.getQueryCapability() != CapabilityQuery.NONE);
+ }
+
+ if (cap.isUnfilingSupported() != null) {
+ supportsUnFiling = cap.isUnfilingSupported();
+ }
+
+ if (cap.isMultifilingSupported() != null) {
+ supportsMultifiling = cap.isMultifilingSupported();
+ }
+
+ if (cap.isGetFolderTreeSupported() != null) {
+ supportsFolderTree = cap.isGetFolderTreeSupported();
+ }
+
+ if (cap.isGetDescendantsSupported() != null) {
+ supportsRootDescendants = cap.isGetDescendantsSupported();
+ }
+
+ if (cap.getChangesCapability() != null) {
+ supportsChanges = (cap.getChangesCapability() != CapabilityChanges.NONE);
+ }
+ }
+
+ serviceDoc.startWorkspace(infoData.getId());
+
+ // 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.getParentTypeId());
+ 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.getParentTypeId());
+ 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();
+ }
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ServiceDocument.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/ServiceDocument.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/ServiceDocument.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ServiceDocument.java Thu Apr 22 16:27:57 2010
@@ -37,47 +37,47 @@ import org.apache.chemistry.opencmis.com
*/
public class ServiceDocument extends AtomDocumentBase {
- public ServiceDocument() {
- }
+ 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(RepositoryInfo 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();
- }
+ 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(RepositoryInfo 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();
+ }
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/VersioningService.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/VersioningService.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/VersioningService.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/VersioningService.java Thu Apr 22 16:27:57 2010
@@ -52,121 +52,121 @@ import org.apache.chemistry.opencmis.ser
*/
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 versionSeriesId = 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, versionSeriesId, filter,
- includeAllowableActions, null, objectInfoHolder);
-
- if (versions == null) {
- throw new CmisRuntimeException("Versions are null!");
- }
-
- ObjectInfo objectInfo = objectInfoHolder.getObjectInfo(versionSeriesId);
- if (objectInfo == null) {
- throw new CmisRuntimeException("Version Series 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, versionSeriesId));
-
- // 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);
- }
+ /**
+ * 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 versionSeriesId = 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, versionSeriesId, filter,
+ includeAllowableActions, null, objectInfoHolder);
+
+ if (versions == null) {
+ throw new CmisRuntimeException("Versions are null!");
+ }
+
+ ObjectInfo objectInfo = objectInfoHolder.getObjectInfo(versionSeriesId);
+ if (objectInfo == null) {
+ throw new CmisRuntimeException("Version Series 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, versionSeriesId));
+
+ // 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);
+ }
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/XMLDocumentBase.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/XMLDocumentBase.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/XMLDocumentBase.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/XMLDocumentBase.java Thu Apr 22 16:27:57 2010
@@ -34,71 +34,71 @@ import org.apache.chemistry.opencmis.com
*/
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;
- }
+ 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;
+ }
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/dummy/DummyRepositoryService.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/dummy/DummyRepositoryService.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/dummy/DummyRepositoryService.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/dummy/DummyRepositoryService.java Thu Apr 22 16:27:57 2010
@@ -41,49 +41,49 @@ import org.apache.chemistry.opencmis.ser
*/
public class DummyRepositoryService implements CmisRepositoryService {
- private RepositoryInfoImpl fRepInfo;
+ private RepositoryInfoImpl fRepInfo;
- public DummyRepositoryService(String id, String name) {
- fRepInfo = new RepositoryInfoImpl();
+ public DummyRepositoryService(String id, String name) {
+ fRepInfo = new RepositoryInfoImpl();
- 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 RepositoryInfo getRepositoryInfo(CallContext context, String repositoryId, ExtensionsData extension) {
-
- if (!fRepInfo.getId().equals(repositoryId)) {
- throw new CmisObjectNotFoundException("A repository with repository id '" + repositoryId
- + "' does not exist!");
- }
-
- return fRepInfo;
- }
-
- public List<RepositoryInfo> getRepositoryInfos(CallContext context, ExtensionsData extension) {
- return Collections.singletonList((RepositoryInfo) 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();
- }
+ 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 RepositoryInfo getRepositoryInfo(CallContext context, String repositoryId, ExtensionsData extension) {
+
+ if (!fRepInfo.getId().equals(repositoryId)) {
+ throw new CmisObjectNotFoundException("A repository with repository id '" + repositoryId
+ + "' does not exist!");
+ }
+
+ return fRepInfo;
+ }
+
+ public List<RepositoryInfo> getRepositoryInfos(CallContext context, ExtensionsData extension) {
+ return Collections.singletonList((RepositoryInfo) 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();
+ }
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/dummy/DummyServicesFactory.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/dummy/DummyServicesFactory.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/dummy/DummyServicesFactory.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/dummy/DummyServicesFactory.java Thu Apr 22 16:27:57 2010
@@ -33,46 +33,46 @@ import org.apache.commons.logging.LogFac
*/
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_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 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 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;
- }
+ 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;
+ }
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.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/webservices/AbstractService.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/webservices/AbstractService.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java Thu Apr 22 16:27:57 2010
@@ -51,79 +51,79 @@ import org.apache.chemistry.opencmis.ser
*/
public abstract class AbstractService {
- public static final String CALL_CONTEXT_MAP = "org.apache.chemistry.opencmis.callcontext";
+ public static final String CALL_CONTEXT_MAP = "org.apache.chemistry.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, String repositoryId) {
- CallContextImpl context = new CallContextImpl(CallContext.BINDING_WEBSERVICES, repositoryId, false);
-
- 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);
- }
- }
+ /**
+ * 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, String repositoryId) {
+ CallContextImpl context = new CallContextImpl(CallContext.BINDING_WEBSERVICES, repositoryId, false);
+
+ 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);
- }
+ return new CmisException(fault.getMessage(), fault, ex);
+ }
}
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AclService.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/webservices/AclService.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/webservices/AclService.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AclService.java Thu Apr 22 16:27:57 2010
@@ -41,55 +41,55 @@ import org.apache.chemistry.opencmis.ser
*/
@WebService(endpointInterface = "org.apache.chemistry.opencmis.commons.impl.jaxb.ACLServicePort")
public class AclService extends AbstractService implements ACLServicePort {
- @Resource
- WebServiceContext wsContext;
+ @Resource
+ WebServiceContext wsContext;
- public CmisACLType applyACL(String repositoryId, String objectId, CmisAccessControlListType addAces,
- CmisAccessControlListType removeAces, EnumACLPropagation aclPropagation, CmisExtensionType extension)
- throws CmisException {
- try {
- AbstractServicesFactory factory = getServicesFactory(wsContext);
- CmisAclService service = factory.getAclService();
- CallContext context = createContext(wsContext, repositoryId);
-
- Acl 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(wsContext);
- CmisAclService service = factory.getAclService();
- CallContext context = createContext(wsContext, repositoryId);
-
- Acl 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);
- }
- }
+ public CmisACLType applyACL(String repositoryId, String objectId, CmisAccessControlListType addAces,
+ CmisAccessControlListType removeAces, EnumACLPropagation aclPropagation, CmisExtensionType extension)
+ throws CmisException {
+ try {
+ AbstractServicesFactory factory = getServicesFactory(wsContext);
+ CmisAclService service = factory.getAclService();
+ CallContext context = createContext(wsContext, repositoryId);
+
+ Acl 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(wsContext);
+ CmisAclService service = factory.getAclService();
+ CallContext context = createContext(wsContext, repositoryId);
+
+ Acl 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);
+ }
+ }
}