Project

General

Profile

« Previous | Next » 

Revision 5847

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

View differences:

lib/web.xml.geoserver
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
3
<web-app>
4
    <display-name>GeoServer</display-name>
5
  
6
      <context-param>
7
    <param-name>serviceStrategy</param-name>
8
    <!-- Meaning of the different values :
9
         
10
         PARTIAL-BUFFER2
11
         - Partially buffers the first xKb to disk. Once that has buffered, the the 
12
           result is streamed to the user. This will allow for most errors to be caught
13
           early. 
14
           
15
         BUFFER
16
         - stores the entire response in memory first, before sending it off to
17
           the user (may run out of memory)
18

  
19
         SPEED
20
         - outputs directly to the response (and cannot recover in the case of an
21
           error)
22

  
23
         FILE
24
         - outputs to the local filesystem first, before sending it off to the user
25
      -->
26
    <param-value>SPEED</param-value>
27
  </context-param>
28
  
29
  <!-- If true, enable versioning datastore as well -->
30
  <context-param>
31
    <param-name>enableVersioning</param-name>
32
    <param-value>true</param-value>
33
  </context-param>
34
  
35
  <context-param>
36
    <!-- see comments on the PARTIAL-BUFFER strategy -->
37
    <!-- this sets the size of the buffer.  default is "50" = 50kb -->
38

  
39
    <param-name>PARTIAL_BUFFER_STRATEGY_SIZE</param-name>
40
    <param-value>50</param-value>
41
  </context-param>
42
  
43
    <!-- 
44
    <context-param>
45
      <param-name>PROXY_BASE_URL</param-name>
46
      <param-value>http://82.58.146.45/</param-value>
47
    </context-param>
48
     -->
49
   
50
	<context-param>
51
		<param-name>GEOSERVER_DATA_DIR</param-name>
52
		<param-value>_GEOSERVER_DATA_DIR_VALUE_</param-value>
53
	</context-param> 
54
  
55
    <!-- pick up all spring application contexts -->
56
    <context-param>
57
        <param-name>contextConfigLocation</param-name>
58
        <param-value>classpath*:/applicationContext.xml classpath*:/applicationSecurityContext.xml</param-value>
59
    </context-param>
60

  
61
    <filter>
62
     <filter-name>Acegi Filter Chain Proxy</filter-name>
63
     <filter-class>org.acegisecurity.util.FilterToBeanProxy</filter-class>
64
     <init-param>
65
       <param-name>targetClass</param-name>
66
       <param-value>org.acegisecurity.util.FilterChainProxy</param-value>
67
     </init-param>
68
    </filter>
69
    
70
       <filter>
71
    <filter-name>Set Character Encoding</filter-name>
72
    <filter-class>org.vfny.geoserver.filters.SetCharacterEncodingFilter</filter-class>
73
    <init-param>
74
      <param-name>encoding</param-name>
75
      <param-value>UTF-8</param-value>
76
    </init-param>
77
  </filter>
78

  
79
   <filter>
80
    <filter-name>Reverse Proxy Filter</filter-name>
81
    <filter-class>org.geoserver.filters.ReverseProxyFilter</filter-class>
82
    <init-param>
83
      <param-name>enabled</param-name>
84
      <param-value>false</param-value>
85
      <description>
86
        Whether to enable the reverse proxy filter or not. Defaults to false. Set to true
87
        in order for GeoServer to perform URL translation for the proxyfied base URL on
88
        textual content whose MIME type matches one of the regular expressions set through
89
        the mime-types init parameter.
90
      </description>
91
    </init-param>
92
    <init-param>
93
      <param-name>mime-types</param-name>
94
      <param-value>text/html.*,text/css.*,text/javascript.*,application/x-javascript.*</param-value>
95
      <description>
96
        Comma separated list of response MIME types the filter shall process in order to translate
97
        absolute urls using the configured proxyBaseUrl. Each token in the comma separated list
98
        is interpreted as a java regular expression.
99
      </description>
100
    </init-param>
101
   </filter>
102
   
