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 javax.ws.rs.GET;
\r
27 import javax.ws.rs.Path;
\r
28 import javax.ws.rs.Produces;
\r
30 import org.collectionspace.services.common.context.ServiceContext;
\r
31 import org.collectionspace.services.common.document.DocumentHandler;
\r
32 import org.collectionspace.services.common.repository.RepositoryClient;
\r
33 import org.collectionspace.services.common.repository.RepositoryClientFactory;
\r
34 import org.collectionspace.services.common.storage.StorageClient;
\r
35 import org.collectionspace.services.common.storage.jpa.JpaStorageClientImpl;
\r
38 * The Class AbstractCollectionSpaceResource.
\r
40 public abstract class AbstractCollectionSpaceResourceImpl
\r
41 implements CollectionSpaceResource {
\r
43 // Fields for default client factory and client
\r
44 /** The repository client factory. */
\r
45 private RepositoryClientFactory repositoryClientFactory;
\r
47 /** The repository client. */
\r
48 private RepositoryClient repositoryClient;
\r
50 /** The storage client. */
\r
51 private StorageClient storageClient;
\r
54 * Instantiates a new abstract collection space resource.
\r
56 public AbstractCollectionSpaceResourceImpl() {
\r
57 repositoryClientFactory = RepositoryClientFactory.getInstance();
\r
61 * @see org.collectionspace.services.common.CollectionSpaceResource#getServiceName()
\r
64 abstract public String getServiceName();
\r
68 * @see org.collectionspace.services.common.CollectionSpaceResource#getRepositoryClient(org.collectionspace.services.common.context.ServiceContext)
\r
71 synchronized public RepositoryClient getRepositoryClient(ServiceContext ctx) {
\r
72 if(repositoryClient != null){
\r
73 return repositoryClient;
\r
75 repositoryClient = repositoryClientFactory.getClient(ctx.getRepositoryClientName());
\r
76 return repositoryClient;
\r
80 * @see org.collectionspace.services.common.CollectionSpaceResource#getStorageClient(org.collectionspace.services.common.context.ServiceContext)
\r
83 synchronized public StorageClient getStorageClient(ServiceContext ctx) {
\r
84 if(storageClient != null) {
\r
85 return storageClient;
\r
87 storageClient = new JpaStorageClientImpl();
\r
88 return storageClient;
\r
92 * @see org.collectionspace.services.common.CollectionSpaceResource#createDocumentHandler(org.collectionspace.services.common.context.ServiceContext)
\r
95 abstract public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception ;
\r
98 * Gets the version string.
\r
100 * @return the version string
\r
102 abstract protected String getVersionString();
\r
105 * Gets the version.
\r
107 * @return the version
\r
111 @Produces("application/xml")
\r
112 public Version getVersion() {
\r
113 Version result = new Version();
\r
115 result.setVersionString(getVersionString());
\r