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 * This document is a part of the source code and related artifacts
\r
25 * for CollectionSpace, an open source collections management system
\r
26 * for museums and related institutions:
\r
28 * http://www.collectionspace.org
\r
29 * http://wiki.collectionspace.org
\r
31 * Copyright 2009 University of California at Berkeley
\r
33 * Licensed under the Educational Community License (ECL), Version 2.0.
\r
34 * You may not use this file except in compliance with this License.
\r
36 * You may obtain a copy of the ECL 2.0 License at
\r
38 * https://source.collectionspace.org/collection-space/LICENSE.txt
\r
40 * Unless required by applicable law or agreed to in writing, software
\r
41 * distributed under the License is distributed on an "AS IS" BASIS,
\r
42 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
43 * See the License for the specific language governing permissions and
\r
44 * limitations under the License.
\r
47 * To change this template, choose Tools | Templates
\r
48 * and open the template in the editor.
\r
50 package org.collectionspace.services.collectionobject.nuxeo;
\r
52 import org.collectionspace.services.client.PoxPayloadIn;
\r
53 import org.collectionspace.services.client.PoxPayloadOut;
\r
54 import org.collectionspace.services.collectionobject.CollectionobjectsCommon;
\r
55 //import org.collectionspace.services.common.context.MultipartServiceContext;
\r
56 //import org.collectionspace.services.common.context.ServiceContext;
\r
57 import org.collectionspace.services.common.document.InvalidDocumentException;
\r
58 import org.collectionspace.services.common.document.ValidatorHandlerImpl;
\r
60 import org.slf4j.Logger;
\r
61 import org.slf4j.LoggerFactory;
\r
67 public class CollectionObjectValidatorHandler extends ValidatorHandlerImpl<PoxPayloadIn, PoxPayloadOut> {
\r
69 final Logger logger = LoggerFactory.getLogger(CollectionObjectValidatorHandler.class);
\r
74 private static final String VALIDATION_ERROR = "The collection object record payload was invalid. See log file for more details.";
\r
75 private static final String OBJECTNUMBER_NULL_ERROR = "The collection object field \"objectNumber\" cannot be empty or missing.";
\r
78 protected Class<?> getCommonPartClass() {
\r
79 return CollectionobjectsCommon.class;
\r
83 protected void handleGet(){
\r
84 // TODO Auto-generated method stub
\r
89 protected void handleGetAll() {
\r
90 // TODO Auto-generated method stub
\r
95 protected void handleUpdate()
\r
96 throws InvalidDocumentException {
\r
98 CollectionobjectsCommon co = (CollectionobjectsCommon) getCommonPart();
\r
99 validateCollectionobjectsCommon(co);
\r
100 } catch (AssertionError e) {
\r
101 if (logger.isErrorEnabled() == true) {
\r
102 logger.error(e.getMessage(), e);
\r
104 throw new InvalidDocumentException(VALIDATION_ERROR, e);
\r
109 protected void handleDelete() {
\r
110 // TODO Auto-generated method stub
\r
115 protected void handleCreate()
\r
116 throws InvalidDocumentException {
\r
118 CollectionobjectsCommon co = (CollectionobjectsCommon) getCommonPart();
\r
119 validateCollectionobjectsCommon(co);
\r
120 } catch (AssertionError e) {
\r
121 if (logger.isErrorEnabled() == true) {
\r
122 logger.error(e.getMessage(), e);
\r
124 throw new InvalidDocumentException(VALIDATION_ERROR, e);
\r
131 private void validateCollectionobjectsCommon(CollectionobjectsCommon co) throws AssertionError {
\r
132 CS_ASSERT(co != null);
\r
133 String objectNumber = co.getObjectNumber();
\r
134 CS_ASSERT(objectNumber != null);
\r
135 CS_ASSERT(objectNumber.isEmpty() == false, OBJECTNUMBER_NULL_ERROR);
\r