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 11AA090DA for ; Tue, 3 Apr 2012 04:53:27 +0000 (UTC) Received: (qmail 67456 invoked by uid 500); 3 Apr 2012 04:53:26 -0000 Delivered-To: apmail-chemistry-commits-archive@chemistry.apache.org Received: (qmail 67409 invoked by uid 500); 3 Apr 2012 04:53:26 -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 67401 invoked by uid 99); 3 Apr 2012 04:53:26 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Apr 2012 04:53:26 +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, 03 Apr 2012 04:53:21 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 1550B2388C74; Tue, 3 Apr 2012 04:52:07 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1308684 [20/34] - in /chemistry/site/trunk/content/java/0.7.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings: ./ css/ images/ images/logos/ xref-test/ xref-test/org/ xref-test/org/apache/ xref-test/org/apache/chemistry/... Date: Tue, 03 Apr 2012 04:51:57 -0000 To: commits@chemistry.apache.org From: gabriele@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120403045207.1550B2388C74@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: chemistry/site/trunk/content/java/0.7.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/atompub/PolicyServiceImpl.html URL: http://svn.apache.org/viewvc/chemistry/site/trunk/content/java/0.7.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/atompub/PolicyServiceImpl.html?rev=1308684&view=auto ============================================================================== --- chemistry/site/trunk/content/java/0.7.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/atompub/PolicyServiceImpl.html (added) +++ chemistry/site/trunk/content/java/0.7.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/atompub/PolicyServiceImpl.html Tue Apr 3 04:51:51 2012 @@ -0,0 +1,203 @@ + + + + +PolicyServiceImpl 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.client.bindings.spi.atompub;
+20  
+21  import static org.apache.chemistry.opencmis.commons.impl.Converter.convert;
+22  
+23  import java.io.OutputStream;
+24  import java.util.ArrayList;
+25  import java.util.List;
+26  
+27  import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
+28  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomElement;
+29  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomEntry;
+30  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomFeed;
+31  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomLink;
+32  import org.apache.chemistry.opencmis.client.bindings.spi.http.HttpUtils;
+33  import org.apache.chemistry.opencmis.commons.PropertyIds;
+34  import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
+35  import org.apache.chemistry.opencmis.commons.data.ObjectData;
+36  import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
+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.impl.jaxb.CmisObjectType;
+40  import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisProperty;
+41  import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisPropertyId;
+42  import org.apache.chemistry.opencmis.commons.spi.PolicyService;
+43  
+44  /**
+45   * Policy Service AtomPub client.
+46   */
+47  public class PolicyServiceImpl extends AbstractAtomPubService implements PolicyService {
+48  
+49      /**
+50       * Constructor.
+51       */
+52      public PolicyServiceImpl(BindingSession session) {
+53          setSession(session);
+54      }
+55  
+56      public void applyPolicy(String repositoryId, String policyId, String objectId, ExtensionsData extension) {
+57          // find the link
+58          String link = loadLink(repositoryId, objectId, Constants.REL_POLICIES, Constants.MEDIATYPE_FEED);
+59  
+60          if (link == null) {
+61              throwLinkException(repositoryId, objectId, Constants.REL_POLICIES, Constants.MEDIATYPE_FEED);
+62          }
+63  
+64          UrlBuilder url = new UrlBuilder(link);
+65  
+66          // set up object and writer
+67          final AtomEntryWriter entryWriter = new AtomEntryWriter(createIdObject(objectId));
+68  
+69          // post applyPolicy request
+70          post(url, Constants.MEDIATYPE_ENTRY, new HttpUtils.Output() {
+71              public void write(OutputStream out) throws Exception {
+72                  entryWriter.write(out);
+73              }
+74          });
+75      }
+76  
+77      public List<ObjectData> getAppliedPolicies(String repositoryId, String objectId, String filter,
+78              ExtensionsData extension) {
+79          List<ObjectData> result = new ArrayList<ObjectData>();
+80  
+81          // find the link
+82          String link = loadLink(repositoryId, objectId, Constants.REL_POLICIES, Constants.MEDIATYPE_FEED);
+83  
+84          if (link == null) {
+85              throwLinkException(repositoryId, objectId, Constants.REL_POLICIES, Constants.MEDIATYPE_FEED);
+86          }
+87  
+88          UrlBuilder url = new UrlBuilder(link);
+89          url.addParameter(Constants.PARAM_FILTER, filter);
+90  
+91          // read and parse
+92          HttpUtils.Response resp = read(url);
+93          AtomFeed feed = parse(resp.getStream(), AtomFeed.class);
+94  
+95          // get the policies
+96          if (!feed.getEntries().isEmpty()) {
+97              for (AtomEntry entry : feed.getEntries()) {
+98                  ObjectData policy = null;
+99  
+100                 // walk through the entry
+101                 for (AtomElement element : entry.getElements()) {
+102                     if (element.getObject() instanceof CmisObjectType) {
+103                         policy = convert((CmisObjectType) element.getObject());
+104                     }
+105                 }
+106 
+107                 if (policy != null) {
+108                     result.add(policy);
+109                 }
+110             }
+111         }
+112 
+113         return result;
+114     }
+115 
+116     public void removePolicy(String repositoryId, String policyId, String objectId, ExtensionsData extension) {
+117         // we need a policy id
+118         if (policyId == null) {
+119             throw new CmisInvalidArgumentException("Policy id must be set!");
+120         }
+121 
+122         // find the link
+123         String link = loadLink(repositoryId, objectId, Constants.REL_POLICIES, Constants.MEDIATYPE_FEED);
+124 
+125         if (link == null) {
+126             throwLinkException(repositoryId, objectId, Constants.REL_POLICIES, Constants.MEDIATYPE_FEED);
+127         }
+128 
+129         UrlBuilder url = new UrlBuilder(link);
+130         url.addParameter(Constants.PARAM_FILTER, PropertyIds.OBJECT_ID);
+131 
+132         // read and parse
+133         HttpUtils.Response resp = read(url);
+134         AtomFeed feed = parse(resp.getStream(), AtomFeed.class);
+135 
+136         // find the policy
+137         String policyLink = null;
+138         boolean found = false;
+139 
+140         if (!feed.getEntries().isEmpty()) {
+141             for (AtomEntry entry : feed.getEntries()) {
+142                 // walk through the entry
+143                 for (AtomElement element : entry.getElements()) {
+144                     if (element.getObject() instanceof AtomLink) {
+145                         AtomLink atomLink = (AtomLink) element.getObject();
+146                         if (Constants.REL_SELF.equals(atomLink.getRel())) {
+147                             policyLink = atomLink.getHref();
+148                         }
+149                     } else if (element.getObject() instanceof CmisObjectType) {
+150                         String id = findIdProperty((CmisObjectType) element.getObject());
+151                         if (policyId.equals(id)) {
+152                             found = true;
+153                         }
+154                     }
+155                 }
+156 
+157                 if (found) {
+158                     break;
+159                 }
+160             }
+161         }
+162 
+163         // if found, delete it
+164         if (found && (policyLink != null)) {
+165             delete(new UrlBuilder(policyLink));
+166         }
+167     }
+168 
+169     /**
+170      * Finds the id property within a CMIS object.
+171      */
+172     private static String findIdProperty(CmisObjectType object) {
+173         if ((object == null) || (object.getProperties() == null)) {
+174             return null;
+175         }
+176 
+177         for (CmisProperty property : object.getProperties().getProperty()) {
+178             if (PropertyIds.OBJECT_ID.equals(property.getPropertyDefinitionId())
+179                     && (property instanceof CmisPropertyId)) {
+180                 List<String> values = ((CmisPropertyId) property).getValue();
+181                 if (values.size() == 1) {
+182                     return values.get(0);
+183                 }
+184             }
+185         }
+186 
+187         return null;
+188     }
+189 }
+
+
+ + Added: chemistry/site/trunk/content/java/0.7.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/atompub/RelationshipServiceImpl.html URL: http://svn.apache.org/viewvc/chemistry/site/trunk/content/java/0.7.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/atompub/RelationshipServiceImpl.html?rev=1308684&view=auto ============================================================================== --- chemistry/site/trunk/content/java/0.7.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/atompub/RelationshipServiceImpl.html (added) +++ chemistry/site/trunk/content/java/0.7.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/atompub/RelationshipServiceImpl.html Tue Apr 3 04:51:51 2012 @@ -0,0 +1,137 @@ + + + + +RelationshipServiceImpl 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.client.bindings.spi.atompub;
+20  
+21  import static org.apache.chemistry.opencmis.commons.impl.Converter.convert;
+22  
+23  import java.math.BigInteger;
+24  import java.util.ArrayList;
+25  
+26  import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
+27  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomElement;
+28  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomEntry;
+29  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomFeed;
+30  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomLink;
+31  import org.apache.chemistry.opencmis.client.bindings.spi.http.HttpUtils;
+32  import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
+33  import org.apache.chemistry.opencmis.commons.data.ObjectData;
+34  import org.apache.chemistry.opencmis.commons.data.ObjectList;
+35  import org.apache.chemistry.opencmis.commons.enums.RelationshipDirection;
+36  import org.apache.chemistry.opencmis.commons.impl.Constants;
+37  import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
+38  import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectListImpl;
+39  import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectType;
+40  import org.apache.chemistry.opencmis.commons.spi.RelationshipService;
+41  
+42  /**
+43   * Relationship Service AtomPub client.
+44   */
+45  public class RelationshipServiceImpl extends AbstractAtomPubService implements RelationshipService {
+46  
+47      /**
+48       * Constructor.
+49       */
+50      public RelationshipServiceImpl(BindingSession session) {
+51          setSession(session);
+52      }
+53  
+54      public ObjectList getObjectRelationships(String repositoryId, String objectId, Boolean includeSubRelationshipTypes,
+55              RelationshipDirection relationshipDirection, String typeId, String filter, Boolean includeAllowableActions,
+56              BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
+57          ObjectListImpl result = new ObjectListImpl();
+58  
+59          // find the link
+60          String link = loadLink(repositoryId, objectId, Constants.REL_RELATIONSHIPS, Constants.MEDIATYPE_FEED);
+61  
+62          if (link == null) {
+63              throwLinkException(repositoryId, objectId, Constants.REL_RELATIONSHIPS, Constants.MEDIATYPE_FEED);
+64          }
+65  
+66          UrlBuilder url = new UrlBuilder(link);
+67          url.addParameter(Constants.PARAM_SUB_RELATIONSHIP_TYPES, includeSubRelationshipTypes);
+68          url.addParameter(Constants.PARAM_RELATIONSHIP_DIRECTION, relationshipDirection);
+69          url.addParameter(Constants.PARAM_TYPE_ID, typeId);
+70          url.addParameter(Constants.PARAM_FILTER, filter);
+71          url.addParameter(Constants.PARAM_ALLOWABLE_ACTIONS, includeAllowableActions);
+72          url.addParameter(Constants.PARAM_MAX_ITEMS, maxItems);
+73          url.addParameter(Constants.PARAM_SKIP_COUNT, skipCount);
+74  
+75          // read and parse
+76          HttpUtils.Response resp = read(url);
+77          AtomFeed feed = parse(resp.getStream(), AtomFeed.class);
+78  
+79          // handle top level
+80          for (AtomElement element : feed.getElements()) {
+81              if (element.getObject() instanceof AtomLink) {
+82                  if (isNextLink(element)) {
+83                      result.setHasMoreItems(Boolean.TRUE);
+84                  }
+85              } else if (isInt(NAME_NUM_ITEMS, element)) {
+86                  result.setNumItems((BigInteger) element.getObject());
+87              }
+88          }
+89  
+90          // get the children
+91          if (!feed.getEntries().isEmpty()) {
+92              result.setObjects(new ArrayList<ObjectData>(feed.getEntries().size()));
+93  
+94              for (AtomEntry entry : feed.getEntries()) {
+95                  ObjectData relationship = null;
+96  
+97                  lockLinks();
+98                  try {
+99                      // clean up cache
+100                     removeLinks(repositoryId, entry.getId());
+101 
+102                     // walk through the entry
+103                     for (AtomElement element : entry.getElements()) {
+104                         if (element.getObject() instanceof AtomLink) {
+105                             addLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
+106                         } else if (element.getObject() instanceof CmisObjectType) {
+107                             relationship = convert((CmisObjectType) element.getObject());
+108                         }
+109                     }
+110                 } finally {
+111                     unlockLinks();
+112                 }
+113 
+114                 if (relationship != null) {
+115                     result.getObjects().add(relationship);
+116                 }
+117             }
+118 
+119         }
+120 
+121         return result;
+122     }
+123 }
+
+
+ + Added: chemistry/site/trunk/content/java/0.7.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/atompub/RepositoryServiceImpl.html URL: http://svn.apache.org/viewvc/chemistry/site/trunk/content/java/0.7.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/atompub/RepositoryServiceImpl.html?rev=1308684&view=auto ============================================================================== --- chemistry/site/trunk/content/java/0.7.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/atompub/RepositoryServiceImpl.html (added) +++ chemistry/site/trunk/content/java/0.7.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/atompub/RepositoryServiceImpl.html Tue Apr 3 04:51:51 2012 @@ -0,0 +1,229 @@ + + + + +RepositoryServiceImpl 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.client.bindings.spi.atompub;
+20  
+21  import static org.apache.chemistry.opencmis.commons.impl.Converter.convert;
+22  
+23  import java.math.BigInteger;
+24  import java.util.ArrayList;
+25  import java.util.List;
+26  
+27  import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
+28  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomElement;
+29  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomEntry;
+30  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomFeed;
+31  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomLink;
+32  import org.apache.chemistry.opencmis.client.bindings.spi.http.HttpUtils;
+33  import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
+34  import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
+35  import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
+36  import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer;
+37  import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionList;
+38  import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
+39  import org.apache.chemistry.opencmis.commons.impl.Constants;
+40  import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
+41  import org.apache.chemistry.opencmis.commons.impl.dataobjects.TypeDefinitionContainerImpl;
+42  import org.apache.chemistry.opencmis.commons.impl.dataobjects.TypeDefinitionListImpl;
+43  import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisTypeDefinitionType;
+44  import org.apache.chemistry.opencmis.commons.spi.RepositoryService;
+45  
+46  /**
+47   * Repository Service AtomPub client.
+48   */
+49  public class RepositoryServiceImpl extends AbstractAtomPubService implements RepositoryService {
+50  
+51      /**
+52       * Constructor.
+53       */
+54      public RepositoryServiceImpl(BindingSession session) {
+55          setSession(session);
+56      }
+57  
+58      public List<RepositoryInfo> getRepositoryInfos(ExtensionsData extension) {
+59          return getRepositoriesInternal(null);
+60      }
+61  
+62      public RepositoryInfo getRepositoryInfo(String repositoryId, ExtensionsData extension) {
+63          List<RepositoryInfo> repositoryInfos = getRepositoriesInternal(repositoryId);
+64  
+65          // find the repository
+66          for (RepositoryInfo info : repositoryInfos) {
+67              if (info.getId() == null) {
+68                  continue;
+69              }
+70  
+71              if (info.getId().equals(repositoryId)) {
+72                  return info;
+73              }
+74          }
+75  
+76          throw new CmisObjectNotFoundException("Repository not found!");
+77      }
+78  
+79      public TypeDefinition getTypeDefinition(String repositoryId, String typeId, ExtensionsData extension) {
+80          return getTypeDefinitionInternal(repositoryId, typeId);
+81      }
+82  
+83      public TypeDefinitionList getTypeChildren(String repositoryId, String typeId, Boolean includePropertyDefinitions,
+84              BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
+85          TypeDefinitionListImpl result = new TypeDefinitionListImpl();
+86  
+87          // find the link
+88          String link = null;
+89          if (typeId == null) {
+90              link = loadCollection(repositoryId, Constants.COLLECTION_TYPES);
+91          } else {
+92              link = loadTypeLink(repositoryId, typeId, Constants.REL_DOWN, Constants.MEDIATYPE_CHILDREN);
+93          }
+94  
+95          if (link == null) {
+96              throw new CmisObjectNotFoundException("Unknown repository or type!");
+97          }
+98  
+99          UrlBuilder url = new UrlBuilder(link);
+100         url.addParameter(Constants.PARAM_PROPERTY_DEFINITIONS, includePropertyDefinitions);
+101         url.addParameter(Constants.PARAM_MAX_ITEMS, maxItems);
+102         url.addParameter(Constants.PARAM_SKIP_COUNT, skipCount);
+103 
+104         // read and parse
+105         HttpUtils.Response resp = read(url);
+106         AtomFeed feed = parse(resp.getStream(), AtomFeed.class);
+107 
+108         // handle top level
+109         for (AtomElement element : feed.getElements()) {
+110             if (element.getObject() instanceof AtomLink) {
+111                 if (isNextLink(element)) {
+112                     result.setHasMoreItems(Boolean.TRUE);
+113                 }
+114             } else if (isInt(NAME_NUM_ITEMS, element)) {
+115                 result.setNumItems((BigInteger) element.getObject());
+116             }
+117         }
+118 
+119         result.setList(new ArrayList<TypeDefinition>(feed.getEntries().size()));
+120 
+121         // get the children
+122         if (!feed.getEntries().isEmpty()) {
+123             for (AtomEntry entry : feed.getEntries()) {
+124                 TypeDefinition child = null;
+125 
+126                 lockTypeLinks();
+127                 try {
+128                     // walk through the entry
+129                     for (AtomElement element : entry.getElements()) {
+130                         if (element.getObject() instanceof AtomLink) {
+131                             addTypeLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
+132                         } else if (element.getObject() instanceof CmisTypeDefinitionType) {
+133                             child = convert((CmisTypeDefinitionType) element.getObject());
+134                         }
+135                     }
+136                 } finally {
+137                     unlockTypeLinks();
+138                 }
+139 
+140                 if (child != null) {
+141                     result.getList().add(child);
+142                 }
+143             }
+144         }
+145 
+146         return result;
+147     }
+148 
+149     public List<TypeDefinitionContainer> getTypeDescendants(String repositoryId, String typeId, BigInteger depth,
+150             Boolean includePropertyDefinitions, ExtensionsData extension) {
+151         List<TypeDefinitionContainer> result = new ArrayList<TypeDefinitionContainer>();
+152 
+153         // find the link
+154         String link = null;
+155         if (typeId == null) {
+156             link = loadRepositoryLink(repositoryId, Constants.REP_REL_TYPEDESC);
+157         } else {
+158             link = loadTypeLink(repositoryId, typeId, Constants.REL_DOWN, Constants.MEDIATYPE_DESCENDANTS);
+159         }
+160 
+161         if (link == null) {
+162             throw new CmisObjectNotFoundException("Unknown repository or type!");
+163         }
+164 
+165         UrlBuilder url = new UrlBuilder(link);
+166         url.addParameter(Constants.PARAM_DEPTH, depth);
+167         url.addParameter(Constants.PARAM_PROPERTY_DEFINITIONS, includePropertyDefinitions);
+168 
+169         // read and parse
+170         HttpUtils.Response resp = read(url);
+171         AtomFeed feed = parse(resp.getStream(), AtomFeed.class);
+172 
+173         // process tree
+174         addTypeDescendantsLevel(repositoryId, feed, result);
+175 
+176         return result;
+177     }
+178 
+179     /**
+180      * Adds type descendants level recursively.
+181      */
+182     private void addTypeDescendantsLevel(String repositoryId, AtomFeed feed, List<TypeDefinitionContainer> containerList) {
+183         if ((feed == null) || (feed.getEntries().isEmpty())) {
+184             return;
+185         }
+186 
+187         // walk through the feed
+188         for (AtomEntry entry : feed.getEntries()) {
+189             TypeDefinitionContainerImpl childContainer = null;
+190             List<TypeDefinitionContainer> childContainerList = new ArrayList<TypeDefinitionContainer>();
+191 
+192             // walk through the entry
+193             lockTypeLinks();
+194             try {
+195                 for (AtomElement element : entry.getElements()) {
+196                     if (element.getObject() instanceof AtomLink) {
+197                         addTypeLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
+198                     } else if (element.getObject() instanceof CmisTypeDefinitionType) {
+199                         childContainer = new TypeDefinitionContainerImpl(
+200                                 convert((CmisTypeDefinitionType) element.getObject()));
+201                     } else if (element.getObject() instanceof AtomFeed) {
+202                         addTypeDescendantsLevel(repositoryId, (AtomFeed) element.getObject(), childContainerList);
+203                     }
+204                 }
+205             } finally {
+206                 unlockTypeLinks();
+207             }
+208 
+209             if (childContainer != null) {
+210                 childContainer.setChildren(childContainerList);
+211                 containerList.add(childContainer);
+212             }
+213         }
+214     }
+215 }
+
+
+ + Added: chemistry/site/trunk/content/java/0.7.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/atompub/SpiSessionParameter.html URL: http://svn.apache.org/viewvc/chemistry/site/trunk/content/java/0.7.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/atompub/SpiSessionParameter.html?rev=1308684&view=auto ============================================================================== --- chemistry/site/trunk/content/java/0.7.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/atompub/SpiSessionParameter.html (added) +++ chemistry/site/trunk/content/java/0.7.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/atompub/SpiSessionParameter.html Tue Apr 3 04:51:51 2012 @@ -0,0 +1,44 @@ + + + + +SpiSessionParameter 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.client.bindings.spi.atompub;
+20  
+21  /**
+22   * Internal session parameters.
+23   */
+24  public final class SpiSessionParameter {
+25  
+26      public static final String LINK_CACHE = "org.apache.chemistry.opencmis.binding.atompub.linkcache";
+27  
+28      private SpiSessionParameter() {
+29      }
+30  }
+
+
+ +