This project has retired. For details please refer to its Attic page.
NavigationService 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.webservices;
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 javax.annotation.Resource;
28  import javax.jws.WebService;
29  import javax.xml.ws.WebServiceContext;
30  import javax.xml.ws.soap.MTOM;
31  
32  import org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer;
33  import org.apache.chemistry.opencmis.commons.data.ObjectParentData;
34  import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
35  import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisException;
36  import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisExtensionType;
37  import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectInFolderContainerType;
38  import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectInFolderListType;
39  import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectListType;
40  import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectParentsType;
41  import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectType;
42  import org.apache.chemistry.opencmis.commons.impl.jaxb.EnumIncludeRelationships;
43  import org.apache.chemistry.opencmis.commons.impl.jaxb.NavigationServicePort;
44  import org.apache.chemistry.opencmis.commons.server.CmisService;
45  
46  /**
47   * CMIS Navigation Service.
48   */
49  @MTOM
50  @WebService(endpointInterface = "org.apache.chemistry.opencmis.commons.impl.jaxb.NavigationServicePort")
51  public class NavigationService extends AbstractService implements NavigationServicePort {
52      @Resource
53      public WebServiceContext wsContext;
54  
55      public CmisObjectListType getCheckedOutDocs(String repositoryId, String folderId, String filter, String orderBy,
56              Boolean includeAllowableActions, EnumIncludeRelationships includeRelationships, String renditionFilter,
57              BigInteger maxItems, BigInteger skipCount, CmisExtensionType extension) throws CmisException {
58          CmisService service = null;
59          try {
60              service = getService(wsContext, repositoryId);
61  
62              return convert(service.getCheckedOutDocs(repositoryId, folderId, filter, orderBy, includeAllowableActions,
63                      convert(IncludeRelationships.class, includeRelationships), renditionFilter, maxItems, skipCount,
64                      convert(extension)));
65          } catch (Exception e) {
66              throw convertException(e);
67          } finally {
68              closeService(service);
69          }
70      }
71  
72      public CmisObjectInFolderListType getChildren(String repositoryId, String folderId, String filter, String orderBy,
73              Boolean includeAllowableActions, EnumIncludeRelationships includeRelationships, String renditionFilter,
74              Boolean includePathSegment, BigInteger maxItems, BigInteger skipCount, CmisExtensionType extension)
75              throws CmisException {
76          CmisService service = null;
77          try {
78              service = getService(wsContext, repositoryId);
79  
80              return convert(service.getChildren(repositoryId, folderId, filter, orderBy, includeAllowableActions,
81                      convert(IncludeRelationships.class, includeRelationships), renditionFilter, includePathSegment,
82                      maxItems, skipCount, convert(extension)));
83          } catch (Exception e) {
84              throw convertException(e);
85          } finally {
86              closeService(service);
87          }
88      }
89  
90      public List<CmisObjectInFolderContainerType> getDescendants(String repositoryId, String folderId, BigInteger depth,
91              String filter, Boolean includeAllowableActions, EnumIncludeRelationships includeRelationships,
92              String renditionFilter, Boolean includePathSegment, CmisExtensionType extension) throws CmisException {
93          CmisService service = null;
94          try {
95              service = getService(wsContext, repositoryId);
96  
97              List<CmisObjectInFolderContainerType> result = new ArrayList<CmisObjectInFolderContainerType>();
98  
99              List<ObjectInFolderContainer> serviceResult = service.getDescendants(repositoryId, folderId, depth, filter,
100                     includeAllowableActions, convert(IncludeRelationships.class, includeRelationships),
101                     renditionFilter, includePathSegment, convert(extension));
102 
103             if (serviceResult != null) {
104                 for (ObjectInFolderContainer container : serviceResult) {
105                     result.add(convert(container));
106                 }
107             }
108 
109             return result;
110         } catch (Exception e) {
111             throw convertException(e);
112         } finally {
113             closeService(service);
114         }
115     }
116 
117     public CmisObjectType getFolderParent(String repositoryId, String folderId, String filter,
118             CmisExtensionType extension) throws CmisException {
119         CmisService service = null;
120         try {
121             service = getService(wsContext, repositoryId);
122 
123             return convert(service.getFolderParent(repositoryId, folderId, filter, convert(extension)));
124         } catch (Exception e) {
125             throw convertException(e);
126         } finally {
127             closeService(service);
128         }
129     }
130 
131     public List<CmisObjectInFolderContainerType> getFolderTree(String repositoryId, String folderId, BigInteger depth,
132             String filter, Boolean includeAllowableActions, EnumIncludeRelationships includeRelationships,
133             String renditionFilter, Boolean includePathSegment, CmisExtensionType extension) throws CmisException {
134         CmisService service = null;
135         try {
136             service = getService(wsContext, repositoryId);
137 
138             List<CmisObjectInFolderContainerType> result = new ArrayList<CmisObjectInFolderContainerType>();
139 
140             List<ObjectInFolderContainer> serviceResult = service.getFolderTree(repositoryId, folderId, depth, filter,
141                     includeAllowableActions, convert(IncludeRelationships.class, includeRelationships),
142                     renditionFilter, includePathSegment, convert(extension));
143 
144             if (serviceResult != null) {
145                 for (ObjectInFolderContainer container : serviceResult) {
146                     result.add(convert(container));
147                 }
148             }
149 
150             return result;
151         } catch (Exception e) {
152             throw convertException(e);
153         } finally {
154             closeService(service);
155         }
156     }
157 
158     public List<CmisObjectParentsType> getObjectParents(String repositoryId, String objectId, String filter,
159             Boolean includeAllowableActions, EnumIncludeRelationships includeRelationships, String renditionFilter,
160             Boolean includeRelativePathSegment, CmisExtensionType extension) throws CmisException {
161         CmisService service = null;
162         try {
163             service = getService(wsContext, repositoryId);
164 
165             List<CmisObjectParentsType> result = new ArrayList<CmisObjectParentsType>();
166 
167             List<ObjectParentData> serviceResult = service.getObjectParents(repositoryId, objectId, filter,
168                     includeAllowableActions, convert(IncludeRelationships.class, includeRelationships),
169                     renditionFilter, includeRelativePathSegment, convert(extension));
170 
171             if (serviceResult != null) {
172                 for (ObjectParentData parent : serviceResult) {
173                     result.add(convert(parent));
174                 }
175             }
176 
177             return result;
178         } catch (Exception e) {
179             throw convertException(e);
180         } finally {
181             closeService(service);
182         }
183     }
184 }