This project has retired. For details please refer to its
Attic page.
ValidateInquiry 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.HashMap;
20 import java.util.HashSet;
21 import java.util.List;
22 import java.util.Hashtable;
23 import java.util.Map;
24 import javax.persistence.EntityManager;
25 import javax.persistence.EntityTransaction;
26 import org.apache.juddi.api.impl.InquiryHelper;
27 import org.apache.juddi.api.util.InquiryQuery;
28 import org.apache.juddi.api.util.QueryStatus;
29 import org.apache.juddi.config.PersistenceManager;
30 import org.apache.juddi.mapping.MappingModelToApi;
31
32 import org.uddi.api_v3.GetBusinessDetail;
33 import org.uddi.api_v3.GetOperationalInfo;
34 import org.uddi.api_v3.GetServiceDetail;
35 import org.uddi.api_v3.GetBindingDetail;
36 import org.uddi.api_v3.GetTModelDetail;
37 import org.uddi.api_v3.FindBusiness;
38 import org.uddi.api_v3.FindService;
39 import org.uddi.api_v3.FindBinding;
40 import org.uddi.api_v3.FindTModel;
41 import org.uddi.api_v3.FindRelatedBusinesses;
42 import org.uddi.api_v3.KeyedReference;
43 import org.uddi.api_v3.KeyedReferenceGroup;
44 import org.uddi.api_v3.Name;
45 import org.uddi.api_v3.TModelBag;
46
47 import org.uddi.v3_service.DispositionReportFaultMessage;
48
49 import org.apache.juddi.model.UddiEntityPublisher;
50 import org.apache.juddi.query.BusinessServiceQuery;
51 import org.apache.juddi.query.util.DynamicQuery;
52 import org.apache.juddi.query.util.FindQualifiers;
53 import org.apache.juddi.v3.error.ErrorMessage;
54 import org.apache.juddi.v3.error.FatalErrorException;
55 import org.apache.juddi.v3.error.InvalidCombinationException;
56 import org.apache.juddi.v3.error.InvalidKeyPassedException;
57 import org.apache.juddi.v3.error.UnsupportedException;
58 import org.apache.juddi.v3.error.ValueNotAllowedException;
59 import org.uddi.api_v3.BindingDetail;
60 import org.uddi.api_v3.ServiceDetail;
61
62
63
64
65
66
67 public class ValidateInquiry extends ValidateUDDIApi {
68
69 public ValidateInquiry(UddiEntityPublisher publisher) {
70 super(publisher);
71 }
72
73 public void validateGetBusinessDetail(GetBusinessDetail body) throws DispositionReportFaultMessage {
74
75
76 if (body == null) {
77 throw new FatalErrorException(new ErrorMessage("errors.NullInput"));
78 }
79
80
81 List<String> entityKeyList = body.getBusinessKey();
82 if (entityKeyList == null || entityKeyList.size() == 0) {
83 throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.NoKeys"));
84 }
85
86 HashSet<String> dupCheck = new HashSet<String>();
87 int i = 0;
88 for (String entityKey : entityKeyList) {
89
90
91 entityKey = entityKey.toLowerCase();
92 entityKeyList.set(i, entityKey);
93
94 boolean inserted = dupCheck.add(entityKey);
95 if (!inserted) {
96 throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.DuplicateKey", entityKey));
97 }
98
99 i++;
100 }
101 }
102
103 public void validateGetServiceDetail(GetServiceDetail body) throws DispositionReportFaultMessage {
104
105
106 if (body == null) {
107 throw new FatalErrorException(new ErrorMessage("errors.NullInput"));
108 }
109
110
111 List<String> entityKeyList = body.getServiceKey();
112 if (entityKeyList == null || entityKeyList.size() == 0) {
113 throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.NoKeys"));
114 }
115
116 HashSet<String> dupCheck = new HashSet<String>();
117 int i = 0;
118 for (String entityKey : entityKeyList) {
119
120
121 entityKey = entityKey.toLowerCase();
122 entityKeyList.set(i, entityKey);
123
124 boolean inserted = dupCheck.add(entityKey);
125 if (!inserted) {
126 throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.DuplicateKey", entityKey));
127 }
128
129 i++;
130 }
131 }
132
133 public void validateGetBindingDetail(GetBindingDetail body) throws DispositionReportFaultMessage {
134
135
136 if (body == null) {
137 throw new FatalErrorException(new ErrorMessage("errors.NullInput"));
138 }
139
140
141 List<String> entityKeyList = body.getBindingKey();
142 if (entityKeyList == null || entityKeyList.size() == 0) {
143 throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.NoKeys"));
144 }
145
146 HashSet<String> dupCheck = new HashSet<String>();
147 int i = 0;
148 for (String entityKey : entityKeyList) {
149
150
151 entityKey = entityKey.toLowerCase();
152 entityKeyList.set(i, entityKey);
153
154 boolean inserted = dupCheck.add(entityKey);
155 if (!inserted) {
156 throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.DuplicateKey", entityKey));
157 }
158
159 i++;
160 }
161 }
162
163 public void validateGetTModelDetail(GetTModelDetail body) throws DispositionReportFaultMessage {
164
165
166 if (body == null) {
167 throw new FatalErrorException(new ErrorMessage("errors.NullInput"));
168 }
169
170
171 List<String> entityKeyList = body.getTModelKey();
172 if (entityKeyList == null || entityKeyList.size() == 0) {
173 throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.NoKeys"));
174 }
175
176 HashSet<String> dupCheck = new HashSet<String>();
177 int i = 0;
178 for (String entityKey : entityKeyList) {
179
180
181 entityKey = entityKey.toLowerCase();
182 entityKeyList.set(i, entityKey);
183
184 boolean inserted = dupCheck.add(entityKey);
185 if (!inserted) {
186 throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.DuplicateKey", entityKey));
187 }
188
189 i++;
190 }
191 }
192
193 public void validateGetOperationalInfo(GetOperationalInfo body) throws DispositionReportFaultMessage {
194
195
196 if (body == null) {
197 throw new FatalErrorException(new ErrorMessage("errors.NullInput"));
198 }
199
200
201 List<String> entityKeyList = body.getEntityKey();
202 if (entityKeyList == null || entityKeyList.size() == 0) {
203 throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.NoKeys"));
204 }
205
206 HashSet<String> dupCheck = new HashSet<String>();
207 int i = 0;
208 for (String entityKey : entityKeyList) {
209
210
211 entityKey = entityKey.toLowerCase();
212 entityKeyList.set(i, entityKey);
213
214 boolean inserted = dupCheck.add(entityKey);
215 if (!inserted) {
216 throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.DuplicateKey", entityKey));
217 }
218
219 i++;
220 }
221 }
222
223 public void validateFindBusiness(FindBusiness body) throws DispositionReportFaultMessage {
224
225 if (body == null) {
226 throw new FatalErrorException(new ErrorMessage("errors.NullInput"));
227 }
228
229 if (body.getCategoryBag() == null && body.getFindTModel() == null && body.getTModelBag() == null && body.getName().size() == 0
230 && body.getIdentifierBag() == null && body.getDiscoveryURLs() == null && body.getFindRelatedBusinesses() == null) {
231 throw new FatalErrorException(new ErrorMessage("errors.findbusiness.NoInput"));
232 }
233
234 validateNames(body.getName());
235 validateFindQualifiers(body.getFindQualifiers());
236 validateTModelBag(body.getTModelBag());
237 validateFindTModel(body.getFindTModel(), true);
238 validateFindRelatedBusinesses(body.getFindRelatedBusinesses(), true);
239 validateDiscoveryUrls(body.getDiscoveryURLs());
240 validateIdentifierBag(body.getIdentifierBag());
241 validateCategoryBag(body.getCategoryBag());
242
243 }
244
245 public void validateFindService(FindService body) throws DispositionReportFaultMessage {
246
247 if (body == null) {
248 throw new FatalErrorException(new ErrorMessage("errors.NullInput"));
249 }
250
251 if (body.getCategoryBag() == null && body.getFindTModel() == null
252 && (body.getTModelBag() == null || body.getTModelBag().getTModelKey().size() == 0)
253 && body.getName().size() == 0 && body.getBusinessKey() == null) {
254 throw new FatalErrorException(new ErrorMessage("errors.findservice.NoInput"));
255 }
256
257 validateNames(body.getName());
258 validateFindQualifiers(body.getFindQualifiers());
259 validateTModelBag(body.getTModelBag());
260 validateFindTModel(body.getFindTModel(), true);
261 validateCategoryBag(body.getCategoryBag());
262
263 }
264
265 public void validateFindBinding(FindBinding body) throws DispositionReportFaultMessage {
266
267 if (body == null) {
268 throw new FatalErrorException(new ErrorMessage("errors.NullInput"));
269 }
270 if (body.getServiceKey()!=null && body.getServiceKey().length() > 0) {
271 validateServiceExists(body.getServiceKey());
272 }
273 if ((body.getServiceKey()==null || body.getServiceKey().length()==0) && body.getCategoryBag() == null && body.getFindTModel() == null && body.getTModelBag() == null) {
274 throw new FatalErrorException(new ErrorMessage("errors.findbinding.NoInput"));
275 }
276
277 validateFindQualifiers(body.getFindQualifiers());
278 validateTModelBag(body.getTModelBag());
279 validateFindTModel(body.getFindTModel(), true);
280 validateCategoryBag(body.getCategoryBag());
281 validateFindingBindingFQ(body.getFindQualifiers());
282 validateFindQualifiers_AppoximateMatchAndCombinedCatbag(body.getFindQualifiers());
283
284 }
285
286 public void validateFindTModel(FindTModel body, boolean nullAllowed) throws DispositionReportFaultMessage {
287 if (body == null) {
288
289 if (nullAllowed) {
290 return;
291 } else {
292 throw new FatalErrorException(new ErrorMessage("errors.NullInput"));
293 }
294 }
295
296 if (body.getCategoryBag() == null && body.getIdentifierBag() == null && body.getName() == null) {
297 throw new FatalErrorException(new ErrorMessage("errors.findtmodel.NoInput"));
298 }
299
300 validateFindQualifiers(body.getFindQualifiers());
301 validateIdentifierBag(body.getIdentifierBag());
302 validateCategoryBag(body.getCategoryBag());
303 validateFindQualifiers_AppoximateMatchAndCombinedCatbag(body.getFindQualifiers());
304 }
305
306 public void validateFindRelatedBusinesses(FindRelatedBusinesses body, boolean nullAllowed) throws DispositionReportFaultMessage {
307 if (body == null) {
308
309 if (nullAllowed) {
310 return;
311 } else {
312 throw new FatalErrorException(new ErrorMessage("errors.NullInput"));
313 }
314 }
315
316 if ((body.getBusinessKey() == null || body.getBusinessKey().length() == 0)
317 && (body.getFromKey() == null || body.getFromKey().length() == 0)
318 && (body.getToKey() == null || body.getToKey().length() == 0)) {
319 throw new FatalErrorException(new ErrorMessage("errors.findrelatedbusiness.NoInput"));
320 }
321
322 boolean businessKeyExists = false;
323 boolean fromKeyExists = false;
324 if (body.getBusinessKey() != null && body.getBusinessKey().length() > 0) {
325 businessKeyExists = true;
326
327
328 body.setBusinessKey(body.getBusinessKey().toLowerCase());
329 }
330 if (body.getFromKey() != null && body.getFromKey().length() > 0) {
331 fromKeyExists = true;
332 if (businessKeyExists) {
333 throw new FatalErrorException(new ErrorMessage("errors.findrelatedbusiness.MultipleInput"));
334 }
335
336
337 body.setFromKey(body.getFromKey().toLowerCase());
338 }
339 if (body.getToKey() != null && body.getToKey().length() > 0) {
340 if (businessKeyExists || fromKeyExists) {
341 throw new FatalErrorException(new ErrorMessage("errors.findrelatedbusiness.MultipleInput"));
342 }
343
344
345 body.setToKey(body.getToKey().toLowerCase());
346 }
347
348 KeyedReference keyedRef = body.getKeyedReference();
349 if (keyedRef != null) {
350 if (keyedRef.getTModelKey() == null || keyedRef.getTModelKey().length() == 0
351 || keyedRef.getKeyName() == null || keyedRef.getKeyName().length() == 0
352 || keyedRef.getKeyValue() == null || keyedRef.getKeyValue().length() == 0) {
353 throw new ValueNotAllowedException(new ErrorMessage("errors.findrelatedbusiness.BlankKeyedRef"));
354 }
355
356 validateKeyedReference(keyedRef);
357 }
358 validateFindQualifiers(body.getFindQualifiers());
359 validateFindRelatedBusinessesFindQualifiers(body.getFindQualifiers());
360 validateFindQualifiers_AppoximateMatchAndCombinedCatbag(body.getFindQualifiers());
361 }
362
363 public void validateNames(List<org.uddi.api_v3.Name> names) throws DispositionReportFaultMessage {
364 if (names != null) {
365 for (Name n : names) {
366 if (n.getValue() == null || n.getValue().length() == 0) {
367 throw new ValueNotAllowedException(new ErrorMessage("errors.names.NoValue"));
368 }
369 ValidatePublish.validateLang(n.getLang());
370 }
371 }
372 }
373
374 public void validateTModelBag(TModelBag tmodelBag) throws DispositionReportFaultMessage {
375
376 if (tmodelBag == null) {
377 return;
378 }
379
380 if (tmodelBag.getTModelKey() == null || tmodelBag.getTModelKey().size() == 0) {
381 throw new ValueNotAllowedException(new ErrorMessage("errors.tmodelbag.NoInput"));
382 }
383
384 List<String> keyList = tmodelBag.getTModelKey();
385 int i = 0;
386 for (String key : keyList) {
387
388 key = key.toLowerCase();
389 keyList.set(i, key);
390 i++;
391 }
392
393 }
394
395 public void validateDiscoveryUrls(org.uddi.api_v3.DiscoveryURLs discUrls) throws DispositionReportFaultMessage {
396
397 if (discUrls == null) {
398 return;
399 }
400
401
402 List<org.uddi.api_v3.DiscoveryURL> discUrlList = discUrls.getDiscoveryURL();
403 if (discUrlList == null || discUrlList.size() == 0) {
404 throw new ValueNotAllowedException(new ErrorMessage("errors.discurls.NoInput"));
405 }
406 }
407
408 public void validateCategoryBag(org.uddi.api_v3.CategoryBag categories) throws DispositionReportFaultMessage {
409
410
411 if (categories == null) {
412 return;
413 }
414
415
416 List<KeyedReference> elems = categories.getKeyedReference();
417 List<KeyedReferenceGroup> krgs = categories.getKeyedReferenceGroup();
418 if ((elems == null || elems.size() == 0) && (krgs == null || krgs.size() == 0)) {
419 throw new ValueNotAllowedException(new ErrorMessage("errors.categorybag.NoInput"));
420 }
421
422 for (KeyedReference elem : elems) {
423 validateKeyedReference(elem);
424 }
425 for (KeyedReferenceGroup elem : krgs) {
426 validateKeyedReferenceGroup(elem);
427 }
428 }
429
430 public void validateIdentifierBag(org.uddi.api_v3.IdentifierBag identifiers) throws DispositionReportFaultMessage {
431
432
433 if (identifiers == null) {
434 return;
435 }
436
437
438 List<org.uddi.api_v3.KeyedReference> keyedRefList = identifiers.getKeyedReference();
439 if (keyedRefList == null || keyedRefList.size() == 0) {
440 throw new ValueNotAllowedException(new ErrorMessage("errors.identifierbag.NoInput"));
441 }
442
443 for (org.uddi.api_v3.KeyedReference keyedRef : keyedRefList) {
444 validateKeyedReference(keyedRef);
445 }
446 }
447
448 public void validateKeyedReferenceGroup(KeyedReferenceGroup krg) throws DispositionReportFaultMessage {
449
450 if (krg.getTModelKey() == null || krg.getTModelKey().length() == 0) {
451 throw new ValueNotAllowedException(new ErrorMessage("errors.keyedreference.NoTModelKey"));
452 }
453
454
455 krg.setTModelKey(krg.getTModelKey().toLowerCase());
456
457 List<KeyedReference> keyedRefs = krg.getKeyedReference();
458
459 if (keyedRefs != null && keyedRefs.size() > 0) {
460 for (KeyedReference keyedRef : keyedRefs) {
461 validateKeyedReference(keyedRef);
462 }
463 }
464 }
465
466 public void validateKeyedReference(KeyedReference kr) throws DispositionReportFaultMessage {
467 if (kr == null) {
468 throw new ValueNotAllowedException(new ErrorMessage("errors.keyedreference.NullInput"));
469 }
470
471
472 if (kr.getTModelKey() == null || kr.getTModelKey().length() == 0) {
473 throw new ValueNotAllowedException(new ErrorMessage("errors.keyedreference.NoTModelKey"));
474 }
475
476
477 kr.setTModelKey(kr.getTModelKey().toLowerCase());
478
479 if (kr.getKeyValue() == null || kr.getKeyValue().length() == 0) {
480 throw new ValueNotAllowedException(new ErrorMessage("errors.keyedreference.NoKeyValue"));
481 }
482 }
483
484 private void validateFindQualifiers(org.uddi.api_v3.FindQualifiers findQualifiers) throws DispositionReportFaultMessage {
485 if (findQualifiers == null) {
486 return;
487 }
488
489 List<String> fqList = findQualifiers.getFindQualifier();
490 if (fqList == null || fqList.size() == 0) {
491 throw new ValueNotAllowedException(new ErrorMessage("errors.findqualifiers.NoInput"));
492 }
493
494 Hashtable<String, String> fqTable = new Hashtable<String, String>();
495 for (String fq : fqList) {
496 String result = fqTable.put(fq.toUpperCase(), fq.toUpperCase());
497 if (result != null) {
498 throw new ValueNotAllowedException(new ErrorMessage("errors.findqualifiers.DuplicateValue", result));
499 }
500
501 ValidateSupportedFindQualifier(fq);
502
503
504 if (fq.equalsIgnoreCase(FindQualifiers.AND_ALL_KEYS) || fq.equalsIgnoreCase(FindQualifiers.AND_ALL_KEYS_TMODEL)) {
505 if (fqTable.get(FindQualifiers.OR_ALL_KEYS.toUpperCase()) != null || fqTable.get(FindQualifiers.OR_ALL_KEYS_TMODEL.toUpperCase()) != null) {
506 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", fq + " & " + FindQualifiers.OR_ALL_KEYS));
507 }
508
509 if (fqTable.get(FindQualifiers.OR_LIKE_KEYS.toUpperCase()) != null || fqTable.get(FindQualifiers.OR_LIKE_KEYS_TMODEL.toUpperCase()) != null) {
510 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", fq + " & " + FindQualifiers.OR_LIKE_KEYS));
511 }
512 } else if (fq.equalsIgnoreCase(FindQualifiers.OR_ALL_KEYS) || fq.equalsIgnoreCase(FindQualifiers.OR_ALL_KEYS_TMODEL)) {
513 if (fqTable.get(FindQualifiers.AND_ALL_KEYS.toUpperCase()) != null || fqTable.get(FindQualifiers.AND_ALL_KEYS_TMODEL.toUpperCase()) != null) {
514 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", fq + " & " + FindQualifiers.AND_ALL_KEYS));
515 }
516
517 if (fqTable.get(FindQualifiers.OR_LIKE_KEYS.toUpperCase()) != null || fqTable.get(FindQualifiers.OR_LIKE_KEYS_TMODEL.toUpperCase()) != null) {
518 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", fq + " & " + FindQualifiers.OR_LIKE_KEYS));
519 }
520 } else if (fq.equalsIgnoreCase(FindQualifiers.OR_LIKE_KEYS) || fq.equalsIgnoreCase(FindQualifiers.OR_LIKE_KEYS_TMODEL)) {
521 if (fqTable.get(FindQualifiers.AND_ALL_KEYS.toUpperCase()) != null || fqTable.get(FindQualifiers.AND_ALL_KEYS_TMODEL.toUpperCase()) != null) {
522 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", fq + " & " + FindQualifiers.AND_ALL_KEYS));
523 }
524
525 if (fqTable.get(FindQualifiers.OR_ALL_KEYS.toUpperCase()) != null || fqTable.get(FindQualifiers.OR_ALL_KEYS_TMODEL.toUpperCase()) != null) {
526 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", fq + " & " + FindQualifiers.OR_ALL_KEYS));
527 }
528 }
529
530
531 if (fq.equalsIgnoreCase(FindQualifiers.SORT_BY_NAME_ASC) || fq.equalsIgnoreCase(FindQualifiers.SORT_BY_NAME_ASC_TMODEL)) {
532 if (fqTable.get(FindQualifiers.SORT_BY_NAME_DESC.toUpperCase()) != null || fqTable.get(FindQualifiers.SORT_BY_NAME_DESC_TMODEL.toUpperCase()) != null) {
533 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", fq + " & " + FindQualifiers.SORT_BY_NAME_DESC));
534 }
535 } else if (fq.equalsIgnoreCase(FindQualifiers.SORT_BY_NAME_DESC) || fq.equalsIgnoreCase(FindQualifiers.SORT_BY_NAME_DESC_TMODEL)) {
536 if (fqTable.get(FindQualifiers.SORT_BY_NAME_ASC.toUpperCase()) != null || fqTable.get(FindQualifiers.SORT_BY_NAME_ASC_TMODEL.toUpperCase()) != null) {
537 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", fq + " & " + FindQualifiers.SORT_BY_NAME_ASC));
538 }
539 }
540
541
542 if (fq.equalsIgnoreCase(FindQualifiers.SORT_BY_DATE_ASC) || fq.equalsIgnoreCase(FindQualifiers.SORT_BY_DATE_ASC_TMODEL)) {
543 if (fqTable.get(FindQualifiers.SORT_BY_DATE_DESC.toUpperCase()) != null || fqTable.get(FindQualifiers.SORT_BY_DATE_DESC_TMODEL.toUpperCase()) != null) {
544 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", fq + " & " + FindQualifiers.SORT_BY_DATE_DESC));
545 }
546 } else if (fq.equalsIgnoreCase(FindQualifiers.SORT_BY_DATE_DESC) || fq.equalsIgnoreCase(FindQualifiers.SORT_BY_DATE_DESC_TMODEL)) {
547 if (fqTable.get(FindQualifiers.SORT_BY_DATE_ASC.toUpperCase()) != null || fqTable.get(FindQualifiers.SORT_BY_DATE_ASC_TMODEL.toUpperCase()) != null) {
548 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", fq + " & " + FindQualifiers.SORT_BY_DATE_ASC));
549 }
550 }
551
552
553 if (fq.equalsIgnoreCase(FindQualifiers.COMBINE_CATEGORY_BAGS) || fq.equalsIgnoreCase(FindQualifiers.COMBINE_CATEGORY_BAGS_TMODEL)) {
554 if (fqTable.get(FindQualifiers.SERVICE_SUBSET.toUpperCase()) != null || fqTable.get(FindQualifiers.SERVICE_SUBSET_TMODEL.toUpperCase()) != null) {
555 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", fq + " & " + FindQualifiers.SERVICE_SUBSET));
556 }
557
558 if (fqTable.get(FindQualifiers.BINDING_SUBSET.toUpperCase()) != null || fqTable.get(FindQualifiers.BINDING_SUBSET_TMODEL.toUpperCase()) != null) {
559 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", fq + " & " + FindQualifiers.BINDING_SUBSET));
560 }
561 } else if (fq.equalsIgnoreCase(FindQualifiers.SERVICE_SUBSET) || fq.equalsIgnoreCase(FindQualifiers.SERVICE_SUBSET_TMODEL)) {
562 if (fqTable.get(FindQualifiers.COMBINE_CATEGORY_BAGS.toUpperCase()) != null || fqTable.get(FindQualifiers.COMBINE_CATEGORY_BAGS_TMODEL.toUpperCase()) != null) {
563 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", fq + " & " + FindQualifiers.COMBINE_CATEGORY_BAGS));
564 }
565
566 if (fqTable.get(FindQualifiers.BINDING_SUBSET.toUpperCase()) != null || fqTable.get(FindQualifiers.BINDING_SUBSET_TMODEL.toUpperCase()) != null) {
567 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", fq + " & " + FindQualifiers.BINDING_SUBSET));
568 }
569 } else if (fq.equalsIgnoreCase(FindQualifiers.BINDING_SUBSET) || fq.equalsIgnoreCase(FindQualifiers.BINDING_SUBSET_TMODEL)) {
570 if (fqTable.get(FindQualifiers.SERVICE_SUBSET.toUpperCase()) != null || fqTable.get(FindQualifiers.SERVICE_SUBSET_TMODEL.toUpperCase()) != null) {
571 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", fq + " & " + FindQualifiers.SERVICE_SUBSET));
572 }
573
574 if (fqTable.get(FindQualifiers.COMBINE_CATEGORY_BAGS.toUpperCase()) != null || fqTable.get(FindQualifiers.COMBINE_CATEGORY_BAGS_TMODEL.toUpperCase()) != null) {
575 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", fq + " & " + FindQualifiers.COMBINE_CATEGORY_BAGS));
576 }
577 }
578
579
580 if (fq.equalsIgnoreCase(FindQualifiers.EXACT_MATCH) || fq.equalsIgnoreCase(FindQualifiers.EXACT_MATCH_TMODEL)) {
581 if (fqTable.get(FindQualifiers.APPROXIMATE_MATCH.toUpperCase()) != null || fqTable.get(FindQualifiers.APPROXIMATE_MATCH_TMODEL.toUpperCase()) != null) {
582 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", fq + " & " + FindQualifiers.APPROXIMATE_MATCH));
583 }
584 } else if (fq.equalsIgnoreCase(FindQualifiers.APPROXIMATE_MATCH) || fq.equalsIgnoreCase(FindQualifiers.APPROXIMATE_MATCH_TMODEL)) {
585 if (fqTable.get(FindQualifiers.EXACT_MATCH.toUpperCase()) != null || fqTable.get(FindQualifiers.EXACT_MATCH_TMODEL.toUpperCase()) != null) {
586 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", fq + " & " + FindQualifiers.EXACT_MATCH));
587 }
588 }
589
590
591 if (fq.equalsIgnoreCase(FindQualifiers.EXACT_MATCH) || fq.equalsIgnoreCase(FindQualifiers.EXACT_MATCH_TMODEL)) {
592 if (fqTable.get(FindQualifiers.CASE_INSENSITIVE_MATCH.toUpperCase()) != null || fqTable.get(FindQualifiers.CASE_INSENSITIVE_MATCH_TMODEL.toUpperCase()) != null) {
593 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", fq + " & " + FindQualifiers.CASE_INSENSITIVE_MATCH));
594 }
595 } else if (fq.equalsIgnoreCase(FindQualifiers.CASE_INSENSITIVE_MATCH) || fq.equalsIgnoreCase(FindQualifiers.CASE_INSENSITIVE_MATCH_TMODEL)) {
596 if (fqTable.get(FindQualifiers.EXACT_MATCH.toUpperCase()) != null || fqTable.get(FindQualifiers.EXACT_MATCH_TMODEL.toUpperCase()) != null) {
597 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", fq + " & " + FindQualifiers.EXACT_MATCH));
598 }
599 }
600
601
602 if (fq.equalsIgnoreCase(FindQualifiers.BINARY_SORT) || fq.equalsIgnoreCase(FindQualifiers.BINARY_SORT_TMODEL)) {
603 if (fqTable.get(FindQualifiers.UTS_10.toUpperCase()) != null || fqTable.get(FindQualifiers.UTS_10_TMODEL.toUpperCase()) != null) {
604 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", fq + " & " + FindQualifiers.UTS_10));
605 }
606 } else if (fq.equalsIgnoreCase(FindQualifiers.UTS_10) || fq.equalsIgnoreCase(FindQualifiers.UTS_10_TMODEL)) {
607 if (fqTable.get(FindQualifiers.BINARY_SORT.toUpperCase()) != null || fqTable.get(FindQualifiers.BINARY_SORT_TMODEL.toUpperCase()) != null) {
608 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", fq + " & " + FindQualifiers.BINARY_SORT));
609 }
610 }
611
612
613 if (fq.equalsIgnoreCase(FindQualifiers.DIACRITIC_SENSITIVE_MATCH) || fq.equalsIgnoreCase(FindQualifiers.DIACRITIC_SENSITIVE_MATCH_TMODEL)) {
614 if (fqTable.get(FindQualifiers.DIACRITIC_INSENSITIVE_MATCH.toUpperCase()) != null || fqTable.get(FindQualifiers.DIACRITIC_INSENSITIVE_MATCH_TMODEL.toUpperCase()) != null) {
615 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", fq + " & " + FindQualifiers.DIACRITIC_INSENSITIVE_MATCH));
616 }
617 } else if (fq.equalsIgnoreCase(FindQualifiers.DIACRITIC_INSENSITIVE_MATCH) || fq.equalsIgnoreCase(FindQualifiers.DIACRITIC_INSENSITIVE_MATCH_TMODEL)) {
618 if (fqTable.get(FindQualifiers.DIACRITIC_SENSITIVE_MATCH.toUpperCase()) != null || fqTable.get(FindQualifiers.DIACRITIC_SENSITIVE_MATCH_TMODEL.toUpperCase()) != null) {
619 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", fq + " & " + FindQualifiers.DIACRITIC_SENSITIVE_MATCH));
620 }
621 }
622
623
624 if (fq.equalsIgnoreCase(FindQualifiers.EXACT_MATCH) || fq.equalsIgnoreCase(FindQualifiers.EXACT_MATCH_TMODEL)) {
625 if (fqTable.get(FindQualifiers.DIACRITIC_INSENSITIVE_MATCH.toUpperCase()) != null || fqTable.get(FindQualifiers.DIACRITIC_INSENSITIVE_MATCH_TMODEL.toUpperCase()) != null) {
626 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", fq + " & " + FindQualifiers.DIACRITIC_INSENSITIVE_MATCH));
627 }
628 } else if (fq.equalsIgnoreCase(FindQualifiers.DIACRITIC_INSENSITIVE_MATCH) || fq.equalsIgnoreCase(FindQualifiers.DIACRITIC_INSENSITIVE_MATCH_TMODEL)) {
629 if (fqTable.get(FindQualifiers.EXACT_MATCH.toUpperCase()) != null || fqTable.get(FindQualifiers.EXACT_MATCH_TMODEL.toUpperCase()) != null) {
630 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", fq + " & " + FindQualifiers.EXACT_MATCH));
631 }
632 }
633
634
635 if (fq.equalsIgnoreCase(FindQualifiers.CASE_SENSITIVE_SORT) || fq.equalsIgnoreCase(FindQualifiers.CASE_SENSITIVE_SORT_TMODEL)) {
636 if (fqTable.get(FindQualifiers.CASE_INSENSITIVE_SORT.toUpperCase()) != null || fqTable.get(FindQualifiers.CASE_INSENSITIVE_SORT_TMODEL.toUpperCase()) != null) {
637 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", fq + " & " + FindQualifiers.CASE_INSENSITIVE_SORT));
638 }
639 } else if (fq.equalsIgnoreCase(FindQualifiers.CASE_INSENSITIVE_SORT) || fq.equalsIgnoreCase(FindQualifiers.CASE_INSENSITIVE_SORT_TMODEL)) {
640 if (fqTable.get(FindQualifiers.CASE_SENSITIVE_SORT.toUpperCase()) != null || fqTable.get(FindQualifiers.CASE_SENSITIVE_SORT_TMODEL.toUpperCase()) != null) {
641 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", fq + " & " + FindQualifiers.CASE_SENSITIVE_SORT));
642 }
643 }
644
645
646 if (fq.equalsIgnoreCase(FindQualifiers.CASE_SENSITIVE_MATCH) || fq.equalsIgnoreCase(FindQualifiers.CASE_SENSITIVE_MATCH_TMODEL)) {
647 if (fqTable.get(FindQualifiers.CASE_INSENSITIVE_MATCH.toUpperCase()) != null || fqTable.get(FindQualifiers.CASE_INSENSITIVE_MATCH_TMODEL.toUpperCase()) != null) {
648 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", fq + " & " + FindQualifiers.CASE_INSENSITIVE_MATCH));
649 }
650 } else if (fq.equalsIgnoreCase(FindQualifiers.CASE_INSENSITIVE_MATCH) || fq.equalsIgnoreCase(FindQualifiers.CASE_INSENSITIVE_MATCH_TMODEL)) {
651 if (fqTable.get(FindQualifiers.CASE_SENSITIVE_MATCH.toUpperCase()) != null || fqTable.get(FindQualifiers.CASE_SENSITIVE_MATCH_TMODEL.toUpperCase()) != null) {
652 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", fq + " & " + FindQualifiers.CASE_SENSITIVE_MATCH));
653 }
654 }
655
656 }
657 }
658
659 private void validateFindingBindingFQ(org.uddi.api_v3.FindQualifiers findQualifiers) throws InvalidCombinationException {
660 if (findQualifiers == null) {
661 return;
662 }
663 for (int i = 0; i < findQualifiers.getFindQualifier().size(); i++) {
664 if (findQualifiers.getFindQualifier().get(i).equals(FindQualifiers.BINARY_SORT) || findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(FindQualifiers.BINARY_SORT_TMODEL)) {
665 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", FindQualifiers.BINARY_SORT));
666 }
667 if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(FindQualifiers.CASE_INSENSITIVE_MATCH) || findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(FindQualifiers.CASE_INSENSITIVE_MATCH_TMODEL)) {
668 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", FindQualifiers.CASE_INSENSITIVE_MATCH));
669 }
670 if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(FindQualifiers.CASE_SENSITIVE_MATCH) || findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(FindQualifiers.CASE_SENSITIVE_MATCH_TMODEL)) {
671 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", FindQualifiers.CASE_SENSITIVE_MATCH));
672 }
673 if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(FindQualifiers.CASE_INSENSITIVE_SORT) || findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(FindQualifiers.CASE_INSENSITIVE_SORT_TMODEL)) {
674 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", FindQualifiers.CASE_INSENSITIVE_SORT));
675 }
676 if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(FindQualifiers.CASE_SENSITIVE_SORT) || findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(FindQualifiers.CASE_SENSITIVE_SORT_TMODEL)) {
677 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", FindQualifiers.CASE_SENSITIVE_SORT_TMODEL));
678 }
679 if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(FindQualifiers.SORT_BY_NAME_ASC) || findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(FindQualifiers.SORT_BY_NAME_ASC_TMODEL)) {
680 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", FindQualifiers.SORT_BY_NAME_ASC));
681 }
682 if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(FindQualifiers.SORT_BY_NAME_DESC) || findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(FindQualifiers.SORT_BY_NAME_DESC_TMODEL)) {
683 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", FindQualifiers.SORT_BY_NAME_DESC));
684 }
685 }
686 }
687
688 private void validateFindRelatedBusinessesFindQualifiers(org.uddi.api_v3.FindQualifiers findQualifiers) throws InvalidCombinationException {
689 if (findQualifiers == null) {
690 return;
691 }
692 for (int i = 0; i < findQualifiers.getFindQualifier().size(); i++) {
693 if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(FindQualifiers.AND_ALL_KEYS) || findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(FindQualifiers.AND_ALL_KEYS_TMODEL)) {
694 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", FindQualifiers.AND_ALL_KEYS));
695 }
696 }
697 }
698
699 private void validateFindQualifiers_AppoximateMatchAndCombinedCatbag(org.uddi.api_v3.FindQualifiers findQualifiers) throws InvalidCombinationException {
700 if (findQualifiers == null) {
701 return;
702 }
703 boolean containsAPPROXIMATE_MATCH = false;
704 boolean containsCOMBINE_CATEGORY_BAGS = false;
705 for (int i = 0; i < findQualifiers.getFindQualifier().size(); i++) {
706 if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(FindQualifiers.APPROXIMATE_MATCH) || findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(FindQualifiers.APPROXIMATE_MATCH_TMODEL)) {
707 containsAPPROXIMATE_MATCH = true;
708 }
709 if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(FindQualifiers.COMBINE_CATEGORY_BAGS) || findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(FindQualifiers.COMBINE_CATEGORY_BAGS_TMODEL)) {
710 containsCOMBINE_CATEGORY_BAGS = true;
711 }
712 }
713 if (containsAPPROXIMATE_MATCH && containsCOMBINE_CATEGORY_BAGS) {
714 throw new InvalidCombinationException(new ErrorMessage("errors.findqualifiers.InvalidCombo", FindQualifiers.COMBINE_CATEGORY_BAGS + " & " + FindQualifiers.APPROXIMATE_MATCH_TMODEL));
715 }
716
717 }
718
719 static Map<String,Boolean> supportedFindqualifiers = null;
720 private void ValidateSupportedFindQualifier(String fq) throws UnsupportedException {
721 if (supportedFindqualifiers==null || supportedFindqualifiers.isEmpty())
722 InitFindQualifierMap();
723 if (supportedFindqualifiers.get(fq.toLowerCase())==null)
724 throw new UnsupportedException(new ErrorMessage("errors.Unsupported.findQualifier", fq));
725 }
726
727 private void InitFindQualifierMap() {
728 supportedFindqualifiers = new HashMap<String, Boolean>();
729 supportedFindqualifiers.put(FindQualifiers.AND_ALL_KEYS.toLowerCase(), true);
730 supportedFindqualifiers.put(FindQualifiers.AND_ALL_KEYS_TMODEL.toLowerCase(), true);
731 supportedFindqualifiers.put(FindQualifiers.APPROXIMATE_MATCH.toLowerCase(), true);
732 supportedFindqualifiers.put(FindQualifiers.APPROXIMATE_MATCH_TMODEL.toLowerCase(), true);
733 supportedFindqualifiers.put(FindQualifiers.BINARY_SORT.toLowerCase(), true);
734 supportedFindqualifiers.put(FindQualifiers.BINARY_SORT_TMODEL.toLowerCase(), true);
735 supportedFindqualifiers.put(FindQualifiers.BINDING_SUBSET.toLowerCase(), true);
736 supportedFindqualifiers.put(FindQualifiers.BINDING_SUBSET_TMODEL.toLowerCase(), true);
737 supportedFindqualifiers.put(FindQualifiers.CASE_INSENSITIVE_MATCH.toLowerCase(), true);
738 supportedFindqualifiers.put(FindQualifiers.CASE_INSENSITIVE_MATCH_TMODEL.toLowerCase(), true);
739
740
741
742 supportedFindqualifiers.put(FindQualifiers.CASE_SENSITIVE_MATCH.toLowerCase(), true);
743 supportedFindqualifiers.put(FindQualifiers.CASE_SENSITIVE_MATCH_TMODEL.toLowerCase(), true);
744 supportedFindqualifiers.put(FindQualifiers.CASE_SENSITIVE_SORT.toLowerCase(), true);
745 supportedFindqualifiers.put(FindQualifiers.CASE_SENSITIVE_SORT_TMODEL.toLowerCase(), true);
746 supportedFindqualifiers.put(FindQualifiers.COMBINE_CATEGORY_BAGS.toLowerCase(), true);
747 supportedFindqualifiers.put(FindQualifiers.COMBINE_CATEGORY_BAGS_TMODEL.toLowerCase(), true);
748 supportedFindqualifiers.put(FindQualifiers.DIACRITIC_INSENSITIVE_MATCH.toLowerCase(), true);
749 supportedFindqualifiers.put(FindQualifiers.DIACRITIC_INSENSITIVE_MATCH_TMODEL.toLowerCase(), true);
750 supportedFindqualifiers.put(FindQualifiers.DIACRITIC_SENSITIVE_MATCH.toLowerCase(), true);
751 supportedFindqualifiers.put(FindQualifiers.DIACRITIC_SENSITIVE_MATCH_TMODEL.toLowerCase(), true);
752 supportedFindqualifiers.put(FindQualifiers.EXACT_MATCH.toLowerCase(), true);
753 supportedFindqualifiers.put(FindQualifiers.EXACT_MATCH_TMODEL.toLowerCase(), true);
754 supportedFindqualifiers.put(FindQualifiers.OR_ALL_KEYS.toLowerCase(), true);
755 supportedFindqualifiers.put(FindQualifiers.OR_ALL_KEYS_TMODEL.toLowerCase(), true);
756 supportedFindqualifiers.put(FindQualifiers.OR_LIKE_KEYS.toLowerCase(), true);
757 supportedFindqualifiers.put(FindQualifiers.OR_LIKE_KEYS_TMODEL.toLowerCase(), true);
758 supportedFindqualifiers.put(FindQualifiers.SERVICE_SUBSET.toLowerCase(), true);
759 supportedFindqualifiers.put(FindQualifiers.SERVICE_SUBSET_TMODEL.toLowerCase(), true);
760 supportedFindqualifiers.put(FindQualifiers.SIGNATURE_PRESENT.toLowerCase(), true);
761 supportedFindqualifiers.put(FindQualifiers.SIGNATURE_PRESENT_TMODEL.toLowerCase(), true);
762 supportedFindqualifiers.put(FindQualifiers.SORT_BY_DATE_ASC.toLowerCase(), true);
763 supportedFindqualifiers.put(FindQualifiers.SORT_BY_DATE_ASC_TMODEL.toLowerCase(), true);
764 supportedFindqualifiers.put(FindQualifiers.SORT_BY_DATE_DESC.toLowerCase(), true);
765 supportedFindqualifiers.put(FindQualifiers.SORT_BY_DATE_DESC_TMODEL.toLowerCase(), true);
766 supportedFindqualifiers.put(FindQualifiers.SORT_BY_NAME_ASC.toLowerCase(), true);
767 supportedFindqualifiers.put(FindQualifiers.SORT_BY_NAME_ASC_TMODEL.toLowerCase(), true);
768 supportedFindqualifiers.put(FindQualifiers.SORT_BY_NAME_DESC.toLowerCase(), true);
769 supportedFindqualifiers.put(FindQualifiers.SORT_BY_NAME_DESC_TMODEL.toLowerCase(), true);
770 supportedFindqualifiers.put(FindQualifiers.SUPPRESS_PROJECTED_SERVICES.toLowerCase(), true);
771 supportedFindqualifiers.put(FindQualifiers.SUPPRESS_PROJECTED_SERVICES_TMODEL.toLowerCase(), true);
772 supportedFindqualifiers.put(FindQualifiers.UTS_10.toLowerCase(), true);
773 supportedFindqualifiers.put(FindQualifiers.UTS_10_TMODEL.toLowerCase(), true);
774
775 }
776
777 private void validateServiceExists(String serviceKey) throws InvalidKeyPassedException {
778
779 EntityManager em = PersistenceManager.getEntityManager();
780 EntityTransaction tx = em.getTransaction();
781 try {
782 tx.begin();
783
784 org.apache.juddi.model.BusinessService modelBusinessService = null;
785 try {
786 modelBusinessService = em.find(org.apache.juddi.model.BusinessService.class, serviceKey);
787 } catch (ClassCastException e) {
788 }
789 if (modelBusinessService == null) {
790 throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.ServiceNotFound", serviceKey));
791 }
792
793 tx.commit();
794
795 } finally {
796 if (tx.isActive()) {
797 tx.rollback();
798 }
799 em.close();
800 }
801 }
802 }