]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
e1bc98dad60c220a61e1b6ab76f8ca5bcc16bb28
[tmp/jakarta-migration.git] /
1 package org.collectionspace.services.relation.nuxeo;\r
2 \r
3 //import junit.framework.Assert;\r
4 \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
10 \r
11 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;\r
12 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;\r
13 \r
14 import org.slf4j.Logger;\r
15 import org.slf4j.LoggerFactory;\r
16 //import org.testng.Assert;\r
17 \r
18 public class RelationValidatorHandler extends ValidatorHandlerImpl<PoxPayloadIn, PoxPayloadOut>  {\r
19 \r
20     /** The logger. */\r
21     private final Logger logger = LoggerFactory.getLogger(RelationValidatorHandler.class);\r
22     \r
23     /* Error messages \r
24      */\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
27     \r
28     @Override\r
29     protected Class<?> getCommonPartClass() {\r
30         return RelationsCommon.class;\r
31     }\r
32     \r
33     @Override\r
34     protected void handleCreate()\r
35                 throws InvalidDocumentException{\r
36         try {\r
37                 RelationsCommon relationsCommon = (RelationsCommon)getCommonPart();\r
38                 assert(relationsCommon != null);\r
39                 if (logger.isTraceEnabled() == true) {\r
40                         logger.trace(relationsCommon.toString());\r
41                 }\r
42                 \r
43                 assert(relationsCommon.getDocumentId1() != null);\r
44                 assert(relationsCommon.getDocumentId1().length() != 0);\r
45                 \r
46                 assert(relationsCommon.getDocumentId2() != null);\r
47                 assert(relationsCommon.getDocumentId2().length() != 0);\r
48                 \r
49                 assert(relationsCommon.getRelationshipType() != null);\r
50                 //\r
51                 // Assert that the Subject ID and Predicate ID are not the same\r
52                 //\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
57                 }\r
58                 throw new InvalidDocumentException(VALIDATION_ERROR, e);\r
59         }\r
60     }\r
61 \r
62         @Override\r
63         protected void handleGet() {\r
64                 // TODO Auto-generated method stub\r
65                 \r
66         }\r
67 \r
68         @Override\r
69         protected void handleGetAll() {\r
70                 // TODO Auto-generated method stub\r
71                 \r
72         }\r
73 \r
74         @Override\r
75         protected void handleUpdate() {\r
76                 // TODO Auto-generated method stub\r
77                 \r
78         }\r
79 \r
80         @Override\r
81         protected void handleDelete() {\r
82                 // TODO Auto-generated method stub\r
83                 \r
84         }\r
85 \r
86 }\r