KickJava   Java API By Example, From Geeks To Geeks.

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


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 AdminService extends AbstractService
35 {
36   // private reference to the webapp's logger.
37
private static Log log = LogFactory.getLog(AdminService.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("get_registryinfo");
49     operations.add("find_publisher");
50     operations.add("get_publisherdetail");
51     operations.add("save_publisher");
52     operations.add("delete_publisher");
53   }
54   
55   public void validateRequest(String JavaDoc operation,String JavaDoc version,Element JavaDoc uddiReq)
56         throws RegistryException
57     {
58     // Grab the generic attribute value. If one isn't
59
// specified or the value specified is not "1.0" then
60
// throw an exception (this value must be specified
61
// for all UDDI requests and the endpoint called only
62
// supports UDDI version 1.0 requests).
63

64     if (version == null)
65       throw new FatalErrorException("A jUDDI generic attribute " +
66         "value was not found for UDDI request: "+operation+" (The " +
67         "'generic' attribute must be present)");
68     else if (!version.equals(IRegistry.JUDDI_V1_GENERIC))
69       throw new UnsupportedException("Only jUDDI v1 requests " +
70         "are currently supported. The generic attribute value " +
71         "received was: "+version);
72
73     if ((operation == null) || (operation.trim().length() == 0))
74       throw new FatalErrorException("The jUDDI service operation " +
75         "could not be identified.");
76     else if (!operations.contains(operation.toLowerCase()))
77         throw new UnsupportedException("The operation "+operation+" is not " +
78                 "supported by the jUDDI Admin API.");
79     }
80 }
81
Popular Tags