1
2
3
4
5
6
7 package gov.noaa.gdsg.xmldbremote.xmldbClient;
8
9 /***
10 * An XML:DB Database API which represents a Service on a remote machine.
11 *
12 * @author tns
13 * @version $Id: XmldbClientService.java,v 1.2 2004/11/03 23:52:40 mrxtravis Exp $
14 */
15 public class XmldbClientService implements org.xmldb.api.base.Service {
16
17 protected gov.noaa.gdsg.xmldbremote.Service service = null;
18 protected gov.noaa.gdsg.xmldbremote.NmmrdbSoapBindingStub stub = null;
19 protected gov.noaa.gdsg.xmldbremote.xmldbClient.XmldbClientCollection parentCollection = null;
20
21 /*** Creates a new instance of XmldbClientService
22 *@param service
23 *@service The object which represents the service on the server
24 *@stub Used to make the remote calls
25 *@param parentCollection The collection this service belongs to.
26 */
27 public XmldbClientService(
28 gov.noaa.gdsg.xmldbremote.Service service,
29 gov.noaa.gdsg.xmldbremote.NmmrdbSoapBindingStub stub,
30 gov.noaa.gdsg.xmldbremote.xmldbClient.XmldbClientCollection parentCollection
31 ) {
32
33 if (service == null){
34 throw new NullPointerException("Parameter service can not be null in constructor");
35 }
36 if (stub == null){
37 throw new NullPointerException("Parameter stub can not be null in constructor");
38 }
39 if (parentCollection == null){
40 throw new NullPointerException("Parameter parentCollection can not be null in constructor");
41 }
42
43 this.service = service;
44 this.stub = stub;
45 this.parentCollection = parentCollection;
46 }
47
48 /***Returns the name of this service.
49 *@throws org.xmldb.api.base.XMLDBException All exceptions are rethrown as one.
50 *@return The name of this Service.
51 */
52 public String getName() throws org.xmldb.api.base.XMLDBException {
53 return this.service.getName();
54 }
55
56 /***Throws an ErrorCodes.NOT_IMPLEMENTED Exception.
57 *@param str ignored
58 *@return Nothing, ever
59 *@param org.xmldb.api.base.XMLDBException with ErrorCode.NOT_IMPLEMENTED all the time.
60 */
61 public String getProperty(String str) throws org.xmldb.api.base.XMLDBException {
62 throw new org.xmldb.api.base.XMLDBException(
63 org.xmldb.api.base.ErrorCodes.NOT_IMPLEMENTED);
64 }
65
66 /*** Returns the version of this Service object.
67 *@return A string representing the service version
68 *@throws org.xmldb.api.base.XMLDBException All exceptions are rethrown as one.
69 */
70 public String getVersion() throws org.xmldb.api.base.XMLDBException {
71 return this.service.getVersion();
72 }
73
74 public void setCollection(org.xmldb.api.base.Collection collection) throws org.xmldb.api.base.XMLDBException {
75 if (collection instanceof XmldbClientCollection){
76 try {
77 XmldbClientCollection clientCollection = (XmldbClientCollection) collection;
78 stub.setCollection(this.service,clientCollection.getCollectionTransport());
79 } catch (java.rmi.RemoteException e){
80 throw new org.xmldb.api.base.XMLDBException(org.xmldb.api.base.ErrorCodes.VENDOR_ERROR, e.toString());
81 }
82 }
83 else {
84 throw new IllegalStateException("Can only set collections of type XmldbClientCollection");
85 }
86 }
87
88 /***Throws an ErrorCodes.NOT_IMPLEMENTED Exception.
89 *@param str ignored
90 *@param str1 ignored
91 *@param org.xmldb.api.base.XMLDBException with ErrorCode.NOT_IMPLEMENTED all the time.
92 */
93 public void setProperty(String str, String str1) throws org.xmldb.api.base.XMLDBException {
94 throw new org.xmldb.api.base.XMLDBException(
95 org.xmldb.api.base.ErrorCodes.NOT_IMPLEMENTED);
96 }
97
98 }