source: greenstone3/trunk/src/java/org/greenstone/server/Server2Settings.java@ 18868

Last change on this file since 18868 was 18868, checked in by ak19, 15 years ago

Updated Server files for Linux GS2 Local Library Server to work the same way as the Windows GS2 LLS. Basically the major difference is that build.properties is no longer used but glisite.cfg or llssite.cfg depending on whether or not gs2-server.sh is launched from gli. There are a few additional changes required for this to keep it consistent with the way the Windows GS2 LLS works: storing the preview URL in glisite.cfg/llssite.cfg while the server is running and removing it when the server has stopped, Server2.java's main method taking the configfile as an additional parameter (and corresponding adjustments in the gsicontrol.sh script of GS2).

File size: 2.8 KB
Line 
1package org.greenstone.server;
2
3import java.awt.BorderLayout;
4import java.awt.event.*;
5import java.util.ArrayList;
6import javax.swing.*;
7import javax.swing.event.*;
8
9import org.greenstone.server.BaseServerSettings;
10
11public class Server2Settings extends BaseServerSettings implements ChangeListener, ActionListener
12{
13 protected JComboBox prefix_combobox;
14
15 public Server2Settings(BaseServer server)
16 {
17 super(server);
18 }
19
20 protected JPanel createServletPanel()
21 {
22 portNumber_spinner.addChangeListener(this);
23
24 JLabel prefix_label = new JLabel(server.dictionary.get(BaseServer.Property.SERVER_SETTINGS+".URL"));
25
26 prefix_combobox = new JComboBox();
27 prefix_combobox.setEditable(true);
28 prefix_combobox.addItem(server.getBrowserURL());
29 prefix_combobox.addActionListener(this);
30
31 JPanel comb_panel = new JPanel();
32 comb_panel.setLayout(new BorderLayout());
33 comb_panel.add(prefix_label, BorderLayout.NORTH);
34 comb_panel.add(prefix_combobox, BorderLayout.CENTER);
35 return comb_panel;
36 }
37
38 public String onSave()
39 {
40 return "";
41 }
42
43 public void save(ScriptReadWrite scriptReadWrite, ArrayList newFileLines)
44 {
45 String newAutoEnter = autoEnter.isSelected() ? "1" : "0";
46 newFileLines = scriptReadWrite.queryReplace(newFileLines, BaseServer.Property.AUTOSTART, newAutoEnter);
47 }
48
49 public void stateChanged(ChangeEvent e) {
50 int portNumber = ((Integer)portNumber_spinner.getValue()).intValue();
51 String url = (String)prefix_combobox.getSelectedItem();
52 url.replace('\\', '/');
53 String pre = "";
54 if(url.indexOf("http://") != -1) {
55 pre = "http://";
56 url = url.substring(7);
57 }
58
59 String[] parts = url.split("/");
60 String prefix = parts[0];
61
62 int colon = prefix.indexOf(':');
63 if(colon != -1) {
64 prefix = prefix.substring(0, colon);
65 }
66
67 url = pre + prefix + ":" + portNumber;
68 for(int i = 1; i < parts.length; i++) {
69 url = url + "/" + parts[i];
70 }
71
72 prefix_combobox.setSelectedItem(url);
73 }
74
75 public void actionPerformed(ActionEvent e) {
76 String url = (String)prefix_combobox.getSelectedItem();
77 int portNumber = 80;
78
79 String oldUrl = url;
80 if(url.indexOf("http://") != -1) {
81 url = url.substring(7);
82 }
83 int colon = url.indexOf(':');
84 int slash = url.indexOf('/');
85 if(slash == -1) {
86 slash = url.length();
87 }
88 if(colon != -1) {
89 url = url.substring(colon+1, slash);
90 try {
91 portNumber_spinner.setValue(Integer.decode(url));
92 } catch(NumberFormatException nfe) { // couldn't parse port number
93 // not an integer, leave portnumber at 80
94 String oldNum = portNumber_spinner.getValue().toString();
95 oldUrl = oldUrl.replaceFirst(oldNum, "80");
96 portNumber_spinner.setValue(new Integer(80));
97 }
98 } else { // no port number
99 oldUrl = oldUrl.replaceFirst(url, url+":80");
100 portNumber_spinner.setValue(new Integer(80));
101 }
102 }
103
104}
Note: See TracBrowser for help on using the repository browser.