1 16 17 package org.apache.jetspeed.daemon.impl; 18 19 import org.apache.jetspeed.daemon.Daemon; 21 import org.apache.jetspeed.daemon.DaemonConfig; 22 import org.apache.jetspeed.daemon.DaemonEntry; 23 import org.apache.jetspeed.cache.disk.DiskCacheUtils; 24 import org.apache.jetspeed.cache.disk.JetspeedDiskCache; 25 import org.apache.jetspeed.services.logging.JetspeedLogFactoryService; 26 import org.apache.jetspeed.services.logging.JetspeedLogger; 27 import org.apache.jetspeed.services.urlmanager.URLManager; 28 import org.apache.jetspeed.services.urlmanager.URLFetcher; 29 30 import java.io.IOException ; 32 import java.util.Iterator ; 33 34 41 public class BadURLManagerDaemon implements Daemon { 42 43 private int status = Daemon.STATUS_NOT_PROCESSED; 44 private int result = Daemon.RESULT_UNKNOWN; 45 private DaemonConfig config = null; 46 private DaemonEntry entry = null; 47 48 51 private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(BadURLManagerDaemon.class.getName()); 52 53 56 public void run() { 57 58 logger.info("Checking for valid URLs within the URLManager"); 59 60 this.setResult( Daemon.RESULT_PROCESSING ); 61 62 Iterator i = URLManager.list().iterator(); 63 64 while ( i.hasNext() ) { 65 66 String url = (String )i.next(); 67 68 if ( URLManager.isOK( url ) ) continue; 70 71 try { 72 73 URLManager.unregister(url); 74 75 logger.info("Removing " + url + " from BadURL list" ); 76 this.save(); 77 78 URLFetcher.refresh(url); 80 81 82 } catch ( Throwable t ) { 83 logger.error("Invalid URL?", t); 86 if ( DiskCacheUtils.isCached( url ) ) { 87 try { 88 JetspeedDiskCache.getInstance().remove( url ); 90 } catch (IOException ioe) {} 91 } 92 logger.info("Failed to load: " + url + " from BadURL list"); 93 } 94 95 } 96 97 this.setResult( Daemon.RESULT_SUCCESS ); 98 } 99 100 102 public void init( DaemonConfig config, 103 DaemonEntry entry ) { 104 this.config = config; 105 this.entry = entry; 106 } 107 108 110 public DaemonConfig getDaemonConfig() { 111 return this.config; 112 } 113 114 116 public DaemonEntry getDaemonEntry() { 117 return this.entry; 118 } 119 120 127 public int getStatus() { 128 return this.status; 129 } 130 131 138 public void setStatus(int status) { 139 this.status = status; 140 } 141 142 145 public int getResult() { 146 return this.result; 147 } 148 149 152 public void setResult( int result ) { 153 this.result = result; 154 } 155 156 159 public String getMessage() { 160 return null; 161 } 162 163 166 public void save() { 167 168 171 } 172 173 public void restore() { } 174 175 176 177 } 178 179 | Popular Tags |