1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.chemistry.opencmis.server.impl.webservices;
20
21 import org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer;
22 import org.apache.chemistry.opencmis.commons.data.ObjectParentData;
23 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
24 import static org.apache.chemistry.opencmis.commons.impl.Converter.convert;
25 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisException;
26 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisExtensionType;
27 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectInFolderContainerType;
28 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectInFolderListType;
29 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectListType;
30 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectParentsType;
31 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectType;
32 import org.apache.chemistry.opencmis.commons.impl.jaxb.EnumIncludeRelationships;
33 import org.apache.chemistry.opencmis.commons.impl.jaxb.NavigationServicePort;
34 import org.apache.chemistry.opencmis.commons.server.CmisService;
35
36 import java.math.BigInteger;
37
38 import java.util.ArrayList;
39 import java.util.List;
40
41 import javax.annotation.Resource;
42
43 import javax.jws.WebService;
44
45 import javax.xml.ws.WebServiceContext;
46 import javax.xml.ws.soap.MTOM;
47
48
49
50
51
52 @MTOM
53 @WebService( endpointInterface = "org.apache.chemistry.opencmis.commons.impl.jaxb.NavigationServicePort" )
54 public class NavigationService extends AbstractService implements NavigationServicePort
55 {
56 @Resource
57 public WebServiceContext wsContext;
58
59 public CmisObjectListType getCheckedOutDocs( String repositoryId, String folderId, String filter, String orderBy,
60 Boolean includeAllowableActions, EnumIncludeRelationships includeRelationships, String renditionFilter,
61 BigInteger maxItems, BigInteger skipCount, CmisExtensionType extension )
62 throws CmisException
63 {
64 CmisService service = null;
65
66 try
67 {
68 service = getService( wsContext, repositoryId );
69
70 return convert( service.getCheckedOutDocs( repositoryId, folderId, filter, orderBy,
71 includeAllowableActions, convert( IncludeRelationships.class, includeRelationships ),
72 renditionFilter, maxItems, skipCount, convert( extension ) ) );
73 }
74 catch ( Exception e )
75 {
76 throw convertException( e );
77 }
78 finally
79 {
80 closeService( service );
81 }
82 }
83
84 public CmisObjectInFolderListType getChildren( String repositoryId, String folderId, String filter, String orderBy,
85 Boolean includeAllowableActions, EnumIncludeRelationships includeRelationships, String renditionFilter,
86 Boolean includePathSegment, BigInteger maxItems, BigInteger skipCount, CmisExtensionType extension )
87 throws CmisException
88 {
89 CmisService service = null;
90
91 try
92 {
93 service = getService( wsContext, repositoryId );
94
95 return convert( service.getChildren( repositoryId, folderId, filter, orderBy, includeAllowableActions,
96 convert( IncludeRelationships.class, includeRelationships ), renditionFilter, includePathSegment,
97 maxItems, skipCount, convert( extension ) ) );
98 }
99 catch ( Exception e )
100 {
101 throw convertException( e );
102 }
103 finally
104 {
105 closeService( service );
106 }
107 }
108
109 public List<CmisObjectInFolderContainerType> getDescendants( String repositoryId, String folderId,
110 BigInteger depth, String filter, Boolean includeAllowableActions,
111 EnumIncludeRelationships includeRelationships, String renditionFilter, Boolean includePathSegment,
112 CmisExtensionType extension ) throws CmisException
113 {
114 CmisService service = null;
115
116 try
117 {
118 service = getService( wsContext, repositoryId );
119
120 List<CmisObjectInFolderContainerType> result = new ArrayList<CmisObjectInFolderContainerType>( );
121
122 List<ObjectInFolderContainer> serviceResult = service.getDescendants( repositoryId, folderId, depth,
123 filter, includeAllowableActions, convert( IncludeRelationships.class, includeRelationships ),
124 renditionFilter, includePathSegment, convert( extension ) );
125
126 if ( serviceResult != null )
127 {
128 for ( ObjectInFolderContainer container : serviceResult )
129 {
130 result.add( convert( container ) );
131 }
132 }
133
134 return result;
135 }
136 catch ( Exception e )
137 {
138 throw convertException( e );
139 }
140 finally
141 {
142 closeService( service );
143 }
144 }
145
146 public CmisObjectType getFolderParent( String repositoryId, String folderId, String filter,
147 CmisExtensionType extension ) throws CmisException
148 {
149 CmisService service = null;
150
151 try
152 {
153 service = getService( wsContext, repositoryId );
154
155 return convert( service.getFolderParent( repositoryId, folderId, filter, convert( extension ) ) );
156 }
157 catch ( Exception e )
158 {
159 throw convertException( e );
160 }
161 finally
162 {
163 closeService( service );
164 }
165 }
166
167 public List<CmisObjectInFolderContainerType> getFolderTree( String repositoryId, String folderId, BigInteger depth,
168 String filter, Boolean includeAllowableActions, EnumIncludeRelationships includeRelationships,
169 String renditionFilter, Boolean includePathSegment, CmisExtensionType extension )
170 throws CmisException
171 {
172 CmisService service = null;
173
174 try
175 {
176 service = getService( wsContext, repositoryId );
177
178 List<CmisObjectInFolderContainerType> result = new ArrayList<CmisObjectInFolderContainerType>( );
179
180 List<ObjectInFolderContainer> serviceResult = service.getFolderTree( repositoryId, folderId, depth, filter,
181 includeAllowableActions, convert( IncludeRelationships.class, includeRelationships ),
182 renditionFilter, includePathSegment, convert( extension ) );
183
184 if ( serviceResult != null )
185 {
186 for ( ObjectInFolderContainer container : serviceResult )
187 {
188 result.add( convert( container ) );
189 }
190 }
191
192 return result;
193 }
194 catch ( Exception e )
195 {
196 throw convertException( e );
197 }
198 finally
199 {
200 closeService( service );
201 }
202 }
203
204 public List<CmisObjectParentsType> getObjectParents( String repositoryId, String objectId, String filter,
205 Boolean includeAllowableActions, EnumIncludeRelationships includeRelationships, String renditionFilter,
206 Boolean includeRelativePathSegment, CmisExtensionType extension )
207 throws CmisException
208 {
209 CmisService service = null;
210
211 try
212 {
213 service = getService( wsContext, repositoryId );
214
215 List<CmisObjectParentsType> result = new ArrayList<CmisObjectParentsType>( );
216
217 List<ObjectParentData> serviceResult = service.getObjectParents( repositoryId, objectId, filter,
218 includeAllowableActions, convert( IncludeRelationships.class, includeRelationships ),
219 renditionFilter, includeRelativePathSegment, convert( extension ) );
220
221 if ( serviceResult != null )
222 {
223 for ( ObjectParentData parent : serviceResult )
224 {
225 result.add( convert( parent ) );
226 }
227 }
228
229 return result;
230 }
231 catch ( Exception e )
232 {
233 throw convertException( e );
234 }
235 finally
236 {
237 closeService( service );
238 }
239 }
240 }