Project

General

Profile

« Previous | Next » 

Revision 526

Added by bojilova about 24 years ago

SRB v1.1.8

View differences:

lib/srbrmi/SrbJavaGlue.java
10 10
 *
11 11
 *     Version: '$Id$'
12 12
 */
13
/**************************************************************************
14
Copyright ^?? General Atomics, 1995-1999
15
All Rights Reserved
16
 
17
This file contains Original Code and/or Modifications of Original Code as
18
defined in and that are subject to the General Atomics Storage Resource
19
Broker Academic and Research Use  License (the 'License'). This license is
20
for academic and research use only. You may not use, copy, modify or
21
distribute SRB for commercial purposes, nor incorporate the SRB into
22
commercial products without the express written permission of General
23
Atomics nor may you distribute SRB to any third party.
24
 
25
You may not use this software except in compliance with the License. Please
26
obtain a copy of the License at http://www.npaci.edu/DICE/SRB/License and
27
read it before using this file.
28
 
29
The Original Code and all software distributed under the License are
30
distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
31
EXPRESS OR IMPLIED, AND GENERAL ATOMICS AND THE SAN DIEGO SUPERCOMPUTER
32
CENTER HEREBY DISCLAIM ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION,
33
ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
34
NON-INFRINGEMENT OF ANY COPYRIGHT, PATENT , TRADEMARK OR OTHER RIGHTS.
35
GENERAL ATOMICS AND THE SAN DIEGO SUPERCOMPUTER CENTER FURTHER  HAVE NO
36
OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCMENTS OR
37
MODIFICATIONS.. Please see the License for the specific language governing
38
rights and limitations under the License."
39
 
40
Please read the terms of this license carefully. By using the SRB software,
41
you are accepting and agreeing to the terms of this license with General
42
Atomics. If you are agreeing to this license on behalf of a company, or
43
other institution, you represent that you are authorized to bind the
44
company/institution to such a license. If you do not meet this criterion or
45
you do not agree to any of the terms of this license, you are not
46
authorized to use the software.
47
**************************************************************************/
13 48

  
14 49
 /* Note: Based on Java code originally produced at SDSC
15 50
 * Copyright   1999   The Regents of the University of California
......
23 58
 *
24 59
 * @version 1.1 6/8/00
25 60
 * @author Dan Higgins - NCEAS
61
 * @version 1.0 10/23/97
62
 * @author John Moreland
26 63
 */
27 64
 
28 65
 import java.rmi.*;
......
31 68
 
32 69
 
33 70
public class SrbJavaGlue extends UnicastRemoteObject implements SrbJavaGlueInterface
71

  
34 72
{
35 73
 byte[] ByteData;
36 74
 String FileName;
37
 boolean previouslyConnected = false;
38 75
    
39 76
	// JNI (Java Native Interface) Glue Routines for the SRB client library.
40 77

  
......
42 79
                  super();
43 80
              }
44 81

  
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
	}
82
	public native int clConnectJ( String host, String port, String auth,
83
	 String user, String domain );
59 84

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

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

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

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

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

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

  
79
	public synchronized native String getDefCollection();
99
	public native String getDefCollection();
80 100

  
81
	public synchronized native String getDefResource();
101
	public native String getDefResource();
82 102

  
83
	public synchronized native String getUser();
103
	public native String getUser();
84 104

  
85
	public synchronized native String getDomain();
105
	public native String getDomain();
86 106

  
87
	public synchronized native String getLocalCacheDir();
107
	public native String getLocalCacheDir();
88 108

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

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

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

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

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

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

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

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

  
110
	public synchronized native int getNCollAttriJ ();
130
	public native int getNCollAttriJ ();
111 131

  
112
	public synchronized native int getNDataAttriJ ();
132
	public native int getNDataAttriJ ();
