1 /*
2 * <cvs:source>$Source: /devel/astrogrid/community/client/src/java/org/astrogrid/community/client/database/manager/DatabaseManagerCoreDelegate.java,v $</cvs:source>
3 * <cvs:author>$Author: dave $</cvs:author>
4 * <cvs:date>$Date: 2004/09/16 23:18:08 $</cvs:date>
5 * <cvs:version>$Revision: 1.7 $</cvs:version>
6 *
7 * <cvs:log>
8 * $Log: DatabaseManagerCoreDelegate.java,v $
9 * Revision 1.7 2004/09/16 23:18:08 dave
10 * Replaced debug logging in Community.
11 * Added stream close() to FileStore.
12 *
13 * Revision 1.6.82.1 2004/09/16 09:58:48 dave
14 * Replaced debug with commons logging ....
15 *
16 * Revision 1.6 2004/06/18 13:45:19 dave
17 * Merged development branch, dave-dev-200406081614, into HEAD
18 *
19 * Revision 1.5.32.3 2004/06/17 15:10:02 dave
20 * Removed unused imports (PMD report).
21 *
22 * Revision 1.5.32.2 2004/06/17 13:38:58 dave
23 * Tidied up old CVS log entries
24 *
25 * </cvs:log>
26 *
27 */
28 package org.astrogrid.community.client.database.manager ;
29
30 import org.apache.commons.logging.Log ;
31 import org.apache.commons.logging.LogFactory ;
32
33 import java.rmi.RemoteException ;
34
35 import org.astrogrid.community.client.service.CommunityServiceCoreDelegate ;
36
37 import org.astrogrid.community.common.database.manager.DatabaseManager ;
38 import org.astrogrid.community.common.exception.CommunityServiceException ;
39
40 /***
41 * The core delegate code for our DatabaseManager service.
42 * This acts as a wrapper for a DatabaseManager service, and handles any RemoteExceptions internally.
43 *
44 */
45 public class DatabaseManagerCoreDelegate
46 extends CommunityServiceCoreDelegate
47 implements DatabaseManager, DatabaseManagerDelegate
48 {
49 /***
50 * Our debug logger.
51 *
52 */
53 private static Log log = LogFactory.getLog(DatabaseManagerCoreDelegate.class);
54
55 /***
56 * Public constructor.
57 *
58 */
59 public DatabaseManagerCoreDelegate()
60 {
61 }
62
63 /***
64 * Our DatabaseManager service.
65 *
66 */
67 private DatabaseManager manager = null ;
68
69 /***
70 * Get a reference to our DatabaseManager service.
71 *
72 */
73 protected DatabaseManager getDatabaseManager()
74 {
75 return this.manager ;
76 }
77
78 /***
79 * Set our our DatabaseManager service.
80 *
81 */
82 protected void setDatabaseManager(DatabaseManager manager)
83 {
84 this.manager = manager ;
85 }
86
87 /***
88 * Get the current database name.
89 * @throws CommunityServiceException If there is an server error.
90 *
91 */
92 public String getDatabaseName()
93 throws CommunityServiceException
94 {
95 //
96 // If we have a valid service reference.
97 if (null != this.manager)
98 {
99 //
100 // Try calling the service method.
101 try {
102 return this.manager.getDatabaseName() ;
103 }
104 //
105 // Catch anything that went BANG.
106 catch (RemoteException ouch)
107 {
108 //
109 // Try converting the Exception.
110 serviceException(ouch) ;
111 //
112 // If we get this far, then we don't know what it is.
113 throw new CommunityServiceException(
114 "WebService call failed - " + ouch,
115 ouch
116 ) ;
117 }
118 }
119 //
120 // If we don't have a valid service.
121 else {
122 throw new CommunityServiceException(
123 "Service not initialised"
124 ) ;
125 }
126 }
127
128 /***
129 * Get our JDO configuration resource name.
130 * @throws CommunityServiceException If there is an server error.
131 *
132 */
133 public String getDatabaseConfigResource()
134 throws CommunityServiceException
135 {
136 //
137 // If we have a valid service reference.
138 if (null != this.manager)
139 {
140 //
141 // Try calling the service method.
142 try {
143 return this.manager.getDatabaseConfigResource() ;
144 }
145 //
146 // Catch anything that went BANG.
147 catch (RemoteException ouch)
148 {
149 //
150 // Try converting the Exception.
151 serviceException(ouch) ;
152 //
153 // If we get this far, then we don't know what it is.
154 throw new CommunityServiceException(
155 "WebService call failed - " + ouch,
156 ouch
157 ) ;
158 }
159 }
160 //
161 // If we don't have a valid service.
162 else {
163 throw new CommunityServiceException(
164 "Service not initialised"
165 ) ;
166 }
167 }
168
169 /***
170 * Get the database SQL script name.
171 * @throws CommunityServiceException If there is an server error.
172 *
173 */
174 public String getDatabaseScriptResource()
175 throws CommunityServiceException
176 {
177 //
178 // If we have a valid service reference.
179 if (null != this.manager)
180 {
181 //
182 // Try calling the service method.
183 try {
184 return this.manager.getDatabaseScriptResource() ;
185 }
186 //
187 // Catch anything that went BANG.
188 catch (RemoteException ouch)
189 {
190 //
191 // Try converting the Exception.
192 serviceException(ouch) ;
193 //
194 // If we get this far, then we don't know what it is.
195 throw new CommunityServiceException(
196 "WebService call failed - " + ouch,
197 ouch
198 ) ;
199 }
200 }
201 //
202 // If we don't have a valid service.
203 else {
204 throw new CommunityServiceException(
205 "Service not initialised"
206 ) ;
207 }
208 }
209
210 /***
211 * Get the database configuration URL.
212 * @throws CommunityServiceException If there is an server error.
213 *
214 */
215 public String getDatabaseConfigUrl()
216 throws CommunityServiceException
217 {
218 //
219 // If we have a valid service reference.
220 if (null != this.manager)
221 {
222 //
223 // Try calling the service method.
224 try {
225 return this.manager.getDatabaseConfigUrl() ;
226 }
227 //
228 // Catch anything that went BANG.
229 catch (RemoteException ouch)
230 {
231 //
232 // Try converting the Exception.
233 serviceException(ouch) ;
234 //
235 // If we get this far, then we don't know what it is.
236 throw new CommunityServiceException(
237 "WebService call failed - " + ouch,
238 ouch
239 ) ;
240 }
241 }
242 //
243 // If we don't have a valid service.
244 else {
245 throw new CommunityServiceException(
246 "Service not initialised"
247 ) ;
248 }
249 }
250
251 /***
252 * Get the database engine description.
253 * @throws CommunityServiceException If there is an server error.
254 *
255 */
256 public String getDatabaseDescription()
257 throws CommunityServiceException
258 {
259 //
260 // If we have a valid service reference.
261 if (null != this.manager)
262 {
263 //
264 // Try calling the service method.
265 try {
266 return this.manager.getDatabaseDescription() ;
267 }
268 //
269 // Catch anything that went BANG.
270 catch (RemoteException ouch)
271 {
272 //
273 // Try converting the Exception.
274 serviceException(ouch) ;
275 //
276 // If we get this far, then we don't know what it is.
277 throw new CommunityServiceException(
278 "WebService call failed - " + ouch,
279 ouch
280 ) ;
281 }
282 }
283 //
284 // If we don't have a valid service.
285 else {
286 throw new CommunityServiceException(
287 "Service not initialised"
288 ) ;
289 }
290 }
291
292 /***
293 * Check the database tables.
294 * @throws CommunityServiceException If there is an server error.
295 *
296 */
297 public boolean checkDatabaseTables()
298 throws CommunityServiceException
299 {
300 //
301 // If we have a valid service reference.
302 if (null != this.manager)
303 {
304 //
305 // Try calling the service method.
306 try {
307 return this.manager.checkDatabaseTables() ;
308 }
309 //
310 // Catch anything that went BANG.
311 catch (RemoteException ouch)
312 {
313 //
314 // Try converting the Exception.
315 serviceException(ouch) ;
316 //
317 // If we get this far, then we don't know what it is.
318 throw new CommunityServiceException(
319 "WebService call failed - " + ouch,
320 ouch
321 ) ;
322 }
323 }
324 //
325 // If we don't have a valid service.
326 else {
327 throw new CommunityServiceException(
328 "Service not initialised"
329 ) ;
330 }
331 }
332
333 /***
334 * Reset our database tables.
335 * @throws CommunityServiceException If there is an server error.
336 *
337 */
338 public void resetDatabaseTables()
339 throws CommunityServiceException
340 {
341 //
342 // If we have a valid service reference.
343 if (null != this.manager)
344 {
345 //
346 // Try calling the service method.
347 try {
348 this.manager.resetDatabaseTables() ;
349 }
350 //
351 // Catch anything that went BANG.
352 catch (RemoteException ouch)
353 {
354 //
355 // Try converting the Exception.
356 serviceException(ouch) ;
357 //
358 // If we get this far, then we don't know what it is.
359 throw new CommunityServiceException(
360 "WebService call failed - " + ouch,
361 ouch
362 ) ;
363 }
364 }
365 //
366 // If we don't have a valid service.
367 else {
368 throw new CommunityServiceException(
369 "Service not initialised"
370 ) ;
371 }
372 }
373 }