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