Project

General

Profile

« Previous | Next » 

Revision 299

Added by higgins over 24 years ago

Copies to replace corrupted class files

View differences:

lib/srbrmi/SrbJavaGlue.java
1
/**
2
 *  Name: SrbJavaGlue.java
3
 *  Institution: National Center for Ecological Analysis and Synthesis
4
 *  Copyright: 2000 The Regents of the University of California and
5
 *         National Center for Ecological Analysis and Synthesis,
6
 *         University of California, Santa Barbara 2000.
7
 *         All rights reserved.
8
 *
9
 *  Authors: Dan Higgins, John Moreland
10
 *
11
 *     Version: '$Id$'
12
 */
13

  
14
 /* Note: Based on Java code originally produced at SDSC
15
 * Copyright   1999   The Regents of the University of California
16
 * All Rights Reserved
17
 */
18

  
19
/**
20
 * SrbJavaGlue
21
 *
22
 * Implementation of RMI Interface
23
 *
24
 * @version 1.1 6/8/00
25
 * @author Dan Higgins - NCEAS
26
 */
27
 
28
 import java.rmi.*;
29
 import java.rmi.server.*;
30
 import java.io.*;   //DFH 6/8/00
31
 
32
 
33
public class SrbJavaGlue extends UnicastRemoteObject implements SrbJavaGlueInterface
34
{
35
 byte[] ByteData;
36
 String FileName;
37
 boolean previouslyConnected = false;
38
    
39
	// JNI (Java Native Interface) Glue Routines for the SRB client library.
40

  
41
public SrbJavaGlue() throws RemoteException {
42
                  super();
43
              }
44

  
45
	public synchronized native int clConnectJ( String host, String port, String auth );
46
	
47
	public synchronized int rmiConnectJ(String host, String port, String auth, String user ) {
48
	    if (previouslyConnected) {
49
	        return -1;
50
	    }
51
	    else {
52
	        writeMdasEnv(user);
53
	        int res = clConnectJ(host, port, auth );
54
	        if (res>0) {previouslyConnected = true;}
55
	        return res;
56
	        
57
	    }
58
	}
59

  
60
	public synchronized native int srbListCollectJ( int conn, int catType,
61
		String collectionName, String flag, int types[] );
62

  
63
	public synchronized native String getFileListItem( int index );
64

  
65
	public synchronized native int clFinishJ( int conn );
66
	
67
	public synchronized int rmiFinishJ(int conn) {
68
	    Reset();
69
	    return clFinishJ(conn);
70
	}
71

  
72
	public synchronized native int srbObjCopyNewJ( String srcDir, String srcFile,
73
		String dstDir, String dstFile, String dstRes );
74

  
75
	public synchronized native int srbListResourceJ( int bs );
76

  
77
	public synchronized native String getResListItem( int index );
78

  
79
	public synchronized native String getDefCollection();
80

  
81
	public synchronized native String getDefResource();
82

  
83
	public synchronized native String getUser();
84

  
85
	public synchronized native String getDomain();
86

  
87
	public synchronized native String getLocalCacheDir();
88

  
89
	public synchronized native int srbObjReplicateJ(int conn, int catType,
90
	  String objID, String replNum, String collection, String resource);
91

  
92
	public synchronized native int srbCollReplicateJ(int conn, int catType,
93
	  String collection, String resource);
94

  
95
	public synchronized native int queryDataInCollJ (int conn, int catType, 
96
	  String parColl);
97

  
98
	public synchronized native int queryDataJ (int conn, int catType, String objID,
99
	  String parColl);
100

  
101
	public synchronized native int querySubCollInCollJ (int conn, int catType, 
102
	  String parColl);
103

  
104
	public synchronized native String getDataResultJ( int metaIndex, int rowIndex );
105

  
106
	public synchronized native String getCollResultJ( int metaIndex, int rowIndex );
107

  
108
	public synchronized native String getGenQueResultJ( int metaIndex, int rowIndex );
109

  
110
	public synchronized native int getNCollAttriJ ();
111

  
112
	public synchronized native int getNDataAttriJ ();
113

  
114
	public synchronized native int srbObjUnlinkJ (int conn,  int catType, 
115
	  String objID, String replNum, String parColl);
116

  
117
	public synchronized native int srbCreateCollectJ (int conn,  int catType, 
118
	  String parColl, String newColl);
119

  
120
	public synchronized native int srbModifyDatasetMetaDJ (int conn,  int catType,
121
	  String objID, String collection, 
122
	   String newValue1, String newValue2, int retractionType);
123
	   
124
	public synchronized native int srbModifyCollectMetaDJ (int conn,  int catType,
125
	  String collection, String newValue1, String newValue2, 
126
	   String newValue3, int retractionType);
127
	   
128
	public synchronized native int importToOldObjJ (int conn,  int catType, 
129
	  String objID, String replNum, String parColl, String resource,
130
	   String localFile, String container);
131

  
132
	public synchronized native int importToNewObjJ (int conn,  int catType, 
133
	 String objID, String parColl, String resource, String localFile,
134
	  String container);
135

  
136
	public synchronized native int importDirJ (int conn,  int catType, 
137
	  String parColl, String resource, String localDir, String container);
138

  
139
	public synchronized native int srbRmCollJ (int conn, int catType, String parColl);
140

  
141
	public synchronized native int srbUnregCollJ (int conn, int catType, String parColl);
142

  
143
	public synchronized native int copyToOldObjJ (int conn,  int catType, 
144
	 String objID, String replNum, String srcColl, String targObj, 
145
	  String targReplNum, String targColl, String targResource, 
146
	   String container);
147

  
148
	public synchronized native int copyDataToCollJ (int conn,  int catType, 
149
	 String objID, String replNum, String srcColl,
150
	  String dataType, String size, String targColl, String targResource,
151
	   String container);
152

  
153
	public synchronized native int copyCollToCollJ (int conn, int catType, 
154
	 String srcColl, String targColl, String targResource, 
155
	  String container);
156

  
157
	public synchronized native int exportToFileJ(int conn, int catType,
158
	 String objID, String replNum, String srcColl,
159
	  String targFile, int forceFlag);
160

  
161
	public synchronized native int exportToDirJ(int conn, int catType,
162
	 String objID, String replNum, String srcColl,
163
	  String targDir);
164

  
165
	public synchronized native int exportCollToDirJ(int conn, int catType,
166
	 String srcColl, String targDir);
167

  
168
	public synchronized native int srbGenQuery (int conn, int catType,
169
	 String[] qval, int qvalInx[], int selVal[]);
170
	
171
        public synchronized native int srbRegisterDatasetJ(int conn, int catType,
172
         String objID, String dataType, String resource, String collection,
173
	  String pathName, int dataSize);
174

  
175
	public synchronized native int srbUnregisterDatasetJ (int conn, int catType,
176
	 String objID, String replNum, String collection);
177

  
178
        public synchronized native int srbRegisterDirJ (int conn, int catType,
179
	 String srcDirPath, String targColl, String resource);
180

  
181
        public synchronized native int getMoreDataRowsJ (int conn, int catType);
182

  
183
        public synchronized native int getMoreCollRowsJ (int conn, int catType);
184

  
185
        public synchronized native int getMoreGenQueRowsJ (int conn, int catType);
186
	
187
	public synchronized native int chmodInCollJ (int conn, int catType, 
188
	 String collection, String user, String domain, String mode);
189

  
190
	public synchronized native int ingestUserJ (int conn, int catType, 
191
	 String userName, String passwd, String domain, 
192
	  String userType, String userAddr, String userPhone, String userEmail,
193
	   String parentColl);
194

  
195
	public synchronized native int ingestGroupJ (int conn, int catType, 
196
	 String groupName, String passwd,
197
	  String groupAddr, String groupPhone, String groupEMail);
198

  
199
	public synchronized native int ingestLocJ (int conn, int catType, 
200
	 String locName, String fullAddr, String parentLoc); 
201

  
202
        public synchronized native int ingestResourceJ (int conn, int catType,
203
         String rescName, String rescType, String location, String phyPath);
204

  
205
        public synchronized native int ingestLogRescJ (int conn, int catType,
206
         String logRescName, String phyResc, String phyPath);
207

  
208
        public synchronized native int addLogRescJ (int conn, int catType,
209
         String logResc, String phyResc, String phyPath);
210

  
211
        public synchronized native int modifyUserJ (int conn, int catType,
212
         int modOpr, String userName, String domain, String modValue);
213

  
214
	public synchronized native int containerCreateJ (int conn, int catType,
215
	 String contName, String dataType, String logResc, int size);
216

  
217
	public synchronized native int containerDeleteJ (int conn, int catType,
218
	 String contName, int forceFlag);
219

  
220
        public native int containerSyncJ (int conn, int catType,
221
         String contName, int purgeFlag);
222
         
223
 //DFH 6/8/00
224
 public synchronized byte[] getByteData(String name) {
225
    File tmp = new File("./tmp/");
226
    if (!tmp.exists()) { tmp.mkdir();}
227
  
228
    File temp = new File("./tmp/"+name);    // looks for file in tmp dir under current directory
229
    if (temp.exists()) {
230
        ByteData = new byte[(int)temp.length()];
231
        try{
232
            FileInputStream fis = new FileInputStream(temp);
233
            fis.read(ByteData);
234
            fis.close();
235
        }
236
        catch (Exception e) {;}
237
        temp.delete();
238
    }
239
    else {
240
        ByteData = new byte[0];   
241
    }
242
    return ByteData;
243
 } 
244
 
245
 public synchronized void setByteData(String name, byte[] in) {
246
    ByteData = in;
247
    FileName = name;
248
    File tmp = new File("./tmp/");
249
    if (!tmp.exists()) { tmp.mkdir();}
250

  
251
    File temp = new File("./tmp/"+name);
252
        try{
253
            FileOutputStream fos = new FileOutputStream(temp);
254
            fos.write(ByteData);
255
            fos.close();
256
        }
257
        catch (Exception e) {;}
258
 }
259
 
260
 public synchronized void clearTmpFiles() {
261
    File temp = new File("./tmp/"+FileName);
262
    if (temp.exists()) { temp.delete(); }
263
 }
264
 
265
 public synchronized void Reset() {
266
      try{
267
        String[] cmdarray = {"java", "-Djava.security.policy=mypolicy", "SrbJavaGlue"};
268
	    Runtime.getRuntime().exec(cmdarray);
269
        Runtime.getRuntime().exit(0);
270
      }
271
      catch (Exception e) {System.out.println("Could not run exec and exit"); }
272
 }
273
 
274
 public synchronized void writeMdasEnv(String username) {
275
	   try{
276
	    String userhome = System.getProperty("user.home");
277
	    File file = new File(userhome+"/.srb/.MdasEnv");
278
		FileWriter fw = new FileWriter(file);
279
		StringBuffer env = new StringBuffer();
280
		env.append("mdasCollectionHome '/home/higgins.bioinfo'\n");
281
		env.append("mdasDomainHome 'bioinfo'\n");
282
		env.append("srbUser '"+username+"'\n");
283
		env.append("srbHost 'penelope.nceas.ucsb.edu'\n");
284
		env.append("defaultResource 'test-unix-nceas'\n");
285
		env.append("SEA_OPT '0'");
286
		StringReader sr = new StringReader(env.toString());
287
		int c;
288
		while ((c = sr.read()) != -1)
289
                 {    
290
                    fw.write(c);
291
                 }
292
		fw.close();
293
		sr.close();
294
	   }
295
	   catch (Exception e) {}  
296
 }
297
 
298
 // --
299

  
300
	static
301
	{
302
		System.loadLibrary( "SrbJavaGlue" );
303
	}
304
	
305
	    public static void main(String[] args) {
306
                  if (System.getSecurityManager() == null) {
307
                      System.setSecurityManager(new RMISecurityManager());
308
                  }
309
                  String name = "//localhost/SrbJavaGlue";
310
                  if (args.length==1) name = "//localhost" + ":"+args[0]+"/SrbJavaGlue";
311
                  try {
312
                      SrbJavaGlue engine = new SrbJavaGlue();
313
                      Naming.rebind(name, engine);
314
                      System.out.println("SrbJavaGlue bound");
315
                  } catch (Exception e) {
316
                      System.err.println("SrbJavaGlue exception: " + 
317
                                         e.getMessage());
318
                      e.printStackTrace();
319
                  }
320
              }
321
	
322
	
323
}
324

  
0 325

  
lib/srbrmi/SrbJavaGlueInterface.java
1
/**
2
 *        Name: SrbJavaGlueInterface.java
3
 *     Purpose: Interface for RMI Implementation
4
 *   Copyright: 2000 Regents of the University of California and the
5
 *              National Center for Ecological Analysis and Synthesis
6
 *     Authors: Dan Higgins
7
 * 
8
 *     Version: '$Id$'
9
 *      @version 1.1 6/8/00
10
 *      @author Dan Higgins - NCEAS
11
 */
