Project

General

Profile

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: SrbJavaGlue.java 526 2000-11-13 18:08:57Z bojilova $'
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
**************************************************************************/
48

    
49
 /* Note: Based on Java code originally produced at SDSC
50
 * Copyright   1999   The Regents of the University of California
51
 * All Rights Reserved
52
 */
53

    
54
/**
55
 * SrbJavaGlue
56
 *
57
 * Implementation of RMI Interface
58
 *
59
 * @version 1.1 6/8/00
60
 * @author Dan Higgins - NCEAS
61
 * @version 1.0 10/23/97
62
 * @author John Moreland
63
 */
64
 
65
 import java.rmi.*;
66
 import java.rmi.server.*;
67
 import java.io.*;   //DFH 6/8/00
68
 
69
 
70
public class SrbJavaGlue extends UnicastRemoteObject implements SrbJavaGlueInterface
71

    
72
{
73
 byte[] ByteData;
74
 String FileName;
75
    
76
	// JNI (Java Native Interface) Glue Routines for the SRB client library.
77

    
78
public SrbJavaGlue() throws RemoteException {
79
                  super();
80
              }
81

    
82
	public native int clConnectJ( String host, String port, String auth,
83
	 String user, String domain );
84

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

    
88
	public native String getFileListItem( int index );
89

    
90
	public native int clFinishJ( int conn );
91

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

    
95
	public native int srbListResourceJ( int bs );
96

    
97
	public native String getResListItem( int index );
98

    
99
	public native String getDefCollection();
100

    
101
	public native String getDefResource();
102

    
103
	public native String getUser();
104

    
105
	public native String getDomain();
106

    
107
	public native String getLocalCacheDir();
108

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

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

    
115
	public native int queryDataInCollJ (int conn, int catType, 
116
	  String parColl);
117

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

    
121
	public native int querySubCollInCollJ (int conn, int catType, 
122
	  String parColl);
123

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

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

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

    
130
	public native int getNCollAttriJ ();
131

    
132
	public native int getNDataAttriJ ();
133

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

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

    
140
	public native int srbModifyDatasetMetaDJ (int conn,  int catType,
141
	  String objID, String collection, 
142
	   String newValue1, String newValue2, int retractionType);
143
	public native int srbModifyCollectMetaDJ (int conn,  int catType,
144
	  String collection, String newValue1, String newValue2, 
145
	   String newValue3, int retractionType);
146
	public native int importToOldObjJ (int conn,  int catType, 
147
	  String objID, String replNum, String parColl, String resource,
148
	   String localFile, String container);
149

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

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

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

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

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

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

    
171
	public native int copyCollToCollJ (int conn, int catType, 
172
	 String srcColl, String targColl, String targResource, 
173
	  String container);
174

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

    
179
	public native int exportToDirJ(int conn, int catType,
180
	 String objID, String replNum, String srcColl,
181
	  String targDir);
182

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

    
186
	public native int srbGenQuery (int conn, int catType,
187
	 String[] qval, int qvalInx[], int selVal[]);
188
	
189
        public native int srbRegisterDatasetJ(int conn, int catType,
190
         String objID, String dataType, String resource, String collection,
191
	  String pathName, int dataSize);
192

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

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

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

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

    
203
        public native int getMoreGenQueRowsJ (int conn, int catType);
204
	
205
	public native int chmodInCollJ (int conn, int catType, 
206
	 String collection, String user, String domain, String mode);
207

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

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

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

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

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

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

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

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

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

    
240
        public native int containerSyncJ (int conn, int catType,
241
         String contName, int purgeFlag);
242
         
243
 //DFH 6/8/00
244
 public byte[] getByteData(String name) {
245
    File tmp = new File("./tmp/");
246
    if (!tmp.exists()) { tmp.mkdir();}
247
  
248
    File temp = new File("./tmp/"+name);    // looks for file in tmp dir under current directory
249
    if (temp.exists()) {
250
        ByteData = new byte[(int)temp.length()];
251
        try{
252
            FileInputStream fis = new FileInputStream(temp);
253
            fis.read(ByteData);
254
            fis.close();
255
        }
256
        catch (Exception e) {;}
257
        temp.delete();
258
    }
259
    else {
260
        ByteData = new byte[0];   
261
    }
262
    return ByteData;
263
 } 
264
 
265
 public void setByteData(String name, byte[] in) {
266
    ByteData = in;
267
    FileName = name;
268
    File tmp = new File("./tmp/");
269
    if (!tmp.exists()) { tmp.mkdir();}
270

    
271
    File temp = new File("./tmp/"+name);
272
        try{
273
            FileOutputStream fos = new FileOutputStream(temp);
274
            fos.write(ByteData);
275
            fos.close();
276
        }
277
        catch (Exception e) {;}
278
 }
279
 
280
 public void clearTmpFiles() {
281
    File temp = new File("./tmp/"+FileName);
282
    if (temp.exists()) { temp.delete(); }
283
 }
284
 
285
 // --
286

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

    
291
	}
292
	
293
	    public static void main(String[] args) {
294
                  if (System.getSecurityManager() == null) {
295
                      System.setSecurityManager(new RMISecurityManager());
296
                  }
297
                  String name = "//localhost/SrbJavaGlue";
298
                  if (args.length==1) name = "//localhost" + ":"+args[0]+"/SrbJavaGlue";
299
                  try {
300
                      SrbJavaGlue engine = new SrbJavaGlue();
301
                      Naming.rebind(name, engine);
302
                      System.out.println("SrbJavaGlue bound");
303
                  } catch (Exception e) {
304
                      System.err.println("SrbJavaGlue exception: " + 
305
                                         e.getMessage());
306
                      e.printStackTrace();
307
                  }
308
              }
309
	
310
	
311
}
312

    
(6-6/10)