This project has retired. For details please refer to its Attic page.
RepositoryService 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  import static org.apache.chemistry.opencmis.commons.impl.Converter.convertTypeContainerList;
23  
24  import java.math.BigInteger;
25  import java.util.ArrayList;
26  import java.util.List;
27  
28  import javax.annotation.Resource;
29  import javax.jws.WebService;
30  import javax.xml.ws.WebServiceContext;
31  import javax.xml.ws.soap.MTOM;
32  
33  import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
34  import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisException;
35  import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisExtensionType;
36  import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisRepositoryEntryType;
37  import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisRepositoryInfoType;
38  import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisTypeContainer;
39  import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisTypeDefinitionListType;
40  import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisTypeDefinitionType;
41  import org.apache.chemistry.opencmis.commons.impl.jaxb.RepositoryServicePort;
42  import org.apache.chemistry.opencmis.commons.server.CmisService;
43  
44  /**
45   * CMIS Repository Service.
46   */
47  @MTOM
48  @WebService(endpointInterface = "org.apache.chemistry.opencmis.commons.impl.jaxb.RepositoryServicePort")
49  public class RepositoryService extends AbstractService implements RepositoryServicePort {
50      @Resource
51      public WebServiceContext wsContext;
52  
53      public List<CmisRepositoryEntryType> getRepositories(CmisExtensionType extension) throws CmisException {
54          CmisService service = null;
55          try {
56              service = getService(wsContext, null);
57  
58              List<RepositoryInfo> infoDataList = service.getRepositoryInfos(convert(extension));
59  
60              if (infoDataList == null) {
61                  return null;
62              }
63  
64              List<CmisRepositoryEntryType> result = new ArrayList<CmisRepositoryEntryType>();
65              for (RepositoryInfo infoData : infoDataList) {
66                  CmisRepositoryEntryType entry = new CmisRepositoryEntryType();
67                  entry.setRepositoryId(infoData.getId());
68                  entry.setRepositoryName(infoData.getName());
69  
70                  result.add(entry);
71              }
72  
73              return result;
74          } catch (Exception e) {
75              throw convertException(e);
76          } finally {
77              closeService(service);
78          }
79      }
80  
81      public CmisRepositoryInfoType getRepositoryInfo(String repositoryId, CmisExtensionType extension)
82              throws CmisException {
83          CmisService service = null;
84          try {
85              service = getService(wsContext, repositoryId);
86  
87              return convert(service.getRepositoryInfo(repositoryId, convert(extension)));
88          } catch (Exception e) {
89              throw convertException(e);
90          } finally {
91              closeService(service);
92          }
93      }
94  
95      public CmisTypeDefinitionListType getTypeChildren(String repositoryId, String typeId,
96              Boolean includePropertyDefinitions, BigInteger maxItems, BigInteger skipCount, CmisExtensionType extension)
97              throws CmisException {
98          CmisService service = null;
99          try {
100             service = getService(wsContext, repositoryId);
101 
102             return convert(service.getTypeChildren(repositoryId, typeId, includePropertyDefinitions, maxItems,
103                     skipCount, convert(extension)));
104         } catch (Exception e) {
105             throw convertException(e);
106         } finally {
107             closeService(service);
108         }
109     }
110 
111     public CmisTypeDefinitionType getTypeDefinition(String repositoryId, String typeId, CmisExtensionType extension)
112             throws CmisException {
113         CmisService service = null;
114         try {
115             service = getService(wsContext, repositoryId);
116 
117             return convert(service.getTypeDefinition(repositoryId, typeId, convert(extension)));
118         } catch (Exception e) {
119             throw convertException(e);
120         } finally {
121             closeService(service);
122         }
123     }
124 
125     public List<CmisTypeContainer> getTypeDescendants(String repositoryId, String typeId, BigInteger depth,
126             Boolean includePropertyDefinitions, CmisExtensionType extension) throws CmisException {
127         CmisService service = null;
128         try {
129             service = getService(wsContext, repositoryId);
130 
131             List<CmisTypeContainer> result = new ArrayList<CmisTypeContainer>();
132             convertTypeContainerList(service.getTypeDescendants(repositoryId, typeId, depth,
133                     includePropertyDefinitions, convert(extension)), result);
134 
135             return result;
136         } catch (Exception e) {
137             throw convertException(e);
138         } finally {
139             closeService(service);
140         }
141     }
142 }