103
   <filter>
104
     <filter-name>GZIP Compression Filter</filter-name>
105
     <filter-class>org.geoserver.filters.GZIPFilter</filter-class>
106
     <init-param>
107
         <!-- The compressed-types parameter is a comma-separated list of regular expressions.
108
              If a mime type matches any of the regular expressions then it will be compressed.
109
              -->
110
         <param-name>compressed-types</param-name>
111
         <param-value>text/.*,.*xml.*,application/json,application/x-javascript</param-value>
112
     </init-param>
113
   </filter>
114

  
115
   <filter>
116
     <filter-name>Request Logging Filter</filter-name>
117
     <filter-class>org.geoserver.filters.LoggingFilter</filter-class>
118
     <init-param>
119
         <!-- The 'enabled' parameter is a boolean value, "true" (case-insensitive) for true or
120
              any other value for false.  If enabled, then the logging will be performed;
121
              otherwise the logging filter will have no effect.  If not specified, this 
122
              parameter defaults to false.
123
              -->
124
         <param-name>enabled</param-name>
125
         <param-value>false</param-value>
126
     </init-param>
127
     <init-param>
128
     <!-- The 'log-request-bodies' parameter is a boolean value, "true" (case-insensitive) for
129
          true or any other value for false.  If enabled, then the logging will include the body
130
          of POST and PUT requests.  If not specified, this parameter defaults to false.
131
          Note that this may noticeably degrade responsiveness of your geoserver since it will
132
          not begin to process requests until the entire request body has been received by the 
133
          server.
134
          -->
135
     <param-name>log-request-bodies</param-name>
136
     <param-value>false</param-value>
137
     </init-param>
138
   </filter>
139

  
140
    <filter-mapping>
141
      <filter-name>GZIP Compression Filter</filter-name>
