ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/server/uk/org/iscream/cms/server/filtermanager/HostInit.java
(Generate patch)

Comparing projects/cms/source/server/uk/org/iscream/cms/server/filtermanager/HostInit.java (file contents):
Revision 1.40 by tdb, Sun Aug 1 10:41:05 2004 UTC vs.
Revision 1.41 by tdb, Sun Sep 25 09:57:42 2005 UTC

# Line 87 | Line 87 | class HostInit extends Thread {
87              while(!cmd.equals("END")) {
88                  if(cmd.equals("STARTCONFIG")) {
89                      // respond to STARTCONFIG
90 <                    _socketOut.println("OK");
90 >                    send("OK");
91                      
92                      // try for LASTMODIFIED
93                      getInBound("LASTMODIFIED");
94 <                    _socketOut.println(cp.getLastModified(configName));
94 >                    send("" + cp.getLastModified(configName));
95                      
96                      // try for FILELIST
97                      getInBound("FILELIST");
98 <                    _socketOut.println(cp.getFileList(configName));
98 >                    send(cp.getFileList(configName));
99                      
100                      // try for FQDN
101                      getInBound("FQDN");
102 <                    _socketOut.println(_socket.getInetAddress().getHostName().toLowerCase());
102 >                    send(_socket.getInetAddress().getHostName().toLowerCase());
103                      
104                      // try for IP
105                      getInBound("IP");
106 <                    _socketOut.println(_socket.getInetAddress().getHostAddress());
106 >                    send(_socket.getInetAddress().getHostAddress());
107                      
108                      // get properties
109                      String reqProperty = getInBound();
# Line 111 | Line 111 | class HostInit extends Thread {
111                          // get the property
112                          try {
113                              String returnedProperty = cp.getProperty(configName, "Host."+reqProperty);
114 <                            _socketOut.println(returnedProperty);
114 >                            send(returnedProperty);
115                          } catch (PropertyNotFoundException e) {
116 <                            _socketOut.println("ERROR");
116 >                            send("ERROR");
117                          }
118                          // get the next request
119                          reqProperty = _socketIn.readLine();
120                      }
121                      _logger.write(toString(), Logger.SYSMSG, "configured host");
122 <                    _socketOut.println("OK");
122 >                    send("OK");
123                      
124                      // get filter reference
125                      getInBound("FILTER");
# Line 143 | Line 143 | class HostInit extends Thread {
143                          _logger.write(toString(), Logger.DEBUG, " found filter- " + filter);
144                          try {
145                              // tell the host about it...
146 <                            _socketOut.println(filterInfoRef.getHostName() + ";"
146 >                            send(filterInfoRef.getHostName() + ";"
147                              + filterInfoRef.getUDPPort());
148                          }
149                          catch(org.omg.CORBA.COMM_FAILURE e) {
150                              // failed to talk to filter, lets signal an error
151 <                            _socketOut.println("ERROR");
151 >                            send("ERROR");
152                              throw new IOException("error communicating with filter - " + e);
153                          }
154                      }
155                      else {
156                          // ...or throw a wobbly (and tell the host!)
157 <                        _socketOut.println("ERROR");
157 >                        send("ERROR");
158                          throw new IOException("unable to find filter for host");
159                      }
160                      
161                  }
162                  else if(cmd.equals("CHECKCONFIG")) {
163                      // respond to CHECKCONFIG
164 <                    _socketOut.println("OK");
164 >                    send("OK");
165                      
166                      // try for {filelist}
167                      String filelist = getInBound();
168 <                    _socketOut.println("OK");
168 >                    send("OK");
169                      
170                      // try for {lastModified}
171                      String lastModified = getInBound();
# Line 174 | Line 174 | class HostInit extends Thread {
174                          lastmod = Long.parseLong(lastModified);
175                      }
176                      catch(NumberFormatException e) {
177 <                        _socketOut.println("ERROR");
177 >                        send("ERROR");
178                          throw new IOException("Last Modified invalid: " + e);
179                      }
180                      
# Line 182 | Line 182 | class HostInit extends Thread {
182                      boolean newConfig = _configManager.isModified(filelist, lastmod);
183                      if(newConfig) {
184                          // new config !
185 <                        _socketOut.println("EXPIRED");
185 >                        send("EXPIRED");
186                      }
187                      else {
188                          // nothing has changed
189 <                        _socketOut.println("OK");
189 >                        send("OK");
190                      }
191                  }
192                  else {
193 <                    _socketOut.println("ERROR");
193 >                    send("ERROR");
194                  }
195                  // get the next command
196                  cmd = getInBound();
197              }
198              // respond to END
199 <            _socketOut.println("OK");
199 >            send("OK");
200              
201          } catch (Exception e) {
202              _logger.write(toString(), Logger.ERROR, "ERROR - " + e);
# Line 236 | Line 236 | class HostInit extends Thread {
236          String inBound = getInBound();
237          // check if it's what we're expecting
238          if(!inBound.equals(expected)) {
239 <            _socketOut.println("ERROR");
239 >            send("ERROR");
240              throw new IOException("protocol error - expected:"+expected+" got:" + inBound);
241          }
242          // it should be ok then
# Line 253 | Line 253 | class HostInit extends Thread {
253          // it's a valid message it seems
254          return inBound;
255      }
256 +
257 +        /* Use this instead of println. println under windows terminates the lines
258 +         * in \c\n which is not the expected result for the ihost client.
259 +         */
260 +        private void send(String data) {
261 +                _socketOut.print(data + "\n");
262 +                _socketOut.flush();
263 +        }
264  
265   //---ACCESSOR/MUTATOR METHODS---
266  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines