source: other-projects/FileTransfer-WebSocketPair/testGXTWithGreenstone/src/org/greenstone/gatherer/FedoraInfo.java@ 33053

Last change on this file since 33053 was 33053, checked in by ak19, 5 years ago

I still had some stuff of Nathan Kelly's (FileTransfer-WebSocketPair) sitting on my USB. Had already commited the Themes folder at the time, 2 years back. Not sure if he wanted this additional folder commited. But I didn't want to delete it and decided it will be better off on SVN. When we use his project, if we find we didn't need this test folder, we can remove it from svn then.

File size: 4.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 and David Bainbridge,
9 * Greenstone Digital Library, University of Waikato
10 *
11 * Copyright (C) 1999 New Zealand Digital Library Project
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 *########################################################################
27 */
28
29package org.greenstone.gatherer;
30
31import java.io.*;
32import org.greenstone.gatherer.util.StaticStrings;
33import org.greenstone.gatherer.util.Utility;
34
35public class FedoraInfo
36{
37 public static final int minimumSupportedMajorVersion = 2;
38
39 private boolean active = false;
40 private String home = null;
41 private String version = null;
42
43 private String hostname = null;
44 private String port = null;
45 private String username = null;
46 private String password = null;
47 private String protocol = null;
48
49 public FedoraInfo()
50 {
51 this("localhost", "8080", "fedoraAdmin", "fedoraAdmin", "http");
52 }
53
54 public FedoraInfo(String hostname, String port, String username, String password, String protocol)
55 {
56 this.hostname = hostname;
57 this.port = port;
58 this.username = username;
59 this.password = password;
60 this.protocol = protocol;
61 }
62
63 // Called when we are attempting to run fedora
64 public void setActive(boolean active) {
65 this.active = active;
66 }
67
68 // Called when an environment variable was wrongly set for running Fedora
69 public void deactivate(String errorMessage) {
70 this.active = false;
71 // display an errormessage and exit cleanly
72 System.err.println(errorMessage);
73 Gatherer.exit();
74 }
75
76 public boolean isActive()
77 {
78 return active;
79 }
80
81 public void setHome(String home)
82 {
83 this.home = home;
84 }
85
86
87 public String getHome()
88 {
89 return home;
90 }
91
92 public void setVersion(String version)
93 {
94 String firstChar = version.substring(0, 1);
95 if(!Character.isDigit(version.charAt(0))) { // version is illegal if it does not begin with a number
96 deactivate("Incorrect format for major version: " + version + ". The Fedora version must start with a number.");
97 }
98 else if(Integer.parseInt(firstChar) < minimumSupportedMajorVersion) {
99 // major version number of Fedora must be more than this
100 deactivate("The major version number of Fedora must be at least " + minimumSupportedMajorVersion + ".");
101 }
102 else { // acceptable
103 this.version = version;
104 }
105 }
106
107
108 public String getVersion()
109 {
110 return version;
111 }
112
113 public void setHostname(String hostname)
114 {
115 this.hostname = hostname;
116 }
117
118 public String getHostname()
119 {
120 return hostname;
121 }
122
123
124 public void setPort(String port)
125 {
126 this.port = port;
127 }
128
129 public String getPort()
130 {
131 return port;
132 }
133
134
135 public void setUsername(String username)
136 {
137 this.username = username;
138 }
139
140 public String getUsername()
141 {
142 return username;
143 }
144
145
146 public void setPassword(String password)
147 {
148 this.password = password;
149 }
150
151 public String getPassword()
152 {
153 return password;
154 }
155
156
157 public void setProtocol(String protocol)
158 {
159 this.protocol = protocol;
160 }
161
162 public String getProtocol()
163 {
164 return protocol;
165 }
166
167 public String getBaseURL()
168 {
169 return this.protocol+"://"+this.hostname+":"+this.port+"/";
170 }
171
172 // The library preview address for Fedora
173 public String getLibraryURL()
174 {
175 return this.getBaseURL() + "fedora/search";
176 }
177}
Note: See TracBrowser for help on using the repository browser.