This project has retired. For details please refer to its
Attic page.
ValidateClientSubscriptionInfo xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.juddi.validation;
19
20 import java.util.HashSet;
21 import java.util.List;
22
23 import javax.persistence.EntityManager;
24
25 import org.apache.juddi.api_v3.ClientSubscriptionInfo;
26 import org.apache.juddi.api_v3.DeleteClientSubscriptionInfo;
27 import org.apache.juddi.api_v3.GetAllClientSubscriptionInfoDetail;
28 import org.apache.juddi.api_v3.GetClientSubscriptionInfoDetail;
29 import org.apache.juddi.api_v3.SaveClientSubscriptionInfo;
30 import org.apache.juddi.model.UddiEntityPublisher;
31 import org.apache.juddi.v3.error.ErrorMessage;
32 import org.apache.juddi.v3.error.FatalErrorException;
33 import org.apache.juddi.v3.error.InvalidKeyPassedException;
34 import org.apache.juddi.v3.error.ValueNotAllowedException;
35 import org.uddi.v3_service.DispositionReportFaultMessage;
36
37
38
39
40
41 public class ValidateClientSubscriptionInfo extends ValidateUDDIApi {
42
43 public ValidateClientSubscriptionInfo(UddiEntityPublisher publisher) {
44 super(publisher);
45 }
46
47
48
49
50
51
52
53 public void validateDeleteClientSubscriptionInfo(EntityManager em, DeleteClientSubscriptionInfo body) throws DispositionReportFaultMessage {
54
55
56 if (body == null)
57 throw new FatalErrorException(new ErrorMessage("errors.NullInput"));
58
59
60 List<String> entityKeyList = body.getSubscriptionKey();
61 if (entityKeyList == null || entityKeyList.size() == 0)
62 throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.NoKeys"));
63
64 HashSet<String> dupCheck = new HashSet<String>();
65 for (String entityKey : entityKeyList) {
66 boolean inserted = dupCheck.add(entityKey);
67 if (!inserted)
68 throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.DuplicateKey", entityKey));
69
70 Object obj = em.find(org.apache.juddi.model.ClientSubscriptionInfo.class, entityKey);
71 if (obj == null)
72 throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.SubscriptionKeyNotFound", entityKey));
73
74 }
75 }
76
77 public void validateSaveClientSubscriptionInfo(EntityManager em, SaveClientSubscriptionInfo body) throws DispositionReportFaultMessage {
78
79
80 if (body == null)
81 throw new FatalErrorException(new ErrorMessage("errors.NullInput"));
82
83
84 List<ClientSubscriptionInfo> clientSubscriptionInfos = body.getClientSubscriptionInfo();
85 if (clientSubscriptionInfos == null)
86 throw new ValueNotAllowedException(new ErrorMessage("errors.saveclientsubscriptioninfo.NoInput"));
87
88 for (ClientSubscriptionInfo clientSubscriptionInfo : body.getClientSubscriptionInfo()) {
89 if (clientSubscriptionInfo.getSubscriptionKey()==null || clientSubscriptionInfo.getSubscriptionKey().equals("")) {
90 throw new ValueNotAllowedException(new ErrorMessage("errors.saveclientsubscriptionKey.NoInput"));
91 }
92 validateClerk(em, clientSubscriptionInfo.getFromClerk());
93 }
94 }
95
96 public void validateClerk(EntityManager em, org.apache.juddi.api_v3.Clerk clerk) throws DispositionReportFaultMessage {
97
98
99 if (clerk == null)
100 throw new ValueNotAllowedException(new ErrorMessage("errors.clerk.NullInput"));
101
102 String name = clerk.getName();
103 if (name == null || name.length() == 0)
104 throw new ValueNotAllowedException(new ErrorMessage("errors.clerk.NoName"));
105
106
107 Object obj = em.find(org.apache.juddi.model.Clerk.class, name);
108 if (obj == null)
109 throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.ClerkNotFound", name));
110 }
111
112 public void validateGetClientSubscriptionInfoDetail(GetClientSubscriptionInfoDetail body) throws DispositionReportFaultMessage {
113
114
115 if (body == null)
116 throw new FatalErrorException(new ErrorMessage("errors.NullInput"));
117
118
119 List<String> clientSubscriptionKeyList = body.getClientSubscriptionKey();
120 if (clientSubscriptionKeyList == null || clientSubscriptionKeyList.size() == 0)
121 throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.NoKeys"));
122
123 HashSet<String> dupCheck = new HashSet<String>();
124 for (String clientSubscriptionKey : clientSubscriptionKeyList) {
125 boolean inserted = dupCheck.add(clientSubscriptionKey);
126 if (!inserted)
127 throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.DuplicateKey", clientSubscriptionKey));
128 }
129 }
130
131 public void validateGetAllClientSubscriptionDetail(GetAllClientSubscriptionInfoDetail body) throws DispositionReportFaultMessage {
132
133
134 if (body == null)
135 throw new FatalErrorException(new ErrorMessage("errors.NullInput"));
136
137 }
138
139
140 }