KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > juddi > function > GetSubscriptionResultsFunction


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.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.GetSubscriptionResults;
24 import org.apache.juddi.datatype.response.SubscriptionResultsList;
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 GetSubscriptionResultsFunction extends AbstractFunction
38 {
39   // private reference to jUDDI Logger
40
private static Log log = LogFactory.getLog(GetSubscriptionResultsFunction.class);
41
42   /**
43    *
44    */

45   public GetSubscriptionResultsFunction(RegistryEngine registry)
46   {
47     super(registry);
48   }
49
50   /**
51    *
52    */

53   public RegistryObject execute(RegistryObject regObject)
54     throws RegistryException
55   {
56     GetSubscriptionResults request = (GetSubscriptionResults)regObject;
57     String JavaDoc generic = request.getGeneric();
58
59     // aquire a jUDDI datastore instance
60
DataStore dataStore = DataStoreFactory.getDataStore();
61
62     try
63     {
64       dataStore.beginTrans();
65
66       // TODO (UDDI v3) Implement get_subscriptionResults business logic.
67

68       dataStore.commit();
69
70       // create a new PublisherDetail and stuff the new tModelVector into it.
71
SubscriptionResultsList list = new SubscriptionResultsList();
72       list.setGeneric(generic);
73       list.setOperator(Config.getOperator());
74       return list;
75     }
76     catch(InvalidKeyPassedException ex)
77     {
78       try { dataStore.rollback(); } catch(Exception JavaDoc e) { }
79       log.info(ex);
80       throw (RegistryException)ex;
81     }
82     catch(InvalidValueException ex)
83     {
84       try { dataStore.rollback(); } catch(Exception JavaDoc e) { }
85       log.info(ex);
86       throw (RegistryException)ex;
87     }
88     catch(UnsupportedException ex)
89     {
90       try { dataStore.rollback(); } catch(Exception JavaDoc e) { }
91       log.info(ex);
92       throw (RegistryException)ex;
93     }
94     catch(UserMismatchException ex)
95     {
96       try { dataStore.rollback(); } catch(Exception JavaDoc e) { }
97       log.info(ex);
98       throw (RegistryException)ex;
99     }
100     catch(InvalidTimeException ex)
101     {
102       try { dataStore.rollback(); } catch(Exception JavaDoc e) { }
103       log.info(ex);
104       throw (RegistryException)ex;
105     }
106     catch(RegistryException regex)
107     {
108       try { dataStore.rollback(); } catch(Exception JavaDoc e) { }
109       log.error(regex);
110       throw (RegistryException)regex;
111     }
112     catch(Exception JavaDoc ex)
113     {
114       try { dataStore.rollback(); } catch(Exception JavaDoc 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 JavaDoc[] args)
133   {
134     // initialize the registry
135
RegistryEngine reg = new RegistryEngine();
136     reg.init();
137
138     try
139     {
140     }
141     catch (Exception JavaDoc ex)
142     {
143       // write execption to the console
144
ex.printStackTrace();
145     }
146     finally
147     {
148       // destroy the registry
149
reg.dispose();
150     }
151   }
152 }
Popular Tags