1 package org.collectionspace.services.relation.nuxeo;
\r
3 //import junit.framework.Assert;
\r
5 import org.collectionspace.services.client.PoxPayloadIn;
\r
6 import org.collectionspace.services.client.PoxPayloadOut;
\r
7 import org.collectionspace.services.common.document.InvalidDocumentException;
\r
8 import org.collectionspace.services.common.document.ValidatorHandlerImpl;
\r
9 import org.collectionspace.services.relation.RelationsCommon;
\r
11 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
\r
12 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
\r
14 import org.slf4j.Logger;
\r
15 import org.slf4j.LoggerFactory;
\r
16 //import org.testng.Assert;
\r
18 public class RelationValidatorHandler extends ValidatorHandlerImpl<PoxPayloadIn, PoxPayloadOut> {
\r
21 private final Logger logger = LoggerFactory.getLogger(RelationValidatorHandler.class);
\r
25 private static final String VALIDATION_ERROR = "The relation record payload was invalid. See log file for more details.";
\r
26 private static final String SUBJECT_EQUALS_PREDICATE_ERROR = "The subject ID and object ID cannot be the same.";
\r
29 protected Class<?> getCommonPartClass() {
\r
30 return RelationsCommon.class;
\r
34 protected void handleCreate()
\r
35 throws InvalidDocumentException{
\r
37 RelationsCommon relationsCommon = (RelationsCommon)getCommonPart();
\r
38 assert(relationsCommon != null);
\r
39 if (logger.isTraceEnabled() == true) {
\r
40 logger.trace(relationsCommon.toString());
\r
43 assert(relationsCommon.getDocumentId1() != null);
\r
44 assert(relationsCommon.getDocumentId1().length() != 0);
\r
46 assert(relationsCommon.getDocumentId2() != null);
\r
47 assert(relationsCommon.getDocumentId2().length() != 0);
\r
49 assert(relationsCommon.getRelationshipType() != null);
\r
51 // Assert that the Subject ID and Predicate ID are not the same
\r
53 assert(relationsCommon.getDocumentId1().equalsIgnoreCase(relationsCommon.getDocumentId2()) == false) : SUBJECT_EQUALS_PREDICATE_ERROR;
\r
54 } catch (AssertionError e) {
\r
55 if (logger.isErrorEnabled() == true) {
\r
56 logger.error(e.getMessage(), e);
\r
58 throw new InvalidDocumentException(VALIDATION_ERROR, e);
\r
63 protected void handleGet() {
\r
64 // TODO Auto-generated method stub
\r
69 protected void handleGetAll() {
\r
70 // TODO Auto-generated method stub
\r
75 protected void handleUpdate() {
\r
76 // TODO Auto-generated method stub
\r
81 protected void handleDelete() {
\r
82 // TODO Auto-generated method stub
\r