113 133

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

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

  
120
	public synchronized native int srbModifyDatasetMetaDJ (int conn,  int catType,
140
	public native int srbModifyDatasetMetaDJ (int conn,  int catType,
121 141
	  String objID, String collection, 
122 142
	   String newValue1, String newValue2, int retractionType);
123
	   
124
	public synchronized native int srbModifyCollectMetaDJ (int conn,  int catType,
143
	public native int srbModifyCollectMetaDJ (int conn,  int catType,
125 144
	  String collection, String newValue1, String newValue2, 
126 145
	   String newValue3, int retractionType);
127
	   
128
	public synchronized native int importToOldObjJ (int conn,  int catType, 
146
	public native int importToOldObjJ (int conn,  int catType, 
129 147
	  String objID, String replNum, String parColl, String resource,
130 148
	   String localFile, String container);
131 149

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  
199
	public synchronized native int ingestLocJ (int conn, int catType, 
200
	 String locName, String fullAddr, String parentLoc); 
217
	public native int ingestLocJ (int conn, int catType, 
218
	 String locName, String fullAddr, String parentLoc,
219
	  String serverUser, String serverUserDomain); 
201 220

  
202
        public synchronized native int ingestResourceJ (int conn, int catType,
203
         String rescName, String rescType, String location, String phyPath);
221
        public native int ingestResourceJ (int conn, int catType,
222
         String rescName, String rescType, String location, String phyPath,
223
	  String rscClass, int size);
204 224

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

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

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

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

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

  
220 240
        public native int containerSyncJ (int conn, int catType,
221 241
         String contName, int purgeFlag);
222 242
         
223 243
 //DFH 6/8/00
224
 public synchronized byte[] getByteData(String name) {
244
 public byte[] getByteData(String name) {
225 245
    File tmp = new File("./tmp/");
226 246
    if (!tmp.exists()) { tmp.mkdir();}
227 247
  
......
242 262
    return ByteData;
243 263
 } 
244 264
 
245
 public synchronized void setByteData(String name, byte[] in) {
265
 public void setByteData(String name, byte[] in) {
246 266
    ByteData = in;
247 267
    FileName = name;
248 268
    File tmp = new File("./tmp/");
......
257 277
        catch (Exception e) {;}
258 278
 }
259 279
 
260
 public synchronized void clearTmpFiles() {
280
 public void clearTmpFiles() {
261 281
    File temp = new File("./tmp/"+FileName);
262 282
    if (temp.exists()) { temp.delete(); }
263 283
 }
264 284
 
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 285
 // --
299 286

  
300 287
	static
301 288
	{
302 289
		System.loadLibrary( "SrbJavaGlue" );
290

  
303 291
	}
304 292
	
305 293
	    public static void main(String[] args) {
lib/srbrmi/SrbJavaGlueInterface.java
1
/**************************************************************************
2
Copyright ^?? General Atomics, 1995-1999
3
All Rights Reserved
4
 
5
This file contains Original Code and/or Modifications of Original Code as
6
defined in and that are subject to the General Atomics Storage Resource
7
Broker Academic and Research Use  License (the 'License'). This license is
8
for academic and research use only. You may not use, copy, modify or
9
distribute SRB for commercial purposes, nor incorporate the SRB into
10
commercial products without the express written permission of General
11
Atomics nor may you distribute SRB to any third party.
12
 
13
You may not use this software except in compliance with the License. Please
14
obtain a copy of the License at http://www.npaci.edu/DICE/SRB/License and
15
read it before using this file.
16
 
17
The Original Code and all software distributed under the License are
18
distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
19
EXPRESS OR IMPLIED, AND GENERAL ATOMICS AND THE SAN DIEGO SUPERCOMPUTER
20
CENTER HEREBY DISCLAIM ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION,
21
ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
22
NON-INFRINGEMENT OF ANY COPYRIGHT, PATENT , TRADEMARK OR OTHER RIGHTS.
23
GENERAL ATOMICS AND THE SAN DIEGO SUPERCOMPUTER CENTER FURTHER  HAVE NO
24
OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCMENTS OR
25
MODIFICATIONS.. Please see the License for the specific language governing
26
rights and limitations under the License."
27
 
28
Please read the terms of this license carefully. By using the SRB software,
29
you are accepting and agreeing to the terms of this license with General
30
Atomics. If you are agreeing to this license on behalf of a company, or
31
other institution, you represent that you are authorized to bind the
32
company/institution to such a license. If you do not meet this criterion or
33
you do not agree to any of the terms of this license, you are not
34
authorized to use the software.
35
**************************************************************************/
36

  
37

  
1 38
/**
39
 * SrbJavaGlue
40
 *
41
 * @version 1.0 10/23/97
42
 * @author John Moreland
43
 */
44
/**
2 45
 *        Name: SrbJavaGlueInterface.java
3 46
 *     Purpose: Interface for RMI Implementation
4 47
 *   Copyright: 2000 Regents of the University of California and the
......
16 59
public interface SrbJavaGlueInterface extends Remote
17 60
{
18 61
    // Interface for JNI/RMI
19
	// JNI (Java Native Interface) Glue Routines for the SRB client library.
20
	
62
    // JNI (Java Native Interface) Glue Routines for the SRB client library.
21 63

  
22
	public int clConnectJ( String host, String port, String auth ) throws RemoteException;
64
	public  int clConnectJ( String host, String port, String auth,
65
	 String user, String domain )throws RemoteException;
23 66

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

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

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

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

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

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

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

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

  
42
	public  String getDefCollection() throws RemoteException;
81
	public  String getDefCollection()throws RemoteException;
43 82

  
44
	public  String getDefResource() throws RemoteException;
83
	public  String getDefResource()throws RemoteException;
45 84

  
46
	public  String getUser() throws RemoteException;
85
	public  String getUser()throws RemoteException;
47 86

  
48
	public  String getDomain() throws RemoteException;
87
	public  String getDomain()throws RemoteException;
49 88

  
50
	public  String getLocalCacheDir() throws RemoteException;
89
	public  String getLocalCacheDir()throws RemoteException;
51 90

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

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

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

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

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

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

  
......
158 197
	  String groupAddr, String groupPhone, String groupEMail) throws RemoteException;
159 198

  
160 199
	public  int ingestLocJ (int conn, int catType, 
161
	 String locName, String fullAddr, String parentLoc) throws RemoteException; 
200
	 String locName, String fullAddr, String parentLoc,
201
	  String serverUser, String serverUserDomain) throws RemoteException; 
162 202

  
163 203
        public  int ingestResourceJ (int conn, int catType,
164
         String rescName, String rescType, String location, String phyPath) throws RemoteException;
204
         String rescName, String rescType, String location, String phyPath,
205
	  String rscClass, int size) throws RemoteException;
165 206

  
166 207
        public  int ingestLogRescJ (int conn, int catType,
167 208
         String logRescName, String phyResc, String phyPath) throws RemoteException;
......
178 219
	public  int containerDeleteJ (int conn, int catType,
179 220
	 String contName, int forceFlag) throws RemoteException;
180 221

  
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
222
  public  int containerSyncJ (int conn, int catType,
223
   String contName, int purgeFlag) throws RemoteException;
224

  
225

  
226
 // additions June 2000 by DFH to allows file transfers to client side of RMI
185 227
  
186 228
  public byte[] getByteData(String fileName) throws RemoteException;
187 229
  
188 230
  public void setByteData(String fileName, byte[] byteData) throws RemoteException;
189 231

  
190 232
  public void clearTmpFiles() throws RemoteException;
191
  
192
  public void Reset() throws RemoteException;
193
  
194
  
233

  
195 234
}
196

  

Also available in: Unified diff