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.server.impl.webservices;
20  
21  import org.apache.chemistry.opencmis.commons.data.ObjectList;
22  import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
23  import static org.apache.chemistry.opencmis.commons.impl.Converter.convert;
24  import static org.apache.chemistry.opencmis.commons.impl.Converter.convertHolder;
25  import static org.apache.chemistry.opencmis.commons.impl.Converter.setHolderValue;
26  import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisException;
27  import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisExtensionType;
28  import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectListType;
29  import org.apache.chemistry.opencmis.commons.impl.jaxb.DiscoveryServicePort;
30  import org.apache.chemistry.opencmis.commons.impl.jaxb.EnumIncludeRelationships;
31  import org.apache.chemistry.opencmis.commons.server.CmisService;
32  
33  import java.math.BigInteger;
34  
35  import javax.annotation.Resource;
36  
37  import javax.jws.WebService;
38  
39  import javax.xml.ws.Holder;
40  import javax.xml.ws.WebServiceContext;
41  import javax.xml.ws.soap.MTOM;
42  
43  
44  /**
45   * CMIS Discovery Service.
46   */
47  @MTOM
48  @WebService( endpointInterface = "org.apache.chemistry.opencmis.commons.impl.jaxb.DiscoveryServicePort" )
49  public class DiscoveryService extends AbstractService implements DiscoveryServicePort
50  {
51      @Resource
52      public WebServiceContext wsContext;
53  
54      public void getContentChanges( String repositoryId, Holder<String> changeLogToken, Boolean includeProperties,
55          String filter, Boolean includePolicyIds, Boolean includeAcl, BigInteger maxItems, CmisExtensionType extension,
56          Holder<CmisObjectListType> objects ) throws CmisException
57      {
58          CmisService service = null;
59  
60          try
61          {
62              service = getService( wsContext, repositoryId );
63  
64              org.apache.chemistry.opencmis.commons.spi.Holder<String> changeLogTokenHolder = convertHolder( changeLogToken );
65  
66              ObjectList changesList = service.getContentChanges( repositoryId, changeLogTokenHolder, includeProperties,
67                      filter, includePolicyIds, includeAcl, maxItems, convert( extension ) );
68  
69              if ( objects != null )
70              {
71                  objects.value = convert( changesList );
72              }
73  
74              setHolderValue( changeLogTokenHolder, changeLogToken );
75          }
76          catch ( Exception e )
77          {
78              throw convertException( e );
79          }
80          finally
81          {
82              closeService( service );
83          }
84      }
85  
86      public CmisObjectListType query( String repositoryId, String statement, Boolean searchAllVersions,
87          Boolean includeAllowableActions, EnumIncludeRelationships includeRelationships, String renditionFilter,
88          BigInteger maxItems, BigInteger skipCount, CmisExtensionType extension )
89          throws CmisException
90      {
91          CmisService service = null;
92  
93          try
94          {
95              service = getService( wsContext, repositoryId );
96  
97              return convert( service.query( repositoryId, statement, searchAllVersions, includeAllowableActions,
98                      convert( IncludeRelationships.class, includeRelationships ), renditionFilter, maxItems, skipCount,
99                      convert( extension ) ) );
100         }
101         catch ( Exception e )
102         {
103             throw convertException( e );
104         }
105         finally
106         {
107             closeService( service );
108         }
109     }
110 }