Changeset 24479 for main/trunk


Ignore:
Timestamp:
2011-08-25T22:04:29+12:00 (13 years ago)
Author:
ak19
Message:

When do not modify port is selected, it displays an error message and does nothing until you hit the restart button.

Location:
main/trunk/greenstone3/src/java/org/greenstone/server
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/server/BaseServer.java

    r24455 r24479  
    250250    }
    251251   
    252     public  void reloadConfigProperties(boolean port_has_changed) {
     252    // returns true on success
     253    public boolean reloadConfigProperties(boolean port_has_changed) {
    253254    try {
    254255        FileInputStream in = new FileInputStream(config_properties_file);
     
    265266    }
    266267   
     268    return true;
    267269    }
    268270
  • main/trunk/greenstone3/src/java/org/greenstone/server/BaseServerControl.java

    r24369 r24479  
    280280    }
    281281    }
     282   
     283    public void errorMessage(String message) {
     284        JOptionPane.showMessageDialog(null,message,"Error", JOptionPane.ERROR_MESSAGE);
     285    }
    282286}
  • main/trunk/greenstone3/src/java/org/greenstone/server/BaseServerSettings.java

    r24455 r24479  
    290290       
    291291        String osName = System.getProperty("os.name");
    292                 if (osName.startsWith("Windows")){
     292        if (osName.startsWith("Windows")){
    293293            browserPath = browserPath.replaceAll("\\\\","/");
    294294        }
     
    297297        scriptReadWrite.writeOutFile(BaseServer.config_properties_file, newFileLines);
    298298
    299         server.reloadConfigProperties(port_has_changed);
    300         server.reload(); // work out the URL again in case it has changed
    301         if (require_restart){
    302             JOptionPane.showMessageDialog(null,server.dictionary.get("ServerSettings.SettingChanged"),"Info", JOptionPane.INFORMATION_MESSAGE);
    303             if(autoStart) {
    304             server.autoStart();
    305             server.getServerControl().updateControl();
    306             }
     299        if(server.reloadConfigProperties(port_has_changed)) { // successful/valid configuration changes
     300                                                              // if failure, it would have displayed an error message
     301            server.reload(); // work out the URL again in case it has changed
     302            if (require_restart){
     303                JOptionPane.showMessageDialog(null,server.dictionary.get("ServerSettings.SettingChanged"),"Info", JOptionPane.INFORMATION_MESSAGE);
     304                if(autoStart) {
     305                    server.autoStart();
     306                    server.getServerControl().updateControl();
     307                }
     308            }
    307309        }
    308310        }
  • main/trunk/greenstone3/src/java/org/greenstone/server/Server2.java

    r24465 r24479  
    301301    }
    302302
    303     public void reloadConfigProperties(boolean port_has_changed) {
     303    public boolean reloadConfigProperties(boolean port_has_changed) {
    304304    super.reloadConfigProperties(port_has_changed);
    305305
     
    318318        if(!PortFinder.isPortAvailable(portNum, verbose)) { // first time, print any Port Unavailable messages
    319319        if(keepport.equals("1")) {
    320             String errorMsg = "Unable to run the Greenstone server on port " + port + ". It may already be in use.";
     320            server_control_.errorMessage(dictionary.get("ServerSettings.SettingsUnchangedPortOccupied", new String[]{port}));
     321            String errorMsg = "Unable to run the Greenstone server on port " + port + ". It appears to already be in use.";
    321322            System.err.println("\n******************");
    322             logger_.error(errorMsg);
     323            logger_.error(errorMsg);
    323324            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.");
    324325            System.err.println("******************\n");
     326           
     327            return false; // property change is unsuccessful
     328           
    325329        } else { // can modify port, try to find a new port
    326330       
     
    355359    }
    356360   
     361    return true;
    357362    }
    358363
Note: See TracChangeset for help on using the changeset viewer.