From c5a412cf67a9d894aede4e478215722b5dded88a Mon Sep 17 00:00:00 2001 From: Sanjay Dalal Date: Fri, 2 Oct 2009 17:42:12 +0000 Subject: [PATCH] CSPACE-60 introduced DocumentHandlerFactory interface that is implemented by all services tests: mvn test passes at trunk/services level M services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/CollectionObjectHandlerFactory.java M services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/nuxeo/AcquisitionHandlerFactory.java A services/common/src/main/java/org/collectionspace/services/common/repository/DocumentHandlerFactory.java D services/common/src/main/java/org/collectionspace/services/common/CollectionSpaceHandlerFactory.java M services/intake/service/src/main/java/org/collectionspace/services/intake/nuxeo/IntakeHandlerFactory.java M services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationHandlerFactory.java --- .../nuxeo/AcquisitionHandlerFactory.java | 4 +- .../nuxeo/CollectionObjectHandlerFactory.java | 4 +- .../DocumentHandlerFactory.java} | 75 ++++++++++--------- .../intake/nuxeo/IntakeHandlerFactory.java | 4 +- .../nuxeo/RelationHandlerFactory.java | 4 +- 5 files changed, 49 insertions(+), 42 deletions(-) rename services/common/src/main/java/org/collectionspace/services/common/{CollectionSpaceHandlerFactory.java => repository/DocumentHandlerFactory.java} (67%) diff --git a/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/nuxeo/AcquisitionHandlerFactory.java b/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/nuxeo/AcquisitionHandlerFactory.java index 163837336..b1522e1e6 100644 --- a/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/nuxeo/AcquisitionHandlerFactory.java +++ b/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/nuxeo/AcquisitionHandlerFactory.java @@ -25,6 +25,7 @@ package org.collectionspace.services.acquisition.nuxeo; import org.collectionspace.services.common.ClientType; import org.collectionspace.services.common.repository.DocumentHandler; +import org.collectionspace.services.common.repository.DocumentHandlerFactory; /** * AcquisitionHandlerFactory creates handlers for acquisition based @@ -33,7 +34,7 @@ import org.collectionspace.services.common.repository.DocumentHandler; * $LastChangedRevision: $ * $LastChangedDate: $ */ -public class AcquisitionHandlerFactory { +public class AcquisitionHandlerFactory implements DocumentHandlerFactory { private static final AcquisitionHandlerFactory self = new AcquisitionHandlerFactory(); @@ -44,6 +45,7 @@ public class AcquisitionHandlerFactory { return self; } + @Override public DocumentHandler getHandler(String clientType) { if(ClientType.JAVA.toString().equals(clientType)){ return new AcquisitionDocumentModelHandler(); diff --git a/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/CollectionObjectHandlerFactory.java b/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/CollectionObjectHandlerFactory.java index a7de6e827..df91d5468 100644 --- a/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/CollectionObjectHandlerFactory.java +++ b/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/CollectionObjectHandlerFactory.java @@ -25,6 +25,7 @@ package org.collectionspace.services.collectionobject.nuxeo; import org.collectionspace.services.common.ClientType; import org.collectionspace.services.common.repository.DocumentHandler; +import org.collectionspace.services.common.repository.DocumentHandlerFactory; /** * CollectionObjectHandlerFactory creates handlers for collectionobject based @@ -33,7 +34,7 @@ import org.collectionspace.services.common.repository.DocumentHandler; * $LastChangedRevision: $ * $LastChangedDate: $ */ -public class CollectionObjectHandlerFactory { +public class CollectionObjectHandlerFactory implements DocumentHandlerFactory { private static final CollectionObjectHandlerFactory self = new CollectionObjectHandlerFactory(); @@ -44,6 +45,7 @@ public class CollectionObjectHandlerFactory { return self; } + @Override public DocumentHandler getHandler(String clientType) { if(ClientType.JAVA.toString().equals(clientType)){ return new CollectionObjectDocumentModelHandler(); diff --git a/services/common/src/main/java/org/collectionspace/services/common/CollectionSpaceHandlerFactory.java b/services/common/src/main/java/org/collectionspace/services/common/repository/DocumentHandlerFactory.java similarity index 67% rename from services/common/src/main/java/org/collectionspace/services/common/CollectionSpaceHandlerFactory.java rename to services/common/src/main/java/org/collectionspace/services/common/repository/DocumentHandlerFactory.java index b3e310b0e..5d3fd2611 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/CollectionSpaceHandlerFactory.java +++ b/services/common/src/main/java/org/collectionspace/services/common/repository/DocumentHandlerFactory.java @@ -1,37 +1,38 @@ -/** - * This document is a part of the source code and related artifacts - * for CollectionSpace, an open source collections management system - * for museums and related institutions: - - * http://www.collectionspace.org - * http://wiki.collectionspace.org - - * Copyright 2009 University of California at Berkeley - - * Licensed under the Educational Community License (ECL), Version 2.0. - * You may not use this file except in compliance with this License. - - * You may obtain a copy of the ECL 2.0 License at - - * https://source.collectionspace.org/collection-space/LICENSE.txt - - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.collectionspace.services.common; - -import org.collectionspace.services.common.repository.DocumentHandler; - -public interface CollectionSpaceHandlerFactory { - /** - * getHandler gets or creates a document handler per given client type - * @param clientType (java|rest) - * @return - * @throws IllegalArgumentException - */ - public DocumentHandler getHandler(String clientType) throws IllegalArgumentException; -} +/** + * This document is a part of the source code and related artifacts + * for CollectionSpace, an open source collections management system + * for museums and related institutions: + + * http://www.collectionspace.org + * http://wiki.collectionspace.org + + * Copyright 2009 University of California at Berkeley + + * Licensed under the Educational Community License (ECL), Version 2.0. + * You may not use this file except in compliance with this License. + + * You may obtain a copy of the ECL 2.0 License at + + * https://source.collectionspace.org/collection-space/LICENSE.txt + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.collectionspace.services.common.repository; + +/** + * + * DocumentHandlerFactory creates document handler + * + */ +public interface DocumentHandlerFactory { + + /** + * getHandler returns a document handler. The factory may create a new + * stateful handler or return an existing stateless handler. + */ + public DocumentHandler getHandler(String clientType); +} diff --git a/services/intake/service/src/main/java/org/collectionspace/services/intake/nuxeo/IntakeHandlerFactory.java b/services/intake/service/src/main/java/org/collectionspace/services/intake/nuxeo/IntakeHandlerFactory.java index 077b226a9..a80dad8de 100644 --- a/services/intake/service/src/main/java/org/collectionspace/services/intake/nuxeo/IntakeHandlerFactory.java +++ b/services/intake/service/src/main/java/org/collectionspace/services/intake/nuxeo/IntakeHandlerFactory.java @@ -25,6 +25,7 @@ package org.collectionspace.services.intake.nuxeo; import org.collectionspace.services.common.ClientType; import org.collectionspace.services.common.repository.DocumentHandler; +import org.collectionspace.services.common.repository.DocumentHandlerFactory; /** * IntakeHandlerFactory creates handlers for collectionobject based @@ -33,7 +34,7 @@ import org.collectionspace.services.common.repository.DocumentHandler; * $LastChangedRevision: $ * $LastChangedDate: $ */ -public class IntakeHandlerFactory { +public class IntakeHandlerFactory implements DocumentHandlerFactory { private static final IntakeHandlerFactory self = new IntakeHandlerFactory(); @@ -44,6 +45,7 @@ public class IntakeHandlerFactory { return self; } + @Override public DocumentHandler getHandler(String clientType) { if(ClientType.JAVA.toString().equals(clientType)){ return new IntakeDocumentModelHandler(); diff --git a/services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationHandlerFactory.java b/services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationHandlerFactory.java index 53ac92ff3..557fbcf23 100644 --- a/services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationHandlerFactory.java +++ b/services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationHandlerFactory.java @@ -25,7 +25,7 @@ package org.collectionspace.services.relation.nuxeo; import org.collectionspace.services.common.ClientType; import org.collectionspace.services.common.repository.DocumentHandler; -import org.collectionspace.services.common.CollectionSpaceHandlerFactory; +import org.collectionspace.services.common.repository.DocumentHandlerFactory; /** * CollectionObjectHandlerFactory creates handlers for collectionobject based @@ -34,7 +34,7 @@ import org.collectionspace.services.common.CollectionSpaceHandlerFactory; * $LastChangedRevision: $ * $LastChangedDate: $ */ -public class RelationHandlerFactory implements CollectionSpaceHandlerFactory { +public class RelationHandlerFactory implements DocumentHandlerFactory { private static final RelationHandlerFactory self = new RelationHandlerFactory(); -- 2.47.3