This project has retired. For details please refer to its Attic page.
CmisWebServicesSpi 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.client.bindings.spi.webservices;
20  
21  import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
22  import org.apache.chemistry.opencmis.client.bindings.spi.CmisSpi;
23  import org.apache.chemistry.opencmis.commons.SessionParameter;
24  import org.apache.chemistry.opencmis.commons.spi.AclService;
25  import org.apache.chemistry.opencmis.commons.spi.DiscoveryService;
26  import org.apache.chemistry.opencmis.commons.spi.MultiFilingService;
27  import org.apache.chemistry.opencmis.commons.spi.NavigationService;
28  import org.apache.chemistry.opencmis.commons.spi.ObjectService;
29  import org.apache.chemistry.opencmis.commons.spi.PolicyService;
30  import org.apache.chemistry.opencmis.commons.spi.RelationshipService;
31  import org.apache.chemistry.opencmis.commons.spi.RepositoryService;
32  import org.apache.chemistry.opencmis.commons.spi.VersioningService;
33  import org.apache.commons.logging.Log;
34  import org.apache.commons.logging.LogFactory;
35  
36  /**
37   * CMIS Web Services SPI implementation.
38   */
39  public class CmisWebServicesSpi implements CmisSpi {
40  
41      private static final Log log = LogFactory.getLog(CmisWebServicesSpi.class);
42  
43      private final RepositoryService repositoryService;
44      private final NavigationService navigationService;
45      private final ObjectService objectService;
46      private final VersioningService versioningService;
47      private final DiscoveryService discoveryService;
48      private final MultiFilingService multiFilingService;
49      private final RelationshipService relationshipService;
50      private final PolicyService policyService;
51      private final AclService aclService;
52  
53      /**
54       * Constructor.
55       */
56      public CmisWebServicesSpi(BindingSession session) {
57          if (log.isDebugEnabled()) {
58              log.debug("Initializing Web Services SPI...");
59          }
60  
61          AbstractPortProvider portProvider = null;
62  
63          String portProviderClass = (String) session.get(SessionParameter.WEBSERVICES_PORT_PROVIDER_CLASS);
64          if (portProviderClass == null) {
65              portProvider = new PortProvider();
66          } else {
67              Object portProviderObj = null;
68  
69              try {
70                  portProviderObj = Class.forName(portProviderClass).newInstance();
71              } catch (Exception e) {
72                  throw new IllegalArgumentException("Could not load port provider: " + e, e);
73              }
74  
75              if (!(portProviderObj instanceof AbstractPortProvider)) {
76                  throw new IllegalArgumentException("Port provider does not implement AbstractPortProvider!");
77              }
78              portProvider = (AbstractPortProvider) portProviderObj;
79          }
80  
81          portProvider.setSession(session);
82  
83          repositoryService = new RepositoryServiceImpl(session, portProvider);
84          navigationService = new NavigationServiceImpl(session, portProvider);
85          objectService = new ObjectServiceImpl(session, portProvider);
86          versioningService = new VersioningServiceImpl(session, portProvider);
87          discoveryService = new DiscoveryServiceImpl(session, portProvider);
88          multiFilingService = new MultiFilingServiceImpl(session, portProvider);
89          relationshipService = new RelationshipServiceImpl(session, portProvider);
90          policyService = new PolicyServiceImpl(session, portProvider);
91          aclService = new AclServiceImpl(session, portProvider);
92      }
93  
94      public RepositoryService getRepositoryService() {
95          return repositoryService;
96      }
97  
98      public NavigationService getNavigationService() {
99          return navigationService;
100     }
101 
102     public ObjectService getObjectService() {
103         return objectService;
104     }
105 
106     public DiscoveryService getDiscoveryService() {
107         return discoveryService;
108     }
109 
110     public VersioningService getVersioningService() {
111         return versioningService;
112     }
113 
114     public MultiFilingService getMultiFilingService() {
115         return multiFilingService;
116     }
117 
118     public RelationshipService getRelationshipService() {
119         return relationshipService;
120     }
121 
122     public PolicyService getPolicyService() {
123         return policyService;
124     }
125 
126     public AclService getAclService() {
127         return aclService;
128     }
129 
130     public void clearAllCaches() {
131     }
132 
133     public void clearRepositoryCache(String repositoryId) {
134     }
135 
136     public void close() {
137         // no-op for Web Services
138     }
139 }