View Javadoc
1   /*
2    * Copyright 2014 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.api.util;
17  
18  import java.util.ArrayList;
19  import java.util.Hashtable;
20  import java.util.List;
21  
22  /**
23   * enumerated data type to help with MBean lookups
24   */
25  public enum JUDDIQuery implements UDDIQuery {
26  
27          SAVE_PUBLISHER("save_publisher"),
28          DELETE_PUBLISHER("delete_publisher"),
29          GET_PUBLISHER_DETAIL("get_publisherDetail"),
30          GET_ALL_PUBLISHER_DETAIL("get_allPublisherDetail"),
31          ADMIN_DELETE_TMODEL("admin_deleteTmodel"),
32          DELETE_CLIENT_SUB("delete_clientSubscriptionInfo"),
33          SAVE_CLIENT_SUB("save_clientSubscriptionInfo"),
34          GET_ALL_CLIENT_SUB("get_allClientSubscriptionInfo"),
35          GET_CLIENT_SUB("get_clientSubscriptionInfo"),
36          SAVE_CLERK("save_clerk"),
37          SAVE_NODE("save_node"),
38          GET_ALL_NODES("get_allNodes"),
39          DELETE_NODE("delete_node"),
40          GET_ALL_CLERKS("get_allClerks"),
41          DELETE_CLERK("delete_clerk"),
42          ADMIN_DELETE_SUB("admin_deleteSubcriptionInfo"),
43          ADMIN_SAVE_TMODEL("admin_saveTmodel"),
44          ADMIN_SAVE_BUSINESS("admin_saveBusiness"),
45          SET_REPLICATION_NODES("set_replicationNodes"),
46          GET_REPLICATION_NODES("get_replicationNodes"),
47          ADMIN_SAVE_SUB("admin_saveClientSubscription"),
48          ADMIN_GET_HISTORY("admin_getEntityHistory"),
49          INVOKE_SYNCSUB("invoke_synchSubscription"),
50          ADMIN_GET_FAILED_CRS("getFailedReplicationChangeRecords");
51          private String _query;
52          private static Hashtable<String, JUDDIQuery> _inquiryQueries = null;
53  
54          JUDDIQuery(final String query) {
55                  _query = query;
56          }
57  
58          public String getQuery() {
59                  return _query;
60          }
61  
62          public synchronized static void initInquiryQueries() {
63                  if (_inquiryQueries == null) {
64                          _inquiryQueries = new Hashtable();
65                          _inquiryQueries.put("save_publisher", JUDDIQuery.SAVE_PUBLISHER);
66                          _inquiryQueries.put("delete_publisher", JUDDIQuery.DELETE_PUBLISHER);
67                          _inquiryQueries.put("get_publisherDetail", JUDDIQuery.GET_PUBLISHER_DETAIL);
68                          _inquiryQueries.put("get_allPublisherDetail", JUDDIQuery.GET_ALL_PUBLISHER_DETAIL);
69                          _inquiryQueries.put("admin_deleteTmodel", JUDDIQuery.ADMIN_DELETE_TMODEL);
70                          _inquiryQueries.put("delete_clientSubscriptionInfo", JUDDIQuery.DELETE_CLIENT_SUB);
71                          _inquiryQueries.put("save_clientSubscriptionInfo", JUDDIQuery.SAVE_CLIENT_SUB);
72                          _inquiryQueries.put("get_allClientSubscriptionInfo", JUDDIQuery.GET_ALL_CLIENT_SUB);
73                          _inquiryQueries.put("get_clientSubscriptionInfo", JUDDIQuery.GET_CLIENT_SUB);
74                          _inquiryQueries.put("save_clerk", JUDDIQuery.SAVE_CLERK);
75                          _inquiryQueries.put("save_node", JUDDIQuery.SAVE_NODE);
76                          _inquiryQueries.put("get_allNodes", JUDDIQuery.GET_ALL_NODES);
77  
78                          _inquiryQueries.put("delete_node", JUDDIQuery.DELETE_NODE);
79  
80                          _inquiryQueries.put("get_allClerks", JUDDIQuery.GET_ALL_CLERKS);
81                          _inquiryQueries.put("delete_clerk", JUDDIQuery.DELETE_CLERK);
82                          _inquiryQueries.put("admin_deleteSubcriptionInfo", JUDDIQuery.ADMIN_DELETE_SUB);
83                          _inquiryQueries.put("admin_saveTmodel", JUDDIQuery.ADMIN_SAVE_TMODEL);
84                          _inquiryQueries.put("admin_saveBusiness", JUDDIQuery.ADMIN_SAVE_BUSINESS);
85                          _inquiryQueries.put("set_replicationNodes", JUDDIQuery.SET_REPLICATION_NODES);
86                          _inquiryQueries.put("get_replicationNodes", JUDDIQuery.GET_REPLICATION_NODES);
87                          _inquiryQueries.put("admin_saveClientSubscription", JUDDIQuery.ADMIN_SAVE_SUB);
88                          _inquiryQueries.put("admin_getEntityHistory", JUDDIQuery.ADMIN_GET_HISTORY);
89                          _inquiryQueries.put("invoke_synchSubscription", JUDDIQuery.INVOKE_SYNCSUB);
90                          _inquiryQueries.put("getFailedReplicationChangeRecords", JUDDIQuery.ADMIN_GET_FAILED_CRS);
91  
92                          
93                  }
94          }
95  
96          public static List<String> getQueries() {
97                  if (_inquiryQueries == null) {
98                          initInquiryQueries();
99                  }
100 
101                 List list = new ArrayList<String>(_inquiryQueries.keySet());
102                 return list;
103         }
104 
105         /**
106         * this doesn't appear to be used anywhere and will be removed in a future version
107         * @param query
108         * @return
109         * @deprecated
110         */
111         public static JUDDIQuery fromQuery(final String query) {
112                 if (_inquiryQueries == null) {
113                         initInquiryQueries();
114                 }
115 
116                 if (_inquiryQueries.contains(query)) {
117                         return _inquiryQueries.get(query);
118                 } else {
119                         throw new IllegalArgumentException("Unrecognized query " + query);
120                 }
121         }
122 
123 }