142
      <url-pattern>/*</url-pattern>
143
    </filter-mapping>
144
    
145
    <filter-mapping>
146
      <filter-name>Reverse Proxy Filter</filter-name>
147
      <url-pattern>/*</url-pattern>
148
    </filter-mapping>
149
  
150
    <filter-mapping>
151
      <filter-name>Request Logging Filter</filter-name>
152
      <url-pattern>/*</url-pattern>
153
    </filter-mapping>
154
   
155
    <!-- 
156
      If you want to use your security system comment out this one too
157
    -->
158
    <filter-mapping>
159
      <filter-name>Acegi Filter Chain Proxy</filter-name>
160
      <url-pattern>/*</url-pattern>
161
    </filter-mapping>
162
    
163
      <filter-mapping>
164
      <filter-name>Set Character Encoding</filter-name>
165
      <url-pattern>/*</url-pattern>
166
    </filter-mapping>
167
    
168
    <!-- general initializer, should be first thing to execute -->
169
    <listener>
170
      <listener-class>org.geoserver.GeoserverInitStartupListener</listener-class>
171
    </listener>
172
    
173
    <!-- logging initializer, should execute before spring context startup -->
174
    <listener>
175
      <listener-class>org.geoserver.logging.LoggingStartupContextListener</listener-class>
176
    </listener>
177
  
178
    <!--  spring context loader -->
179
    <listener>
180
      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
181
    </listener>
182
    
183
    
184
    <!-- spring dispatcher servlet, dispatches all incoming requests -->
185
    <servlet>
186
      <servlet-name>dispatcher</servlet-name>
187
      <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
188
    </servlet>
189
    <servlet>
190
	   <servlet-name>TestWfsPost</servlet-name>
191
	   <servlet-class>org.vfny.geoserver.wfs.servlets.TestWfsPost</servlet-class>
192
	</servlet>
193
    
194
    <servlet-mapping>
195
        <servlet-name>dispatcher</servlet-name>
196
        <url-pattern>/web/*</url-pattern>
197
    </servlet-mapping>
198
    <!-- TODO: find a way to remove this mighty list of mappings and have just one... -->
199
    <servlet-mapping>
200
      <servlet-name>dispatcher</servlet-name>
201
      <url-pattern>/rest/*</url-pattern>
202
    </servlet-mapping>
203
    <servlet-mapping>
204
      <servlet-name>dispatcher</servlet-name>
205
      <url-pattern>/security/*</url-pattern>
206
    </servlet-mapping>    
207
    <servlet-mapping>
208
      <servlet-name>dispatcher</servlet-name>
209
      <url-pattern>/wms/*</url-pattern>
210
    </servlet-mapping>
211
    <servlet-mapping>
212
      <servlet-name>dispatcher</servlet-name>
213
      <url-pattern>/wcs/*</url-pattern>
214
    </servlet-mapping>
215
    <servlet-mapping>
216
      <servlet-name>dispatcher</servlet-name>
217
      <url-pattern>/wfs/*</url-pattern>
218
    </servlet-mapping>
219
    <servlet-mapping>
220
      <servlet-name>dispatcher</servlet-name>
221
      <url-pattern>/ows/*</url-pattern>
222
    </servlet-mapping>
223
    <servlet-mapping>
224
      <servlet-name>dispatcher</servlet-name>
225
      <url-pattern>/wfsv/*</url-pattern>
226
    </servlet-mapping>
227
    <servlet-mapping>
228
      <servlet-name>dispatcher</servlet-name>
229
      <url-pattern>/wcs111/*</url-pattern>
230
    </servlet-mapping>
231
    <servlet-mapping>
232
      <servlet-name>dispatcher</servlet-name>
233
      <url-pattern>/kml/*</url-pattern>
234
    </servlet-mapping>
235
    <servlet-mapping>
236
     <servlet-name>dispatcher</servlet-name>
237
     <url-pattern>/styles/*</url-pattern>
238
    </servlet-mapping>
239
    <servlet-mapping>
240
     <servlet-name>dispatcher</servlet-name>
241
     <url-pattern>/www/*</url-pattern>
242
    </servlet-mapping>
243
    <servlet-mapping>
244
     <servlet-name>dispatcher</servlet-name>
245
     <url-pattern>/temp/*</url-pattern>
246
    </servlet-mapping>
247
    <servlet-mapping>
248
     <servlet-name>dispatcher</servlet-name>
249
     <url-pattern>/history/*</url-pattern>
250
    </servlet-mapping>
251
    <servlet-mapping>
252
     <servlet-name>dispatcher</servlet-name>
253
     <url-pattern>/gwc/*</url-pattern>
254
    </servlet-mapping>
255
    <servlet-mapping>
256
     <servlet-name>dispatcher</servlet-name>
257
     <url-pattern>/pdf/*</url-pattern>
258
    </servlet-mapping>
259
    
260
    <servlet-mapping>
261
     <servlet-name>TestWfsPost</servlet-name>
262
     <url-pattern>/TestWfsPost/*</url-pattern>
263
    </servlet-mapping>
264
    
265
    <mime-mapping>
266
      <extension>xsl</extension>
267
      <mime-type>text/xml</mime-type>
268
    </mime-mapping>
269
    <mime-mapping>
270
      <extension>sld</extension>
271
      <mime-type>text/xml</mime-type>
272
    </mime-mapping>
273
  
274
    <welcome-file-list>
275
        <welcome-file>index.html</welcome-file>
276
    </welcome-file-list>
277
    
278
</web-app>
lib/admin/geoserver-configuration.jsp
59 59
	<hr class="config-line">
60 60
	
61 61
	<div class="form-row">
62
		<img class="question-mark" src="style/images/question-mark.gif" 
63
			onClick="helpWindow('<%= request.getContextPath() %>','metacat-configure.html#GEOSERVER_DATA_DIR')"/>
64
		<div class="textinput-label"><label for="geoserver.context" title="Geoserver data directory">Geoserver Data Directory</label></div>
65
		<input class="textinput" id="geoserver.GEOSERVER_DATA_DIR" 
66
				name="geoserver.GEOSERVER_DATA_DIR" 	             		    	    	           		    	             			
67
				value="<%= request.getAttribute("geoserver.GEOSERVER_DATA_DIR") %>"/> 
68
	</div>
69
	<div class="form-row">
70
		<img class="question-mark" src="style/images/question-mark.gif" 
71
			onClick="helpWindow('<%= request.getContextPath() %>','metacat-configure.html#GeoserverContext')"/>
72
		<div class="textinput-label"><label for="geoserver.context" title="Geoserver context">Context</label></div>
73
		<input class="textinput" id="geoserver.context" 
74
				name="geoserver.context" 	             		    	    	           		    	             			
75
				value="<%= request.getAttribute("geoserver.context") %>"/> 
76
	</div>
77
	<hr class="config-line">
78
	<div class="form-row">
62 79
				<img class="question-mark" src="style/images/question-mark.gif" 
63 80
	           		 onClick="helpWindow('<%= request.getContextPath() %>','metacat-configure.html#GeoserverUpdatePassword')"/>
64 81
				<div class="textinput-label"><label for="geoserver.username" title="Geoserver user name">User Name</label></div>
65 82
				<input class="textinput" id="geoserver.username" 
66
					   name="geoserver.username" 	             		    	    	           		    	             			
83
					   name="geoserver.username" readonly="readonly" 		    	    	           		    	             			
67 84
	           		   value="<%= request.getAttribute("geoserver.username") %>"/> 
68 85
	</div>
69 86
	<div class="form-row">
lib/metacat.properties
409 409

  
410 410
######## Geoserver section              #######################################
411 411

  
412
geoserver.loginPostPage=admin/loginSubmit.do
413
geoserver.loginSuccessString=admin/logout.do
414
geoserver.passwordPostPage=config/loginEditSubmit.do
415
geoserver.passwordSuccessString=Data loaded without incident
416
geoserver.applyPostPage=admin/saveToGeoServer.do
417
geoserver.defaultUsername=admin
418
geoserver.defaultPassword=geoserver
419
geoserver.username=
412
geoserver.username=admin
420 413
geoserver.password=
414
geoserver.context=geoserver
415
geoserver.GEOSERVER_DATA_DIR=
421 416

  
417

  
422 418
######## workflowScheduler section              #######################################
423 419

  
424 420
workflowScheduler.url=http://chico1.dyndns.org/workflowscheduler/scheduler
src/edu/ucsb/nceas/metacat/spatial/SpatialFeatureSchema.java
26 26
import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
27 27
import org.opengis.feature.simple.SimpleFeatureType;
28 28

  
29
import edu.ucsb.nceas.metacat.properties.PropertyService;
29 30
import edu.ucsb.nceas.metacat.util.SystemUtil;
30 31
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
31 32

  
......
42 43
	static {
43 44
		try {
44 45
			
45
			String geoserverDataDir = System.getProperty("GEOSERVER_DATA_DIR");
46
			String geoserverDataDir = PropertyService.getProperty("geoserver.GEOSERVER_DATA_DIR");
46 47
			if (geoserverDataDir != null) {
47 48
				// use configured resource (might be same as local)
48 49
				polygonShpUri = geoserverDataDir + "/data/metacat_shps/data_bounds.shp";
src/edu/ucsb/nceas/metacat/util/GeoserverUtil.java
26 26

  
27 27
package edu.ucsb.nceas.metacat.util;
28 28

  
29
import org.apache.commons.httpclient.HttpClient;
30 29
import org.apache.log4j.Logger;
31 30

  
32
import java.io.IOException;
33
import java.util.HashMap;
31
import java.io.StringReader;
34 32

  
35 33
import edu.ucsb.nceas.metacat.properties.PropertyService;
36 34
import edu.ucsb.nceas.metacat.shared.MetacatUtilException;
37 35
import edu.ucsb.nceas.utilities.FileUtil;
36
import edu.ucsb.nceas.utilities.GeneralPropertyException;
38 37
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
38
import edu.ucsb.nceas.utilities.SortedProperties;
39
import edu.ucsb.nceas.utilities.UtilException;
39 40

  
40 41
public class GeoserverUtil {
41 42
	
......
47 48
	 */
