source: trunk/gli/src/org/greenstone/gatherer/GathererApplet.java@ 8204

Last change on this file since 8204 was 7991, checked in by mdewsnip, 20 years ago

Removed some dead code.

  • Property svn:keywords set to Author Date Id Revision
File size: 6.2 KB
Line 
1/**
2 *#########################################################################
3 *
4 * A component of the Gatherer application, part of the Greenstone digital
5 * library suite from the New Zealand Digital Library Project at the
6 * University of Waikato, New Zealand.
7 *
8 * Author: John Thompson, Greenstone Digital Library, University of Waikato
9 *
10 * Copyright (C) 1999 New Zealand Digital Library Project
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 *########################################################################
26 */
27
28package org.greenstone.gatherer;
29
30import java.awt.event.ActionEvent;
31import java.awt.event.ActionListener;
32import java.io.*;
33import java.net.*;
34import javax.swing.JApplet;
35import java.applet.*;
36
37import java.awt.*;
38import java.util.*;
39import javax.swing.*;
40import org.greenstone.gatherer.Configuration;
41import org.greenstone.gatherer.feedback.ActionRecorderDialog;
42import org.greenstone.gatherer.gui.GUIManager;
43import org.greenstone.gatherer.gui.Splash;
44import org.greenstone.gatherer.util.Utility;
45
46public class GathererApplet extends JApplet implements ActionListener
47{
48 Gatherer gatherer;
49 GUIManager g_man;
50 Dimension size = new Dimension(800, 540);
51
52 protected String fullLibraryURL(String address)
53 {
54 String full_address = "";
55
56 // make sure the URL has protocol, host, and file
57 if (address.startsWith("http:")) {
58 // the address has all the necessary components
59 full_address = address;
60 }
61 else if (address.startsWith("/")) {
62 // there is not protocol and host
63 URL document = getDocumentBase();
64 int port_no = document.getPort();
65
66 String port = (port_no>0) ? ":" + port_no : "";
67 full_address = "http://" + document.getHost() + port + address;
68 }
69
70 return full_address;
71 }
72
73 public void init()
74 {
75 try {
76 // Work-around to reduce number of
77 // 'Could not lock user prefs' error messages.
78 // Thanks to Walter Schatz from the java forums.
79 System.setProperty("java.util.prefs.syncInterval","2000000");
80 }
81
82 catch (Exception exception) {
83 // convenient way of finding out if user has agreed to
84 // to requested security settings
85
86 JLabel lab
87 = new JLabel("Greenstone Librarian Interface Applet deactivated",
88 JLabel.CENTER);
89 getContentPane().add(lab);
90 return;
91 }
92
93 // Ensure platform specific LAF
94 try {
95 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
96 }
97 catch(Exception exception) {
98 exception.printStackTrace();
99 }
100
101 String gwcgi = getParameter("gwcgi");
102 String library_cgi = fullLibraryURL(gwcgi);
103 int cgi_base_cut = library_cgi.lastIndexOf('/');
104 String cgi_base = library_cgi.substring(0,cgi_base_cut+1);
105
106 gatherer = new Gatherer();
107
108 String gli_user_folder = Utility.getGLIUserFolder().toString();
109
110 String[] args = { "-gsdl", gli_user_folder,
111 "-library", library_cgi,
112 };
113
114 GetOpt go = new GetOpt(args);
115
116 if (go.feedback_enabled) {
117 // If feedback is enabled, set up the recorder dialog.
118 // Use the default locale for now - this will be changed by the
119 // Gatherer run method
120 Locale currLocale = Locale.getDefault();
121 ActionRecorderDialog dlg = new ActionRecorderDialog (currLocale);
122 gatherer.feedback_enabled = true;
123 gatherer.feedback_dialog = dlg;
124 }
125
126 Gatherer.isGsdlRemote = true;
127 Gatherer.cgiBase = cgi_base;
128
129 Utility.BASE_DIR = go.gsdl_path;
130 if (!Utility.BASE_DIR.endsWith(File.separator)) {
131 Utility.BASE_DIR += File.separator;
132 }
133
134 Utility.CACHE_DIR = Utility.BASE_DIR + "cache" + File.separator;
135 Utility.HELP_DIR = Utility.BASE_DIR + "help" + File.separator;
136 Utility.METADATA_DIR = Utility.BASE_DIR + "metadata" + File.separator;
137 Utility.RECYCLE = Utility.BASE_DIR + "recycle" + File.separator;
138 Utility.RES_DIR = Utility.BASE_DIR + "resource" + File.separator;
139 Utility.WELCOME_DIR = Utility.BASE_DIR + "welcome" + File.separator;
140
141 Configuration.TEMPLATE_CONFIG_XML = "xml/configRemote.xml";
142 Configuration.CONFIG_XML = "configRemote.xml";
143 Configuration.GS3_CONFIG_XML = "config3Remote.xml";
144
145 File gli_user_dir = new File(gli_user_folder);
146 if (!gli_user_dir.exists()) {
147 gli_user_dir.mkdirs();
148 }
149
150 File col_dir = new File(Utility.getCollectDir(go.gsdl_path));
151 if (!col_dir.exists()) {
152 col_dir.mkdir();
153 }
154
155 File metadata_directory = new File(Utility.METADATA_DIR);
156 if (!metadata_directory.exists()) {
157 // digout metadata.zip from JAR file and unzip it
158 Utility.unzipFromJar(Utility.METADATA_ZIP,gli_user_folder);
159 }
160
161
162 File plug_dat = new File(Utility.BASE_DIR + "plugins.dat");
163 if (!plug_dat.exists()) {
164 Utility.extractFromJar("plugins.dat",Utility.BASE_DIR,false);
165 }
166
167 File class_dat = new File(Utility.BASE_DIR + "classifiers.dat");
168 if (!class_dat.exists()) {
169 Utility.extractFromJar("classifiers.dat",Utility.BASE_DIR,false);
170 }
171
172
173 g_man = gatherer.init(size, go.gsdl_path, go.gsdl3_path,
174 go.exec_path, go.debug, go.perl_path,
175 go.no_load, go.filename, go.site_name,
176 go.servlet_path, go.mirroring_enabled,
177 go.wget_version_str, go.wget_path);
178
179
180 JButton bttn = new JButton("Launch Greenstone Librarian Interface ...");
181 bttn.addActionListener(this);
182 getContentPane().add(bttn);
183 }
184
185
186
187 public void start()
188 {
189 System.err.println("Start called");
190 }
191
192
193
194 public void stop()
195 {
196 System.err.println("Stop called");
197
198 }
199
200 public void destroy()
201 {
202 System.err.println("Destroy called");
203 gatherer.exit();
204 System.err.println("Done gatherer exit.");
205 }
206
207 public void actionPerformed(ActionEvent e)
208 {
209 Splash splash = null;
210
211 gatherer.run(size, splash, g_man);
212 }
213}
Note: See TracBrowser for help on using the repository browser.