KickJava   Java API By Example, From Geeks To Geeks.

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


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.publisher.Publisher;
24 import org.apache.juddi.datatype.request.AuthInfo;
25 import org.apache.juddi.datatype.request.GetAssertionStatusReport;
26 import org.apache.juddi.datatype.response.AssertionStatusReport;
27 import org.apache.juddi.error.RegistryException;
28 import org.apache.juddi.registry.RegistryEngine;
29 import org.apache.juddi.util.Config;
30
31 /**
32  * @author Steve Viens (sviens@apache.org)
33  */

34 public class GetAssertionStatusReportFunction extends AbstractFunction
35 {
36   // private reference to jUDDI Logger
37
private static Log log = LogFactory.getLog(GetAssertionStatusReportFunction.class);
38
39   /**
40    *
41    */

42   public GetAssertionStatusReportFunction(RegistryEngine registry)
43   {
44     super(registry);
45   }
46
47   /**
48    *
49    */

50   public RegistryObject execute(RegistryObject regObject)
51     throws RegistryException
52   {
53     GetAssertionStatusReport request = (GetAssertionStatusReport)regObject;
54     String JavaDoc generic = request.getGeneric();
55     String JavaDoc completionStatus = request.getCompletionStatus();
56     AuthInfo authInfo = request.getAuthInfo();
57     AssertionStatusReport report = null;
58
59     // aquire a jUDDI datastore instance
60
DataStore dataStore = DataStoreFactory.getDataStore();
61
62     try
63     {
64       dataStore.beginTrans();
65
66       // validates authentication parameters
67
Publisher publisher = getPublisher(authInfo,dataStore);
68       String JavaDoc publisherID = publisher.getPublisherID();
69
70       // validate request parameters & execute
71
// nothing to validate
72

73       // get the AssertionStatusReport
74
report = new AssertionStatusReport();
75       report.setGeneric(generic);
76       report.setOperator(Config.getOperator());
77       report.setAssertionStatusItemVector(dataStore.getAssertionStatusItems(publisherID,completionStatus));
78
79       dataStore.commit();
80     }
81     catch(RegistryException regex)
82     {
83       try { dataStore.rollback(); } catch(Exception JavaDoc e) { }
84       log.error(regex);
85       throw (RegistryException)regex;
86     }
87     catch(Exception JavaDoc ex)
88     {
89       try { dataStore.rollback(); } catch(Exception JavaDoc e) { }
90       log.error(ex);
91       throw new RegistryException(ex);
92     }
93     finally
94     {
95       if (dataStore != null)
96         dataStore.release();
97     }
98
99     // didn't encounter an exception so let's return
100
// the pre-constructed successful DispositionReport
101
return report;
102   }
103
104
105   /***************************************************************************/
106   /***************************** TEST DRIVER *********************************/
107   /***************************************************************************/
108
109
110   public static void main(String JavaDoc[] args)
111   {
112     // initialize the registry
113
RegistryEngine reg = new RegistryEngine();
114     reg.init();
115
116     try
117     {
118     }
119     catch (Exception JavaDoc ex)
120     {
121       // write execption to the console
122
ex.printStackTrace();
123     }
124     finally
125     {
126       // destroy the registry
127
reg.dispose();
128     }
129   }
130 }
Popular Tags