Changeset 20618 for greenstone3
- Timestamp:
- 2009-09-17T16:24:39+12:00 (15 years ago)
- Location:
- greenstone3/trunk/src/java/org/greenstone/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
greenstone3/trunk/src/java/org/greenstone/server/Server2.java
r20604 r20618 8 8 import java.io.InputStreamReader; 9 9 import java.io.IOException; 10 import java.net.InetAddress; 10 11 import java.net.ServerSocket; 11 12 import java.net.Socket; 13 import java.net.UnknownHostException; 12 14 import java.net.URL; 13 15 //import java.net.URLConnection; … … 207 209 //reloadConfigProperties(); 208 210 port = config_properties.getProperty("portnumber", port); 209 host = config_properties.getProperty("host", host); 210 211 212 // The "hosts" property in the config file contains more than one allowed host 213 // Need to work out the particular host chosen from the address_resolution_method 214 // Default is address_resolution_method 2: localhost 215 String addressResolutionMethod = config_properties.getProperty("address_resolution_method"); 216 int address_resolution_method = (addressResolutionMethod == null) ? 2 : Integer.parseInt(addressResolutionMethod); 217 InetAddress inetAddress = null; 218 try { 219 inetAddress = InetAddress.getLocalHost(); 220 } catch(UnknownHostException e) { 221 logger_.error(e); 222 logger_.info("Defaulting host IP to "+ host); // use the default 223 address_resolution_method = 2; 224 } 225 switch(address_resolution_method) { 226 case 0: 227 host = inetAddress.getHostName(); 228 break; 229 case 1: 230 host = inetAddress.getHostAddress(); 231 break; 232 case 2: 233 host = "localhost"; 234 break; 235 case 3: 236 host = "127.0.0.1"; 237 break; 238 default: 239 host = "localhost"; 240 } 211 241 } catch(Exception e) { 212 242 recordError("Exception trying to load properties from gsdlsite_cfg. Using default library prefix.", e); -
greenstone3/trunk/src/java/org/greenstone/server/Server2Settings.java
r20604 r20618 13 13 import org.greenstone.server.BaseServerSettings; 14 14 15 public class Server2Settings extends BaseServerSettings implements ActionListener15 public class Server2Settings extends BaseServerSettings 16 16 { 17 17 protected JComboBox prefix_combobox; … … 41 41 allowConnections = new JCheckBox(server.dictionary.get(BaseServer.Property.SERVER_SETTINGS+".ExternalAccess"), allowCons); 42 42 allowConnections.setBackground(bg_color); 43 allowConnections.addActionListener(this);44 43 45 44 JPanel connect_panel = new JPanel(new GridLayout(4, 1)); 46 45 connect_panel.setBackground(bg_color); 47 connect_panel.setBorder(BorderFactory.createTitledBorder( "Connection configuration"));46 connect_panel.setBorder(BorderFactory.createTitledBorder(server.dictionary.get(BaseServer.Property.SERVER_SETTINGS+".AddressResolutionMethod"))); 48 47 49 48 hostRadioButtons = new JRadioButton[4]; … … 58 57 hostGroup.add(hostRadioButtons[i]); 59 58 hostRadioButtons[i].setBackground(bg_color); 60 hostRadioButtons[i].setEnabled(!allowCons); 61 } 62 59 } 63 60 64 61 String addressResolutionMethod = server.config_properties.getProperty("address_resolution_method").trim(); … … 114 111 115 112 // work out the host (default is address_resolution_method 2: localhost) 116 String host = "localhost"; 113 String hosts = "127.0.0.1 localhost"; 114 String fixedHostIP = "127.0.0.1"; 117 115 InetAddress inetAddress = null; 118 116 try { 119 117 inetAddress = InetAddress.getLocalHost(); 118 119 fixedHostIP = inetAddress.getHostAddress(); // used for all cases unless things go wrong 120 hosts = "127.0.0.1 " + fixedHostIP; // for address_resolution_methods 1 and 3 121 122 if(address_resolution_method == 2) { 123 hosts = hosts + " localhost"; 124 } else if(address_resolution_method == 0) { 125 hosts = hosts + " " + inetAddress.getHostName() + " localhost"; 126 } 120 127 } catch(UnknownHostException e) { 121 128 logger.error(e); 122 logger.info("Server2.java reload(): Defaulting host IP to "+ host); // use the default 129 logger.info("Server2.java reload(): Defaulting host IP to localhost"); 130 fixedHostIP = "127.0.0.1"; 123 131 address_resolution_method = 2; 132 hosts = "127.0.0.1 localhost"; 124 133 } 125 switch(address_resolution_method) { 126 case 0: 127 host = inetAddress.getHostName(); 128 break; 129 case 1: 130 host = inetAddress.getHostAddress(); 131 break; 132 case 3: 133 host = "127.0.0.1"; 134 break; 135 case 2: default: 136 host = "localhost"; 137 } 138 newFileLines = scriptReadWrite.queryReplace(newFileLines, "host", host); 134 135 newFileLines = scriptReadWrite.queryReplace(newFileLines, "hosts", hosts); 136 newFileLines = scriptReadWrite.queryReplace(newFileLines, "hostIP", fixedHostIP); 139 137 140 138 // address resolution method - onSave() would have updated … … 142 140 newFileLines = scriptReadWrite.queryReplace(newFileLines, "address_resolution_method", Integer.toString(address_resolution_method)); 143 141 144 } 145 146 public void actionPerformed(ActionEvent e) { 147 boolean toggle = !allowConnections.isSelected(); 148 if(e.getSource() == allowConnections) { 149 for(int i = 0; i < hostRadioButtons.length; i++) { 150 hostRadioButtons[i].setEnabled(toggle); 151 } 152 } 153 } 154 142 } 155 143 }
Note:
See TracChangeset
for help on using the changeset viewer.