View Javadoc

1   /*
2    *
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *   http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   *
20   */
21  package org.apache.chemistry.opencmis.client.bindings.spi.local;
22  
23  import java.math.BigInteger;
24  import java.util.List;
25  
26  import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
27  import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
28  import org.apache.chemistry.opencmis.commons.data.ObjectData;
29  import org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer;
30  import org.apache.chemistry.opencmis.commons.data.ObjectInFolderList;
31  import org.apache.chemistry.opencmis.commons.data.ObjectList;
32  import org.apache.chemistry.opencmis.commons.data.ObjectParentData;
33  import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
34  import org.apache.chemistry.opencmis.commons.server.CmisService;
35  import org.apache.chemistry.opencmis.commons.server.CmisServiceFactory;
36  import org.apache.chemistry.opencmis.commons.spi.NavigationService;
37  
38  public class NavigationServiceImpl extends AbstractLocalService implements NavigationService {
39  
40      /**
41       * Constructor.
42       */
43      public NavigationServiceImpl(BindingSession session, CmisServiceFactory factory) {
44          setSession(session);
45          setServiceFactory(factory);
46      }
47  
48      @Override
49      public ObjectList getCheckedOutDocs(String repositoryId, String folderId, String filter, String orderBy,
50              Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
51              BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
52          CmisService service = getService(repositoryId);
53  
54          try {
55              if (stopBeforeService(service)) {
56                  return null;
57              }
58              ObjectList serviceResult = service.getCheckedOutDocs(repositoryId, folderId, filter, orderBy,
59                      includeAllowableActions, includeRelationships, renditionFilter, maxItems, skipCount, extension);
60  
61              if (stopAfterService(service)) {
62                  return null;
63              }
64  
65              return serviceResult;
66          } finally {
67              service.close();
68          }
69      }
70  
71      @Override
72      public ObjectInFolderList getChildren(String repositoryId, String folderId, String filter, String orderBy,
73              Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
74              Boolean includePathSegment, BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
75          CmisService service = getService(repositoryId);
76  
77          try {
78              if (stopBeforeService(service)) {
79                  return null;
80              }
81  
82              ObjectInFolderList serviceResult = service.getChildren(repositoryId, folderId, filter, orderBy,
83                      includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, maxItems,
84                      skipCount, extension);
85  
86              if (stopAfterService(service)) {
87                  return null;
88              }
89  
90              return serviceResult;
91          } finally {
92              service.close();
93          }
94      }
95  
96      @Override
97      public List<ObjectInFolderContainer> getDescendants(String repositoryId, String folderId, BigInteger depth,
98              String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
99              String renditionFilter, Boolean includePathSegment, ExtensionsData extension) {
100         CmisService service = getService(repositoryId);
101 
102         try {
103             if (stopBeforeService(service)) {
104                 return null;
105             }
106             List<ObjectInFolderContainer> serviceResult = service.getDescendants(repositoryId, folderId, depth, filter,
107                     includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, extension);
108 
109             if (stopAfterService(service)) {
110                 return null;
111             }
112 
113             return serviceResult;
114         } finally {
115             service.close();
116         }
117     }
118 
119     @Override
120     public ObjectData getFolderParent(String repositoryId, String folderId, String filter, ExtensionsData extension) {
121         CmisService service = getService(repositoryId);
122 
123         try {
124             if (stopBeforeService(service)) {
125                 return null;
126             }
127 
128             ObjectData serviceResult = service.getFolderParent(repositoryId, folderId, filter, extension);
129 
130             if (stopAfterService(service)) {
131                 return null;
132             }
133 
134             return serviceResult;
135         } finally {
136             service.close();
137         }
138     }
139 
140     @Override
141     public List<ObjectInFolderContainer> getFolderTree(String repositoryId, String folderId, BigInteger depth,
142             String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
143             String renditionFilter, Boolean includePathSegment, ExtensionsData extension) {
144         CmisService service = getService(repositoryId);
145 
146         try {
147             if (stopBeforeService(service)) {
148                 return null;
149             }
150 
151             List<ObjectInFolderContainer> serviceResult = service.getFolderTree(repositoryId, folderId, depth, filter,
152                     includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, extension);
153 
154             if (stopAfterService(service)) {
155                 return null;
156             }
157             return serviceResult;
158         } finally {
159             service.close();
160         }
161     }
162 
163     @Override
164     public List<ObjectParentData> getObjectParents(String repositoryId, String objectId, String filter,
165             Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
166             Boolean includeRelativePathSegment, ExtensionsData extension) {
167         CmisService service = getService(repositoryId);
168 
169         try {
170             if (stopBeforeService(service)) {
171                 return null;
172             }
173 
174             List<ObjectParentData> serviceResult = service.getObjectParents(repositoryId, objectId, filter,
175                     includeAllowableActions, includeRelationships, renditionFilter, includeRelativePathSegment,
176                     extension);
177 
178             if (stopAfterService(service)) {
179                 return null;
180             }
181 
182             return serviceResult;
183         } finally {
184             service.close();
185         }
186     }
187 }