KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > juddi > registry > InquiryService


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.juddi.registry;
17
18 import java.util.TreeSet JavaDoc;
19
20 import javax.servlet.ServletConfig JavaDoc;
21 import javax.servlet.ServletException JavaDoc;
22
23 import org.apache.commons.logging.Log;
24 import org.apache.commons.logging.LogFactory;
25 import org.apache.juddi.IRegistry;
26 import org.apache.juddi.error.FatalErrorException;
27 import org.apache.juddi.error.RegistryException;
28 import org.apache.juddi.error.UnsupportedException;
29 import org.w3c.dom.Element JavaDoc;
30
31 /**
32  * @author Steve Viens (sviens@apache.org)
33  */

34 public class InquiryService extends AbstractService
35 {
36   // private reference to the webapp's logger.
37
private static Log log = LogFactory.getLog(InquiryService.class);
38   
39   // collection of valid operations
40
private TreeSet JavaDoc operations = null;
41
42   public void init(ServletConfig JavaDoc config)
43     throws ServletException JavaDoc
44     {
45     super.init(config);
46     
47     operations = new TreeSet JavaDoc();
48     operations.add("find_business");
49     operations.add("find_service");
50     operations.add("find_binding");
51     operations.add("find_tmodel");
52     operations.add("find_relatedbusinesses");
53     operations.add("get_businessdetail");
54     operations.add("get_businessdetailext");
55     operations.add("get_servicedetail");
56     operations.add("get_bindingdetail");
57     operations.add("get_tmodeldetail");
58     }
59
60   public void validateRequest(String JavaDoc operation,String JavaDoc version,Element JavaDoc uddiReq)
61         throws RegistryException
62     {
63     // If the value
64
// specified is not "2.0" then throw an exception (this
65
// value must be specified for all UDDI requests and
66
// only version 2.0 UDDI requests are supported by
67
// this endpoint).
68

69     if (version == null)
70       throw new FatalErrorException("A UDDI generic attribute " +
71         "value was not found for UDDI request: "+operation+" (The " +
72         "'generic' attribute must be present)");
73     else if (!version.equals(IRegistry.UDDI_V2_GENERIC))
74       throw new UnsupportedException("Only UDDI v2 " +
75         "requests are currently supported. The generic attribute value " +
76         "received was: "+version);
77
78     if ((operation == null) || (operation.trim().length() == 0))
79       throw new FatalErrorException("The UDDI service operation " +
80         "could not be identified.");
81     else if (!operations.contains(operation.toLowerCase()))
82         throw new UnsupportedException("The operation "+operation+" is not " +
83                 "supported by the UDDI version 2 Inquiry API.");
84     }
85 }
86
Popular Tags