12
 
13
import java.rmi.Remote;
14
import java.rmi.RemoteException; 
15

  
16
public interface SrbJavaGlueInterface extends Remote
17
{
18
    // Interface for JNI/RMI
19
	// JNI (Java Native Interface) Glue Routines for the SRB client library.
20
	
21

  
22
	public int clConnectJ( String host, String port, String auth ) throws RemoteException;
23

  
24
    public int rmiConnectJ(String host, String port, String auth, String user ) throws RemoteException;
25

  
26
	public  int srbListCollectJ( int conn, int catType,
27
		String collectionName, String flag, int types[] ) throws RemoteException;
28

  
29
	public  String getFileListItem( int index ) throws RemoteException;
30

  
31
	public  int clFinishJ( int conn ) throws RemoteException;
32

  
33
	public  int rmiFinishJ( int conn ) throws RemoteException;
34

  
35
	public  int srbObjCopyNewJ( String srcDir, String srcFile,
36
		String dstDir, String dstFile, String dstRes ) throws RemoteException;
37

  
38
	public  int srbListResourceJ( int bs ) throws RemoteException;
39

  
40
	public  String getResListItem( int index ) throws RemoteException;
41

  
42
	public  String getDefCollection() throws RemoteException;
43

  
44
	public  String getDefResource() throws RemoteException;
45

  
46
	public  String getUser() throws RemoteException;
47

  
48
	public  String getDomain() throws RemoteException;
49

  
50
	public  String getLocalCacheDir() throws RemoteException;
51

  
52
	public  int srbObjReplicateJ(int conn, int catType,
53
	  String objID, String replNum, String collection, String resource) throws RemoteException;
54

  
55
	public  int srbCollReplicateJ(int conn, int catType,
56
	  String collection, String resource) throws RemoteException;
57

  
58
	public  int queryDataInCollJ (int conn, int catType, 
59
	  String parColl) throws RemoteException;
60

  
61
	public  int queryDataJ (int conn, int catType, String objID,
62
	  String parColl) throws RemoteException;
63

  
64
	public  int querySubCollInCollJ (int conn, int catType, 
65
	  String parColl) throws RemoteException;
66

  
67
	public  String getDataResultJ( int metaIndex, int rowIndex ) throws RemoteException;
68

  
69
	public  String getCollResultJ( int metaIndex, int rowIndex ) throws RemoteException;
70

  
71
	public  String getGenQueResultJ( int metaIndex, int rowIndex ) throws RemoteException;
72

  
73
	public  int getNCollAttriJ () throws RemoteException;
74

  
75
	public  int getNDataAttriJ () throws RemoteException;
76

  
77
	public  int srbObjUnlinkJ (int conn,  int catType, 
78
	  String objID, String replNum, String parColl) throws RemoteException;
79

  
80
	public  int srbCreateCollectJ (int conn,  int catType, 
81
	  String parColl, String newColl) throws RemoteException;
82

  
83
	public  int srbModifyDatasetMetaDJ (int conn,  int catType,
84
	  String objID, String collection, 
85
	   String newValue1, String newValue2, int retractionType) throws RemoteException;
86
	public  int srbModifyCollectMetaDJ (int conn,  int catType,
87
	  String collection, String newValue1, String newValue2, 
88
	   String newValue3, int retractionType) throws RemoteException;
89
	public  int importToOldObjJ (int conn,  int catType, 
90
	  String objID, String replNum, String parColl, String resource,
91
	   String localFile, String container) throws RemoteException;
92

  
93
	public  int importToNewObjJ (int conn,  int catType, 
94
	 String objID, String parColl, String resource, String localFile,
95
	  String container) throws RemoteException;
96

  
97
	public  int importDirJ (int conn,  int catType, 
98
	  String parColl, String resource, String localDir, String container) throws RemoteException;
99

  
100
	public  int srbRmCollJ (int conn, int catType, String parColl) throws RemoteException;
101

  
102
	public  int srbUnregCollJ (int conn, int catType, String parColl) throws RemoteException;
103

  
104
	public  int copyToOldObjJ (int conn,  int catType, 
105
	 String objID, String replNum, String srcColl, String targObj, 
106
	  String targReplNum, String targColl, String targResource, 
107
	   String container) throws RemoteException;
108

  
109
	public  int copyDataToCollJ (int conn,  int catType, 
110
	 String objID, String replNum, String srcColl,
111
	  String dataType, String size, String targColl, String targResource,
112
	   String container) throws RemoteException;
113

  
114
	public  int copyCollToCollJ (int conn, int catType, 
115
	 String srcColl, String targColl, String targResource, 
116
	  String container) throws RemoteException;
117

  
118
	public  int exportToFileJ(int conn, int catType,
119
	 String objID, String replNum, String srcColl,
120
	  String targFile, int forceFlag) throws RemoteException;
121

  
122
	public  int exportToDirJ(int conn, int catType,
123
	 String objID, String replNum, String srcColl,
124
	  String targDir) throws RemoteException;
125

  
126
	public  int exportCollToDirJ(int conn, int catType,
127
	 String srcColl, String targDir) throws RemoteException;
128

  
129
	public  int srbGenQuery (int conn, int catType,
130
	 String[] qval, int qvalInx[], int selVal[]) throws RemoteException;
131
	
132
        public  int srbRegisterDatasetJ(int conn, int catType,
133
         String objID, String dataType, String resource, String collection,
134
	  String pathName, int dataSize) throws RemoteException;
135

  
136
	public  int srbUnregisterDatasetJ (int conn, int catType,
137
	 String objID, String replNum, String collection) throws RemoteException;
138

  
139
        public  int srbRegisterDirJ (int conn, int catType,
140
	 String srcDirPath, String targColl, String resource) throws RemoteException;
141

  
142
        public  int getMoreDataRowsJ (int conn, int catType) throws RemoteException;
143

  
144
        public  int getMoreCollRowsJ (int conn, int catType) throws RemoteException;
145

  
146
        public  int getMoreGenQueRowsJ (int conn, int catType) throws RemoteException;
147
	
148
	public  int chmodInCollJ (int conn, int catType, 
149
	 String collection, String user, String domain, String mode) throws RemoteException;
150

  
151
	public  int ingestUserJ (int conn, int catType, 
152
	 String userName, String passwd, String domain, 
153
	  String userType, String userAddr, String userPhone, String userEmail,
154
	   String parentColl) throws RemoteException;
155

  
156
	public  int ingestGroupJ (int conn, int catType, 
157
	 String groupName, String passwd,
158
	  String groupAddr, String groupPhone, String groupEMail) throws RemoteException;
159

  
160
	public  int ingestLocJ (int conn, int catType, 
161
	 String locName, String fullAddr, String parentLoc) throws RemoteException; 
162

  
163
        public  int ingestResourceJ (int conn, int catType,
164
         String rescName, String rescType, String location, String phyPath) throws RemoteException;
165

  
166
        public  int ingestLogRescJ (int conn, int catType,
167
         String logRescName, String phyResc, String phyPath) throws RemoteException;
168

  
169
        public  int addLogRescJ (int conn, int catType,
170
         String logResc, String phyResc, String phyPath) throws RemoteException;
171

  
172
        public  int modifyUserJ (int conn, int catType,
173
         int modOpr, String userName, String domain, String modValue) throws RemoteException;
174

  
175
	public  int containerCreateJ (int conn, int catType,
176
	 String contName, String dataType, String logResc, int size) throws RemoteException;
177

  
178
	public  int containerDeleteJ (int conn, int catType,
179
	 String contName, int forceFlag) throws RemoteException;
180

  
181
        public  int containerSyncJ (int conn, int catType,
182
         String contName, int purgeFlag) throws RemoteException;
183
         
184
  // additions June 2000 by DFH to allows file transfers to client side of RMI
185
  
186
  public byte[] getByteData(String fileName) throws RemoteException;
187
  
188
  public void setByteData(String fileName, byte[] byteData) throws RemoteException;
189

  
190
  public void clearTmpFiles() throws RemoteException;
191
  
192
  public void Reset() throws RemoteException;
193
  
194
  
195
}
196

  
0 197

  
lib/srbrmi/RMIControllerInterface.java
1
/**
2
 *        Name: RMIControllerInterface.java
3
 *     Purpose: Interface for RMI Implementation
4
 *   Copyright: 2000 Regents of the University of California and the
5
 *              National Center for Ecological Analysis and Synthesis
6
 *     Authors: Dan Higgins
7
 * 
8
 *     Version: '$Id$'
9
 *      @version 1.1 6/8/00
10
 *      @author Dan Higgins - NCEAS
11
 */
12

  
13
 
14
import java.rmi.Remote;
15
import java.rmi.RemoteException; 
16

  
17
public interface RMIControllerInterface extends Remote
18
{
19
    
20
public void restart() throws RemoteException;    
21
    
22
    
23
}
0 24

  

Also available in: Unified diff