source: main/trunk/greenstone3/src/java/org/greenstone/admin/GAI.java

Last change on this file was 22085, checked in by sjm84, 14 years ago

Created a util package from classes that could be useful outside of their original packages

  • Property svn:keywords set to Author Date Id Revision
File size: 5.0 KB
Line 
1/**
2 *#########################################################################
3 *
4 * A component of the Greenstone Administrator Interface, 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: Chi-Yu Huang, 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.admin;
29
30import java.awt.*;
31import java.awt.event.*;
32import java.io.*;
33import java.lang.*;
34import java.net.*;
35import java.util.*;
36import javax.swing.*;
37import javax.swing.plaf.*;
38import javax.swing.text.*;
39
40import org.greenstone.util.Configuration;
41import org.greenstone.gsdl3.util.Dictionary;
42import org.greenstone.admin.gui.SetServerPane;
43import org.greenstone.gsdl3.util.GSPath;
44
45/** Containing the top-level "core" for the GAI(Greenstone Administrator
46 * Interface) this class is the common core for the GAI application and
47 * applet. It first parses the command line arguments, preparing to update
48 * the configuration as required. Next it loads several important support
49 * classes such as the Configuration and Dictionary. Finally it creates the
50 * other important managers and sends them on their way.
51 * @author Chi-Yu Huang, Greenstone Digital Library, University of Waikato
52 * @version ###
53 */
54public class GAI
55{
56 public static Dimension screen_size = Toolkit.getDefaultToolkit().getScreenSize();
57 public static String gsdl3_src_home;
58 public static String gsdl3_web_home;
59 public static String tomcat_home;
60
61 public static File build_properties_file;
62
63 public static String images_path;
64 /** A public reference to the GAIManager. */
65 static public GAIManager ga_man;
66
67 /** a public reference to the Dictionary */
68 static public Dictionary dictionary = null;
69
70 public GAI(String gsdl3_src_home, String gsdl3_web_home)
71 {
72 this.gsdl3_src_home = gsdl3_src_home;
73 this.gsdl3_web_home = gsdl3_web_home;
74
75 // set up the Configuration
76 new Configuration();
77
78 // Read Dictionary
79 this.dictionary = new Dictionary("gai", Configuration.getLocale("general.locale"));
80 this.build_properties_file = new File(this.gsdl3_src_home, "build.properties");
81 // this may change if using preinstalled tomcat
82 this.tomcat_home = this.gsdl3_src_home+File.separatorChar+"packages"+File.separatorChar+"tomcat";
83
84 // should come from classpath ??
85 this.images_path = this.gsdl3_src_home+File.separatorChar+"resources"+File.separatorChar+"images"+File.separatorChar;
86 // start the GAIManager
87 ga_man = new GAIManager(screen_size);
88 ga_man.display();
89
90 }
91
92 public static String getGSDL3Home(){
93
94 String gsdl3Home = gsdl3_web_home;
95 String os = "linux";
96
97 if(System.getProperty("os.name").toLowerCase().indexOf("windows")!=-1){
98 gsdl3Home = gsdl3Home.replaceAll("\\\\", "/");
99 os = "windows";
100 }
101
102 gsdl3Home = GSPath.removeLastLink(gsdl3Home);
103
104 if(os.equals("windows")){
105 gsdl3Home = gsdl3Home.replaceAll("/", "\\\\");
106 }
107 return gsdl3Home;
108 }
109
110 public static String getGSDL3ExtensionHome(){
111 String gsdl3ExtHome = gsdl3_web_home;
112 String os = "linux";
113
114 if(System.getProperty("os.name").toLowerCase().indexOf("windows")!=-1){
115 gsdl3ExtHome = gsdl3ExtHome.replaceAll("\\\\", "/");
116 os = "windows";
117 }
118
119 gsdl3ExtHome = GSPath.removeLastLink(gsdl3ExtHome);
120 gsdl3ExtHome += "/ext";
121
122 if(os.equals("windows")){
123 gsdl3ExtHome = gsdl3ExtHome.replaceAll("/", "\\\\");
124 }
125 return gsdl3ExtHome;
126 }
127
128 public static void main (String[] args){
129 // A serious hack, but its good enough to stop crappy 'Could not
130 // lock user prefs' error messages. Thanks to Walter Schatz from
131 // the java forums.
132 System.setProperty("java.util.prefs.syncInterval","2000000");
133
134 if (args.length != 2) {
135 System.err.println("Usage: java org.greenstone.admin.GAI <gsdl3 src home> <gsdl3 web home>");
136 System.exit(1);
137 }
138
139 File gsdl3_src_dir = new File(args[0]);
140 File gsdl3_web_dir = new File(args[1]);
141 if (!gsdl3_src_dir.isDirectory() || !gsdl3_web_dir.isDirectory()) {
142 System.err.println("Usage: java org.greenstone.admin.GAI <gsdl3 src home> <gsdl3 web home>");
143 System.err.println("src or web directory does not exist!");
144 System.exit(1);
145 }
146
147 GAI gai = new GAI(args[0], args[1]);
148
149 }
150
151}
152
153
Note: See TracBrowser for help on using the repository browser.