Changeset 2070
- Timestamp:
- 2001-02-26T01:07:28+13:00 (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/java-client/org/nzdl/gsdl/SimpleClient.java
r2067 r2070 26 26 27 27 // java libraries we're using 28 import java.io.BufferedReader; 28 29 import java.io.File; 29 30 import java.io.FileInputStream; … … 31 32 import java.io.FileReader; 32 33 import java.io.IOException; 34 import java.io.InputStreamReader; 33 35 import java.io.LineNumberReader; 34 36 import java.io.Serializable; 35 import java. util.Vector;37 import java.net.URL; 36 38 import java.util.Enumeration; 37 39 import java.util.Iterator; … … 41 43 import java.util.Properties; 42 44 import java.util.Set; 45 import java.util.Vector; 43 46 44 47 // local libraries … … 56 59 * A class to test the workings of Corba interface from the client side. 57 60 * 61 * @author stuart yeates ([email protected]) 62 * @author Brett Sheeran ([email protected]) 58 63 * @author Dave Nichols ([email protected]) 59 64 * @author Gordon Paynter ([email protected]) 60 * @author stuart yeates ([email protected])61 65 * @version $Revision$ 62 * @see org.nzdl.service.NzdlCollectionInfo ;63 * @see org.nzdl.service.NzdlQuery ;64 * @see org.nzdl.service.NzdlRequest ;65 * @see org.nzdl.service.NzdlResponse ;66 * @see org.nzdl.service.NzdlResultSet ;67 * @see org.nzdl.service.NzdlService ;68 * @see org.nzdl.service.NzdlServiceImpl ;66 * @see org.nzdl.service.NzdlCollectionInfo 67 * @see org.nzdl.service.NzdlQuery 68 * @see org.nzdl.service.NzdlRequest 69 * @see org.nzdl.service.NzdlResponse 70 * @see org.nzdl.service.NzdlResultSet 71 * @see org.nzdl.service.NzdlService 72 * @see org.nzdl.service.NzdlServiceImpl 69 73 * @see gnu.getopt.Getopt; 70 74 * @see gnu.getopt.LongOpt; 71 75 */ 72 76 73 public class SimpleClient implements Cloneable, Serializable {77 public class SimpleClient implements Cloneable, Serializable { 74 78 75 79 /** The collection of CORBA IORs we know about */ … … 129 133 130 134 if (nzdl == null) { 131 String IOR = getIorKey( );135 String IOR = getIorKey(IORFileName); 132 136 System.err.println("ior = " + IOR); 133 137 System.err.println("after IOR"); … … 151 155 } 152 156 153 private String getIorKey() { 157 /** 158 * Pre: Accept SourceOfID as either: URL or IOR string or Filename 159 * Post: extract localcorba.objid from source of ID 160 */ 161 private String getIorKey(String sourceOfID) { 154 162 String ior = null; 155 163 try { 156 LineNumberReader input 157 = new LineNumberReader(new FileReader(IORFileName)); 158 ior = input.readLine(); 159 } 160 catch (java.io.IOException e) { 164 sourceOfID = sourceOfID.trim(); 165 System.err.println("Reading IOR from: " + sourceOfID); 166 167 String firstChars = sourceOfID.substring(0, Math.min(4,sourceOfID.length())).toUpperCase(); 168 // if sourceOfID is a URL --------------------------------------- 169 if (sourceOfID.length() > 4 && firstChars.equalsIgnoreCase("HTTP")) { 170 URL myUrl = new URL(sourceOfID); 171 BufferedReader input =new 172 BufferedReader(new InputStreamReader(myUrl.openStream())); 173 ior = input.readLine(); 174 } 175 176 // if sourceOfID is an IOR -------------------------------------- 177 else if (sourceOfID.length() > 4 && firstChars.equalsIgnoreCase("IOR:")) { 178 ior = sourceOfID; 179 } 180 181 // else assume sourceOfID is a file name ------------------------ 182 else { 183 BufferedReader input 184 = new BufferedReader(new FileReader(sourceOfID)); 185 ior = input.readLine(); 186 } 187 } //end of try 188 catch (java.io.IOException e) { 161 189 System.err.println("Error reading IOR key:\n" + e); 162 190 System.err.println("Aborting service..."); … … 164 192 } 165 193 return ior; 166 } 194 } // end of getIorKey 195 196 167 197 168 198 private boolean attemptToInitialise(String [] _args, … … 281 311 Map metaData = nzdl.getMetaData( collName, docIDs, metaTag ); 282 312 283 for (ListIterator i = docIDs.listIterator(); i.hasNext(); ) { 284 String id = (String) i.next(); 285 Set meta = (Set) metaData.get( id ); 286 if (loadDocs) { 287 if (verbosity > 3) { 288 System.out.println(meta.toString()); 289 System.out.println("getting document contents ... "); 290 } 291 String documentContents = nzdl.getDocument(collName, id); 292 if (verbosity > 3) { 293 System.out.println("got document contents. "); 294 System.out.println(" *************** START DOC " + id + " ***************"); 295 System.out.println(documentContents); 296 System.out.println(" *************** END DOC " + id + " ***************"); 297 } 298 } else { 299 if (verbosity > 3) 300 System.out.println(meta.toString()); 313 for (ListIterator i = docIDs.listIterator(); i.hasNext(); ) { 314 String id = (String) i.next(); 315 Set meta = (Set) metaData.get( id ); 316 if (loadDocs) { 317 if (verbosity > 3) { 318 System.out.println(meta.toString()); 319 System.out.println("getting document contents ... "); 301 320 } 302 } 321 String documentContents = nzdl.getDocument(collName, id); 322 if (verbosity > 3) { 323 System.out.println("got document contents. "); 324 System.out.println(" *************** START DOC " + id + " ***************"); 325 System.out.println(documentContents); 326 System.out.println(" *************** END DOC " + id + " ***************"); 327 } 328 } else { 329 if (verbosity > 3) 330 System.out.println(meta.toString()); 331 } 332 } 303 333 } 304 334 }
Note:
See TracChangeset
for help on using the changeset viewer.