Changeset 5319


Ignore:
Timestamp:
2003-08-28T12:38:21+12:00 (21 years ago)
Author:
jmt12
Message:

Rewrote to match WGet, and also debugged proxy problems. Also fixed difference between page requisite destination folders

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/collection/Job.java

    r4675 r5319  
    3838import java.awt.event.*;
    3939import java.io.*;
     40import java.net.*;
    4041import java.util.*;
    4142import javax.swing.tree.*;
     
    8889    /**
    8990     */
    90     public Job(TreeModel model, boolean clobber, boolean debug, boolean no_parents, boolean other_hosts, boolean page_requisites, boolean quiet, GURL initial, int depth, String destination, String proxy_pass, String proxy_user, WGet mummy, boolean simple) {
     91    public Job(TreeModel model, boolean clobber, boolean debug, boolean no_parents, boolean other_hosts, boolean page_requisites, boolean quiet, URL initial, int depth, String destination, String proxy_pass, String proxy_user, WGet mummy, boolean simple) {
    9192    this.model = model;
    9293
     
    9798    this.page_requisites = page_requisites;
    9899    this.quiet = quiet;
    99     this.initial = initial;
     100    this.initial = new GURL(initial);
    100101    this.depth = depth;
    101102    this.destination = destination;
     
    208209    }
    209210
    210     if(proxy_user != null) {
    211         command = command + "--proxy-user=" + proxy_user
    212         + " --proxy-passwd=" + proxy_pass + " ";
     211    // Determine if we have to use a proxy.
     212    if(Gatherer.config.get("general.use_proxy", true)) {
     213        String proxy_host = Gatherer.config.getString("general.proxy_host", true);
     214        String proxy_port = Gatherer.config.getString("general.proxy_port", true);
     215        // Find out whether the user has already authenticated themselves
     216        String user_pass = null;
     217        String address = proxy_host + ":" + proxy_port;
     218        System.err.println("Searching for authentication for: " + address);
     219        int count = 0;
     220        while(count < 3 && (user_pass = (String) Gatherer.authentications.get(address)) == null) {
     221        Authenticator.requestPasswordAuthentication(proxy_host, null, Integer.parseInt(proxy_port), "http://", Gatherer.dictionary.get("WGet.Prompt"), "HTTP");
     222        count++;
     223        }
     224        if(count >= 3) {
     225        state = STOPPED;
     226        return;
     227        }
     228        System.err.println("login@pass: " + user_pass);
     229        if(user_pass.indexOf("@") != -1) {
     230        // Write the use proxy command
     231        command = command + "-e httpproxy=" + proxy_host + ":" + proxy_port + "/ --proxy-user=" + user_pass.substring(0, user_pass.indexOf("@")) + " --proxy-passwd=" + user_pass.substring(user_pass.indexOf("@") + 1) + " -Y on ";
     232
     233        }
     234        else {
     235        Gatherer.println("Unknown user/pass");
     236        }
    213237    }
    214238         
     
    225249
    226250    if(previous_state == Job.COMPLETE) {
    227         progress.mirrorBegun(true);
     251        progress.mirrorBegun(true, true);
    228252    }
    229253    else {
    230         progress.mirrorBegun(false);
     254        progress.mirrorBegun(false, true);
    231255    }         
    232256
     
    258282            if(!ignore_for_robots) {
    259283            // Add download
    260             String new_url =
    261                 line.substring(line.indexOf("`") + 1,
    262                        line.lastIndexOf("'"));
     284            String new_url = line.substring(line.indexOf("`") + 1, line.lastIndexOf("'"));
    263285            // Remove the destination guff
    264286            if(destination != null) {
     
    291313            line.substring(line.indexOf("`") + 1,
    292314                       line.lastIndexOf("'"));
     315            // For some strange reason this won't compile
     316            //   src/org/greenstone/gatherer/collection/Job.java:311: cannot resolve symbol
     317            //   symbol  : class CAKE 
     318            //   location: class org.greenstone.gatherer.collection.Job
     319            /* ***********************************************************
     320            CAKE CAKE CAKE CAKE I WANT CAKE GIVE ME CAKE NOW!!
     321            *********************************************************** */
    293322            // Remove the destination guff
    294323            if(destination != null) {
     
    348377    // downloaded will be correct.
    349378    if(previous_state == Job.COMPLETE) {
    350         progress.mirrorBegun(true);
     379        progress.mirrorBegun(true, false);
    351380    }
    352381    else {
    353         progress.mirrorBegun(false);
     382        progress.mirrorBegun(false, false);
    354383    }
    355384
Note: See TracChangeset for help on using the changeset viewer.