Added: websites/staging/chemistry/trunk/content/java/0.13.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/atompub/PolicyServiceImpl.html ============================================================================== --- websites/staging/chemistry/trunk/content/java/0.13.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/atompub/PolicyServiceImpl.html (added) +++ websites/staging/chemistry/trunk/content/java/0.13.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/atompub/PolicyServiceImpl.html Mon Apr 6 17:11:37 2015 @@ -0,0 +1,181 @@ + + + + +PolicyServiceImpl xref + + + +
View Javadoc
+
+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 java.io.IOException;
+22  import java.io.OutputStream;
+23  import java.util.ArrayList;
+24  import java.util.List;
+25  
+26  import javax.xml.stream.XMLStreamException;
+27  
+28  import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
+29  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomElement;
+30  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomEntry;
+31  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomFeed;
+32  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomLink;
+33  import org.apache.chemistry.opencmis.client.bindings.spi.http.Output;
+34  import org.apache.chemistry.opencmis.client.bindings.spi.http.Response;
+35  import org.apache.chemistry.opencmis.commons.PropertyIds;
+36  import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
+37  import org.apache.chemistry.opencmis.commons.data.ObjectData;
+38  import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
+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.spi.PolicyService;
+42  
+43  /**
+44   * Policy Service AtomPub client.
+45   */
+46  public class PolicyServiceImpl extends AbstractAtomPubService implements PolicyService {
+47  
+48      /**
+49       * Constructor.
+50       */
+51      public PolicyServiceImpl(BindingSession session) {
+52          setSession(session);
+53      }
+54  
+55      public void applyPolicy(String repositoryId, String policyId, String objectId, ExtensionsData extension) {
+56          // find the link
+57          String link = loadLink(repositoryId, objectId, Constants.REL_POLICIES, Constants.MEDIATYPE_FEED);
+58  
+59          if (link == null) {
+60              throwLinkException(repositoryId, objectId, Constants.REL_POLICIES, Constants.MEDIATYPE_FEED);
+61          }
+62  
+63          UrlBuilder url = new UrlBuilder(link);
+64  
+65          // set up object and writer
+66          final AtomEntryWriter entryWriter = new AtomEntryWriter(createIdObject(objectId), getCmisVersion(repositoryId));
+67  
+68          // post applyPolicy request
+69          post(url, Constants.MEDIATYPE_ENTRY, new Output() {
+70              public void write(OutputStream out) throws XMLStreamException, IOException {
+71                  entryWriter.write(out);
+72              }
+73          });
+74      }
+75  
+76      public List<ObjectData> getAppliedPolicies(String repositoryId, String objectId, String filter,
+77              ExtensionsData extension) {
+78          List<ObjectData> result = new ArrayList<ObjectData>();
+79  
+80          // find the link
+81          String link = loadLink(repositoryId, objectId, Constants.REL_POLICIES, Constants.MEDIATYPE_FEED);
+82  
+83          if (link == null) {
+84              throwLinkException(repositoryId, objectId, Constants.REL_POLICIES, Constants.MEDIATYPE_FEED);
+85          }
+86  
+87          UrlBuilder url = new UrlBuilder(link);
+88          url.addParameter(Constants.PARAM_FILTER, filter);
+89  
+90          // read and parse
+91          Response resp = read(url);
+92          AtomFeed feed = parse(resp.getStream(), AtomFeed.class);
+93  
+94          // get the policies
+95          if (!feed.getEntries().isEmpty()) {
+96              for (AtomEntry entry : feed.getEntries()) {
+97                  ObjectData policy = null;
+98  
+99                  // walk through the entry
+100                 for (AtomElement element : entry.getElements()) {
+101                     if (element.getObject() instanceof ObjectData) {
+102                         policy = (ObjectData) element.getObject();
+103                     }
+104                 }
+105 
+106                 if (policy != null) {
+107                     result.add(policy);
+108                 }
+109             }
+110         }
+111 
+112         return result;
+113     }
+114 
+115     public void removePolicy(String repositoryId, String policyId, String objectId, ExtensionsData extension) {
+116         // we need a policy id
+117         if (policyId == null) {
+118             throw new CmisInvalidArgumentException("Policy id must be set!");
+119         }
+120 
+121         // find the link
+122         String link = loadLink(repositoryId, objectId, Constants.REL_POLICIES, Constants.MEDIATYPE_FEED);
+123 
+124         if (link == null) {
+125             throwLinkException(repositoryId, objectId, Constants.REL_POLICIES, Constants.MEDIATYPE_FEED);
+126         }
+127 
+128         UrlBuilder url = new UrlBuilder(link);
+129         url.addParameter(Constants.PARAM_FILTER, PropertyIds.OBJECT_ID);
+130 
+131         // read and parse
+132         Response resp = read(url);
+133         AtomFeed feed = parse(resp.getStream(), AtomFeed.class);
+134 
+135         // find the policy
+136         String policyLink = null;
+137         boolean found = false;
+138 
+139         if (!feed.getEntries().isEmpty()) {
+140             for (AtomEntry entry : feed.getEntries()) {
+141                 // walk through the entry
+142                 for (AtomElement element : entry.getElements()) {
+143                     if (element.getObject() instanceof AtomLink) {
+144                         AtomLink atomLink = (AtomLink) element.getObject();
+145                         if (Constants.REL_SELF.equals(atomLink.getRel())) {
+146                             policyLink = atomLink.getHref();
+147                         }
+148                     } else if (element.getObject() instanceof ObjectData) {
+149                         String id = ((ObjectData) element.getObject()).getId();
+150                         if (policyId.equals(id)) {
+151                             found = true;
+152                         }
+153                     }
+154                 }
+155 
+156                 if (found) {
+157                     break;
+158                 }
+159             }
+160         }
+161 
+162         // if found, delete it
+163         if (found && (policyLink != null)) {
+164             delete(new UrlBuilder(policyLink));
+165         }
+166     }
+167 }
+
+
+ + Added: websites/staging/chemistry/trunk/content/java/0.13.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/atompub/RelationshipServiceImpl.html ============================================================================== --- websites/staging/chemistry/trunk/content/java/0.13.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/atompub/RelationshipServiceImpl.html (added) +++ websites/staging/chemistry/trunk/content/java/0.13.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/atompub/RelationshipServiceImpl.html Mon Apr 6 17:11:37 2015 @@ -0,0 +1,134 @@ + + + + +RelationshipServiceImpl xref + + + +
View Javadoc
+
+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 java.math.BigInteger;
+22  import java.util.ArrayList;
+23  
+24  import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
+25  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomElement;
+26  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomEntry;
+27  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomFeed;
+28  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomLink;
+29  import org.apache.chemistry.opencmis.client.bindings.spi.http.Response;
+30  import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
+31  import org.apache.chemistry.opencmis.commons.data.ObjectData;
+32  import org.apache.chemistry.opencmis.commons.data.ObjectList;
+33  import org.apache.chemistry.opencmis.commons.enums.RelationshipDirection;
+34  import org.apache.chemistry.opencmis.commons.impl.Constants;
+35  import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
+36  import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectListImpl;
+37  import org.apache.chemistry.opencmis.commons.spi.RelationshipService;
+38  
+39  /**
+40   * Relationship Service AtomPub client.
+41   */
+42  public class RelationshipServiceImpl extends AbstractAtomPubService implements RelationshipService {
+43  
+44      /**
+45       * Constructor.
+46       */
+47      public RelationshipServiceImpl(BindingSession session) {
+48          setSession(session);
+49      }
+50  
+51      public ObjectList getObjectRelationships(String repositoryId, String objectId, Boolean includeSubRelationshipTypes,
+52              RelationshipDirection relationshipDirection, String typeId, String filter, Boolean includeAllowableActions,
+53              BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
+54          ObjectListImpl result = new ObjectListImpl();
+55  
+56          // find the link
+57          String link = loadLink(repositoryId, objectId, Constants.REL_RELATIONSHIPS, Constants.MEDIATYPE_FEED);
+58  
+59          if (link == null) {
+60              throwLinkException(repositoryId, objectId, Constants.REL_RELATIONSHIPS, Constants.MEDIATYPE_FEED);
+61          }
+62  
+63          UrlBuilder url = new UrlBuilder(link);
+64          url.addParameter(Constants.PARAM_SUB_RELATIONSHIP_TYPES, includeSubRelationshipTypes);
+65          url.addParameter(Constants.PARAM_RELATIONSHIP_DIRECTION, relationshipDirection);
+66          url.addParameter(Constants.PARAM_TYPE_ID, typeId);
+67          url.addParameter(Constants.PARAM_FILTER, filter);
+68          url.addParameter(Constants.PARAM_ALLOWABLE_ACTIONS, includeAllowableActions);
+69          url.addParameter(Constants.PARAM_MAX_ITEMS, maxItems);
+70          url.addParameter(Constants.PARAM_SKIP_COUNT, skipCount);
+71  
+72          // read and parse
+73          Response resp = read(url);
+74          AtomFeed feed = parse(resp.getStream(), AtomFeed.class);
+75  
+76          // handle top level
+77          for (AtomElement element : feed.getElements()) {
+78              if (element.getObject() instanceof AtomLink) {
+79                  if (isNextLink(element)) {
+80                      result.setHasMoreItems(Boolean.TRUE);
+81                  }
+82              } else if (isInt(NAME_NUM_ITEMS, element)) {
+83                  result.setNumItems((BigInteger) element.getObject());
+84              }
+85          }
+86  
+87          // get the children
+88          if (!feed.getEntries().isEmpty()) {
+89              result.setObjects(new ArrayList<ObjectData>(feed.getEntries().size()));
+90  
+91              for (AtomEntry entry : feed.getEntries()) {
+92                  ObjectData relationship = null;
+93  
+94                  lockLinks();
+95                  try {
+96                      // clean up cache
+97                      removeLinks(repositoryId, entry.getId());
+98  
+99                      // walk through the entry
+100                     for (AtomElement element : entry.getElements()) {
+101                         if (element.getObject() instanceof AtomLink) {
+102                             addLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
+103                         } else if (element.getObject() instanceof ObjectData) {
+104                             relationship = (ObjectData) element.getObject();
+105                         }
+106                     }
+107                 } finally {
+108                     unlockLinks();
+109                 }
+110 
+111                 if (relationship != null) {
+112                     result.getObjects().add(relationship);
+113                 }
+114             }
+115 
+116         }
+117 
+118         return result;
+119     }
+120 }
+
+
+ + Added: websites/staging/chemistry/trunk/content/java/0.13.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/atompub/RepositoryServiceImpl.html ============================================================================== --- websites/staging/chemistry/trunk/content/java/0.13.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/atompub/RepositoryServiceImpl.html (added) +++ websites/staging/chemistry/trunk/content/java/0.13.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/atompub/RepositoryServiceImpl.html Mon Apr 6 17:11:37 2015 @@ -0,0 +1,368 @@ + + + + +RepositoryServiceImpl xref + + + +
View Javadoc
+
+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 java.io.IOException;
+22  import java.io.OutputStream;
+23  import java.math.BigInteger;
+24  import java.util.ArrayList;
+25  import java.util.HashMap;
+26  import java.util.List;
+27  import java.util.Map;
+28  
+29  import javax.xml.stream.XMLStreamException;
+30  
+31  import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
+32  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomElement;
+33  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomEntry;
+34  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomFeed;
+35  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomLink;
+36  import org.apache.chemistry.opencmis.client.bindings.spi.http.Output;
+37  import org.apache.chemistry.opencmis.client.bindings.spi.http.Response;
+38  import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
+39  import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
+40  import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
+41  import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer;
+42  import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionList;
+43  import org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException;
+44  import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
+45  import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
+46  import org.apache.chemistry.opencmis.commons.impl.Constants;
+47  import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
+48  import org.apache.chemistry.opencmis.commons.impl.dataobjects.TypeDefinitionContainerImpl;
+49  import org.apache.chemistry.opencmis.commons.impl.dataobjects.TypeDefinitionListImpl;
+50  import org.apache.chemistry.opencmis.commons.spi.RepositoryService;
+51  
+52  /**
+53   * Repository Service AtomPub client.
+54   */
+55  public class RepositoryServiceImpl extends AbstractAtomPubService implements RepositoryService {
+56  
+57      /**
+58       * Constructor.
+59       */
+60      public RepositoryServiceImpl(BindingSession session) {
+61          setSession(session);
+62      }
+63  
+64      public List<RepositoryInfo> getRepositoryInfos(ExtensionsData extension) {
+65          return getRepositoriesInternal(null);
+66      }
+67  
+68      public RepositoryInfo getRepositoryInfo(String repositoryId, ExtensionsData extension) {
+69          List<RepositoryInfo> repositoryInfos = getRepositoriesInternal(repositoryId);
+70  
+71          if (repositoryInfos.isEmpty()) {
+72              throw new CmisObjectNotFoundException("Repository '" + repositoryId + "'not found!");
+73          }
+74  
+75          if (repositoryInfos.size() == 1) {
+76              return repositoryInfos.get(0);
+77          }
+78  
+79          // find the repository
+80          for (RepositoryInfo info : repositoryInfos) {
+81              if (info.getId() == null) {
+82                  continue;
+83              }
+84  
+85              if (info.getId().equals(repositoryId)) {
+86                  return info;
+87              }
+88          }
+89  
+90          throw new CmisObjectNotFoundException("Repository '" + repositoryId + "'not found!");
+91      }
+92  
+93      public TypeDefinition getTypeDefinition(String repositoryId, String typeId, ExtensionsData extension) {
+94          return getTypeDefinitionInternal(repositoryId, typeId);
+95      }
+96  
+97      public TypeDefinitionList getTypeChildren(String repositoryId, String typeId, Boolean includePropertyDefinitions,
+98              BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
+99          TypeDefinitionListImpl result = new TypeDefinitionListImpl();
+100 
+101         // find the link
+102         String link = null;
+103         if (typeId == null) {
+104             link = loadCollection(repositoryId, Constants.COLLECTION_TYPES);
+105         } else {
+106             link = loadTypeLink(repositoryId, typeId, Constants.REL_DOWN, Constants.MEDIATYPE_CHILDREN);
+107         }
+108 
+109         if (link == null) {
+110             throw new CmisObjectNotFoundException("Unknown repository or type!");
+111         }
+112 
+113         UrlBuilder url = new UrlBuilder(link);
+114         url.addParameter(Constants.PARAM_PROPERTY_DEFINITIONS, includePropertyDefinitions);
+115         url.addParameter(Constants.PARAM_MAX_ITEMS, maxItems);
+116         url.addParameter(Constants.PARAM_SKIP_COUNT, skipCount);
+117 
+118         // read and parse
+119         Response resp = read(url);
+120         AtomFeed feed = parse(resp.getStream(), AtomFeed.class);
+121 
+122         // handle top level
+123         for (AtomElement element : feed.getElements()) {
+124             if (element.getObject() instanceof AtomLink) {
+125                 if (isNextLink(element)) {
+126                     result.setHasMoreItems(Boolean.TRUE);
+127                 }
+128             } else if (isInt(NAME_NUM_ITEMS, element)) {
+129                 result.setNumItems((BigInteger) element.getObject());
+130             }
+131         }
+132 
+133         result.setList(new ArrayList<TypeDefinition>(feed.getEntries().size()));
+134 
+135         // get the children
+136         if (!feed.getEntries().isEmpty()) {
+137             for (AtomEntry entry : feed.getEntries()) {
+138                 TypeDefinition child = null;
+139 
+140                 lockTypeLinks();
+141                 try {
+142                     // walk through the entry
+143                     for (AtomElement element : entry.getElements()) {
+144                         if (element.getObject() instanceof AtomLink) {
+145                             addTypeLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
+146                         } else if (element.getObject() instanceof TypeDefinition) {
+147                             child = (TypeDefinition) element.getObject();
+148                         }
+149                     }
+150                 } finally {
+151                     unlockTypeLinks();
+152                 }
+153 
+154                 if (child != null) {
+155                     result.getList().add(child);
+156                 }
+157             }
+158         }
+159 
+160         return result;
+161     }
+162 
+163     public List<TypeDefinitionContainer> getTypeDescendants(String repositoryId, String typeId, BigInteger depth,
+164             Boolean includePropertyDefinitions, ExtensionsData extension) {
+165         List<TypeDefinitionContainer> result = new ArrayList<TypeDefinitionContainer>();
+166 
+167         // find the link
+168         String link = null;
+169         if (typeId == null) {
+170             link = loadRepositoryLink(repositoryId, Constants.REP_REL_TYPEDESC);
+171         } else {
+172             link = loadTypeLink(repositoryId, typeId, Constants.REL_DOWN, Constants.MEDIATYPE_DESCENDANTS);
+173         }
+174 
+175         if (link == null) {
+176             throw new CmisObjectNotFoundException("Unknown repository or type!");
+177         }
+178 
+179         UrlBuilder url = new UrlBuilder(link);
+180         url.addParameter(Constants.PARAM_DEPTH, depth);
+181         url.addParameter(Constants.PARAM_PROPERTY_DEFINITIONS, includePropertyDefinitions);
+182 
+183         // read and parse
+184         Response resp = read(url);
+185         AtomFeed feed = parse(resp.getStream(), AtomFeed.class);
+186 
+187         // process tree
+188         addTypeDescendantsLevel(repositoryId, feed, result);
+189 
+190         return result;
+191     }
+192 
+193     /**
+194      * Adds type descendants level recursively.
+195      */
+196     private void addTypeDescendantsLevel(String repositoryId, AtomFeed feed, List<TypeDefinitionContainer> containerList) {
+197         if (feed == null || feed.getEntries().isEmpty()) {
+198             return;
+199         }
+200 
+201         // walk through the feed
+202         for (AtomEntry entry : feed.getEntries()) {
+203             TypeDefinitionContainerImpl childContainer = null;
+204             List<TypeDefinitionContainer> childContainerList = new ArrayList<TypeDefinitionContainer>();
+205 
+206             // walk through the entry
+207             lockTypeLinks();
+208             try {
+209                 for (AtomElement element : entry.getElements()) {
+210                     if (element.getObject() instanceof AtomLink) {
+211                         addTypeLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
+212                     } else if (element.getObject() instanceof TypeDefinition) {
+213                         childContainer = new TypeDefinitionContainerImpl((TypeDefinition) element.getObject());
+214                     } else if (element.getObject() instanceof AtomFeed) {
+215                         addTypeDescendantsLevel(repositoryId, (AtomFeed) element.getObject(), childContainerList);
+216                     }
+217                 }
+218             } finally {
+219                 unlockTypeLinks();
+220             }
+221 
+222             if (childContainer != null) {
+223                 childContainer.setChildren(childContainerList);
+224                 containerList.add(childContainer);
+225             }
+226         }
+227     }
+228 
+229     public TypeDefinition createType(String repositoryId, TypeDefinition type, ExtensionsData extension) {
+230         if (type == null) {
+231             throw new CmisInvalidArgumentException("Type definition must be set!");
+232         }
+233 
+234         String parentId = type.getParentTypeId();
+235         if (parentId == null) {
+236             throw new CmisInvalidArgumentException("Type definition has no parent type id!");
+237         }
+238 
+239         // find the link
+240         String link = loadTypeLink(repositoryId, parentId, Constants.REL_DOWN, Constants.MEDIATYPE_CHILDREN);
+241 
+242         if (link == null) {
+243             throw new CmisObjectNotFoundException("Unknown repository or parent type!");
+244         }
+245 
+246         // set up writer
+247         final AtomEntryWriter entryWriter = new AtomEntryWriter(type, getCmisVersion(repositoryId));
+248 
+249         // post the new type definition
+250         Response resp = post(new UrlBuilder(link), Constants.MEDIATYPE_ENTRY, new Output() {
+251             public void write(OutputStream out) throws XMLStreamException, IOException {
+252                 entryWriter.write(out);
+253             }
+254         });
+255 
+256         // parse the response
+257         AtomEntry entry = parse(resp.getStream(), AtomEntry.class);
+258 
+259         // we expect a CMIS entry
+260         if (entry.getId() == null) {
+261             throw new CmisConnectionException("Received Atom entry is not a CMIS entry!");
+262         }
+263 
+264         lockTypeLinks();
+265         TypeDefinition result = null;
+266         try {
+267             // clean up cache
+268             removeTypeLinks(repositoryId, entry.getId());
+269 
+270             // walk through the entry
+271             for (AtomElement element : entry.getElements()) {
+272                 if (element.getObject() instanceof AtomLink) {
+273                     addTypeLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
+274                 } else if (element.getObject() instanceof TypeDefinition) {
+275                     result = (TypeDefinition) element.getObject();
+276                 }
+277             }
+278         } finally {
+279             unlockTypeLinks();
+280         }
+281 
+282         return result;
+283     }
+284 
+285     public TypeDefinition updateType(String repositoryId, TypeDefinition type, ExtensionsData extension) {
+286         if (type == null) {
+287             throw new CmisInvalidArgumentException("Type definition must be set!");
+288         }
+289 
+290         String typeId = type.getId();
+291         if (typeId == null) {
+292             throw new CmisInvalidArgumentException("Type definition has no type id!");
+293         }
+294 
+295         // find the link
+296         Map<String, Object> parameters = new HashMap<String, Object>();
+297         parameters.put(Constants.PARAM_ID, typeId);
+298 
+299         String link = loadTemplateLink(repositoryId, Constants.TEMPLATE_TYPE_BY_ID, parameters);
+300         if (link == null) {
+301             throw new CmisObjectNotFoundException("Unknown repository or type!");
+302         }
+303 
+304         // set up writer
+305         final AtomEntryWriter entryWriter = new AtomEntryWriter(type, getCmisVersion(repositoryId));
+306 
+307         // post the new type definition
+308         Response resp = put(new UrlBuilder(link), Constants.MEDIATYPE_ENTRY, new Output() {
+309             public void write(OutputStream out) throws XMLStreamException, IOException {
+310                 entryWriter.write(out);
+311             }
+312         });
+313 
+314         // parse the response
+315         AtomEntry entry = parse(resp.getStream(), AtomEntry.class);
+316 
+317         // we expect a CMIS entry
+318         if (entry.getId() == null) {
+319             throw new CmisConnectionException("Received Atom entry is not a CMIS entry!");
+320         }
+321 
+322         lockTypeLinks();
+323         TypeDefinition result = null;
+324         try {
+325             // clean up cache
+326             removeTypeLinks(repositoryId, entry.getId());
+327 
+328             // walk through the entry
+329             for (AtomElement element : entry.getElements()) {
+330                 if (element.getObject() instanceof AtomLink) {
+331                     addTypeLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
+332                 } else if (element.getObject() instanceof TypeDefinition) {
+333                     result = (TypeDefinition) element.getObject();
+334                 }
+335             }
+336         } finally {
+337             unlockTypeLinks();
+338         }
+339 
+340         return result;
+341     }
+342 
+343     public void deleteType(String repositoryId, String typeId, ExtensionsData extension) {
+344         Map<String, Object> parameters = new HashMap<String, Object>();
+345         parameters.put(Constants.PARAM_ID, typeId);
+346 
+347         String link = loadTemplateLink(repositoryId, Constants.TEMPLATE_TYPE_BY_ID, parameters);
+348         if (link == null) {
+349             throw new CmisObjectNotFoundException("Unknown repository!");
+350         }
+351 
+352         delete(new UrlBuilder(link));
+353     }
+354 }
+
+
+ +