2 * This document is a part of the source code and related artifacts
\r
3 * for CollectionSpace, an open source collections management system
\r
4 * for museums and related institutions:
\r
6 * http://www.collectionspace.org
\r
7 * http://wiki.collectionspace.org
\r
9 * Copyright 2009 University of California at Berkeley
\r
11 * Licensed under the Educational Community License (ECL), Version 2.0.
\r
12 * You may not use this file except in compliance with this License.
\r
14 * You may obtain a copy of the ECL 2.0 License at
\r
16 * https://source.collectionspace.org/collection-space/LICENSE.txt
\r
18 * Unless required by applicable law or agreed to in writing, software
\r
19 * distributed under the License is distributed on an "AS IS" BASIS,
\r
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
21 * See the License for the specific language governing permissions and
\r
22 * limitations under the License.
\r
24 package org.collectionspace.services.common;
\r
26 import org.collectionspace.services.common.context.RemoteServiceContext;
\r
27 import org.collectionspace.services.common.context.ServiceContext;
\r
28 import org.collectionspace.services.common.context.RemoteServiceContextImpl;
\r
29 import org.collectionspace.services.common.document.DocumentHandler;
\r
30 import org.collectionspace.services.common.repository.RepositoryClient;
\r
31 import org.collectionspace.services.common.repository.RepositoryClientFactory;
\r
32 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
\r
34 public abstract class AbstractCollectionSpaceResource
\r
35 implements CollectionSpaceResource {
\r
37 // Fields for default client factory and client
\r
38 private RepositoryClientFactory repositoryClientFactory;
\r
39 private RepositoryClient repositoryClient;
\r
41 public AbstractCollectionSpaceResource() {
\r
42 repositoryClientFactory = RepositoryClientFactory.getInstance();
\r
46 abstract public String getServiceName();
\r
49 public RepositoryClientFactory getRepositoryClientFactory() {
\r
50 return repositoryClientFactory;
\r
54 synchronized public RepositoryClient getRepositoryClient(ServiceContext ctx) {
\r
55 if(repositoryClient != null){
\r
56 return repositoryClient;
\r
58 repositoryClient = repositoryClientFactory.getClient(ctx.getRepositoryClientName());
\r
59 return repositoryClient;
\r
63 public RemoteServiceContext createServiceContext(MultipartInput input) throws Exception {
\r
64 return createServiceContext(input,getServiceName());
\r
68 public RemoteServiceContext createServiceContext(MultipartInput input, String serviceName) throws Exception {
\r
69 RemoteServiceContext ctx = new RemoteServiceContextImpl(serviceName);
\r
70 ctx.setInput(input);
\r
75 abstract public DocumentHandler createDocumentHandler(RemoteServiceContext ctx) throws Exception ;
\r