KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sync4j > server > admin > ws > AdminWS


1 /**
2  * Copyright (C) 2003-2005 Funambol
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18 package sync4j.server.admin.ws;
19
20 import java.util.logging.*;
21
22 import sync4j.framework.config.*;
23 import sync4j.framework.engine.source.*;
24 import sync4j.framework.logging.*;
25 import sync4j.framework.security.*;
26 import sync4j.framework.server.*;
27 import sync4j.framework.server.error.*;
28 import sync4j.framework.server.store.*;
29 import sync4j.framework.tools.beans.*;
30
31 import sync4j.server.admin.*;
32 import sync4j.server.config.*;
33
34 /**
35  * This is the session enterprise java bean that handles the administration
36  * console. It is designed to be a stateless session bean.
37  * <p>
38  * This server accepts the requests addressed to the hostname
39  * indicated by the configuration property pointed by {CONFIG_SERVER_URI} (see
40  * Sync4j.properties).
41  * <p>
42  * AdminBean uses the system property sync4j.configpath to set the base of the
43  * config path.
44  *
45  * @author Luigia Fassina @ Funambol
46  *
47  * @version $Id: AdminWS.java,v 1.7 2005/07/19 12:39:39 nichele Exp $
48  *
49  */

50 public class AdminWS {
51     // ------------------------------------------------------- Private constants
52

53     // ------------------------------------------------------------ Private data
54

55     private AdminManager admin;
56
57     private transient Logger log = Sync4jLogger.getLogger();
58
59     // ------------------------------------------------------------ Constructors
60

61     /**
62      * Creates a new AdminWS instance. This will initialize <i>admin</i>
63      *
64      * @throws ServerException if the AdminManager cannot be created.
65      *
66      */

67     public AdminWS() {
68         admin = new AdminManager();
69     }
70
71     // ---------------------------------------------------------- Public methods
72

73     /**
74      * Read the list of roles available.
75      *
76      * @return names of roles available
77      *
78      * @throws ServerException
79      * @throws AdminException
80      */

81     public String JavaDoc[] getRoles()
82     throws ServerException, AdminException {
83         return admin.getRoles();
84     }
85
86     /**
87      * Read all users that satisfy the parameter of search.
88      *
89      * @param clause array of conditions for the query
90      *
91      * @return array of Sync4jUser
92      *
93      * @throws ServerException
94      * @throws AdminException
95      */

96     public Sync4jUser[] getUsers(String JavaDoc clause)
97     throws ServerException, AdminException {
98         try {
99             return admin.getUsers((Clause)BeanFactory.unmarshal(clause));
100         } catch (AdminException e) {
101             log.severe("Server error: " + e.getMessage());
102             log.throwing(getClass().getName(), "getUsers", e);
103             throw e;
104         } catch (ServerException e) {
105             log.severe("Server error: " + e.getMessage());
106             log.throwing(getClass().getName(), "getUsers", e);
107             throw e;
108         } catch (Exception JavaDoc e) {
109             log.severe("Server error: " + e.getMessage());
110             log.throwing(getClass().getName(), "getUsers", e);
111             throw new ServerException(e.getMessage(), e);
112         }
113     }
114
115     /**
116      * Adds a new user and the assigned role to it
117      *
118      * @param user the user to add
119      *
120      * @throws ServerException
121      * @throws AdminException
122      */

123     public void addUser(Sync4jUser user)
124         throws ServerException, AdminException {
125         try {
126             admin.addUser(user);
127         } catch (AdminException e) {
128             log.severe("Server error: " + e.getMessage());
129             log.throwing(getClass().getName(), "addUser", e);
130             throw e;
131         } catch (ServerException e) {
132             log.severe("Server error: " + e.getMessage());
133             log.throwing(getClass().getName(), "addUser", e);
134             throw e;
135         } catch (Exception JavaDoc e) {
136             log.severe("Server error: " + e.getMessage());
137             log.throwing(getClass().getName(), "addUser", e);
138             throw new ServerException(e.getMessage(), e);
139         }
140     }
141
142     /**
143      * Update the information of the specific user
144      *
145      * @param user the user with informations updated
146      *
147      * @throws ServerException
148      * @throws AdminException
149      */

150     public void setUser(Sync4jUser user)
151         throws ServerException, AdminException {
152         try {
153             admin.setUser(user);
154         } catch (AdminException e) {
155             log.severe("Server error: " + e.getMessage());
156             log.throwing(getClass().getName(), "setUser", e);
157             throw e;
158         } catch (ServerException e) {
159             log.severe("Server error: " + e.getMessage());
160             log.throwing(getClass().getName(), "setUser", e);
161             throw e;
162         } catch (Exception JavaDoc e) {
163             log.severe("Server error: " + e.getMessage());
164             log.throwing(getClass().getName(), "setUser", e);
165             throw new ServerException(e.getMessage(), e);
166         }
167     }
168
169     /**
170      * Delete the user
171      *
172      * @param userName the name of user to delete
173      *
174      * @throws ServerException
175      * @throws AdminException
176      */

177     public void deleteUser(String JavaDoc userName)
178         throws ServerException, AdminException {
179         try {
180             admin.deleteUser(userName);
181         } catch (AdminException e) {
182             log.severe("Server error: " + e.getMessage());
183             log.throwing(getClass().getName(), "deleteUser", e);
184             throw e;
185         } catch (ServerException e) {
186             log.severe("Server error: " + e.getMessage());
187             log.throwing(getClass().getName(), "deleteUser", e);
188             throw e;
189         } catch (Exception JavaDoc e) {
190             log.severe("Server error: " + e.getMessage());
191             log.throwing(getClass().getName(), "deleteUser", e);
192             throw new ServerException(e.getMessage(), e);
193         }
194     }
195
196     /**
197      * Count the number of users that satisfy the specif clauses.
198      *
199      * @param clause the conditions of the search
200      *
201      * @return number of users
202      *
203      * @throws ServerException
204      * @throws AdminException
205      */

206     public int countUsers(String JavaDoc clause)
207     throws ServerException, AdminException {
208         try {
209             return admin.countUsers((Clause)BeanFactory.unmarshal(clause));
210         } catch (AdminException e) {
211             log.severe("Server error: " + e.getMessage());
212             log.throwing(getClass().getName(), "countUsers", e);
213             throw e;
214         } catch (ServerException e) {
215             log.severe("Server error: " + e.getMessage());
216             log.throwing(getClass().getName(), "countUsers", e);
217             throw e;
218         } catch (Exception JavaDoc e) {
219             log.severe("Server error: " + e.getMessage());
220             log.throwing(getClass().getName(), "countUsers", e);
221             throw new ServerException(e.getMessage(), e);
222         }
223     }
224
225     /**
226      * Read a list of device that satisfy the specific conditions.
227      *
228      * @param clauses the conditions foe search informations.
229      *
230      * @return array of device
231      *
232      * @throws ServerException
233      * @throws AdminException
234      */

235     public Sync4jDevice[] getDevices(String JavaDoc clauses)
236         throws ServerException, AdminException {
237         try {
238             return admin.getDevices((Clause)BeanFactory.unmarshal(clauses));
239         } catch (AdminException e) {
240             log.severe("Server error: " + e.getMessage());
241             log.throwing(getClass().getName(), "getDevices", e);
242             throw e;
243         } catch (ServerException e) {
244             log.severe("Server error: " + e.getMessage());
245             log.throwing(getClass().getName(), "getDevices", e);
246             throw e;
247         } catch (Exception JavaDoc e) {
248             log.severe("Server error: " + e.getMessage());
249             log.throwing(getClass().getName(), "getDevices", e);
250             throw new ServerException(e.getMessage(), e);
251         }
252     }
253
254     /**
255      * Adds a new device.
256      *
257      * @param d the new device
258      *
259      * @return the device id
260      *
261      * @throws ServerException
262      * @throws AdminException
263      */

264     public String JavaDoc addDevice(Sync4jDevice d)
265         throws ServerException, AdminException {
266         try {
267             return admin.addDevice(d);
268         } catch (AdminException e) {
269             log.severe("Server error: " + e.getMessage());
270             log.throwing(getClass().getName(), "addDevice", e);
271             throw e;
272         } catch (ServerException e) {
273             log.severe("Server error: " + e.getMessage());
274             log.throwing(getClass().getName(), "addDevice", e);
275             throw e;
276         } catch (Exception JavaDoc e) {
277             log.severe("Server error: " + e.getMessage());
278             log.throwing(getClass().getName(), "addDevice", e);
279             throw new ServerException(e.getMessage(), e);
280         }
281     }
282
283     /**
284      * Update the information of specific device.
285      *
286      * @param d the device to update
287      *
288      * @throws ServerException
289      * @throws AdminException
290      */

291     public void setDevice(Sync4jDevice d)
292         throws ServerException, AdminException {
293         try {
294             admin.setDevice(d);
295         } catch (AdminException e) {
296             log.severe("Server error: " + e.getMessage());
297             log.throwing(getClass().getName(), "setDevice", e);
298             throw e;
299         } catch (ServerException e) {
300             log.severe("Server error: " + e.getMessage());
301             log.throwing(getClass().getName(), "setDevice", e);
302             throw e;
303         } catch (Exception JavaDoc e) {
304             log.severe("Server error: " + e.getMessage());
305             log.throwing(getClass().getName(), "setDevice", e);
306             throw new ServerException(e.getMessage(), e);
307         }
308     }
309
310     /**
311      * Delete the specific device.
312      *
313      * @param deviceId the device id that identifies the device
314      *
315      * @throws ServerException
316      * @throws AdminException
317      */

318     public void deleteDevice(String JavaDoc deviceId)
319         throws ServerException, AdminException{
320         try {
321             admin.deleteDevice(deviceId);
322         } catch (AdminException e) {
323             log.severe("Server error: " + e.getMessage());
324             log.throwing(getClass().getName(), "deleteDevice", e);
325             throw e;
326         } catch (ServerException e) {
327             log.severe("Server error: " + e.getMessage());
328             log.throwing(getClass().getName(), "deleteDevice", e);
329             throw e;
330         } catch (Exception JavaDoc e) {
331             log.severe("Server error: " + e.getMessage());
332             log.throwing(getClass().getName(), "deleteDevice", e);
333             throw new ServerException(e.getMessage(), e);
334         }
335     }
336
337     /**
338      * Count the number of device that satisfy the specific clauses.
339      *
340      * @param clauses the specific conditions for search device
341      *
342      * @return the number of device finds
343      *
344      * @throws ServerException
345      * @throws AdminException
346      */

347     public int countDevices(String JavaDoc clauses)
348         throws ServerException, AdminException {
349         try {
350             return admin.countDevices((Clause)BeanFactory.unmarshal(clauses));
351         } catch (AdminException e) {
352            log.severe("Server error: " + e.getMessage());
353            log.throwing(getClass().getName(), "countDevices", e);
354            throw e;
355         } catch (ServerException e) {
356            log.severe("Server error: " + e.getMessage());
357            log.throwing(getClass().getName(), "countDevices", e);
358            throw e;
359         } catch (Exception JavaDoc e) {
360            log.severe("Server error: " + e.getMessage());
361            log.throwing(getClass().getName(), "countDevices", e);
362            throw new ServerException(e.getMessage(), e);
363         }
364
365     }
366
367     /**
368      * Read all principal that satisfy the clauses.
369      *
370      * @param clauses the specific conditions for search principal
371      *
372      * @return array of principal
373      *
374      * @throws ServerException
375      * @throws AdminException
376      */

377     public Sync4jPrincipal[] getPrincipals(String JavaDoc clauses)
378         throws ServerException, AdminException {
379         try {
380             return admin.getPrincipals((Clause)BeanFactory.unmarshal(clauses));
381         } catch (AdminException e) {
382             log.severe("Server error: " + e.getMessage());
383             log.throwing(getClass().getName(), "getPrincipals", e);
384             throw e;
385         } catch (ServerException e) {
386             log.severe("Server error: " + e.getMessage());
387             log.throwing(getClass().getName(), "getPrincipals", e);
388             throw e;
389         } catch (Exception JavaDoc e) {
390             log.severe("Server error: " + e.getMessage());
391             log.throwing(getClass().getName(), "getPrincipals", e);
392             throw new ServerException(e.getMessage(), e);
393         }
394     }
395
396     /**
397      * Adds a new principal.
398      *
399      * @param p the new principal
400      *
401      * @return the principal id
402      *
403      * @throws ServerException
404      * @throws AdminException
405      */

406     public String JavaDoc addPrincipal(Sync4jPrincipal p)
407         throws ServerException, AdminException {
408         try {
409             return admin.addPrincipal(p);
410         } catch (AdminException e) {
411             log.severe("Server error: " + e.getMessage());
412             log.throwing(getClass().getName(), "addPrincipal", e);
413             throw e;
414         } catch (ServerException e) {
415             log.severe("Server error: " + e.getMessage());
416             log.throwing(getClass().getName(), "addPrincipal", e);
417             throw e;
418         } catch (Exception JavaDoc e) {
419             log.severe("Server error: " + e.getMessage());
420             log.throwing(getClass().getName(), "addPrincipal", e);
421             throw new ServerException(e.getMessage(), e);
422         }
423     }
424
425     /**
426      * Delete the specific principal.
427      *
428      * @param principalId the principal id that identifies the principal
429      *
430      * @throws ServerException
431      * @throws AdminException
432      */

433     public void deletePrincipal(String JavaDoc principalId)
434         throws ServerException, AdminException {
435         try {
436             admin.deletePrincipal(principalId);
437         } catch (AdminException e) {
438             log.severe("Server error: " + e.getMessage());
439             log.throwing(getClass().getName(), "deletePrincipal", e);
440             throw e;
441         } catch (ServerException e) {
442             log.severe("Server error: " + e.getMessage());
443             log.throwing(getClass().getName(), "deletePrincipal", e);
444             throw e;
445         } catch (Exception JavaDoc e) {
446             log.severe("Server error: " + e.getMessage());
447             log.throwing(getClass().getName(), "deletePrincipal", e);
448             throw new ServerException(e.getMessage(), e);
449         }
450     }
451
452     /**
453      * Count the number of principal that satisfy the specific clauses.
454      *
455      * @param clauses the specific conditions for search principal
456      *
457      * @return the number of principal finds
458      *
459      * @throws ServerException
460      * @throws AdminException
461      */

462     public int countPrincipals(String JavaDoc clauses)
463     throws ServerException, AdminException {
464         try {
465             return admin.countPrincipals((Clause)BeanFactory.unmarshal(clauses));
466         } catch (AdminException e) {
467             log.severe("Server error: " + e.getMessage());
468             log.throwing(getClass().getName(), "countPrincipals", e);
469             throw e;
470         } catch (ServerException e) {
471             log.severe("Server error: " + e.getMessage());
472             log.throwing(getClass().getName(), "countPrincipals", e);
473             throw e;
474         } catch (Exception JavaDoc e) {
475             log.severe("Server error: " + e.getMessage());
476             log.throwing(getClass().getName(), "countPrincipals", e);
477             throw new ServerException(e.getMessage(), e);
478         }
479     }
480
481     /**
482      * Read a list of syncSource that satisfy the specific conditions.
483      *
484      * @param clauses the conditions foe search informations.
485      *
486      * @return array of syncSource
487      *
488      * @throws ServerException
489      * @throws AdminException
490      */

491     public Sync4jSource[] getSync4jSources(String JavaDoc clauses)
492         throws ServerException, AdminException {
493         try {
494             return admin.getSync4jSources((Clause)BeanFactory.unmarshal(clauses));
495         } catch (AdminException e) {
496             log.severe("Server error: " + e.getMessage());
497             log.throwing(getClass().getName(), "getSync4jSources", e);
498             throw e;
499         } catch (ServerException e) {
500             log.severe("Server error: " + e.getMessage());
501             log.throwing(getClass().getName(), "getSync4jSources", e);
502             throw e;
503         } catch (Exception JavaDoc e) {
504             log.severe("Server error: " + e.getMessage());
505             log.throwing(getClass().getName(), "getSync4jSources", e);
506             throw new ServerException(e.getMessage(), e);
507         }
508     }
509
510     /**
511      * Read all modules information
512      *
513      * @return an array with the modules information (empty if no objects are found)
514      *
515      * @throws ServerException
516      * @throws AdminException
517      */

518     public Sync4jModule[] getModulesName()
519         throws ServerException, AdminException {
520         try {
521             return admin.getModulesName();
522         } catch (AdminException e) {
523             log.severe("Server error: " + e.getMessage());
524             log.throwing(getClass().getName(), "getModulesName", e);
525             throw e;
526         } catch (ServerException e) {
527             log.severe("Server error: " + e.getMessage());
528             log.throwing(getClass().getName(), "getModulesName", e);
529             throw e;
530         } catch (Exception JavaDoc e) {
531             log.severe("Server error: " + e.getMessage());
532             log.throwing(getClass().getName(), "getModulesName", e);
533             throw new ServerException(e.getMessage(), e);
534         }
535     }
536
537     /**
538      * Read the information of the specific module
539      *
540      * @param moduleId the module id that identifies the module to search
541      *
542      * @return the relative information to the module
543      *
544      * @throws ServerException
545      * @throws AdminException
546      */

547     public String JavaDoc getModule(String JavaDoc moduleId)
548         throws ServerException, AdminException {
549         try {
550             return BeanFactory.marshal(admin.getModule(moduleId));
551         } catch (AdminException e) {
552             log.severe("Server error: " + e.getMessage());
553             log.throwing(getClass().getName(), "getModule", e);
554             throw e;
555         } catch (ServerException e) {
556             log.severe("Server error: " + e.getMessage());
557             log.throwing(getClass().getName(), "getModule", e);
558             throw e;
559         } catch (Exception JavaDoc e) {
560             log.severe("Server error: " + e.getMessage());
561             log.throwing(getClass().getName(), "getModule", e);
562             throw new ServerException(e.getMessage(), e);
563         }
564     }
565
566     /**
567      * Adds a new source into datastore and create a relative file xml with configuration.
568      * The source must have a defined source type.
569      * The source type must refer to a connector.
570      * The connector must refer to a module.
571      *
572      * @param moduleId the module id
573      * @param connectorId the connector id
574      * @param sourceTypeId the source type id
575      * @param source the information of the new source
576      *
577      * @throws ServerException
578      * @throws AdminException
579      */

580     public void addSource(String JavaDoc moduleId, String JavaDoc connectorId, String JavaDoc sourceTypeId, String JavaDoc source)
581     throws ServerException, AdminException {
582         try {
583             admin.addSource(moduleId, connectorId, sourceTypeId, (SyncSource)BeanFactory.unmarshal(source));
584         } catch (AdminException e) {
585             log.severe("Server error: " + e.getMessage());
586             log.throwing(getClass().getName(), "addSource", e);
587             throw e;
588         } catch (ServerException e) {
589             log.severe("Server error: " + e.getMessage());
590             log.throwing(getClass().getName(), "addSource", e);
591             throw e;
592         } catch (Exception JavaDoc e) {
593             log.severe("Server error: " + e.getMessage());
594             log.throwing(getClass().getName(), "addSource", e);
595             throw new ServerException(e.getMessage(), e);
596         }
597     }
598
599     /**
600      * Update a specific source into datastore and create a relative file xml with configuration.
601      * The source must have a defined source type.
602      * The source type must refer to a connector.
603      * The connector must refer to a module.
604      *
605      * @param moduleId the module id
606      * @param connectorId the connector id
607      * @param sourceTypeId the source type id
608      * @param source the information of the new source
609      *
610      * @throws ServerException
611      * @throws AdminException
612      */

613     public void setSource(String JavaDoc moduleId, String JavaDoc connectorId, String JavaDoc sourceTypeId, String JavaDoc source)
614     throws ServerException, AdminException{
615         try {
616             admin.setSource(moduleId, connectorId, sourceTypeId, (SyncSource)BeanFactory.unmarshal(source));
617         } catch (AdminException e) {
618             log.severe("Server error: " + e.getMessage());
619             log.throwing(getClass().getName(), "setSource", e);
620             throw e;
621         } catch (ServerException e) {
622             log.severe("Server error: " + e.getMessage());
623             log.throwing(getClass().getName(), "setSource", e);
624             throw e;
625         } catch (Exception JavaDoc e) {
626             log.severe("Server error: " + e.getMessage());
627             log.throwing(getClass().getName(), "setSource", e);
628             throw new ServerException(e.getMessage(), e);
629         }
630     }
631
632     /**
633      * Delete a specific source and the relative file of configuration.
634      *
635      * @param sourceUri the uri that identifies the source
636      *
637      * @throws ServerException
638      * @throws AdminException
639      */

640     public void deleteSource(String JavaDoc sourceUri)
641         throws ServerException, AdminException {
642         try {
643             admin.deleteSource(sourceUri);
644         } catch (AdminException e) {
645             log.severe("Server error: " + e.getMessage());
646             log.throwing(getClass().getName(), "deleteSource", e);
647             throw e;
648         } catch (ServerException e) {
649             log.severe("Server error: " + e.getMessage());
650             log.throwing(getClass().getName(), "deleteSource", e);
651             throw e;
652         } catch (Exception JavaDoc e) {
653             log.severe("Server error: " + e.getMessage());
654             log.throwing(getClass().getName(), "deleteSource", e);
655             throw new ServerException(e.getMessage(), e);
656         }
657     }
658
659     /**
660      * Returns the server logging configuration
661      *
662      * @return the server logging configuration as a <i>LoggingConfiguration</i>
663      * object.
664      *
665      * @throws ServerException, AdminException
666      */

667     public LoggingConfiguration getLoggingConfiguration()
668         throws ServerException, AdminException {
669         try {
670             return admin.getLoggingConfiguration();
671         } catch (AdminException e) {
672             log.severe("Server error: " + e.getMessage());
673             log.throwing(getClass().getName(), "getLoggingConfiguration", e);
674             throw e;
675         } catch (ServerException e) {
676             log.severe("Server error: " + e.getMessage());
677             log.throwing(getClass().getName(), "getLoggingConfiguration", e);
678             throw e;
679         } catch (Exception JavaDoc e) {
680             log.severe("Server error: " + e.getMessage());
681             log.throwing(getClass().getName(), "getLoggingConfiguration", e);
682             throw new ServerException(e.getMessage(), e);
683         }
684     }
685
686     /**
687      * Saves and apply the new logging configuration
688      *
689      * @param config the new logging configuration
690      *
691      * @throws ServerException
692      * @throws AdminException
693      */

694     public void setLoggingConfiguration(LoggingConfiguration config)
695         throws ServerException, AdminException {
696         try {
697             admin.setLoggingConfiguration(config);
698         } catch (AdminException e) {
699             log.severe("Server error: " + e.getMessage());
700             log.throwing(getClass().getName(), "setLoggingConfiguration", e);
701             throw e;
702         } catch (ServerException e) {
703             log.severe("Server error: " + e.getMessage());
704             log.throwing(getClass().getName(), "setLoggingConfiguration", e);
705             throw e;
706         } catch (Exception JavaDoc e) {
707             log.severe("Server error: " + e.getMessage());
708             log.throwing(getClass().getName(), "setLoggingConfiguration", e);
709             throw new ServerException(e.getMessage(), e);
710         }
711     }
712
713     /**
714      * Returns the server configuration
715      *
716      * @return the server configuration as a <i>ServerConfiguration</i>
717      * object.
718      *
719      * @throws ServerException, AdminException
720      */

721     public ServerConfiguration getServerConfiguration()
722         throws ServerException, AdminException {
723         try {
724             return admin.getServerConfiguration();
725         } catch (AdminException e) {
726             log.severe("Server error: " + e.getMessage());
727             log.throwing(getClass().getName(), "getServerConfiguration", e);
728             throw e;
729         } catch (ServerException e) {
730             log.severe("Server error: " + e.getMessage());
731             log.throwing(getClass().getName(), "getServerConfiguration", e);
732             throw e;
733         } catch (Exception JavaDoc e) {
734             log.severe("Server error: " + e.getMessage());
735             log.throwing(getClass().getName(), "getServerConfiguration", e);
736             throw new ServerException(e.getMessage(), e);
737         }
738     }
739
740     /**
741      * Saves and apply the new server configuration
742      *
743      * @param config the new server configuration
744      *
745      * @throws ServerException
746      * @throws AdminException
747      */

748     public void setServerConfiguration(ServerConfiguration config)
749         throws ServerException, AdminException {
750         try {
751             admin.setServerConfiguration(config);
752         } catch (AdminException e) {
753             log.severe("Server error: " + e.getMessage());
754             log.throwing(getClass().getName(), "setServerConfiguration", e);
755             throw e;
756         } catch (ServerException e) {
757             log.severe("Server error: " + e.getMessage());
758             log.throwing(getClass().getName(), "setServerConfiguration", e);
759             throw e;
760         } catch (Exception JavaDoc e) {
761             log.severe("Server error: " + e.getMessage());
762             log.throwing(getClass().getName(), "setServerConfiguration", e);
763             throw new ServerException(e.getMessage(), e);
764         }
765     }
766
767
768     /**
769      * This method is only used to check credentials. Being this WS stateless,
770      * its methods are always called on request and each of them has to pass
771      * authentication. However, for instance the SyncAdmin, has a login panel
772      * that is displayed before any access to one of the other WS methods. In
773      * order to provide to the user an immediate feedback, the SyncAdmin (or any
774      * other client can just call <i>login()</i>.
775      *
776      * @param username administrator username
777      */

778     public void login(String JavaDoc username) {
779         if (log.isLoggable(Level.INFO)) {
780             log.info("New administrative session for " + username);
781         }
782     }
783
784     /**
785      * Returns the server version.
786      *
787      * @return the server version
788      *
789      */

790     public String JavaDoc getServerVersion(String JavaDoc version) {
791         return admin.getServerVersion();
792     }
793
794     /**
795      * Returns the server bean with the given name. If the bean does not exist,
796      * am AdminException is thrown.
797      *
798      * @param bean the server bean
799      *
800      * @throws ServerException, AdminException
801      */

802     public String JavaDoc getServerBean(String JavaDoc bean)
803     throws ServerException, AdminException {
804         try {
805             return BeanFactory.marshal(admin.getServerBean(bean));
806         } catch (AdminException e) {
807             log.severe("Server error: " + e.getMessage());
808             log.throwing(getClass().getName(), "getServerBean", e);
809             throw e;
810         } catch (ServerException e) {
811             log.severe("Server error: " + e.getMessage());
812             log.throwing(getClass().getName(), "getServerBean", e);
813             throw e;
814         } catch (Exception JavaDoc e) {
815             log.severe("Server error: " + e.getMessage());
816             log.throwing(getClass().getName(), "getServerBean", e);
817             throw new ServerException(e.getMessage(), e);
818         }
819
820     }
821
822     /**
823      * Sets the server bean with the given name.
824      *
825      * @param bean the server bean
826      * @param obj the bean instance
827      *
828      * @throws ServerException, AdminException
829      */

830     public void setServerBean(String JavaDoc bean, String JavaDoc obj)
831     throws ServerException, AdminException {
832         try {
833             admin.setServerBean(bean, BeanFactory.unmarshal(obj));
834         } catch (AdminException e) {
835             log.severe("Server error: " + e.getMessage());
836             log.throwing(getClass().getName(), "setServerBean", e);
837             throw e;
838         } catch (ServerException e) {
839             log.severe("Server error: " + e.getMessage());
840             log.throwing(getClass().getName(), "setServerBean", e);
841             throw e;
842         } catch (Exception JavaDoc e) {
843             log.severe("Server error: " + e.getMessage());
844             log.throwing(getClass().getName(), "setServerBean", e);
845             throw new ServerException(e.getMessage(), e);
846         }
847     }
848
849     // --------------------------------------------------------- Private methods
850
}
851
852
Popular Tags