Changeset 13779
- Timestamp:
- 2007-01-24T11:43:02+13:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/greenstone/LocalLibraryServer.java
r13593 r13779 52 52 { 53 53 config(ADD_COMMAND + collection_name); 54 // This is very important -- it ensures that the above command has finished55 config("");56 54 } 57 55 58 56 59 57 // Used to send messages to the local library 60 // Warning: this has a lot of potential for nasty race conditions61 // The response code is returned immediately -- but this does not mean the local62 // library action has finished!63 58 static private void config(String command) 64 59 { … … 71 66 URL url = new URL(Configuration.library_url.toString() + command); 72 67 HttpURLConnection library_connection = (HttpURLConnection) url.openConnection(); 68 69 // It's very important that we read the output of the command 70 // This ensures that the command has actually finished 71 // (The response code is returned immediately) 72 InputStream library_is = library_connection.getInputStream(); 73 BufferedReader library_in = new BufferedReader(new InputStreamReader(library_is, "UTF-8")); 74 String library_output_line = library_in.readLine(); 75 while (library_output_line != null) { 76 DebugStream.println("Local library server output: " + library_output_line); 77 library_output_line = library_in.readLine(); 78 } 79 library_in.close(); 80 73 81 int response_code = library_connection.getResponseCode(); 74 82 if (response_code >= HttpURLConnection.HTTP_OK && response_code < HttpURLConnection.HTTP_MULT_CHOICE) { … … 79 87 } 80 88 } 81 catch (Exception ex ) {82 DebugStream.printStackTrace(ex );89 catch (Exception exception) { 90 DebugStream.printStackTrace(exception); 83 91 } 84 92 } … … 93 101 } 94 102 103 95 104 static public void releaseCollection(String collection_name) 96 105 { 97 106 config(RELEASE_COMMAND + collection_name); 98 // This is very important -- it ensures that the above command has finished99 config("");100 101 // !! HACK: Wait a couple of seconds, in the hope that this will reduce the "could not delete index" errors102 new OneSecondWait();103 new OneSecondWait();104 107 } 105 108
Note:
See TracChangeset
for help on using the changeset viewer.