KickJava   Java API By Example, From Geeks To Geeks.

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


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.apache.juddi.registry.AbstractService;
30 import org.w3c.dom.Element JavaDoc;
31
32 /**
33  * @author Steve Viens (sviens@apache.org)
34  */

35 public class PublishService extends AbstractService
36 {
37   // private reference to the webapp's logger.
38
private static Log log = LogFactory.getLog(PublishService.class);
39
40   // collection of valid operations
41
private TreeSet JavaDoc operations = null;
42
43   public void init(ServletConfig JavaDoc config)
44     throws ServletException JavaDoc
45     {
46     super.init(config);
47     
48     operations = new TreeSet JavaDoc();
49     operations.add("get_authtoken");
50     operations.add("get_registeredinfo");
51     operations.add("discard_authtoken");
52     operations.add("save_business");
53     operations.add("save_service");
54     operations.add("save_binding");
55     operations.add("save_tmodel");
56     operations.add("delete_business");
57     operations.add("delete_service");
58     operations.add("delete_binding");
59     operations.add("delete_tmodel");
60     operations.add("add_publisherassertions");
61     operations.add("set_publisherassertions");
62     operations.add("get_publisherassertions");
63     operations.add("delete_publisherassertions");
64     operations.add("get_assertionstatusreport");
65     }
66
67   public void validateRequest(String JavaDoc operation,String JavaDoc version,Element JavaDoc uddiReq)
68         throws RegistryException
69     {
70     // If the value
71
// specified is not "2.0" then throw an exception (this
72
// value must be specified for all UDDI requests and
73
// only version 2.0 UDDI requests are supported by
74
// this endpoint).
75

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