Revision 5026
Added by daigle over 15 years ago
src/edu/ucsb/nceas/metacat/admin/MetaCatAdminServlet.java | ||
---|---|---|
1 |
/** |
|
2 |
* '$RCSfile$' |
|
3 |
* Purpose: A Class that implements utility methods for a metadata catalog |
|
4 |
* Copyright: 2008 Regents of the University of California and the |
|
5 |
* National Center for Ecological Analysis and Synthesis |
|
6 |
* Authors: Michael Daigle |
|
7 |
* |
|
8 |
* '$Author$' |
|
9 |
* '$Date$' |
|
10 |
* '$Revision$' |
|
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
25 |
*/ |
|
26 |
|
|
27 |
package edu.ucsb.nceas.metacat.admin; |
|
28 |
|
|
29 |
import java.io.IOException; |
|
30 |
import java.util.Vector; |
|
31 |
|
|
32 |
import javax.servlet.ServletConfig; |
|
33 |
import javax.servlet.ServletException; |
|
34 |
import javax.servlet.http.HttpServlet; |
|
35 |
import javax.servlet.http.HttpServletRequest; |
|
36 |
import javax.servlet.http.HttpServletResponse; |
|
37 |
import javax.servlet.http.HttpSession; |
|
38 |
|
|
39 |
import org.apache.log4j.Logger; |
|
40 |
|
|
41 |
import edu.ucsb.nceas.metacat.MetaCatServlet; |
|
42 |
import edu.ucsb.nceas.metacat.service.PropertyService; |
|
43 |
import edu.ucsb.nceas.metacat.service.SessionService; |
|
44 |
import edu.ucsb.nceas.metacat.shared.MetacatUtilException; |
|
45 |
import edu.ucsb.nceas.metacat.util.AuthUtil; |
|
46 |
import edu.ucsb.nceas.metacat.util.MetacatUtil; |
|
47 |
import edu.ucsb.nceas.metacat.util.RequestUtil; |
|
48 |
import edu.ucsb.nceas.metacat.util.SkinUtil; |
|
49 |
import edu.ucsb.nceas.metacat.util.SystemUtil; |
|
50 |
import edu.ucsb.nceas.utilities.GeneralPropertyException; |
|
51 |
|
|
52 |
/** |
|
53 |
* Entry servlet for the metadata configuration utility |
|
54 |
*/ |
|
55 |
public class MetaCatAdminServlet extends HttpServlet { |
|
56 |
|
|
57 |
private static final long serialVersionUID = 1L; |
|
58 |
|
|
59 |
private Logger logMetacat = Logger.getLogger(MetaCatAdminServlet.class); |
|
60 |
|
|
61 |
/** |
|
62 |
* Initialize the servlet |
|
63 |
*/ |
|
64 |
public void init(ServletConfig config) throws ServletException { |
|
65 |
super.init(config); |
|
66 |
} |
|
67 |
|
|
68 |
/** Handle "GET" method requests from HTTP clients */ |
|
69 |
public void doGet(HttpServletRequest request, HttpServletResponse response) |
|
70 |
throws ServletException, IOException { |
|
71 |
|
|
72 |
// Process the data and send back the response |
|
73 |
handleGetOrPost(request, response); |
|
74 |
} |
|
75 |
|
|
76 |
/** Handle "POST" method requests from HTTP clients */ |
|
77 |
public void doPost(HttpServletRequest request, HttpServletResponse response) |
|
78 |
throws ServletException, IOException { |
|
79 |
|
|
80 |
// Process the data and send back the response |
|
81 |
handleGetOrPost(request, response); |
|
82 |
} |
|
83 |
|
|
84 |
/** |
|
85 |
* Control servlet response depending on the action parameter specified |
|
86 |
* |
|
87 |
* @param request |
|
88 |
* the http request information |
|
89 |
* @param response |
|
90 |
* the http response to be sent back to the client |
|
91 |
*/ |
|
92 |
private void handleGetOrPost(HttpServletRequest request, |
|
93 |
HttpServletResponse response) throws ServletException, IOException { |
|
94 |
String action = request.getParameter("configureType"); |
|
95 |
logMetacat.debug("Processing admin action: " + action); |
|
96 |
Vector<String> processingMessage = new Vector<String>(); |
|
97 |
Vector<String> processingErrors = new Vector<String>(); |
|
98 |
|
|
99 |
try { |
|
100 |
// Update the last update time for this user if they are not new |
|
101 |
HttpSession httpSession = request.getSession(false); |
|
102 |
if (httpSession != null) { |
|
103 |
SessionService.touchSession(httpSession.getId()); |
|
104 |
} |
|
105 |
|
|
106 |
if (!MetacatUtil.isBackupDirConfigured()) { |
|
107 |
// if the backup dir has not been configured, then show the |
|
108 |
// backup directory configuration screen. |
|
109 |
processingMessage.add("You must configure the backup directory" |
|
110 |
+ " before you can continue with Metacat configuration."); |
|
111 |
RequestUtil.setRequestMessage(request, processingMessage); |
|
112 |
action = "backup"; |
|
113 |
logMetacat.debug("Admin action changed to 'backup'"); |
|
114 |
} else if (!AuthUtil.isAuthConfigured()) { |
|
115 |
// if authentication isn't configured, change the action to auth. |
|
116 |
// Authentication needs to be set up before we do anything else |
|
117 |
processingMessage.add("You must configure authentication before " |
|
118 |
+ "you can continue with MetaCat configuration."); |
|
119 |
RequestUtil.setRequestMessage(request, processingMessage); |
|
120 |
action = "auth"; |
|
121 |
logMetacat.debug("Admin action changed to 'auth'"); |
|
122 |
} else if (!AuthUtil.isUserLoggedInAsAdmin(request)) { |
|
123 |
// If auth is configured, see if the user is logged in |
|
124 |
// as an administrator. If not, they need to log in before |
|
125 |
// they can continue with configuration. |
|
126 |
processingMessage.add("You must log in as an administrative " + "" + |
|
127 |
"user before you can continue with MetaCat configuration."); |
|
128 |
RequestUtil.setRequestMessage(request, processingMessage); |
|
129 |
action = "login"; |
|
130 |
logMetacat.debug("Admin action changed to 'login'"); |
|
131 |
} |
|
132 |
|
|
133 |
if (action == null || action.equals("configure")) { |
|
134 |
// Forward the request main configuration page |
|
135 |
request.setAttribute("metaCatVersion", SystemUtil.getMetacatVersion()); |
|
136 |
request.setAttribute("propsConfigured", new Boolean(PropertyService.arePropertiesConfigured())); |
|
137 |
request.setAttribute("authConfigured", new Boolean(AuthUtil.isAuthConfigured())); |
|
138 |
// TODO MCD figure out if we still need an org section |
|
139 |
//request.setAttribute("orgsConfigured", new Boolean(OrganizationUtil.areOrganizationsConfigured())); |
|
140 |
request.setAttribute("skinsConfigured", new Boolean(SkinUtil.areSkinsConfigured())); |
|
141 |
request.setAttribute("metacatConfigured", new Boolean(MetacatUtil.isMetacatConfigured())); |
|
142 |
request.setAttribute("geoserverConfigured", |
|
143 |
PropertyService.getProperty("configutil.geoserverConfigured")); |
|
144 |
request.setAttribute("metcatServletInitialized", MetaCatServlet.isFullyInitialized()); |
|
145 |
if (PropertyService.arePropertiesConfigured()) { |
|
146 |
request.setAttribute("databaseVersion", |
|
147 |
DBAdmin.getInstance().getDBVersion()); |
|
148 |
request.setAttribute("contextURL", SystemUtil.getContextURL()); |
|
149 |
} |
|
150 |
RequestUtil.forwardRequest(request, response, |
|
151 |
"/admin/metacat-configuration.jsp?configureType=configure"); |
|
152 |
return; |
|
153 |
} else if (action.equals("properties")) { |
|
154 |
// process properties |
|
155 |
PropertiesAdmin.getInstance().configureProperties(request, |
|
156 |
response); |
|
157 |
return; |
|
158 |
} else if (action.equals("skins")) { |
|
159 |
// process skins |
|
160 |
SkinsAdmin.getInstance().configureSkins(request, response); |
|
161 |
return; |
|
162 |
} else if (action.equals("database")) { |
|
163 |
// process database |
|
164 |
DBAdmin.getInstance().configureDatabase(request, response); |
|
165 |
return; |
|
166 |
} else if (action.equals("auth")) { |
|
167 |
// process authentication |
|
168 |
AuthAdmin.getInstance().configureAuth(request, response); |
|
169 |
return; |
|
170 |
} else if (action.equals("login")) { |
|
171 |
// process login |
|
172 |
LoginAdmin.getInstance().authenticateUser(request, response); |
|
173 |
return; |
|
174 |
} else if (action.equals("backup")) { |
|
175 |
// process login |
|
176 |
BackupAdmin.getInstance().configureBackup(request, response); |
|
177 |
return; |
|
178 |
} else if (action.equals("geoserver")) { |
|
179 |
// process geoserver password change |
|
180 |
GeoserverAdmin.getInstance().configureGeoserver(request, response); |
|
181 |
return; |
|
182 |
} else { |
|
183 |
String errorMessage = "Invalid action in configuration request: " + action; |
|
184 |
logMetacat.error(errorMessage); |
|
185 |
processingErrors.add(errorMessage); |
|
186 |
} |
|
187 |
} catch (GeneralPropertyException ge) { |
|
188 |
String errorMessage = |
|
189 |
"Property problem while handling request: " + ge.getMessage(); |
|
190 |
logMetacat.error(errorMessage); |
|
191 |
processingErrors.add(errorMessage); |
|
192 |
} catch (AdminException ae) { |
|
193 |
String errorMessage = |
|
194 |
"Admin problem while handling request: " + ae.getMessage(); |
|
195 |
logMetacat.error(errorMessage); |
|
196 |
processingErrors.add(errorMessage); |
|
197 |
} catch (MetacatUtilException ue) { |
|
198 |
String errorMessage = |
|
199 |
"Utility problem while handling request: " + ue.getMessage(); |
|
200 |
logMetacat.error(errorMessage); |
|
201 |
processingErrors.add(errorMessage); |
|
202 |
} |
|
203 |
|
|
204 |
if (processingErrors.size() > 0) { |
|
205 |
RequestUtil.clearRequestMessages(request); |
|
206 |
RequestUtil.setRequestErrors(request,processingErrors); |
|
207 |
// if the action that threw an exception was "configure" just go straight to the metacat |
|
208 |
// configuration. This will avoid a loop. Otherwise, call the admin servlet with |
|
209 |
// configuration action. |
|
210 |
if (action != null && action.equals("configure")) { |
|
211 |
RequestUtil.forwardRequest(request, response, "/admin/metacat-configuration.jsp"); |
|
212 |
} else { |
|
213 |
RequestUtil.forwardRequest(request, response, "/admin?configureType=configure"); |
|
214 |
} |
|
215 |
} |
|
216 |
} |
|
217 |
} |
|
218 | 0 |
src/edu/ucsb/nceas/metacat/admin/MetaCatAdmin.java | ||
---|---|---|
1 |
/** |
|
2 |
* '$RCSfile$' |
|
3 |
* Purpose: A Class that implements utility methods like: |
|
4 |
* 1/ Reding all doctypes from db connection |
|
5 |
* 2/ Reading DTD or Schema file from Metacat catalog system |
|
6 |
* 3/ Reading Lore type Data Guide from db connection |
|
7 |
* Copyright: 2000 Regents of the University of California and the |
|
8 |
* National Center for Ecological Analysis and Synthesis |
|
9 |
* Authors: Jivka Bojilova |
|
10 |
* |
|
11 |
* '$Author$' |
|
12 |
* '$Date$' |
|
13 |
* '$Revision$' |
|
14 |
* |
|
15 |
* This program is free software; you can redistribute it and/or modify |
|
16 |
* it under the terms of the GNU General Public License as published by |
|
17 |
* the Free Software Foundation; either version 2 of the License, or |
|
18 |
* (at your option) any later version. |
|
19 |
* |
|
20 |
* This program is distributed in the hope that it will be useful, |
|
21 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
22 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
23 |
* GNU General Public License for more details. |
|
24 |
* |
|
25 |
* You should have received a copy of the GNU General Public License |
|
26 |
* along with this program; if not, write to the Free Software |
|
27 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
28 |
*/ |
|
29 |
|
|
30 |
package edu.ucsb.nceas.metacat.admin; |
|
31 |
|
|
32 |
import java.util.Vector; |
|
33 |
|
|
34 |
import javax.servlet.http.HttpServletRequest; |
|
35 |
|
|
36 |
/** |
|
37 |
* A suite of utility classes for querying DB |
|
38 |
* |
|
39 |
*/ |
|
40 |
public abstract class MetaCatAdmin { |
|
41 |
|
|
42 |
/** |
|
43 |
* Require subclasses to implement a properties validator. |
|
44 |
* |
|
45 |
* @return a vector holding error message for any fields that fail |
|
46 |
* validation. |
|
47 |
*/ |
|
48 |
protected abstract Vector<String> validateOptions(HttpServletRequest request); |
|
49 |
|
|
50 |
} |
|
51 | 0 |
src/edu/ucsb/nceas/metacat/admin/MetacatAdmin.java | ||
---|---|---|
1 |
/** |
|
2 |
* '$RCSfile$' |
|
3 |
* Purpose: A Class that implements utility methods like: |
|
4 |
* 1/ Reding all doctypes from db connection |
|
5 |
* 2/ Reading DTD or Schema file from Metacat catalog system |
|
6 |
* 3/ Reading Lore type Data Guide from db connection |
|
7 |
* Copyright: 2000 Regents of the University of California and the |
|
8 |
* National Center for Ecological Analysis and Synthesis |
|
9 |
* Authors: Jivka Bojilova |
|
10 |
* |
|
11 |
* '$Author$' |
|
12 |
* '$Date$' |
|
13 |
* '$Revision$' |
|
14 |
* |
|
15 |
* This program is free software; you can redistribute it and/or modify |
|
16 |
* it under the terms of the GNU General Public License as published by |
|
17 |
* the Free Software Foundation; either version 2 of the License, or |
|
18 |
* (at your option) any later version. |
|
19 |
* |
|
20 |
* This program is distributed in the hope that it will be useful, |
|
21 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
22 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
23 |
* GNU General Public License for more details. |
|
24 |
* |
|
25 |
* You should have received a copy of the GNU General Public License |
|
26 |
* along with this program; if not, write to the Free Software |
|
27 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
28 |
*/ |
|
29 |
|
|
30 |
package edu.ucsb.nceas.metacat.admin; |
|
31 |
|
|
32 |
import java.util.Vector; |
|
33 |
|
|
34 |
import javax.servlet.http.HttpServletRequest; |
|
35 |
|
|
36 |
/** |
|
37 |
* A suite of utility classes for querying DB |
|
38 |
* |
|
39 |
*/ |
|
40 |
public abstract class MetacatAdmin { |
|
41 |
|
|
42 |
/** |
|
43 |
* Require subclasses to implement a properties validator. |
|
44 |
* |
|
45 |
* @return a vector holding error message for any fields that fail |
|
46 |
* validation. |
|
47 |
*/ |
|
48 |
protected abstract Vector<String> validateOptions(HttpServletRequest request); |
|
49 |
|
|
50 |
} |
|
0 | 51 |
src/edu/ucsb/nceas/metacat/admin/MetacatAdminServlet.java | ||
---|---|---|
1 |
/** |
|
2 |
* '$RCSfile$' |
|
3 |
* Purpose: A Class that implements utility methods for a metadata catalog |
|
4 |
* Copyright: 2008 Regents of the University of California and the |
|
5 |
* National Center for Ecological Analysis and Synthesis |
|
6 |
* Authors: Michael Daigle |
|
7 |
* |
|
8 |
* '$Author$' |
|
9 |
* '$Date$' |
|
10 |
* '$Revision$' |
|
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
25 |
*/ |
|
26 |
|
|
27 |
package edu.ucsb.nceas.metacat.admin; |
|
28 |
|
|
29 |
import java.io.IOException; |
|
30 |
import java.util.Vector; |
|
31 |
|
|
32 |
import javax.servlet.ServletConfig; |
|
33 |
import javax.servlet.ServletException; |
|
34 |
import javax.servlet.http.HttpServlet; |
|
35 |
import javax.servlet.http.HttpServletRequest; |
|
36 |
import javax.servlet.http.HttpServletResponse; |
|
37 |
import javax.servlet.http.HttpSession; |
|
38 |
|
|
39 |
import org.apache.log4j.Logger; |
|
40 |
|
|
41 |
import edu.ucsb.nceas.metacat.MetaCatServlet; |
|
42 |
import edu.ucsb.nceas.metacat.service.PropertyService; |
|
43 |
import edu.ucsb.nceas.metacat.service.SessionService; |
|
44 |
import edu.ucsb.nceas.metacat.shared.MetacatUtilException; |
|
45 |
import edu.ucsb.nceas.metacat.util.AuthUtil; |
|
46 |
import edu.ucsb.nceas.metacat.util.ConfigurationUtil; |
|
47 |
import edu.ucsb.nceas.metacat.util.RequestUtil; |
|
48 |
import edu.ucsb.nceas.metacat.util.SkinUtil; |
|
49 |
import edu.ucsb.nceas.metacat.util.SystemUtil; |
|
50 |
import edu.ucsb.nceas.utilities.GeneralPropertyException; |
|
51 |
|
|
52 |
/** |
|
53 |
* Entry servlet for the metadata configuration utility |
|
54 |
*/ |
|
55 |
public class MetacatAdminServlet extends HttpServlet { |
|
56 |
|
|
57 |
private static final long serialVersionUID = 1L; |
|
58 |
|
|
59 |
private Logger logMetacat = Logger.getLogger(MetacatAdminServlet.class); |
|
60 |
|
|
61 |
/** |
|
62 |
* Initialize the servlet |
|
63 |
*/ |
|
64 |
public void init(ServletConfig config) throws ServletException { |
|
65 |
super.init(config); |
|
66 |
} |
|
67 |
|
|
68 |
/** Handle "GET" method requests from HTTP clients */ |
|
69 |
public void doGet(HttpServletRequest request, HttpServletResponse response) |
|
70 |
throws ServletException, IOException { |
|
71 |
|
|
72 |
// Process the data and send back the response |
|
73 |
handleGetOrPost(request, response); |
|
74 |
} |
|
75 |
|
|
76 |
/** Handle "POST" method requests from HTTP clients */ |
|
77 |
public void doPost(HttpServletRequest request, HttpServletResponse response) |
|
78 |
throws ServletException, IOException { |
|
79 |
|
|
80 |
// Process the data and send back the response |
|
81 |
handleGetOrPost(request, response); |
|
82 |
} |
|
83 |
|
|
84 |
/** |
|
85 |
* Control servlet response depending on the action parameter specified |
|
86 |
* |
|
87 |
* @param request |
|
88 |
* the http request information |
|
89 |
* @param response |
|
90 |
* the http response to be sent back to the client |
|
91 |
*/ |
|
92 |
private void handleGetOrPost(HttpServletRequest request, |
|
93 |
HttpServletResponse response) throws ServletException, IOException { |
|
94 |
String action = request.getParameter("configureType"); |
|
95 |
logMetacat.debug("Processing admin action: " + action); |
|
96 |
Vector<String> processingMessage = new Vector<String>(); |
|
97 |
Vector<String> processingErrors = new Vector<String>(); |
|
98 |
|
|
99 |
try { |
|
100 |
// Update the last update time for this user if they are not new |
|
101 |
HttpSession httpSession = request.getSession(false); |
|
102 |
if (httpSession != null) { |
|
103 |
SessionService.touchSession(httpSession.getId()); |
|
104 |
} |
|
105 |
|
|
106 |
if (!ConfigurationUtil.isBackupDirConfigured()) { |
|
107 |
// if the backup dir has not been configured, then show the |
|
108 |
// backup directory configuration screen. |
|
109 |
processingMessage.add("You must configure the backup directory" |
|
110 |
+ " before you can continue with Metacat configuration."); |
|
111 |
RequestUtil.setRequestMessage(request, processingMessage); |
|
112 |
action = "backup"; |
|
113 |
logMetacat.debug("Admin action changed to 'backup'"); |
|
114 |
} else if (!AuthUtil.isAuthConfigured()) { |
|
115 |
// if authentication isn't configured, change the action to auth. |
|
116 |
// Authentication needs to be set up before we do anything else |
|
117 |
processingMessage.add("You must configure authentication before " |
|
118 |
+ "you can continue with MetaCat configuration."); |
|
119 |
RequestUtil.setRequestMessage(request, processingMessage); |
|
120 |
action = "auth"; |
|
121 |
logMetacat.debug("Admin action changed to 'auth'"); |
|
122 |
} else if (!AuthUtil.isUserLoggedInAsAdmin(request)) { |
|
123 |
// If auth is configured, see if the user is logged in |
|
124 |
// as an administrator. If not, they need to log in before |
|
125 |
// they can continue with configuration. |
|
126 |
processingMessage.add("You must log in as an administrative " + "" + |
|
127 |
"user before you can continue with MetaCat configuration."); |
|
128 |
RequestUtil.setRequestMessage(request, processingMessage); |
|
129 |
action = "login"; |
|
130 |
logMetacat.debug("Admin action changed to 'login'"); |
|
131 |
} |
|
132 |
|
|
133 |
if (action == null || action.equals("configure")) { |
|
134 |
// Forward the request main configuration page |
|
135 |
request.setAttribute("metaCatVersion", SystemUtil.getMetacatVersion()); |
|
136 |
request.setAttribute("propsConfigured", new Boolean(PropertyService.arePropertiesConfigured())); |
|
137 |
request.setAttribute("authConfigured", new Boolean(AuthUtil.isAuthConfigured())); |
|
138 |
// TODO MCD figure out if we still need an org section |
|
139 |
//request.setAttribute("orgsConfigured", new Boolean(OrganizationUtil.areOrganizationsConfigured())); |
|
140 |
request.setAttribute("skinsConfigured", new Boolean(SkinUtil.areSkinsConfigured())); |
|
141 |
request.setAttribute("metacatConfigured", new Boolean(ConfigurationUtil.isMetacatConfigured())); |
|
142 |
request.setAttribute("geoserverConfigured", |
|
143 |
PropertyService.getProperty("configutil.geoserverConfigured")); |
|
144 |
request.setAttribute("metcatServletInitialized", MetaCatServlet.isFullyInitialized()); |
|
145 |
if (PropertyService.arePropertiesConfigured()) { |
|
146 |
request.setAttribute("databaseVersion", |
|
147 |
DBAdmin.getInstance().getDBVersion()); |
|
148 |
request.setAttribute("contextURL", SystemUtil.getContextURL()); |
|
149 |
} |
|
150 |
RequestUtil.forwardRequest(request, response, |
|
151 |
"/admin/metacat-configuration.jsp?configureType=configure", null); |
|
152 |
return; |
|
153 |
} else if (action.equals("properties")) { |
|
154 |
// process properties |
|
155 |
PropertiesAdmin.getInstance().configureProperties(request, |
|
156 |
response); |
|
157 |
return; |
|
158 |
} else if (action.equals("skins")) { |
|
159 |
// process skins |
|
160 |
SkinsAdmin.getInstance().configureSkins(request, response); |
|
161 |
return; |
|
162 |
} else if (action.equals("database")) { |
|
163 |
// process database |
|
164 |
DBAdmin.getInstance().configureDatabase(request, response); |
|
165 |
return; |
|
166 |
} else if (action.equals("auth")) { |
|
167 |
// process authentication |
|
168 |
AuthAdmin.getInstance().configureAuth(request, response); |
|
169 |
return; |
|
170 |
} else if (action.equals("login")) { |
|
171 |
// process login |
|
172 |
LoginAdmin.getInstance().authenticateUser(request, response); |
|
173 |
return; |
|
174 |
} else if (action.equals("backup")) { |
|
175 |
// process login |
|
176 |
BackupAdmin.getInstance().configureBackup(request, response); |
|
177 |
return; |
|
178 |
} else if (action.equals("geoserver")) { |
|
179 |
// process geoserver password change |
|
180 |
GeoserverAdmin.getInstance().configureGeoserver(request, response); |
|
181 |
return; |
|
182 |
} else { |
|
183 |
String errorMessage = "Invalid action in configuration request: " + action; |
|
184 |
logMetacat.error(errorMessage); |
|
185 |
processingErrors.add(errorMessage); |
|
186 |
} |
|
187 |
} catch (GeneralPropertyException ge) { |
|
188 |
String errorMessage = |
|
189 |
"Property problem while handling request: " + ge.getMessage(); |
|
190 |
logMetacat.error(errorMessage); |
|
191 |
processingErrors.add(errorMessage); |
|
192 |
} catch (AdminException ae) { |
|
193 |
String errorMessage = |
|
194 |
"Admin problem while handling request: " + ae.getMessage(); |
|
195 |
logMetacat.error(errorMessage); |
|
196 |
processingErrors.add(errorMessage); |
|
197 |
} catch (MetacatUtilException ue) { |
|
198 |
String errorMessage = |
|
199 |
"Utility problem while handling request: " + ue.getMessage(); |
|
200 |
logMetacat.error(errorMessage); |
|
201 |
processingErrors.add(errorMessage); |
|
202 |
} |
|
203 |
|
|
204 |
if (processingErrors.size() > 0) { |
|
205 |
RequestUtil.clearRequestMessages(request); |
|
206 |
RequestUtil.setRequestErrors(request,processingErrors); |
|
207 |
// if the action that threw an exception was "configure" just go straight to the metacat |
|
208 |
// configuration. This will avoid a loop. Otherwise, call the admin servlet with |
|
209 |
// configuration action. |
|
210 |
if (action != null && action.equals("configure")) { |
|
211 |
RequestUtil.forwardRequest(request, response, "/admin/metacat-configuration.jsp", null); |
|
212 |
} else { |
|
213 |
RequestUtil.forwardRequest(request, response, "/admin?configureType=configure", null); |
|
214 |
} |
|
215 |
} |
|
216 |
} |
|
217 |
} |
|
0 | 218 |
Also available in: Unified diff
Rename MetaCat to Metacat