Return-Path: X-Original-To: apmail-chemistry-commits-archive@www.apache.org Delivered-To: apmail-chemistry-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6A7F4D626 for ; Tue, 28 May 2013 07:23:15 +0000 (UTC) Received: (qmail 75125 invoked by uid 500); 28 May 2013 07:23:13 -0000 Delivered-To: apmail-chemistry-commits-archive@chemistry.apache.org Received: (qmail 74989 invoked by uid 500); 28 May 2013 07:23:12 -0000 Mailing-List: contact commits-help@chemistry.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@chemistry.apache.org Delivered-To: mailing list commits@chemistry.apache.org Received: (qmail 74756 invoked by uid 99); 28 May 2013 07:23:10 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 May 2013 07:23:09 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 May 2013 07:23:05 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 79D852388C2D; Tue, 28 May 2013 07:21:51 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1486787 [18/40] - in /chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-server/chemistry-opencmis-server-bindings: ./ css/ images/ images/logos/ xref-test/ xref-test/org/ xref-test/org/apache/ xref-test/org/apache/chemistry/... Date: Tue, 28 May 2013 07:21:44 -0000 To: commits@chemistry.apache.org From: gabriele@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130528072151.79D852388C2D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-server/chemistry-opencmis-server-bindings/xref/org/apache/chemistry/opencmis/server/impl/atompub/RepositoryService.html URL: http://svn.apache.org/viewvc/chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-server/chemistry-opencmis-server-bindings/xref/org/apache/chemistry/opencmis/server/impl/atompub/RepositoryService.html?rev=1486787&view=auto ============================================================================== --- chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-server/chemistry-opencmis-server-bindings/xref/org/apache/chemistry/opencmis/server/impl/atompub/RepositoryService.html (added) +++ chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-server/chemistry-opencmis-server-bindings/xref/org/apache/chemistry/opencmis/server/impl/atompub/RepositoryService.html Tue May 28 07:21:41 2013 @@ -0,0 +1,503 @@ + + + + +RepositoryService xref + + + +
+
+1   /*
+2    * Licensed to the Apache Software Foundation (ASF) under one
+3    * or more contributor license agreements.  See the NOTICE file
+4    * distributed with this work for additional information
+5    * regarding copyright ownership.  The ASF licenses this file
+6    * to you under the Apache License, Version 2.0 (the
+7    * "License"); you may not use this file except in compliance
+8    * with the License.  You may obtain a copy of the License at
+9    *
+10   * http://www.apache.org/licenses/LICENSE-2.0
+11   *
+12   * Unless required by applicable law or agreed to in writing,
+13   * software distributed under the License is distributed on an
+14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+15   * KIND, either express or implied.  See the License for the
+16   * specific language governing permissions and limitations
+17   * under the License.
+18   */
+19  package org.apache.chemistry.opencmis.server.impl.atompub;
+20  
+21  import java.math.BigInteger;
+22  import java.util.Collections;
+23  import java.util.GregorianCalendar;
+24  import java.util.List;
+25  
+26  import javax.servlet.http.HttpServletRequest;
+27  import javax.servlet.http.HttpServletResponse;
+28  
+29  import org.apache.chemistry.opencmis.commons.data.RepositoryCapabilities;
+30  import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
+31  import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
+32  import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer;
+33  import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionList;
+34  import org.apache.chemistry.opencmis.commons.enums.CapabilityChanges;
+35  import org.apache.chemistry.opencmis.commons.enums.CapabilityQuery;
+36  import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
+37  import org.apache.chemistry.opencmis.commons.impl.Constants;
+38  import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
+39  import org.apache.chemistry.opencmis.commons.server.CallContext;
+40  import org.apache.chemistry.opencmis.commons.server.CmisService;
+41  import org.apache.chemistry.opencmis.server.impl.CallContextImpl;
+42  import org.apache.chemistry.opencmis.server.shared.ThresholdOutputStreamFactory;
+43  
+44  /**
+45   * Repository Service operations.
+46   */
+47  public class RepositoryService {
+48  
+49      /**
+50       * Renders the service document.
+51       */
+52      public static class GetRepositories extends AbstractAtomPubServiceCall {
+53          public void serve(CallContext context, CmisService service, String repositoryId, HttpServletRequest request,
+54                  HttpServletResponse response) throws Exception {
+55              // get parameters
+56              repositoryId = getStringParameter(request, Constants.PARAM_REPOSITORY_ID);
+57  
+58              // execute
+59              List<RepositoryInfo> infoDataList = null;
+60  
+61              if (repositoryId == null) {
+62                  infoDataList = service.getRepositoryInfos(null);
+63              } else {
+64                  infoDataList = Collections.singletonList(service.getRepositoryInfo(repositoryId, null));
+65                  if (context instanceof CallContextImpl) {
+66                      ((CallContextImpl) context).put(CallContext.REPOSITORY_ID, repositoryId);
+67                  }
+68              }
+69  
+70              // set headers
+71              response.setStatus(HttpServletResponse.SC_OK);
+72              response.setContentType(Constants.MEDIATYPE_SERVICE);
+73  
+74              // write XML
+75              ServiceDocument serviceDoc = new ServiceDocument();
+76  
+77              serviceDoc.startDocument(response.getOutputStream(), getNamespaces(service));
+78              serviceDoc.startServiceDocument();
+79  
+80              if (infoDataList != null) {
+81                  CmisVersion cmisVersion = context.getCmisVersion();
+82                  for (RepositoryInfo infoData : infoDataList) {
+83                      if (infoData == null) {
+84                          continue;
+85                      }
+86  
+87                      String repId = infoData.getId();
+88                      UrlBuilder baseUrl = compileBaseUrl(request, repId);
+89  
+90                      boolean supportsQuery = false;
+91                      boolean supportsUnFiling = false;
+92                      boolean supportsMultifiling = false;
+93                      boolean supportsFolderTree = false;
+94                      boolean supportsRootDescendants = false;
+95                      boolean supportsChanges = false;
+96  
+97                      if (infoData.getCapabilities() != null) {
+98                          RepositoryCapabilities cap = infoData.getCapabilities();
+99  
+100                         if (cap.getQueryCapability() != null) {
+101                             supportsQuery = (cap.getQueryCapability() != CapabilityQuery.NONE);
+102                         }
+103 
+104                         if (cap.isUnfilingSupported() != null) {
+105                             supportsUnFiling = cap.isUnfilingSupported();
+106                         }
+107 
+108                         if (cap.isMultifilingSupported() != null) {
+109                             supportsMultifiling = cap.isMultifilingSupported();
+110                         }
+111 
+112                         if (cap.isGetFolderTreeSupported() != null) {
+113                             supportsFolderTree = cap.isGetFolderTreeSupported();
+114                         }
+115 
+116                         if (cap.isGetDescendantsSupported() != null) {
+117                             supportsRootDescendants = cap.isGetDescendantsSupported();
+118                         }
+119 
+120                         if (cap.getChangesCapability() != null) {
+121                             supportsChanges = (cap.getChangesCapability() != CapabilityChanges.NONE);
+122                         }
+123                     }
+124 
+125                     serviceDoc.startWorkspace(infoData.getId());
+126 
+127                     // add collections
+128 
+129                     // - root collection
+130                     serviceDoc.writeCollection(compileUrl(baseUrl, RESOURCE_CHILDREN, infoData.getRootFolderId()),
+131                             Constants.COLLECTION_ROOT, "Root Collection", Constants.MEDIATYPE_ENTRY,
+132                             Constants.MEDIATYPE_CMISATOM);
+133 
+134                     // - types collection
+135                     serviceDoc.writeCollection(compileUrl(baseUrl, RESOURCE_TYPES, null), Constants.COLLECTION_TYPES,
+136                             "Types Collection", "");
+137 
+138                     // - query collection
+139                     if (supportsQuery) {
+140                         serviceDoc.writeCollection(compileUrl(baseUrl, RESOURCE_QUERY, null),
+141                                 Constants.COLLECTION_QUERY, "Query Collection", Constants.MEDIATYPE_QUERY);
+142                     }
+143 
+144                     // - checked out collection collection
+145                     serviceDoc.writeCollection(compileUrl(baseUrl, RESOURCE_CHECKEDOUT, null),
+146                             Constants.COLLECTION_CHECKEDOUT, "Checked Out Collection", Constants.MEDIATYPE_CMISATOM);
+147 
+148                     // - unfiled collection collection
+149                     if (supportsUnFiling || supportsMultifiling) {
+150                         serviceDoc.writeCollection(compileUrl(baseUrl, RESOURCE_UNFILED, null),
+151                                 Constants.COLLECTION_UNFILED, "Unfiled Collection", Constants.MEDIATYPE_CMISATOM);
+152                     }
+153 
+154                     // - bulk update collection
+155                     serviceDoc.writeCollection(compileUrl(baseUrl, RESOURCE_BULK_UPDATE, null),
+156                             Constants.COLLECTION_BULK_UPDATE, "Bulk Update Collection", Constants.MEDIATYPE_CMISATOM);
+157 
+158                     // add repository info
+159                     serviceDoc.writeRepositoryInfo(infoData, cmisVersion);
+160 
+161                     // add links
+162 
+163                     // - types descendants
+164                     serviceDoc.writeLink(Constants.REP_REL_TYPEDESC, compileUrl(baseUrl, RESOURCE_TYPESDESC, null),
+165                             Constants.MEDIATYPE_FEED, null);
+166 
+167                     // - folder tree
+168                     if (supportsFolderTree) {
+169                         serviceDoc.writeLink(Constants.REP_REL_FOLDERTREE,
+170                                 compileUrl(baseUrl, RESOURCE_FOLDERTREE, infoData.getRootFolderId()),
+171                                 Constants.MEDIATYPE_DESCENDANTS, null);
+172                     }
+173 
+174                     // - root descendants
+175                     if (supportsRootDescendants) {
+176                         serviceDoc.writeLink(Constants.REP_REL_ROOTDESC,
+177                                 compileUrl(baseUrl, RESOURCE_DESCENDANTS, infoData.getRootFolderId()),
+178                                 Constants.MEDIATYPE_DESCENDANTS, infoData.getRootFolderId());
+179                     }
+180 
+181                     // - changes
+182                     if (supportsChanges) {
+183                         serviceDoc.writeLink(Constants.REP_REL_CHANGES, compileUrl(baseUrl, RESOURCE_CHANGES, null),
+184                                 Constants.MEDIATYPE_FEED, null);
+185                     }
+186 
+187                     // add URI templates
+188 
+189                     // - object by id
+190                     String url = compileUrl(baseUrl, RESOURCE_OBJECTBYID, null)
+191                             + "?id={id}&filter={filter}&includeAllowableActions={includeAllowableActions}&includeACL={includeACL}&includePolicyIds={includePolicyIds}&includeRelationships={includeRelationships}&renditionFilter={renditionFilter}";
+192                     serviceDoc.writeUriTemplate(url, Constants.TEMPLATE_OBJECT_BY_ID, Constants.MEDIATYPE_ENTRY);
+193 
+194                     // - object by path
+195                     url = compileUrl(baseUrl, RESOURCE_OBJECTBYPATH, null)
+196                             + "?path={path}&filter={filter}&includeAllowableActions={includeAllowableActions}&includeACL={includeACL}&includePolicyIds={includePolicyIds}&includeRelationships={includeRelationships}&renditionFilter={renditionFilter}";
+197                     serviceDoc.writeUriTemplate(url, Constants.TEMPLATE_OBJECT_BY_PATH, Constants.MEDIATYPE_ENTRY);
+198 
+199                     // - type by id
+200                     url = compileUrl(baseUrl, RESOURCE_TYPE, null) + "?id={id}";
+201                     serviceDoc.writeUriTemplate(url, Constants.TEMPLATE_TYPE_BY_ID, Constants.MEDIATYPE_ENTRY);
+202 
+203                     // - query
+204                     if (supportsQuery) {
+205                         url = compileUrl(baseUrl, RESOURCE_QUERY, null)
+206                                 + "?q={q}&searchAllVersions={searchAllVersions}&includeAllowableActions={includeAllowableActions}&includeRelationships={includeRelationships}&maxItems={maxItems}&skipCount={skipCount}";
+207                         serviceDoc.writeUriTemplate(url, Constants.TEMPLATE_QUERY, Constants.MEDIATYPE_FEED);
+208                     }
+209 
+210                     serviceDoc.endWorkspace();
+211                 }
+212             }
+213 
+214             serviceDoc.endServiceDocument();
+215             serviceDoc.endDocument();
+216         }
+217     }
+218 
+219     /**
+220      * Renders a type children collection.
+221      */
+222     public static class GetTypeChildren extends AbstractAtomPubServiceCall {
+223         public void serve(CallContext context, CmisService service, String repositoryId, HttpServletRequest request,
+224                 HttpServletResponse response) throws Exception {
+225             // get parameters
+226             String typeId = getStringParameter(request, Constants.PARAM_TYPE_ID);
+227             boolean includePropertyDefinitions = getBooleanParameter(request, Constants.PARAM_PROPERTY_DEFINITIONS,
+228                     false);
+229             BigInteger maxItems = getBigIntegerParameter(request, Constants.PARAM_MAX_ITEMS);
+230             BigInteger skipCount = getBigIntegerParameter(request, Constants.PARAM_SKIP_COUNT);
+231 
+232             // execute
+233             TypeDefinitionList typeList = service.getTypeChildren(repositoryId, typeId, includePropertyDefinitions,
+234                     maxItems, skipCount, null);
+235 
+236             BigInteger numItems = (typeList == null ? null : typeList.getNumItems());
+237             Boolean hasMoreItems = (typeList == null ? null : typeList.hasMoreItems());
+238 
+239             String parentTypeId = null;
+240             String typeName = "Type Children";
+241 
+242             // in order to get the parent type, we need the type definition of
+243             // this type as well
+244             if (typeId != null) {
+245                 TypeDefinition typeDefinition = service.getTypeDefinition(repositoryId, typeId, null);
+246 
+247                 parentTypeId = (typeDefinition == null ? null : typeDefinition.getParentTypeId());
+248                 typeName = (typeDefinition == null ? typeId : typeDefinition.getDisplayName());
+249             }
+250 
+251             // write XML
+252             response.setStatus(HttpServletResponse.SC_OK);
+253             response.setContentType(Constants.MEDIATYPE_FEED);
+254 
+255             AtomFeed feed = new AtomFeed();
+256             feed.startDocument(response.getOutputStream(), getNamespaces(service));
+257             feed.startFeed(true);
+258 
+259             // write basic Atom feed elements
+260             feed.writeFeedElements(typeId, null, TYPE_AUTHOR, typeName, new GregorianCalendar(), null, numItems);
+261 
+262             // write links
+263             UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
+264 
+265             feed.writeServiceLink(baseUrl.toString(), repositoryId);
+266 
+267             UrlBuilder selfLink = compileUrlBuilder(baseUrl, RESOURCE_TYPES, null);
+268             selfLink.addParameter(Constants.PARAM_TYPE_ID, typeId);
+269             selfLink.addParameter(Constants.PARAM_PROPERTY_DEFINITIONS, includePropertyDefinitions);
+270             selfLink.addParameter(Constants.PARAM_MAX_ITEMS, maxItems);
+271             selfLink.addParameter(Constants.PARAM_SKIP_COUNT, skipCount);
+272             feed.writeSelfLink(selfLink.toString(), typeId);
+273 
+274             feed.writeViaLink(compileUrl(baseUrl, RESOURCE_TYPE, typeId));
+275 
+276             UrlBuilder downLink = compileUrlBuilder(baseUrl, RESOURCE_TYPESDESC, null);
+277             downLink.addParameter(Constants.PARAM_TYPE_ID, typeId);
+278             feed.writeDownLink(downLink.toString(), Constants.MEDIATYPE_DESCENDANTS);
+279 
+280             if (parentTypeId != null) {
+281                 feed.writeUpLink(compileUrl(baseUrl, RESOURCE_TYPE, parentTypeId), Constants.MEDIATYPE_ENTRY);
+282             }
+283 
+284             // write paging links
+285             UrlBuilder pagingUrl = compileUrlBuilder(baseUrl, RESOURCE_TYPES, null);
+286             pagingUrl.addParameter(Constants.PARAM_TYPE_ID, typeId);
+287             pagingUrl.addParameter(Constants.PARAM_PROPERTY_DEFINITIONS, includePropertyDefinitions);
+288             feed.writePagingLinks(pagingUrl, maxItems, skipCount, numItems, hasMoreItems, PAGE_SIZE);
+289 
+290             // write collection
+291             UrlBuilder collectionUrl = compileUrlBuilder(baseUrl, RESOURCE_TYPES, null);
+292             collectionUrl.addParameter(Constants.PARAM_TYPE_ID, typeId);
+293             feed.writeCollection(collectionUrl.toString(), null, "Types Collection", "");
+294 
+295             // write type entries
+296             if ((typeList != null) && (typeList.getList() != null)) {
+297                 AtomEntry entry = new AtomEntry(feed.getWriter());
+298                 for (TypeDefinition type : typeList.getList()) {
+299                     writeTypeEntry(entry, type, null, repositoryId, baseUrl, false, context.getCmisVersion());
+300                 }
+301             }
+302 
+303             // we are done
+304             feed.endFeed();
+305             feed.endDocument();
+306         }
+307     }
+308 
+309     /**
+310      * Renders a type descendants feed.
+311      */
+312     public static class GetTypeDescendants extends AbstractAtomPubServiceCall {
+313         public void serve(CallContext context, CmisService service, String repositoryId, HttpServletRequest request,
+314                 HttpServletResponse response) throws Exception {
+315             // get parameters
+316             String typeId = getStringParameter(request, Constants.PARAM_TYPE_ID);
+317             BigInteger depth = getBigIntegerParameter(request, Constants.PARAM_DEPTH);
+318             boolean includePropertyDefinitions = getBooleanParameter(request, Constants.PARAM_PROPERTY_DEFINITIONS,
+319                     false);
+320 
+321             // execute
+322             List<TypeDefinitionContainer> typeTree = service.getTypeDescendants(repositoryId, typeId, depth,
+323                     includePropertyDefinitions, null);
+324 
+325             String parentTypeId = null;
+326             String typeName = "Type Children";
+327 
+328             // in order to get the parent type, we need the type definition of
+329             // this type as well
+330             if (typeId != null) {
+331                 TypeDefinition typeDefinition = service.getTypeDefinition(repositoryId, typeId, null);
+332 
+333                 parentTypeId = (typeDefinition == null ? null : typeDefinition.getParentTypeId());
+334                 typeName = (typeDefinition == null ? typeId : typeDefinition.getDisplayName());
+335             }
+336 
+337             // write XML
+338             response.setStatus(HttpServletResponse.SC_OK);
+339             response.setContentType(Constants.MEDIATYPE_FEED);
+340 
+341             AtomFeed feed = new AtomFeed();
+342             feed.startDocument(response.getOutputStream(), getNamespaces(service));
+343             feed.startFeed(true);
+344 
+345             // write basic Atom feed elements
+346             feed.writeFeedElements(typeId, null, TYPE_AUTHOR, typeName, new GregorianCalendar(), null, null);
+347 
+348             // write links
+349             UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
+350 
+351             feed.writeServiceLink(baseUrl.toString(), repositoryId);
+352 
+353             UrlBuilder selfLink = compileUrlBuilder(baseUrl, RESOURCE_TYPESDESC, null);
+354             selfLink.addParameter(Constants.PARAM_TYPE_ID, typeId);
+355             selfLink.addParameter(Constants.PARAM_DEPTH, depth);
+356             selfLink.addParameter(Constants.PARAM_PROPERTY_DEFINITIONS, includePropertyDefinitions);
+357             feed.writeSelfLink(selfLink.toString(), typeId);
+358 
+359             feed.writeViaLink(compileUrl(baseUrl, RESOURCE_TYPE, typeId));
+360 
+361             UrlBuilder downLink = compileUrlBuilder(baseUrl, RESOURCE_TYPES, null);
+362             downLink.addParameter(Constants.PARAM_TYPE_ID, typeId);
+363             feed.writeDownLink(downLink.toString(), Constants.MEDIATYPE_FEED);
+364 
+365             if (parentTypeId != null) {
+366                 feed.writeUpLink(compileUrl(baseUrl, RESOURCE_TYPE, parentTypeId), Constants.MEDIATYPE_ENTRY);
+367             }
+368 
+369             // write tree
+370             if (typeTree != null) {
+371                 AtomEntry entry = new AtomEntry(feed.getWriter());
+372 
+373                 for (TypeDefinitionContainer container : typeTree) {
+374                     if ((container != null) && (container.getTypeDefinition() != null)) {
+375                         writeTypeEntry(entry, container.getTypeDefinition(), container.getChildren(), repositoryId,
+376                                 baseUrl, false, context.getCmisVersion());
+377                     }
+378                 }
+379             }
+380 
+381             // we are done
+382             feed.endFeed();
+383             feed.endDocument();
+384         }
+385     }
+386 
+387     /**
+388      * Renders a type definition.
+389      */
+390     public static class GetTypeDefinition extends AbstractAtomPubServiceCall {
+391         public void serve(CallContext context, CmisService service, String repositoryId, HttpServletRequest request,
+392                 HttpServletResponse response) throws Exception {
+393             // get parameters
+394             String typeId = getStringParameter(request, Constants.PARAM_ID);
+395 
+396             // execute
+397             TypeDefinition type = service.getTypeDefinition(repositoryId, typeId, null);
+398 
+399             // write XML
+400             response.setStatus(HttpServletResponse.SC_OK);
+401             response.setContentType(Constants.MEDIATYPE_ENTRY);
+402 
+403             AtomEntry entry = new AtomEntry();
+404             entry.startDocument(response.getOutputStream(), getNamespaces(service));
+405             writeTypeEntry(entry, type, null, repositoryId, compileBaseUrl(request, repositoryId), true,
+406                     context.getCmisVersion());
+407             entry.endDocument();
+408         }
+409     }
+410 
+411     /**
+412      * Creates a type.
+413      */
+414     public static class CreateType extends AbstractAtomPubServiceCall {
+415         public void serve(CallContext context, CmisService service, String repositoryId, HttpServletRequest request,
+416                 HttpServletResponse response) throws Exception {
+417             // parse entry
+418             ThresholdOutputStreamFactory streamFactory = (ThresholdOutputStreamFactory) context
+419                     .get(CallContext.STREAM_FACTORY);
+420             AtomEntryParser parser = new AtomEntryParser(streamFactory);
+421             parser.parse(request.getInputStream());
+422 
+423             // execute
+424             TypeDefinition newType = service.createType(repositoryId, parser.getTypeDefinition(), null);
+425 
+426             // set headers
+427             UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
+428 
+429             response.setStatus(HttpServletResponse.SC_CREATED);
+430             response.setContentType(Constants.MEDIATYPE_ENTRY);
+431             response.setHeader("Location", compileUrl(baseUrl, RESOURCE_TYPE, newType.getId()));
+432 
+433             // write XML
+434             AtomEntry entry = new AtomEntry();
+435             entry.startDocument(response.getOutputStream(), getNamespaces(service));
+436             writeTypeEntry(entry, newType, null, repositoryId, compileBaseUrl(request, repositoryId), true,
+437                     context.getCmisVersion());
+438             entry.endDocument();
+439         }
+440     }
+441 
+442     /**
+443      * Updates a type.
+444      */
+445     public static class UpdateType extends AbstractAtomPubServiceCall {
+446         public void serve(CallContext context, CmisService service, String repositoryId, HttpServletRequest request,
+447                 HttpServletResponse response) throws Exception {
+448             // parse entry
+449             ThresholdOutputStreamFactory streamFactory = (ThresholdOutputStreamFactory) context
+450                     .get(CallContext.STREAM_FACTORY);
+451             AtomEntryParser parser = new AtomEntryParser(streamFactory);
+452             parser.parse(request.getInputStream());
+453 
+454             // execute
+455             TypeDefinition newType = service.updateType(repositoryId, parser.getTypeDefinition(), null);
+456 
+457             // set headers
+458             UrlBuilder baseUrl = compileBaseUrl(request, repositoryId);
+459 
+460             response.setStatus(HttpServletResponse.SC_OK);
+461             response.setContentType(Constants.MEDIATYPE_ENTRY);
+462             response.setHeader("Location", compileUrl(baseUrl, RESOURCE_TYPE, newType.getId()));
+463 
+464             // write XML
+465             AtomEntry entry = new AtomEntry();
+466             entry.startDocument(response.getOutputStream(), getNamespaces(service));
+467             writeTypeEntry(entry, newType, null, repositoryId, compileBaseUrl(request, repositoryId), true,
+468                     context.getCmisVersion());
+469             entry.endDocument();
+470         }
+471     }
+472 
+473     /**
+474      * Deletes a type.
+475      */
+476     public static class DeleteType extends AbstractAtomPubServiceCall {
+477         public void serve(CallContext context, CmisService service, String repositoryId, HttpServletRequest request,
+478                 HttpServletResponse response) throws Exception {
+479             // get parameters
+480             String typeId = getStringParameter(request, Constants.PARAM_ID);
+481 
+482             // execute
+483             service.deleteType(repositoryId, typeId, null);
+484 
+485             // set headers
+486             response.setStatus(HttpServletResponse.SC_NO_CONTENT);
+487         }
+488     }
+489 }
+
+
+ + Added: chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-server/chemistry-opencmis-server-bindings/xref/org/apache/chemistry/opencmis/server/impl/atompub/ServiceDocument.html URL: http://svn.apache.org/viewvc/chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-server/chemistry-opencmis-server-bindings/xref/org/apache/chemistry/opencmis/server/impl/atompub/ServiceDocument.html?rev=1486787&view=auto ============================================================================== --- chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-server/chemistry-opencmis-server-bindings/xref/org/apache/chemistry/opencmis/server/impl/atompub/ServiceDocument.html (added) +++ chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-server/chemistry-opencmis-server-bindings/xref/org/apache/chemistry/opencmis/server/impl/atompub/ServiceDocument.html Tue May 28 07:21:41 2013 @@ -0,0 +1,93 @@ + + + + +ServiceDocument xref + + + +
+
+1   /*
+2    * Licensed to the Apache Software Foundation (ASF) under one
+3    * or more contributor license agreements.  See the NOTICE file
+4    * distributed with this work for additional information
+5    * regarding copyright ownership.  The ASF licenses this file
+6    * to you under the Apache License, Version 2.0 (the
+7    * "License"); you may not use this file except in compliance
+8    * with the License.  You may obtain a copy of the License at
+9    *
+10   * http://www.apache.org/licenses/LICENSE-2.0
+11   *
+12   * Unless required by applicable law or agreed to in writing,
+13   * software distributed under the License is distributed on an
+14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+15   * KIND, either express or implied.  See the License for the
+16   * specific language governing permissions and limitations
+17   * under the License.
+18   */
+19  package org.apache.chemistry.opencmis.server.impl.atompub;
+20  
+21  import javax.xml.stream.XMLStreamException;
+22  import javax.xml.stream.XMLStreamWriter;
+23  
+24  import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
+25  import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
+26  import org.apache.chemistry.opencmis.commons.impl.XMLConstants;
+27  import org.apache.chemistry.opencmis.commons.impl.XMLConverter;
+28  import org.apache.chemistry.opencmis.commons.impl.XMLUtils;
+29  
+30  /**
+31   * Service document class.
+32   */
+33  public class ServiceDocument extends AtomDocumentBase {
+34  
+35      public ServiceDocument() {
+36      }
+37  
+38      public void startServiceDocument() throws XMLStreamException {
+39          XMLStreamWriter xsw = getWriter();
+40          
+41          xsw.writeStartElement(XMLConstants.PREFIX_APP, "service", XMLConstants.NAMESPACE_APP);
+42  
+43          xsw.writeNamespace(XMLConstants.PREFIX_ATOM, XMLConstants.NAMESPACE_ATOM);
+44          xsw.writeNamespace(XMLConstants.PREFIX_CMIS, XMLConstants.NAMESPACE_CMIS);
+45          xsw.writeNamespace(XMLConstants.PREFIX_RESTATOM, XMLConstants.NAMESPACE_RESTATOM);
+46          xsw.writeNamespace(XMLConstants.PREFIX_APP, XMLConstants.NAMESPACE_APP);
+47  
+48          writeAllCustomNamespace();
+49      }
+50  
+51      public void endServiceDocument() throws XMLStreamException {
+52          getWriter().writeEndElement();
+53      }
+54  
+55      public void startWorkspace(String title) throws XMLStreamException {
+56          XMLStreamWriter xsw = getWriter();
+57  
+58          xsw.writeStartElement(XMLConstants.PREFIX_APP, "workspace", XMLConstants.NAMESPACE_APP);
+59          XMLUtils.write(xsw, XMLConstants.PREFIX_ATOM, XMLConstants.NAMESPACE_ATOM, "title", title);
+60      }
+61  
+62      public void endWorkspace() throws XMLStreamException {
+63          getWriter().writeEndElement();
+64      }
+65  
+66      public void writeRepositoryInfo(RepositoryInfo repInfo, CmisVersion cmisVersion) throws XMLStreamException {
+67          XMLConverter.writeRepositoryInfo(getWriter(), cmisVersion, XMLConstants.NAMESPACE_RESTATOM, repInfo);
+68      }
+69  
+70      public void writeUriTemplate(String template, String type, String mediatype) throws XMLStreamException {
+71          XMLStreamWriter xsw = getWriter();
+72  
+73          xsw.writeStartElement(XMLConstants.PREFIX_RESTATOM, "uritemplate", XMLConstants.NAMESPACE_RESTATOM);
+74          XMLUtils.write(xsw, XMLConstants.PREFIX_RESTATOM, XMLConstants.NAMESPACE_RESTATOM, "template", template);
+75          XMLUtils.write(xsw, XMLConstants.PREFIX_RESTATOM, XMLConstants.NAMESPACE_RESTATOM, "type", type);
+76          XMLUtils.write(xsw, XMLConstants.PREFIX_RESTATOM, XMLConstants.NAMESPACE_RESTATOM, "mediatype", mediatype);
+77          xsw.writeEndElement();
+78      }
+79  }
+
+
+ +