1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.juddi.registry.local;
17
18 import java.util.TreeSet;
19
20 import org.apache.juddi.IRegistry;
21 import org.apache.juddi.error.FatalErrorException;
22 import org.apache.juddi.error.RegistryException;
23 import org.apache.juddi.error.UnsupportedException;
24 import org.w3c.dom.Element;
25 import org.w3c.dom.Node;
26
27 /***
28 * @author Kurt Stam (kurt.stam@redhat.com)
29 */
30 public class InquiryService
31 {
32
33 private TreeSet operations = null;
34
35 public InquiryService() {
36 super();
37 operations = new TreeSet();
38 operations.add("find_business");
39 operations.add("find_service");
40 operations.add("find_binding");
41 operations.add("find_tmodel");
42 operations.add("find_relatedbusinesses");
43 operations.add("get_businessdetail");
44 operations.add("get_businessdetailext");
45 operations.add("get_servicedetail");
46 operations.add("get_bindingdetail");
47 operations.add("get_tmodeldetail");
48 }
49
50
51
52
53 public void validateRequest(String operation,String version,Element uddiReq)
54 throws RegistryException
55 {
56
57
58
59
60
61
62 if (version == null)
63 throw new FatalErrorException("A UDDI generic attribute " +
64 "value was not found for UDDI request: "+operation+" (The " +
65 "'generic' attribute must be present)");
66 else if (!version.equals(IRegistry.UDDI_V2_GENERIC))
67 throw new UnsupportedException("Only UDDI v2 " +
68 "requests are currently supported. The generic attribute value " +
69 "received was: "+version);
70
71 if ((operation == null) || (operation.trim().length() == 0))
72 throw new FatalErrorException("The UDDI service operation " +
73 "could not be identified.");
74 else if (!operations.contains(operation.toLowerCase()))
75 throw new UnsupportedException("The operation "+operation+" is not " +
76 "supported by the UDDI version 2 Inquiry API.");
77 }
78
79 public Node inquire(Element uddiReq) throws Exception{
80
81
82 RequestHandler requestHandler = new RequestHandler();
83 requestHandler.setUddiReq(uddiReq);
84 String operation = requestHandler.getOperation(uddiReq);
85 String version = requestHandler.getVersion(uddiReq,operation);
86 validateRequest(operation, version, uddiReq);
87 Thread thread = new Thread(requestHandler, "WorkThread");
88 thread.start();
89 thread.join();
90 if (requestHandler.getException()!=null) {
91 throw new Exception(requestHandler.getException());
92 }
93 return requestHandler.getResponse();
94 }
95
96 }