Changeset 24207
- Timestamp:
- 2011-06-28T17:07:42+12:00 (12 years ago)
- Location:
- main/trunk/greenstone3
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/build.properties.in
r23849 r24207 26 26 # does running the server automatically start up Tomcat and a browser 27 27 server.auto.start=false 28 # if set to true, won't try other ports if the specified port is not available 29 server.keep.port=false 28 30 # default servlet to start with 29 31 server.default.servlet=/library -
main/trunk/greenstone3/resources/java/server.properties
r20948 r24207 18 18 ServerSettings.Title=Server settings 19 19 ServerSettings.Auto_Start=Enter the library automatically 20 ServerSettings.Keep_Port=Do not modify port 20 21 ServerSettings.OK=OK 21 22 ServerSettings.Cancel=Cancel -
main/trunk/greenstone3/src/java/org/greenstone/server/BaseProperty.java
r22054 r24207 6 6 public final String GSDL_VERSION; 7 7 public final String AUTOSTART; 8 public final String KEEPPORT; 8 9 public final String START_BROWSER; 9 10 … … 21 22 public final String SERVER_SETTINGS; 22 23 23 protected BaseProperty(String version, String web_port, String autostart, String startbrowser )24 protected BaseProperty(String version, String web_port, String autostart, String startbrowser, String keepport) 24 25 { 25 26 // property names … … 31 32 AUTOSTART = autostart; 32 33 START_BROWSER = startbrowser; 34 KEEPPORT = keepport; 33 35 } 34 36 -
main/trunk/greenstone3/src/java/org/greenstone/server/BaseServerSettings.java
r22085 r24207 21 21 22 22 protected JCheckBox autoEnter; 23 protected JCheckBox keepPortToggle; 23 24 24 25 protected JSpinner portNumber_spinner = null; … … 31 32 protected int portNum = DEFPORT; 32 33 protected boolean autoStart = false; 34 protected boolean keepPort = false; 33 35 protected String browserPath = ""; 34 36 protected boolean useDefaultBrowser = true; … … 67 69 } 68 70 71 String keep_port_str = server.config_properties.getProperty(BaseServer.Property.KEEPPORT).trim(); 72 if (keep_port_str.equals("true") || keep_port_str.equals("1")) { 73 this.keepPort = true; 74 } else { 75 this.keepPort = false; 76 } 77 78 69 79 setTitle(server.dictionary.get("ServerSettings.Title")); 70 80 setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); … … 76 86 77 87 autoEnter = new JCheckBox(server.dictionary.get("ServerSettings.Auto_Start")); 88 keepPortToggle = new JCheckBox(server.dictionary.get("ServerSettings.Keep_Port")); 78 89 79 90 if (autoStart) { … … 83 94 } 84 95 autoEnter.setBackground(bg_color); 96 97 if(keepPort) { 98 keepPortToggle.setSelected(true); 99 } else { 100 keepPortToggle.setSelected(false); 101 } 102 keepPortToggle.setBackground(bg_color); 85 103 86 104 … … 107 125 port_panel.setBackground(bg_color); 108 126 109 JPanel top_panel = new JPanel(new GridLayout( 2,1));127 JPanel top_panel = new JPanel(new GridLayout(3,1)); 110 128 top_panel.add(port_panel); 129 top_panel.add(keepPortToggle); 111 130 top_panel.add(autoEnter); 112 131 … … 227 246 has_changed = true; 228 247 } 248 if (keepPort != keepPortToggle.isSelected()) { 249 has_changed = true; 250 } 251 229 252 230 253 // call subclass' onSave method, which may indicate (further) changes, -
main/trunk/greenstone3/src/java/org/greenstone/server/Server2.java
r23251 r24207 26 26 import org.greenstone.server.BaseServer; 27 27 import org.greenstone.server.BaseProperty; 28 28 29 29 30 public class Server2 extends BaseServer … … 287 288 suffix = httpprefix + suffix; 288 289 } 289 290 290 291 libraryURL = "http://" + host + ":" + port + suffix; 291 292 } … … 297 298 // first choice is port 80, second choice starts at 8282 298 299 String port = config_properties.getProperty("portnumber", "80"); 300 String keepport = config_properties.getProperty("keepport", "0"); // default is to not try to keep the same port 301 299 302 int portDefault = 8282; 300 303 try { … … 302 305 boolean verbose = true; 303 306 if(!PortFinder.isPortAvailable(portNum, verbose)) { // first time, print any Port Unavailable messages 304 305 PortFinder portFinder = new PortFinder(portDefault, 101); 306 // Search for a free port silently from now on--don't want more 307 // messages saying that a port could not be found... 308 portNum = portFinder.findPortInRange(!verbose); 309 310 if (portNum == -1) { 311 // If we've still not found a free port, do we try the default port again? 312 System.err.println("No free port found. Going to try on " + portDefault + " anyway."); 313 port = Integer.toString(portDefault); 307 if(keepport.equals("1")) { 308 String errorMsg = "Unable to run the Greenstone server on port " + port + ". It may already be in use."; 309 System.err.println("\n******************"); 310 logger_.error(errorMsg); 311 System.err.println("If you wish to try another port, go to File > Settings of the Greenstone Server interface and either change the port number or untick the \"Do Not Modify Port\" option there. Then press the \"Enter Library\" button."); 312 System.err.println("******************\n"); 314 313 } else { 315 port = Integer.toString(portNum); 316 } 317 config_properties.setProperty("portnumber", port); // store the correct port 318 319 // write this updated port to the config file, since the configure target uses the file to run 320 ScriptReadWrite scriptReadWrite = new ScriptReadWrite(); 321 ArrayList fileLines = scriptReadWrite.readInFile(BaseServer.config_properties_file); 322 scriptReadWrite.replaceOrAddLine(fileLines, "portnumber", port, false); // write the correct port 323 scriptReadWrite.writeOutFile(config_properties_file, fileLines); 324 325 configure_required_ = true; 326 System.err.println("Running server on port " + port + "."); 314 315 PortFinder portFinder = new PortFinder(portDefault, 101); 316 // Search for a free port silently from now on--don't want more 317 // messages saying that a port could not be found... 318 portNum = portFinder.findPortInRange(!verbose); 319 320 if (portNum == -1) { 321 // If we've still not found a free port, do we try the default port again? 322 System.err.println("No free port found. Going to try on " + portDefault + " anyway."); 323 port = Integer.toString(portDefault); 324 } else { 325 port = Integer.toString(portNum); 326 } 327 config_properties.setProperty("portnumber", port); // store the correct port 328 329 // write this updated port to the config file, since the configure target uses the file to run 330 ScriptReadWrite scriptReadWrite = new ScriptReadWrite(); 331 ArrayList fileLines = scriptReadWrite.readInFile(BaseServer.config_properties_file); 332 scriptReadWrite.replaceOrAddLine(fileLines, "portnumber", port, false); // write the correct port 333 scriptReadWrite.writeOutFile(config_properties_file, fileLines); 334 335 configure_required_ = true; 336 System.err.println("Running server on port " + port + "."); 337 } 327 338 } 328 339 } catch (Exception e) { -
main/trunk/greenstone3/src/java/org/greenstone/server/Server2Property.java
r18868 r24207 9 9 // Initialising customised final variables 10 10 // Version number, WEB_PORT 11 super("2", "portnumber", "autoenter", "start_browser" );11 super("2", "portnumber", "autoenter", "start_browser", "keepport"); 12 12 } 13 13 -
main/trunk/greenstone3/src/java/org/greenstone/server/Server2Settings.java
r23251 r24207 109 109 newFileLines = scriptReadWrite.queryReplace(newFileLines, BaseServer.Property.AUTOSTART, newAutoEnter); 110 110 } 111 boolean keep_port = keepPortToggle.isSelected(); 112 if(keepPort != keep_port) { 113 String newKeepPort = keep_port ? "1" : "0"; 114 newFileLines = scriptReadWrite.queryReplace(newFileLines, BaseServer.Property.KEEPPORT, newKeepPort); 115 } 111 116 112 117 // external access - onSave() would have updated this value -
main/trunk/greenstone3/src/java/org/greenstone/server/Server3Property.java
r18868 r24207 10 10 // Version number, WEB_PORT, autoenter, startbrowser 11 11 // For GS3, the last two are controlled by the same property 12 super("3", "tomcat.port", "server.auto.start", "server.auto.start" );12 super("3", "tomcat.port", "server.auto.start", "server.auto.start", "server.keep.port"); 13 13 } 14 14 -
main/trunk/greenstone3/src/java/org/greenstone/server/Server3Settings.java
r22085 r24207 93 93 newFileLines = scriptReadWrite.queryReplace(newFileLines, BaseServer.Property.AUTOSTART, newAutoEnter); 94 94 95 String newKeepPort = (new Boolean(keepPortToggle.isSelected())).toString(); 96 newFileLines = scriptReadWrite.queryReplace(newFileLines, BaseServer.Property.KEEPPORT, newKeepPort); 97 95 98 String newServletDef = (String) servlet_combobox.getSelectedItem(); 96 99 newFileLines = scriptReadWrite.queryReplace(newFileLines,BaseServer.Property.DEFAULT_SERVLET, (String) url_mappings.get(newServletDef));
Note:
See TracChangeset
for help on using the changeset viewer.