Changeset 7658
- Timestamp:
- 2004-06-29T14:54:18+12:00 (20 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer
- Files:
-
- 1 added
- 1 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/WGet.java
r6770 r7658 44 44 import javax.swing.tree.*; 45 45 import org.greenstone.gatherer.Gatherer; 46 import org.greenstone.gatherer.collection. Job;46 import org.greenstone.gatherer.collection.DownloadJob; 47 47 48 48 /** This class provides access to the functionality of the WGet program, either by calling it via a shell script or by the JNI. It maintains a queue of pending jobs, and the component for showing these tasks to the user. … … 64 64 private JPanel list_pane; 65 65 /** The job currently underway. */ 66 private Job job;66 private DownloadJob job; 67 67 /** A scroll pane which will be used to display the list of pending tasks. */ 68 68 private JScrollPane list_scroll; … … 92 92 /** Called by the WGet native code to inform us of a new download starting within the given job. 93 93 * @param url The url that is being downloaded, as a <strong>String</strong>. 94 * @see org.greenstone.gatherer.collection. Job94 * @see org.greenstone.gatherer.collection.DownloadJob 95 95 */ 96 96 public synchronized void addDownload(String url) { … … 98 98 } 99 99 100 /* Used to advise the Job of a newly parsed link. Its up toJob to decide if it already knows about this url, and if not to update its progress bar.100 /* Used to advise the DownloadJob of a newly parsed link. Its up to DownloadJob to decide if it already knows about this url, and if not to update its progress bar. 101 101 * @param url The url in question as a <strong>String</strong>. 102 102 * @param type <i>true</i> if this is an internal link, <i>false</i> for and external one. 103 103 * @return A <i>boolean</i> with a value of <i>true</i> indicating if the url was added, <i>false</i> otherwise. 104 * @see org.greenstone.gatherer.collection. Job104 * @see org.greenstone.gatherer.collection.DownloadJob 105 105 */ 106 106 public synchronized boolean addLink(String url, int type) { … … 167 167 * wait until the native job has cleanly exited before removing 168 168 * the job. 169 * @param delete_me The <strong> Job</strong> that is to be deleted.170 */ 171 public void delete Job(Job delete_me) {169 * @param delete_me The <strong>DownloadJob</strong> that is to be deleted. 170 */ 171 public void deleteDownloadJob(DownloadJob delete_me) { 172 172 if (delete_me == job) { 173 173 // While this seems wasteful its only for the briefest moment. … … 202 202 * for the indicated job, is completed. In turn all download 203 203 * listeners are informed. 204 * @see org.greenstone.gatherer.collection. Job204 * @see org.greenstone.gatherer.collection.DownloadJob 205 205 */ 206 206 public synchronized void downloadComplete() { … … 211 211 * a status code other than 200-399 for the specified download job. 212 212 * for. 213 * @see org.greenstone.gatherer.collection. Job213 * @see org.greenstone.gatherer.collection.DownloadJob 214 214 */ 215 215 public synchronized void downloadFailed() { … … 222 222 * be downloaded as doing so would clobber an existing file and the -nc 223 223 * flag is set. 224 * @see org.greenstone.gatherer.collection. Job224 * @see org.greenstone.gatherer.collection.DownloadJob 225 225 */ 226 226 public synchronized void downloadWarning() { … … 231 231 * scroll pane containing the current list of jobs. 232 232 */ 233 public JScrollPane get JobList() {233 public JScrollPane getDownloadJobList() { 234 234 return list_scroll; 235 235 } … … 238 238 * @return A boolean representing whether the user has requested to 239 239 * stop. 240 * @see org.greenstone.gatherer.collection. Job240 * @see org.greenstone.gatherer.collection.DownloadJob 241 241 */ 242 242 public synchronized boolean hasSignalledStop() { … … 253 253 * @see org.greenstone.gatherer.Configuration 254 254 * @see org.greenstone.gatherer.Gatherer 255 * @see org.greenstone.gatherer.collection. Job256 * @see org.greenstone.gatherer.gui. GProgressBar255 * @see org.greenstone.gatherer.collection.DownloadJob 256 * @see org.greenstone.gatherer.gui.DownloadProgressBar 257 257 * @see org.greenstone.gatherer.util.GURL 258 258 */ 259 public void new Job(boolean no_parents, boolean other_hosts, boolean page_requisites, URL url, int depth, String destination) {259 public void newDownloadJob(boolean no_parents, boolean other_hosts, boolean page_requisites, URL url, int depth, String destination) { 260 260 // Create the job and fill in the details from gatherer.config. 261 261 Gatherer.println("About to create a new job"); 262 // If it was decided not to download page requisites, then create the destination by basing it on the given destination, but appending the url host and paths. If page requisites is used then WGet will do this for us 263 if(!page_requisites && depth == 0) { 264 Gatherer.println("Initially destination: " + destination); 265 String almost_the_entire_path = url.getPath(); 266 int index = -1; 267 if((index = almost_the_entire_path.lastIndexOf("/")) != -1) { 268 almost_the_entire_path = almost_the_entire_path.substring(0, index); 269 } 270 destination = destination + url.getHost() + almost_the_entire_path; 271 Gatherer.println("Final destination: " + destination); 272 } 273 Job new_job = new Job(Gatherer.config.get("mirroring.debug", false), no_parents, other_hosts, page_requisites, Gatherer.config.get("mirroring.quiet", false), url, depth, destination, Gatherer.config.proxy_pass, Gatherer.config.proxy_user, this, simple); 262 263 DownloadJob new_job = new DownloadJob(Gatherer.config.get("mirroring.debug", false), no_parents, other_hosts, page_requisites, Gatherer.config.get("mirroring.quiet", false), url, depth, destination, Gatherer.config.proxy_pass, Gatherer.config.proxy_user, this, simple); 264 274 265 // Tell it to run as soon as possible 275 new_job.setState( Job.RUNNING);266 new_job.setState(DownloadJob.RUNNING); 276 267 277 268 // Add to job_queue job list. … … 303 294 * @param expected A long representing the total number of bytes 304 295 * expected for this download. 305 * @see org.greenstone.gatherer.collection. Job296 * @see org.greenstone.gatherer.collection.DownloadJob 306 297 */ 307 298 public synchronized void updateProgress(long current, long expected) { … … 324 315 * waiting list. 325 316 * @see org.greenstone.gatherer.Gatherer 326 * @see org.greenstone.gatherer.collection. Job317 * @see org.greenstone.gatherer.collection.DownloadJob 327 318 */ 328 319 public void run() { … … 333 324 while(job_queue.size() > 0 && index < job_queue.size()) { 334 325 // Get the first job that isn't stopped. 335 job = ( Job) job_queue.get(index);336 if(job.getState() == Job.RUNNING) {337 Gatherer.println(" Job " + job.toString() + " Begun.");326 job = (DownloadJob) job_queue.get(index); 327 if(job.getState() == DownloadJob.RUNNING) { 328 Gatherer.println("DownloadJob " + job.toString() + " Begun."); 338 329 // A lock to prevent us deleting this job while its being 339 330 // run, unless you want things to go really wrong. … … 346 337 } 347 338 busy = false; 348 Gatherer.println(" Job " + job.toString() + " complete.");339 Gatherer.println("DownloadJob " + job.toString() + " complete."); 349 340 // And if the user has requested that complete jobs 350 341 // be removed, then remove it from the list. 351 //delete Job(job);342 //deleteDownloadJob(job); 352 343 job = null; 353 344 } … … 361 352 try { 362 353 synchronized(this) { 363 Gatherer.println("WGet thread is waiting for Jobs.");354 Gatherer.println("WGet thread is waiting for DownloadJobs."); 364 355 wait(); 365 356 }
Note:
See TracChangeset
for help on using the changeset viewer.