Ignore:
Timestamp:
2008-02-12T16:13:13+13:00 (16 years ago)
Author:
davidb
Message:

Changes to GLI to support export into Fedora. New utility called flisvn diff gems/MetadataSetManager.java

File:
1 edited

Legend:

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

    r14605 r14974  
    3636import javax.swing.plaf.*;
    3737import javax.swing.text.*;
     38
     39
    3840import org.greenstone.gatherer.Configuration;
    3941import org.greenstone.gatherer.GAuthenticator;
     42import org.greenstone.gatherer.FedoraInfo;
    4043import org.greenstone.gatherer.collection.CollectionManager;
    4144import org.greenstone.gatherer.feedback.ActionRecorderDialog;
     
    5154import org.greenstone.gatherer.gui.URLField;
    5255import org.greenstone.gatherer.gui.WarningDialog;
     56import org.greenstone.gatherer.gui.FedoraLogin;
    5357import org.greenstone.gatherer.remote.RemoteGreenstoneServer;
    5458import org.greenstone.gatherer.util.JarTools;
     
    7781        * change the regex in the gs3-release-maker code and in this message
    7882        */
    79     static final public String PROGRAM_VERSION = "trunk";
     83    static final public String PROGRAM_VERSION = "1.0";
    8084
    8185    static private Dimension size = new Dimension(800, 540);
     
    186190    // More special code for running with a remote Greenstone
    187191    if (isGsdlRemote) {
    188         Configuration.TEMPLATE_CONFIG_XML = "xml/configRemote.xml";
     192        if (go.fedora_info.isActive()) {
     193        Configuration.TEMPLATE_CONFIG_XML = "xml/" + Configuration.FEDORA_CONFIG_PREFIX + "configRemote.xml";
     194        }
     195        else {
     196        Configuration.TEMPLATE_CONFIG_XML = "xml/configRemote.xml";
     197        }
     198
    189199        if (!go.run_gsdl3){ 
    190200        Configuration.CONFIG_XML = "configRemote.xml";
     
    198208        }
    199209    }
    200 
    201     init(go.gsdl_path, go.gsdl3_path, go.gsdl3_src_path, go.local_library_path, go.library_url_string,
     210    else {     
     211        if (go.fedora_info.isActive()) {
     212        Configuration.TEMPLATE_CONFIG_XML = "xml/" + Configuration.FEDORA_CONFIG_PREFIX + Configuration.CONFIG_XML;
     213
     214        }
     215    }
     216
     217    init(go.gsdl_path, go.gsdl3_path, go.gsdl3_src_path,
     218         go.fedora_info,
     219         go.local_library_path, go.library_url_string,
    202220         go.gliserver_url_string, go.debug, go.perl_path, go.no_load, go.filename, go.site_name,
    203221         go.servlet_path);
     
    205223
    206224
    207     public void init(String gsdl_path, String gsdl3_path, String gsdl3_src_path, String local_library_path,
     225    public void init(String gsdl_path, String gsdl3_path, String gsdl3_src_path,
     226             FedoraInfo fedora_info,
     227             String local_library_path,
    208228             String library_url_string, String gliserver_url_string, boolean debug_enabled,
    209229             String perl_path, boolean no_load, String open_collection,
     
    245265    try {
    246266        // Load GLI config file
    247         new Configuration(getGLIUserDirectoryPath(), gsdl_path, gsdl3_path, gsdl3_src_path, site_name);
     267        new Configuration(getGLIUserDirectoryPath(), gsdl_path, gsdl3_path, gsdl3_src_path, site_name,
     268                  fedora_info);
    248269
    249270        // Check we know where Perl is
     
    278299        }
    279300
     301        if (fedora_info.isActive()) {
     302        popupFedoraInfo();
     303        }
     304
     305
    280306        // Start up the local library server, if that's what we want
    281307        if (Utility.isWindows() && local_library_path != null && !isGsdlRemote && !GS3) {
     
    298324        if (Configuration.library_url == null) {
    299325        missingEXEC();
     326
    300327        if ((Configuration.library_url!=null) && isGsdlRemote && (gliserver_url_string==null)){
    301328            if (GS3){
    302329            default_gliserver_url = new URL(Configuration.library_url.toString() + "/cgi-bin/gliserver4gs3.pl");
    303330            }else{
    304             default_gliserver_url = new URL(Configuration.library_url.toString().substring(0,Configuration.library_url.toString().lastIndexOf("/library")) + "/gliserver.pl");
     331            String default_gliserver_str = "";
     332            String library_url_str = Configuration.library_url.toString();         
     333            int cut_pos = library_url_str.lastIndexOf("/library");
     334
     335            if (cut_pos>0) {
     336                default_gliserver_str = library_url_str.substring(0,cut_pos) + "/gliserver.pl";
     337            }
     338            else {
     339                cut_pos = library_url_str.lastIndexOf("/");
     340                if (cut_pos>0) {
     341                default_gliserver_str = library_url_str.substring(0,cut_pos) + "/gliserver.pl";
     342                }
     343                else {
     344                default_gliserver_str = library_url_str + "/gliserver.pl";
     345                }
     346            }
     347
     348            default_gliserver_url = new URL(default_gliserver_str);
    305349            }
    306350            missingGLIServer();
     
    327371                default_gliserver_url = new URL(Configuration.library_url.toString() + "/cgi-bin/gliserver4gs3.pl");
    328372            }else{
    329                 default_gliserver_url = new URL(Configuration.library_url.toString().substring(0,Configuration.library_url.toString().lastIndexOf("/library")) + "/gliserver.pl");
     373                String library_url = Configuration.library_url.toString();
     374                default_gliserver_url = new URL(library_url.substring(0,library_url.lastIndexOf("/library")) + "/gliserver.pl");
    330375            }
    331376            }
     
    787832    }
    788833    }
     834
     835
     836
     837    /** Prints a warning message about a missing library path, which means the final collection cannot be previewed in the Gatherer.
     838     */
     839    static private void popupFedoraInfo() {
     840
     841    FedoraLogin dialog = new FedoraLogin("Fedora Login", false);
     842
     843    if (Configuration.library_url == null) {
     844       
     845        String library_url_string = dialog.getLibraryURL();
     846        if (!library_url_string.equals("")) {
     847        try {
     848            Configuration.library_url = new URL(library_url_string);
     849        }
     850        catch (MalformedURLException exception) {
     851            DebugStream.printStackTrace(exception);
     852        }
     853        }
     854    }
     855       
     856    if (dialog.loginRequested()) {
     857
     858        String hostname = dialog.getHostname();
     859        String port     = dialog.getPort();
     860        String username = dialog.getUsername();
     861        String password = dialog.getPassword();
     862        String protocol = dialog.getProtocol();
     863
     864        Configuration.fedora_info.setHostname(hostname);
     865        Configuration.fedora_info.setPort(port);
     866        Configuration.fedora_info.setUsername(username);
     867        Configuration.fedora_info.setPassword(password);
     868        Configuration.fedora_info.setProtocol(protocol);
     869
     870        String ping_url_str = protocol + "://" + hostname + ":" + port + "/fedora";
     871        String login_str = username + ":" + password;
     872       
     873        String login_encoding = new sun.misc.BASE64Encoder().encode(login_str.getBytes());
     874
     875
     876        try {
     877        URL ping_url = new URL(ping_url_str);
     878        URLConnection uc = ping_url.openConnection();
     879        uc.setRequestProperty  ("Authorization", "Basic " + login_encoding);
     880        // Attempt to access some content ...
     881        InputStream content = (InputStream)uc.getInputStream();
     882
     883        }
     884        catch (Exception exception) {
     885        System.err.println("****");
     886        System.err.println("* Failed to connect to Fedora server.");
     887        System.err.println("* Server might not be running, or incorrect username and/or password.");
     888        System.err.println("***");
     889        DebugStream.printStackTrace(exception);
     890        System.exit(1);
     891        }
     892    }
     893    else {
     894        System.exit(0);
     895    }
     896
     897
     898    dialog.dispose();
     899    dialog = null;
     900
     901
     902    }
     903
    789904
    790905
Note: See TracChangeset for help on using the changeset viewer.