48 49
	private GeoserverUtil() {}
49 50
	
50
	/**
51
	 * Log in to geoserver as the administrative user. If the geoserver.username
52
	 * and geoserver.password already exists in metacat.properties, we assume
53
	 * that the password was already changed at least once. We use these values.
54
	 * Otherwise we use the default values.
55
	 * 
56
	 * @param httpClient
57
	 *            the HttpClient we will use to post. This is passed in since it
58
	 *            may need to be used after login by other methods.
59
	 */
60
	public static void loginAdmin(HttpClient httpClient) throws MetacatUtilException {
61
		try {
62
			String username = 
63
				PropertyService.getProperty("geoserver.username");
64
			String password = 
65
				PropertyService.getProperty("geoserver.password");
66
			String defaultUserName = 
67
				PropertyService.getProperty("geoserver.defaultUsername");
68
			String defaultPassword = 
69
				PropertyService.getProperty("geoserver.defaultPassword");
70
			String loginSuccessString = 
71
				PropertyService.getProperty("geoserver.loginSuccessString");
72
			
73
			HashMap<String, String> paramMap = new HashMap<String, String>();
74
			// if the username and password exist, we assume the geoserver was 
75
			// already updated at least once.  Use the existing values as the 
76
			// current admin values.  Otherwise,use the default values.
77
			if (username != null && !username.equals("")
78
					&& password != null && !password.equals("")) {
79
				paramMap.put("username", username);
80
				paramMap.put("password", password);
81
			} else {
82
				paramMap.put("username", defaultUserName);
83
				paramMap.put("password", defaultPassword);
84
			}
85
			
86
			// Create the post url from values in metacat.properties
87
			String loginPostPage = 
88
				PropertyService.getProperty("geoserver.loginPostPage");
89
			String loginPostURL = SystemUtil.getContextURL() + "/"
90
					+ loginPostPage;
91
			
92
			logMetacat.debug("loginPostURL: " + loginPostURL);
93
			
94
			// Do the post
95
			String postResult = RequestUtil.post(httpClient, loginPostURL, paramMap);
96
			
97
			// check to see if the success string is part of the result
98
			if(postResult.indexOf(loginSuccessString) == -1) {
99
				logMetacat.debug(postResult);
100
				throw new MetacatUtilException("Could not log in to geoserver.");
101
			}
102

  
103
		} catch (PropertyNotFoundException pnfe) {
104
			throw new MetacatUtilException("Property error while logging in with " 
105
					+ "default account: " + pnfe.getMessage());
106
		} catch (IOException ioe) {
107
			throw new MetacatUtilException("I/O error while logging in with " 
108
					+ "default account: " + ioe.getMessage());
109
		} 
110
	}
