2 * This document is a part of the source code and related artifacts
3 * for CollectionSpace, an open source collections management system
4 * for museums and related institutions:
6 * http://www.collectionspace.org
7 * http://wiki.collectionspace.org
9 * Licensed under the Educational Community License (ECL), Version 2.0.
10 * You may not use this file except in compliance with this License.
12 * You may obtain a copy of the ECL 2.0 License at
13 * https://source.collectionspace.org/collection-space/LICENSE.txt
15 package org.collectionspace.services.repatriationclaim.nuxeo;
17 import org.collectionspace.services.client.PoxPayloadIn;
18 import org.collectionspace.services.client.PoxPayloadOut;
19 import org.collectionspace.services.common.document.InvalidDocumentException;
20 import org.collectionspace.services.common.document.ValidatorHandlerImpl;
21 import org.collectionspace.services.repatriationclaim.RepatriationClaimsCommon;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
26 * Validation handler for a RepatriationClaim. Checks for the common part and claimNumber on create.
28 public class RepatriationClaimValidatorHandler extends ValidatorHandlerImpl<PoxPayloadIn, PoxPayloadOut> {
30 private static final String COMMON_PART_MISSING = "Validation exception: repatriationclaims_common part is missing";
31 private static final String CLAIM_NUMBER_MISSING =
32 "Validation exception: The repatriation claim field \"claimNumber\" cannot be empty or missing";
34 private final Logger logger = LoggerFactory.getLogger(RepatriationClaimValidatorHandler.class);
37 protected Class<?> getCommonPartClass() {
38 return RepatriationClaimsCommon.class;
42 protected void handleCreate() throws InvalidDocumentException {
43 final RepatriationClaimsCommon claim = (RepatriationClaimsCommon) getCommonPart();
45 logger.error(COMMON_PART_MISSING);
46 throw new InvalidDocumentException(COMMON_PART_MISSING);
49 final String claimNumber = claim.getClaimNumber();
50 if (claimNumber == null || claimNumber.isEmpty()) {
51 logger.error(CLAIM_NUMBER_MISSING);
52 throw new InvalidDocumentException(CLAIM_NUMBER_MISSING);
57 protected void handleGet() {}
60 protected void handleGetAll() {}
63 protected void handleUpdate() {}
66 protected void handleDelete() {}