1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.juddi.function;
17
18 import org.apache.commons.logging.Log;
19 import org.apache.commons.logging.LogFactory;
20 import org.apache.juddi.datastore.DataStore;
21 import org.apache.juddi.datastore.DataStoreFactory;
22 import org.apache.juddi.datatype.RegistryObject;
23 import org.apache.juddi.datatype.request.GetSubscriptions;
24 import org.apache.juddi.datatype.response.Subscriptions;
25 import org.apache.juddi.error.InvalidKeyPassedException;
26 import org.apache.juddi.error.InvalidTimeException;
27 import org.apache.juddi.error.InvalidValueException;
28 import org.apache.juddi.error.RegistryException;
29 import org.apache.juddi.error.UnsupportedException;
30 import org.apache.juddi.error.UserMismatchException;
31 import org.apache.juddi.registry.RegistryEngine;
32 import org.apache.juddi.util.Config;
33
34 /***
35 * @author Steve Viens (sviens@apache.org)
36 */
37 public class GetSubscriptionsFunction extends AbstractFunction
38 {
39
40 private static Log log = LogFactory.getLog(GetSubscriptionsFunction.class);
41
42 /***
43 *
44 */
45 public GetSubscriptionsFunction(RegistryEngine registry)
46 {
47 super(registry);
48 }
49
50 /***
51 *
52 */
53 public RegistryObject execute(RegistryObject regObject)
54 throws RegistryException
55 {
56 GetSubscriptions request = (GetSubscriptions)regObject;
57 String generic = request.getGeneric();
58
59
60 DataStore dataStore = DataStoreFactory.getDataStore();
61
62 try
63 {
64 dataStore.beginTrans();
65
66
67
68 dataStore.commit();
69
70
71 Subscriptions subs = new Subscriptions();
72 subs.setGeneric(generic);
73 subs.setOperator(Config.getOperator());
74 return subs;
75 }
76 catch(InvalidKeyPassedException ex)
77 {
78 try { dataStore.rollback(); } catch(Exception e) { }
79 log.info(ex);
80 throw (RegistryException)ex;
81 }
82 catch(InvalidValueException ex)
83 {
84 try { dataStore.rollback(); } catch(Exception e) { }
85 log.info(ex);
86 throw (RegistryException)ex;
87 }
88 catch(UnsupportedException ex)
89 {
90 try { dataStore.rollback(); } catch(Exception e) { }
91 log.info(ex);
92 throw (RegistryException)ex;
93 }
94 catch(UserMismatchException ex)
95 {
96 try { dataStore.rollback(); } catch(Exception e) { }
97 log.info(ex);
98 throw (RegistryException)ex;
99 }
100 catch(InvalidTimeException ex)
101 {
102 try { dataStore.rollback(); } catch(Exception e) { }
103 log.info(ex);
104 throw (RegistryException)ex;
105 }
106 catch(RegistryException regex)
107 {
108 try { dataStore.rollback(); } catch(Exception e) { }
109 log.error(regex);
110 throw (RegistryException)regex;
111 }
112 catch(Exception ex)
113 {
114 try { dataStore.rollback(); } catch(Exception e) { }
115 log.error(ex);
116 throw new RegistryException(ex);
117 }
118 finally
119 {
120 if (dataStore != null)
121 dataStore.release();
122 }
123
124 }
125
126
127 /****************************************************************************/
128 /****************************** TEST DRIVER *********************************/
129 /****************************************************************************/
130
131
132 public static void main(String[] args)
133 {
134
135 RegistryEngine reg = new RegistryEngine();
136 reg.init();
137
138 try
139 {
140 }
141 catch (Exception ex)
142 {
143
144 ex.printStackTrace();
145 }
146 finally
147 {
148
149 reg.dispose();
150 }
151 }
152 }