Revision 5847
Added by ben leinfelder about 13 years ago
GeoserverAdmin.java | ||
---|---|---|
31 | 31 |
import javax.servlet.http.HttpServletRequest; |
32 | 32 |
import javax.servlet.http.HttpServletResponse; |
33 | 33 |
|
34 |
import org.apache.commons.httpclient.HttpClient; |
|
35 | 34 |
import org.apache.log4j.Logger; |
36 | 35 |
|
37 | 36 |
import edu.ucsb.nceas.metacat.properties.PropertyService; |
... | ... | |
97 | 96 |
|
98 | 97 |
String username = PropertyService.getProperty("geoserver.username"); |
99 | 98 |
String password = PropertyService.getProperty("geoserver.password"); |
99 |
String context = PropertyService.getProperty("geoserver.context"); |
|
100 |
String dataDir = PropertyService.getProperty("geoserver.GEOSERVER_DATA_DIR"); |
|
100 | 101 |
|
101 | 102 |
request.setAttribute("geoserver.username", username); |
102 | 103 |
request.setAttribute("geoserver.password", password); |
104 |
request.setAttribute("geoserver.context", context); |
|
105 |
request.setAttribute("geoserver.GEOSERVER_DATA_DIR", dataDir); |
|
103 | 106 |
|
104 | 107 |
// Forward the request to the JSP page |
105 | 108 |
RequestUtil.forwardRequest(request, response, |
... | ... | |
165 | 168 |
|
166 | 169 |
String username = (String)request.getParameter("geoserver.username"); |
167 | 170 |
String password = (String)request.getParameter("geoserver.password"); |
171 |
String context = (String)request.getParameter("geoserver.context"); |
|
172 |
String dataDir = (String)request.getParameter("geoserver.GEOSERVER_DATA_DIR"); |
|
168 | 173 |
|
174 |
// process the context/data dir |
|
175 |
if (context != null && dataDir != null) { |
|
176 |
PropertyService.setPropertyNoPersist("geoserver.context", context); |
|
177 |
boolean reconfig = PropertyService.checkAndSetProperty(request, "geoserver.GEOSERVER_DATA_DIR"); |
|
178 |
PropertyService.persistProperties(); |
|
179 |
// put the web.xml in place |
|
180 |
if (reconfig) { |
|
181 |
GeoserverUtil.writeConfig(); |
|
182 |
} |
|
183 |
} else { |
|
184 |
validationErrors.add("Context and Data Directory cannot be null"); |
|
185 |
} |
|
186 |
|
|
169 | 187 |
if (username == null || password == null) { |
170 |
validationErrors.add("User Name and Password can not be null");
|
|
188 |
validationErrors.add("User Name and Password cannot be null"); |
|
171 | 189 |
} else { |
172 |
HttpClient httpClient = new HttpClient(); |
|
173 |
GeoserverUtil.loginAdmin(httpClient); |
|
174 |
GeoserverUtil.changePassword(httpClient, username, password); |
|
175 |
|
|
190 |
GeoserverUtil.changePassword(username, password); |
|
176 | 191 |
PropertyService.setPropertyNoPersist("geoserver.username", username); |
177 | 192 |
PropertyService.setPropertyNoPersist("geoserver.password", password); |
178 | 193 |
PropertyService.persistProperties(); |
Also available in: Unified diff
rework geoserver configuration:
-geoserver context is set to 'geoserver' by default, but can be reconfigured
-data directory is set in the geoserver web.xml file (we have a template, set the value accordingly, then overwrite the deployed version in the geoserver webapp)
-the admin password is set directly in the data/security/users.properties file