This project has retired. For details please refer to its Attic page.
PublicationQuery xref
View Javadoc
1   /*
2    * Copyright 2001-2008 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   */
17  package org.apache.juddi.api.util;
18  
19  import java.util.ArrayList;
20  import java.util.Hashtable;
21  import java.util.List;
22  
23  /**
24   * Enum to represent the queries within the publication API.
25   * 
26   * @author <a href="mailto:tcunning@apache.org">Tom Cunningham</a>
27   */
28  public enum PublicationQuery implements UDDIQuery {
29      GET_REGISTEREDINFO("get_registeredInfo"),
30      SAVE_BUSINESS("save_business"),
31      SAVE_SERVICE("save_service"),
32      SAVE_BINDING("save_binding"),
33      SAVE_TMODEL("save_tmodel"),
34      DELETE_BUSINESS("delete_business"),
35      DELETE_SERVICE("delete_service"),
36      DELETE_BINDING("delete_binding"),
37      DELETE_TMODEL("delete_tmodel"),
38      ADD_PUBLISHERASSERTIONS("add_publisherassertions"),
39      SET_PUBLISHERASSERTIONS("set_publisherassertions"),
40      GET_PUBLISHERASSERTIONS("get_publisherassertions"),
41      DELETE_PUBLISHERASSERTIONS("delete_publisherassertions"),
42      GET_ASSERTIONSTATUSREPORT("get_assertionstatusreport");
43      
44      private String _query;
45      private static Hashtable<String, PublicationQuery> _publicationQueries = null;
46      
47      PublicationQuery(final String query) {
48          _query = query;
49      }
50      
51      public String getQuery() {
52          return _query;
53      }
54      
55      public synchronized static void initPublicationQueries () {
56              if (_publicationQueries == null) {
57                  _publicationQueries = new Hashtable();
58  
59                  _publicationQueries.put(PublicationQuery.GET_REGISTEREDINFO.getQuery(), PublicationQuery.GET_REGISTEREDINFO);
60                  _publicationQueries.put(PublicationQuery.SAVE_BUSINESS.getQuery(), PublicationQuery.SAVE_BUSINESS);
61                  _publicationQueries.put(PublicationQuery.SAVE_SERVICE.getQuery(), PublicationQuery.SAVE_SERVICE);
62                  _publicationQueries.put(PublicationQuery.SAVE_BINDING.getQuery(), PublicationQuery.SAVE_BINDING);
63                  _publicationQueries.put(PublicationQuery.SAVE_TMODEL.getQuery(), PublicationQuery.SAVE_TMODEL);
64                  _publicationQueries.put(PublicationQuery.DELETE_BUSINESS.getQuery(), PublicationQuery.DELETE_BUSINESS);
65                  _publicationQueries.put(PublicationQuery.DELETE_SERVICE.getQuery(), PublicationQuery.DELETE_SERVICE);
66                  _publicationQueries.put(PublicationQuery.DELETE_BINDING.getQuery(), PublicationQuery.DELETE_BINDING);
67                  _publicationQueries.put(PublicationQuery.DELETE_TMODEL.getQuery(), PublicationQuery.DELETE_TMODEL);
68                  _publicationQueries.put(PublicationQuery.ADD_PUBLISHERASSERTIONS.getQuery(), PublicationQuery.ADD_PUBLISHERASSERTIONS);
69                  _publicationQueries.put(PublicationQuery.SET_PUBLISHERASSERTIONS.getQuery(), PublicationQuery.SET_PUBLISHERASSERTIONS);
70                  _publicationQueries.put(PublicationQuery.GET_PUBLISHERASSERTIONS.getQuery(), PublicationQuery.GET_PUBLISHERASSERTIONS);
71                  _publicationQueries.put(PublicationQuery.DELETE_PUBLISHERASSERTIONS.getQuery(), PublicationQuery.DELETE_PUBLISHERASSERTIONS);
72                  _publicationQueries.put(PublicationQuery.GET_ASSERTIONSTATUSREPORT.getQuery(), PublicationQuery.GET_ASSERTIONSTATUSREPORT);       
73              }
74      }
75  
76      public static List<String> getQueries() {
77          if (_publicationQueries == null) {
78              initPublicationQueries();
79          }
80          
81          List list = new ArrayList<String>(_publicationQueries.keySet());
82          return list;
83      }
84  
85      /**
86       * this doesn't appear to be used anywhere and will be removed in a future version
87       * @param query
88       * @return
89       * @deprecated
90       */
91      public static PublicationQuery fromQuery(final String query) {
92          if (_publicationQueries == null) {
93              initPublicationQueries();
94          }
95          
96          if (_publicationQueries.contains(query)) {
97              return _publicationQueries.get(query);
98          } else {
99              throw new IllegalArgumentException("Unrecognized query " + query);
100         }        
101     }    
102 }