KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > corba > RepositoryManagerCORBA


1 package org.enhydra.shark.corba;
2
3 import org.omg.WfBase.*;
4 import org.enhydra.shark.corba.WorkflowService.*;
5
6 /**
7  * Used for work with shark's external repository.
8  *
9  * @author Sasa Bojanic
10  */

11 public class RepositoryManagerCORBA extends _RepositoryMgrImplBase {
12    private SharkCORBAServer myServer;
13
14    private String JavaDoc userId;
15
16    private boolean connected = false;
17
18    org.enhydra.shark.api.client.wfservice.RepositoryMgr myRepMgr;
19
20    RepositoryManagerCORBA(SharkCORBAServer server,
21                           org.enhydra.shark.api.client.wfservice.RepositoryMgr rm) {
22       this.myServer = server;
23       this.myRepMgr = rm;
24    }
25
26    public void connect(String JavaDoc userId,
27                        String JavaDoc password,
28                        String JavaDoc engineName,
29                        String JavaDoc scope) throws BaseException, ConnectFailed {
30       this.userId = userId;
31
32       try {
33          if (!myServer.validateUser(userId, password)) { throw new ConnectFailed("Connection failed, invalid username or password"); }
34          connected = true;
35          myRepMgr.connect(userId);
36       } catch (ConnectFailed cf) {
37          throw cf;
38       } catch (Exception JavaDoc ex) {
39          throw new BaseException();
40       }
41    }
42
43    public void disconnect() throws BaseException, NotConnected {
44       if (!connected) { throw new NotConnected("The connection is not established..."); }
45       connected = false;
46       this._orb().disconnect(this);
47    }
48
49    public void deletePkg(String JavaDoc relativePath) throws BaseException,
50                                              NotConnected,
51                                              RepositoryInvalid {
52       if (!connected) { throw new NotConnected("The connection is not established..."); }
53       try {
54          myRepMgr.deletePackage(relativePath);
55       } catch (org.enhydra.shark.api.client.wfservice.RepositoryInvalid ri) {
56          throw new RepositoryInvalid(ri.getXPDLValidationErrors());
57       } catch (Exception JavaDoc ex) {
58          throw new BaseException();
59       }
60    }
61
62    public void uploadPkg(byte[] pkgContent, String JavaDoc relativePath) throws BaseException,
63                                                                 NotConnected,
64                                                                 RepositoryInvalid {
65       if (!connected) { throw new NotConnected("The connection is not established..."); }
66       try {
67          myRepMgr.uploadPackage(pkgContent, relativePath);
68       } catch (org.enhydra.shark.api.client.wfservice.RepositoryInvalid ri) {
69          throw new RepositoryInvalid(ri.getXPDLValidationErrors());
70       } catch (Exception JavaDoc ex) {
71          throw new BaseException();
72       }
73    }
74
75    public String JavaDoc[] getPackagePaths() throws BaseException, NotConnected {
76       if (!connected) { throw new NotConnected("The connection is not established..."); }
77       try {
78          return myRepMgr.getPackagePaths();
79       } catch (Exception JavaDoc ex) {
80          throw new BaseException();
81       }
82    }
83
84    public NameValue[] getPackagePathToIdMapping() throws BaseException,
85                                                  NotConnected {
86       if (!connected) { throw new NotConnected("The connection is not established..."); }
87       try {
88          return SharkCORBAUtilities.makeCORBANameValueArray(this._orb(),
89                                                             myRepMgr.getPackagePathToIdMapping());
90       } catch (Exception JavaDoc ex) {
91          throw new BaseException();
92       }
93    }
94
95    public String JavaDoc getPackageId(String JavaDoc relativePath) throws BaseException,
96                                                   NotConnected {
97       if (!connected) { throw new NotConnected("The connection is not established..."); }
98       try {
99          return myRepMgr.getPackageId(relativePath);
100       } catch (Exception JavaDoc ex) {
101          throw new BaseException();
102       }
103    }
104
105 }
Popular Tags