111 51
	
112 52
	/**
113 53
	 * Change the password on the geoserver. The loginAdmin method must have
......
122 62
	 * @param password
123 63
	 *            the new password
124 64
	 */
125
	public static void changePassword(HttpClient httpClient, String username, String password) 
65
	public static void changePassword(String username, String password) 
126 66
		throws MetacatUtilException {
127 67
		try {	
128 68
			
129
			HashMap<String, String> paramMap = new HashMap<String, String>();
130
			paramMap.put("username", username);
131
			paramMap.put("password", password);
69
			// the users file
70
			String usersFile = 
71
			 PropertyService.getProperty("geoserver.GEOSERVER_DATA_DIR")
72
				+ FileUtil.getFS() 
73
				+ "security"
74
				+ FileUtil.getFS()
75
				+ "users.properties";
76
			SortedProperties userProperties = new SortedProperties(usersFile);
77
			userProperties.load();
78
			/* looks like this:
79
				#Wed Jan 26 12:13:09 PST 2011
80
				admin=geoserver,ROLE_ADMINISTRATOR,enabled
81
			*/
82
			String value = password + ",ROLE_ADMINISTRATOR,enabled";
83
			userProperties.setProperty(username, value);
132 84
			
133
			// Create the post url from values in metacat.properties
134
			String passwordPostPage = 
135
				PropertyService.getProperty("geoserver.passwordPostPage");
136
			String passwordPostURL = SystemUtil.getContextURL() + "/"
137
					+ passwordPostPage;
138
			
139
			String passwordSuccessString = 
140
				PropertyService.getProperty("geoserver.passwordSuccessString");
141

  
142
			logMetacat.debug("passwordPostURL: " + passwordPostURL);
143
			
144
			// Do the post
145
			String postResult = RequestUtil.post(httpClient, passwordPostURL, paramMap);
146
			
147
			// check to see if the success string is part of the result
148
			if(postResult.indexOf(passwordSuccessString) == -1) {
149
				logMetacat.debug(postResult);
150
				throw new MetacatUtilException("Could not change geoserver password.");
151
			}
152
			
153
			// send a post to apply the password changes.  Unfortunately, there really
154
			// isn't anything of the geoserver side saying if the post passed, so we have
155
			// to assume it did.
156
			String applyPostPage = 
157
				PropertyService.getProperty("geoserver.applyPostPage");
158
			String applyPostURL = SystemUtil.getContextURL() + "/"
159
				+ applyPostPage;
160
			RequestUtil.post(httpClient, applyPostURL, null);		
161
			
162
		} catch (PropertyNotFoundException pnfe) {
163
			throw new MetacatUtilException("Property error while logging in with " 
164
					+ "default account: " + pnfe.getMessage());
165
		} catch (IOException ioe) {
166
			throw new MetacatUtilException("I/O error while logging in with " 
167
					+ "default account: " + ioe.getMessage());
168
		} 
85
		} catch (Exception e) {
86
			throw new MetacatUtilException("Property error while changing default password: " 
87
				 + e.getMessage());
88
		}
