KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > corba > poa > PackageAdminCORBA


1 package org.enhydra.shark.corba.poa;
2
3 import org.omg.WfBase.*;
4 import org.enhydra.shark.corba.WorkflowService.*;
5
6
7 /**
8  * Various package related operations.
9  * @author David Forslund
10  *
11  */

12 public class PackageAdminCORBA extends PackageAdministrationPOA {
13    private SharkCORBAServer myServer;
14
15    private String JavaDoc userId;
16    private boolean connected=false;
17
18    org.enhydra.shark.api.client.wfservice.PackageAdministration myPkgAdmin;
19
20    PackageAdminCORBA (SharkCORBAServer server,org.enhydra.shark.api.client.wfservice.PackageAdministration pa) {
21       this.myServer=server;
22       this.myPkgAdmin=pa;
23
24    }
25
26    public void connect(String JavaDoc userId, String JavaDoc password, String JavaDoc engineName, String JavaDoc scope) throws BaseException, ConnectFailed {
27       this.userId=userId;
28
29       try {
30          if (!myServer.validateUser(userId,password)) {
31             throw new ConnectFailed("Connection failed, invalid username or password");
32          }
33          connected=true;
34          myPkgAdmin.connect(userId);
35       } catch (ConnectFailed cf) {
36          throw cf;
37       } catch (Exception JavaDoc ex) {
38          throw new BaseException();
39       }
40    }
41
42    public void disconnect() throws BaseException, NotConnected {
43       if (!connected) {
44          throw new NotConnected("The connection is not established...");
45       }
46       connected=false;
47       _this()._release();
48    }
49
50    public String JavaDoc[] getOpenedPackageIds () throws BaseException, NotConnected {
51       if (!connected) {
52          throw new NotConnected("The connection is not established...");
53       }
54       try {
55          return myPkgAdmin.getOpenedPackageIds();
56       } catch (Exception JavaDoc ex) {
57          throw new BaseException();
58       }
59    }
60
61    public String JavaDoc[] getPackageVersions (String JavaDoc pkgId) throws BaseException, NotConnected {
62       if (!connected) {
63          throw new NotConnected("The connection is not established...");
64       }
65       try {
66          return myPkgAdmin.getPackageVersions(pkgId);
67       } catch (Exception JavaDoc ex) {
68          throw new BaseException();
69       }
70    }
71
72    public boolean isPackageOpened (String JavaDoc pkgId) throws BaseException, NotConnected {
73       if (!connected) {
74          throw new NotConnected("The connection is not established...");
75       }
76       try {
77          return myPkgAdmin.isPackageOpened(pkgId);
78       } catch (Exception JavaDoc ex) {
79          throw new BaseException();
80       }
81    }
82
83    public byte[] getPackageContent (String JavaDoc pkgId) throws BaseException, NotConnected {
84       if (!connected) {
85          throw new NotConnected("The connection is not established...");
86       }
87       try {
88          return myPkgAdmin.getPackageContent(pkgId);
89       } catch (Exception JavaDoc ex) {
90          throw new BaseException();
91       }
92    }
93
94    public byte[] getPackageVersionContent (String JavaDoc pkgId,String JavaDoc pkgVer) throws BaseException, NotConnected {
95       if (!connected) {
96          throw new NotConnected("The connection is not established...");
97       }
98       try {
99          return myPkgAdmin.getPackageContent(pkgId,pkgVer);
100       } catch (Exception JavaDoc ex) {
101          throw new BaseException();
102       }
103    }
104
105    public String JavaDoc getCurrentPackageVersion(String JavaDoc pkgId) throws BaseException, NotConnected {
106       if (!connected) {
107          throw new NotConnected("The connection is not established...");
108       }
109       try {
110          return myPkgAdmin.getCurrentPackageVersion(pkgId);
111       } catch (Exception JavaDoc ex) {
112          throw new BaseException();
113       }
114    }
115
116    public String JavaDoc openPkg (String JavaDoc relativePath) throws BaseException, NotConnected, PackageInvalid, ExternalPackageInvalid {
117       if (!connected) {
118          throw new NotConnected("The connection is not established...");
119       }
120       try {
121          return myPkgAdmin.openPackage(relativePath);
122       } catch (org.enhydra.shark.api.client.wfservice.PackageInvalid pi) {
123          throw new PackageInvalid(pi.getXPDLValidationErrors());
124       } catch (org.enhydra.shark.api.client.wfservice.ExternalPackageInvalid epi) {
125          throw new ExternalPackageInvalid(epi.getXPDLValidationErrors());
126       } catch (Exception JavaDoc ex) {
127          throw new BaseException();
128       }
129    }
130
131    public void updatePackage1 (String JavaDoc id, String JavaDoc relativePathToNewPackage) throws BaseException, NotConnected, PackageUpdateNotAllowed, PackageInvalid, ExternalPackageInvalid {
132       if (!connected) {
133          throw new NotConnected("The connection is not established...");
134       }
135       try {
136          myPkgAdmin.updatePackage(id,relativePathToNewPackage);
137       } catch (org.enhydra.shark.api.client.wfservice.PackageInvalid pi) {
138          throw new PackageInvalid(pi.getXPDLValidationErrors());
139       } catch (org.enhydra.shark.api.client.wfservice.ExternalPackageInvalid epi) {
140          throw new ExternalPackageInvalid(epi.getXPDLValidationErrors());
141       } catch (org.enhydra.shark.api.client.wfservice.PackageUpdateNotAllowed pna) {
142          throw new PackageUpdateNotAllowed();
143       } catch (Exception JavaDoc ex) {
144          throw new BaseException();
145       }
146    }
147
148    public void closePkg (String JavaDoc pkgId) throws BaseException, NotConnected, PackageInUse, PackageHasActiveProcesses {
149       if (!connected) {
150          throw new NotConnected("The connection is not established...");
151       }
152       try {
153          myPkgAdmin.closePackage(pkgId);
154       } catch (org.enhydra.shark.api.client.wfservice.PackageInUse piu) {
155          throw new PackageInUse();
156       } catch (org.enhydra.shark.api.client.wfservice.PackageHasActiveProcesses phap) {
157          throw new PackageHasActiveProcesses();
158       } catch (Exception JavaDoc ex) {
159          throw new BaseException();
160       }
161    }
162
163    public void closePkgWithVersion(String JavaDoc pkgId,String JavaDoc pkgVer) throws BaseException, NotConnected, PackageInUse, PackageHasActiveProcesses {
164       if (!connected) {
165          throw new NotConnected("The connection is not established...");
166       }
167       try {
168          myPkgAdmin.closePackage(pkgId,pkgVer);
169       } catch (org.enhydra.shark.api.client.wfservice.PackageInUse piu) {
170          throw new PackageInUse();
171       } catch (org.enhydra.shark.api.client.wfservice.PackageHasActiveProcesses phap) {
172          throw new PackageHasActiveProcesses();
173       } catch (Exception JavaDoc ex) {
174          throw new BaseException();
175       }
176    }
177
178    public boolean isPackageReferenced (String JavaDoc pkgId) throws BaseException, NotConnected {
179       if (!connected) {
180          throw new NotConnected("The connection is not established...");
181       }
182       try {
183          return myPkgAdmin.isPackageReferenced(pkgId);
184       } catch (Exception JavaDoc ex) {
185          throw new BaseException();
186       }
187    }
188
189    public void synchronizeXPDLCache () throws BaseException, NotConnected {
190       if (!connected) {
191          throw new NotConnected("The connection is not established...");
192       }
193       try {
194          myPkgAdmin.synchronizeXPDLCache();
195       } catch (Exception JavaDoc ex) {
196          throw new BaseException();
197       }
198    }
199
200    public void clearXPDLCache () throws BaseException, NotConnected {
201       if (!connected) {
202          throw new NotConnected("The connection is not established...");
203       }
204       try {
205          myPkgAdmin.clearXPDLCache();
206       } catch (Exception JavaDoc ex) {
207          throw new BaseException();
208       }
209    }
210
211    public void refreshXPDLCache () throws BaseException, NotConnected {
212       if (!connected) {
213          throw new NotConnected("The connection is not established...");
214       }
215       try {
216          myPkgAdmin.refreshXPDLCache();
217       } catch (Exception JavaDoc ex) {
218          throw new BaseException();
219       }
220    }
221
222 }
223
224
Popular Tags