]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
01fc0228f612ab091d8f9fcd32183932abc6a1d9
[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.common.document.InvalidDocumentException;\r
6 import org.collectionspace.services.common.document.ValidatorHandlerImpl;\r
7 import org.collectionspace.services.relation.RelationsCommon;\r
8 \r
9 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;\r
10 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;\r
11 \r
12 import org.slf4j.Logger;\r
13 import org.slf4j.LoggerFactory;\r
14 //import org.testng.Assert;\r
15 \r
16 public class RelationValidatorHandler extends ValidatorHandlerImpl<MultipartInput, MultipartOutput>      {\r
17 \r
18     /** The logger. */\r
19     private final Logger logger = LoggerFactory.getLogger(RelationValidatorHandler.class);\r
20     \r
21     /* Error messages \r
22      */\r
23     private static final String VALIDATION_ERROR = "The relation record payload was invalid. See log file for more details.";\r
24     private static final String SUBJECT_EQUALS_PREDICATE_ERROR = "The subject ID and object ID cannot be the same.";\r
25     \r
26     @Override\r
27     protected Class<?> getCommonPartClass() {\r
28         return RelationsCommon.class;\r
29     }\r
30     \r
31     @Override\r
32     protected void handleCreate()\r
33                 throws InvalidDocumentException{\r
34         try {\r
35                 RelationsCommon relationsCommon = (RelationsCommon)getCommonPart();\r
36                 assert(relationsCommon != null);\r
37                 \r
38                 assert(relationsCommon.getDocumentId1() != null);\r
39                 assert(relationsCommon.getDocumentId1().length() != 0);\r
40                 \r
41                 assert(relationsCommon.getDocumentId2() != null);\r
42                 assert(relationsCommon.getDocumentId2().length() != 0);\r
43                 \r
44                 assert(relationsCommon.getRelationshipType() != null);\r
45                 //\r
46                 // Assert that the Subject ID and Predicate ID are not the same\r
47                 //\r
48                 assert(relationsCommon.getDocumentId1().equalsIgnoreCase(relationsCommon.getDocumentId2()) == false) :\r
49                         SUBJECT_EQUALS_PREDICATE_ERROR;\r
50         } catch (AssertionError e) {\r
51                 if (logger.isErrorEnabled() == true) {\r
52                         logger.error(e.getMessage(), e);\r
53                 }\r
54                 throw new InvalidDocumentException(VALIDATION_ERROR, e);\r
55         }\r
56     }\r
57 \r
58         @Override\r
59         protected void handleGet() {\r
60                 // TODO Auto-generated method stub\r
61                 \r
62         }\r
63 \r
64         @Override\r
65         protected void handleGetAll() {\r
66                 // TODO Auto-generated method stub\r
67                 \r
68         }\r
69 \r
70         @Override\r
71         protected void handleUpdate() {\r
72                 // TODO Auto-generated method stub\r
73                 \r
74         }\r
75 \r
76         @Override\r
77         protected void handleDelete() {\r
78                 // TODO Auto-generated method stub\r
79                 \r
80         }\r
81 \r
82 }\r