169 89
	}
170 90
	
171 91
	/**
......
184 104
		// geoserver is configured if not unconfigured
185 105
		return !geoserverConfiguredString.equals(PropertyService.UNCONFIGURED);
186 106
	}
107
	
108
	public static void writeConfig() throws MetacatUtilException {
109
		try {
110
			// the template geoserver web.xml file
111
			String configFileTemplate = 
112
				SystemUtil.getContextDir()
113
				+ FileUtil.getFS()
114
				+ "web.xml.geoserver";
115
			
116
			// the destination for the template
117
			String configFileDestination = 
118
				PropertyService.getProperty("application.deployDir")
119
				+ FileUtil.getFS()
120
				+ PropertyService.getProperty("geoserver.context")
121
				+ FileUtil.getFS() 
122
				+ "WEB-INF"
123
				+ FileUtil.getFS()
124
				+ "web.xml";
125
			
126
			// look up the configured value for the data dir, write it to the file
127
			String dataDir = PropertyService.getProperty("geoserver.GEOSERVER_DATA_DIR");
128
			String configContents = FileUtil.readFileToString(configFileTemplate, "UTF-8");
129
			configContents = configContents.replace("_GEOSERVER_DATA_DIR_VALUE_", dataDir);
130
			FileUtil.writeFile(configFileDestination, new StringReader(configContents), "UTF-8");			
131
		} catch (PropertyNotFoundException pnfe) {
132
			throw new MetacatUtilException(
133
					"Property error while setting geoserver config: " + pnfe.getMessage());
134
		}
135
		catch (UtilException ue) {
136
			throw new MetacatUtilException(
137
					"Util error while setting geoserver config: " + ue.getMessage());
138
		}
139
	
140
	}
141
	
142
	/**
143
	 * Get the server URL with the Geoserver context. This is made up of the server URL +
144
	 * file separator + the Geoserver context
145
	 * 
146
	 * @return string holding the server URL with context
147
	 */
148
	public static String getGeoserverContextURL() throws PropertyNotFoundException {
149
		return SystemUtil.getServerURL() + "/"
150
				+ PropertyService.getProperty("geoserver.context");
151
	}
187 152
}
src/edu/ucsb/nceas/metacat/admin/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