This project has retired. For details please refer to its
Attic page.
ValidateNode xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.juddi.validation;
18
19 import java.util.List;
20 import java.util.logging.Logger;
21
22 import javax.persistence.EntityManager;
23
24 import org.apache.juddi.api_v3.Node;
25 import org.apache.juddi.model.UddiEntityPublisher;
26 import org.apache.juddi.v3.error.ErrorMessage;
27 import org.apache.juddi.v3.error.FatalErrorException;
28 import org.apache.juddi.v3.error.ValueNotAllowedException;
29 import org.uddi.v3_service.DispositionReportFaultMessage;
30
31
32
33
34
35 public class ValidateNode extends ValidateUDDIApi {
36
37 public ValidateNode(UddiEntityPublisher publisher) {
38 super(publisher);
39 }
40 private static final Logger logger = Logger.getLogger(ValidateNode.class.getCanonicalName());
41
42
43
44
45 public void validateSaveNode(EntityManager em, org.apache.juddi.api_v3.SaveNode body) throws DispositionReportFaultMessage {
46
47 if (body == null) {
48 throw new FatalErrorException(new ErrorMessage("errors.NullInput"));
49 }
50
51
52 List<Node> nodes = body.getNode();
53 if (nodes == null) {
54 throw new ValueNotAllowedException(new ErrorMessage("errors.saveNodes.NoInput"));
55 }
56
57 for (Node clerk : body.getNode()) {
58 validateNode(clerk);
59 }
60
61 }
62
63 public void validateNode(org.apache.juddi.api_v3.Node node) throws DispositionReportFaultMessage {
64
65
66 if (node == null) {
67 throw new ValueNotAllowedException(new ErrorMessage("errors.node.NullInput"));
68 }
69
70 String name = node.getName();
71 if (name == null || name.length() == 0 || name.length()>255 || node.getClientName()==null|| node.getClientName().length() > 255) {
72 throw new ValueNotAllowedException(new ErrorMessage("errors.node.NoName"));
73 }
74 if (node.getDescription() == null || node.getDescription().length() == 0 || node.getDescription().length() > 255) {
75 throw new ValueNotAllowedException(new ErrorMessage("errors.node.NoDescription"));
76 }
77 if (node.getClientName() == null || node.getClientName().length() == 0 || node.getClientName().length() > 255) {
78 throw new ValueNotAllowedException(new ErrorMessage("errors.node.NoClientName"));
79 }
80 if (node.getCustodyTransferUrl() == null || node.getCustodyTransferUrl().length() == 0 || node.getClientName().length() > 255) {
81 throw new ValueNotAllowedException(new ErrorMessage("errors.node.NoNCT"));
82 }
83 if (node.getInquiryUrl() == null || node.getInquiryUrl().length() == 0 || node.getInquiryUrl().length() > 255) {
84 throw new ValueNotAllowedException(new ErrorMessage("errors.node.NoIN"));
85 }
86 if (node.getPublishUrl() == null || node.getPublishUrl().length() == 0 || node.getPublishUrl().length() > 255) {
87 throw new ValueNotAllowedException(new ErrorMessage("errors.node.NoPUB"));
88 }
89 if (node.getSubscriptionListenerUrl() == null || node.getSubscriptionListenerUrl().length() == 0 || node.getSubscriptionListenerUrl().length() > 255) {
90
91 }
92 if (node.getReplicationUrl() == null || node.getReplicationUrl().length() == 0 || node.getReplicationUrl().length() > 255) {
93
94
95 }
96 if (node.getSubscriptionUrl() == null || node.getSubscriptionUrl().length() == 0 || node.getSubscriptionUrl().length() > 255) {
97 throw new ValueNotAllowedException(new ErrorMessage("errors.node.NoSUB"));
98 }
99 if (node.getSecurityUrl()== null || node.getSecurityUrl().length() == 0 || node.getSecurityUrl().length() > 255) {
100 throw new ValueNotAllowedException(new ErrorMessage("errors.node.NoSec"));
101 }
102 if (node.getProxyTransport() == null || node.getProxyTransport().length() == 0 || node.getProxyTransport().length() > 255) {
103 throw new ValueNotAllowedException(new ErrorMessage("errors.node.NoProxy"));
104 } else {
105 try {
106
107
108 Class<?> forName = Class.forName(node.getProxyTransport());
109 Object j = forName.newInstance();
110 if (!(j instanceof org.apache.juddi.v3.client.transport.Transport)) {
111 throw new ValueNotAllowedException(new ErrorMessage("errors.node.illegalProxyTransport"));
112 }
113 } catch (Exception ex) {
114 throw new ValueNotAllowedException(new ErrorMessage("errors.node.illegalProxyTransport"));
115 }
116 }
117 if (node.getProxyTransport().equalsIgnoreCase("org.apache.juddi.v3.client.transport.RMITransport")) {
118 throw new ValueNotAllowedException(new ErrorMessage("errors.node.NoRMIData"));
119
120 }
121
122 }
123 }