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

Comparing projects/cms/source/server/uk/org/iscream/cms/server/client/WebFeeder.java (file contents):
Revision 1.12 by tdb, Thu Mar 15 22:20:41 2001 UTC vs.
Revision 1.15 by tdb, Fri Mar 16 16:47:33 2001 UTC

# Line 36 | Line 36 | public class WebFeeder extends Thread {
36       */
37      public final int DEFAULT_AGE = 3600;
38      
39 +    /**
40 +     * The default path seperator, here for convienience
41 +     */
42 +    private final String sep = File.separator;
43 +    
44   //---STATIC METHODS---
45  
46      /**
# Line 71 | Line 76 | public class WebFeeder extends Thread {
76              alertSubDir = cp.getProperty("WebFeeder", "WebFeeder.alertSubDir");
77              File alertsDir = new File(rootPath, alertSubDir);
78              if(deleteContents(alertsDir)) {
79 <                _logger.write(this.toString(), Logger.DEBUG, "Deleted all files and directories from: "+rootPath+"/"+alertSubDir);
79 >                _logger.write(this.toString(), Logger.DEBUG, "Deleted all files and directories from: "+rootPath+sep+alertSubDir);
80              } else {
81 <                _logger.write(this.toString(), Logger.WARNING, "Failed to delete all files and directories from: "+rootPath+"/"+alertSubDir);
81 >                _logger.write(this.toString(), Logger.WARNING, "Failed to delete all files and directories from: "+rootPath+sep+alertSubDir);
82              }
83              // cleanup complete
84          } catch (PropertyNotFoundException e) {
# Line 143 | Line 148 | public class WebFeeder extends Thread {
148              
149              // list the files and delete as appropriate
150              File alertsDir = new File(rootPath, alertSubDir);
151 +            // get all the hostnames directories
152              File[] contents = alertsDir.listFiles();
153              for(int i=0; i < contents.length; i++) {
154 +                // get a single directory from the array..
155                  File hostdir = contents[i];
156 +                // ..and check it's a directory
157                  if(hostdir.isDirectory()) {
158 +                    // get all the contents of that directory
159                      File[] hostdirContents = hostdir.listFiles();
160                      for(int j=0; j < hostdirContents.length; j++) {
161                          File alertFile = hostdirContents[j];
162 +                        // get the filename..
163                          String filename = alertFile.getName();
164 +                        // ..and see if it ends with OK or FINAL
165                          if(filename.endsWith(Alert.alertLevels[0]) ||
166                             filename.endsWith(Alert.alertLevels[Alert.alertLevels.length-1])) {
167 <                            // it ends with either OK or FINAL
167 >                            // it does end with either OK or FINAL
168                              // ... so we can check it for deletion
169                              long lastModified = alertFile.lastModified();
170                              long age = System.currentTimeMillis() - lastModified;
# Line 200 | Line 211 | public class WebFeeder extends Thread {
211          String data = packet.printAll();
212          String hostname = packet.getParam("packet.attributes.machine_name");
213          // set paths
214 <        File outDir = new File(rootPath, latestSubDir+"/"+hostname);
215 <        File outFile = new File(rootPath, latestSubDir+"/"+hostname+"/"+latestFileName);
214 >        File outDir = new File(rootPath, latestSubDir+sep+hostname);
215 >        File outFile = new File(rootPath, latestSubDir+sep+hostname+sep+latestFileName);
216          // write the data out
217          writeData(outDir, outFile, data);
218      }
# Line 230 | Line 241 | public class WebFeeder extends Thread {
241          String data = alert.printAll();
242          String hostname = alert.getSource();
243          // set paths
244 <        File outDir = new File(rootPath, alertSubDir+"/"+hostname);
245 <        String destFile = alertSubDir+"/"+hostname+"/"+alertFileName+"."+String.valueOf(alert.getInitialAlertTime());
244 >        File outDir = new File(rootPath, alertSubDir+sep+hostname);
245 >        String destFile = alertSubDir+sep+hostname+sep+alertFileName+"."+String.valueOf(alert.getInitialAlertTime());
246          File outFile;
247          // check if we're at a special "end case" (OK or FINAL)
248          if(alert.getLevel()==0 || alert.getLevel()==Alert.alertLevels.length-1) {
# Line 241 | Line 252 | public class WebFeeder extends Thread {
252                  _logger.write(this.toString(), Logger.WARNING, "Failed to rename old file, "+oldFile.getPath()+" to new file, "+outFile.getPath());
253              }
254          } else {
255 <            outFile = new File(destFile);
255 >            outFile = new File(rootPath, destFile);
256          }
257          // write the data out
258          writeData(outDir, outFile, data);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines