- Timestamp:
- 2008-04-02T18:08:50+13:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gli/trunk/src/org/greenstone/gatherer/remote/RemoteGreenstoneServer.java
r14974 r15164 149 149 } 150 150 151 static public boolean exists(String collection_name, File collection_file) 152 { 153 String result = performAction(new RemoteGreenstoneServerExistsAction(collection_name, collection_file)); 154 if(result.contains("exists")) { 155 return true; 156 } 157 else if(result.contains("does not exist")) { 158 return false; 159 } 160 return false; 161 } 151 162 152 163 // ---------------------------------------------------------------------------------------------------- … … 518 529 /** 519 530 * -------------------------------------------------------------------------------------------- 531 * CHECKING IF A FILE/FOLDER EXISTS ON SERVER SIDE 532 * -------------------------------------------------------------------------------------------- 533 */ 534 static private class RemoteGreenstoneServerExistsAction 535 extends RemoteGreenstoneServerAction 536 { 537 private String collection_name; 538 private File collection_file; 539 540 public RemoteGreenstoneServerExistsAction(String collection_name, File collection_file) 541 { 542 this.collection_name = collection_name; 543 this.collection_file = collection_file; 544 } 545 546 public void perform() 547 throws Exception 548 { 549 String collection_directory_path = CollectionManager.getCollectionDirectoryPath(collection_name); 550 String collection_file_relative_path = getPathRelativeToDirectory(collection_file, collection_directory_path); 551 collection_file_relative_path = collection_file_relative_path.replaceAll((Utility.isWindows() ? "\\\\" : "\\/"), "|"); 552 File file = new File(collection_directory_path, collection_file_relative_path); 553 554 String file_exists_command = "cmd=file-exists"; 555 file_exists_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8"); 556 file_exists_command += "&file=" + URLEncoder.encode(collection_file_relative_path, "UTF-8"); 557 // returns either "File <filename> exists" or "File <filename> does not exist" 558 // for the file/folder collection_file 559 action_output = sendCommandToServer(file_exists_command, null); 560 } 561 } 562 563 564 /** 565 * -------------------------------------------------------------------------------------------- 520 566 * DOWNLOAD COLLECTION FILE 521 567 * -------------------------------------------------------------------------------------------- … … 1014 1060 } 1015 1061 // Handle other types of errors by throwing an exception 1016 else if (command_output.startsWith("ERROR: ")) { 1062 else if (command_output.startsWith("ERROR: ")) { 1017 1063 throw new Exception(command_output.substring("ERROR: ".length())); 1064 } else if (command_output.contains("ERROR: ")) { // check if ERROR occurs anywhere else in the output 1065 throw new Exception(command_output); 1018 1066 } 1019 1067 … … 1167 1215 } 1168 1216 1169 1217 1170 1218 /** Returns the command output if the action completed, throws some kind of exception otherwise. */ 1171 1219 static private String uploadFileInternal(String upload_cgi, String cgi_args, String file_path)
Note:
See TracChangeset
for help on using the changeset viewer.