svn-gvsig-desktop / branches / v10 / extensions / extPublishGeoserver / src / org / gvsig / publish / geoserver / model / Geoserver.java @ 22616
History | View | Annotate | Download (11.3 KB)
1 |
/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004-2006 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ibañez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package org.gvsig.publish.geoserver.model; |
42 |
|
43 |
import java.io.File; |
44 |
|
45 |
import org.gvsig.publish.PublishLogger; |
46 |
import org.gvsig.publish.exceptions.PublishException; |
47 |
import org.gvsig.publish.geoserver.conf.GSConfiguration; |
48 |
import org.gvsig.publish.serversmodel.Server; |
49 |
|
50 |
import com.iver.andami.PluginServices; |
51 |
import com.iver.utiles.XMLEntity; |
52 |
/**
|
53 |
* This class represents the server Geoserver.
|
54 |
*
|
55 |
* @author jvhigon
|
56 |
*
|
57 |
*/
|
58 |
public class Geoserver extends Server { |
59 |
/*
|
60 |
* Constant to identify the server
|
61 |
*/
|
62 |
public static final String REGISTER_TAG = "Geoserver"; |
63 |
|
64 |
//constants
|
65 |
public static final String LOG_SEVERE="SEVERE"; |
66 |
public static final String LOG_WARNING="WARNING"; |
67 |
public static final String LOG_INFO="INFO"; |
68 |
public static final String LOG_CONFIG="CONFIG"; |
69 |
public static final String LOG_FINNER="FINNER"; |
70 |
public static final String LOG_FINNEST="FINNEST"; |
71 |
|
72 |
//Attributes
|
73 |
private boolean loginToFile=false; |
74 |
private double jaiMemoryCapacity=0.5; |
75 |
private double jaiMemoryThreshold=0.75; |
76 |
private int jaiTileThreads=7; |
77 |
private int jaiTilePriority=5; |
78 |
private boolean jaiRecycling=true; |
79 |
private boolean ImageIOCache=false; |
80 |
private boolean JaiJPEGNative=true; |
81 |
private boolean jaiPNGNative=true; |
82 |
private boolean verbose=false; |
83 |
private boolean verboseExceptions=false; |
84 |
private int numDecimals=8; |
85 |
private String logginLevel=LOG_INFO; |
86 |
private int maxFeatures=2000; |
87 |
private String charset="UTF-8"; |
88 |
private String adminUser="admin"; |
89 |
private String adminPassword="geoserver"; |
90 |
|
91 |
private File configDirectory; |
92 |
private GSConfiguration configuration=null; |
93 |
|
94 |
/**
|
95 |
* Constructor.
|
96 |
*
|
97 |
*/
|
98 |
public Geoserver() {
|
99 |
super();
|
100 |
} |
101 |
|
102 |
/**
|
103 |
* TODO:
|
104 |
*/
|
105 |
public void postInitialize() { |
106 |
// TODO Auto-generated method stub
|
107 |
|
108 |
} |
109 |
/*
|
110 |
* (non-Javadoc)
|
111 |
* @see com.iver.utiles.IPersistance#getClassName()
|
112 |
*/
|
113 |
public String getClassName() { |
114 |
return "Geoserver"; |
115 |
} |
116 |
|
117 |
public File getConfigDirectory() { |
118 |
return configDirectory;
|
119 |
} |
120 |
|
121 |
public void setConfigDirectory(File configDirectory) { |
122 |
this.configDirectory = configDirectory;
|
123 |
} |
124 |
|
125 |
/**
|
126 |
*
|
127 |
* @see org.gvsig.publish.serversmodel.Server#publish()
|
128 |
*/
|
129 |
public String publish() throws PublishException { |
130 |
//generate server configuration
|
131 |
checkParameters(); |
132 |
configuration = new GSConfiguration(this); |
133 |
//generate services configuration
|
134 |
super.publish();
|
135 |
//write configuration
|
136 |
configuration.toXML(); |
137 |
return "publishgs_publish_message"; |
138 |
} |
139 |
/**
|
140 |
* check a minimum of parameters for publishing
|
141 |
*
|
142 |
* @throws PublishException
|
143 |
*/
|
144 |
private void checkParameters()throws PublishException{ |
145 |
//check config directory
|
146 |
//TODO: this code never is executed
|
147 |
if (configDirectory == null){ |
148 |
throw new PublishException("config_dir_not_defined"); |
149 |
} |
150 |
//check user
|
151 |
if (getAdminUser() == null){ |
152 |
throw new PublishException("user_not_defined"); |
153 |
} |
154 |
//check password
|
155 |
if (getAdminPassword() == null){ |
156 |
throw new PublishException("password_not_defined"); |
157 |
} |
158 |
//check if there is anything to publish
|
159 |
if (getPublication().getProjectInfo() == null){ |
160 |
throw new PublishException(PluginServices.getText(this,"nothing_to_publish")); |
161 |
} |
162 |
} |
163 |
/*
|
164 |
* (non-Javadoc)
|
165 |
* @see org.gvsig.publish.serversmodel.Server#getId()
|
166 |
*/
|
167 |
public String getId() { |
168 |
return "geoserver"; |
169 |
} |
170 |
/*
|
171 |
* (non-Javadoc)
|
172 |
* @see org.gvsig.publish.serversmodel.Server#getRegisterTag()
|
173 |
*/
|
174 |
public String getRegisterTag() { |
175 |
return REGISTER_TAG;
|
176 |
} |
177 |
/*
|
178 |
* (non-Javadoc)
|
179 |
* @see org.gvsig.publish.IPublishPersistence#getVersion()
|
180 |
*/
|
181 |
public int getVersion() { |
182 |
return 1; |
183 |
} |
184 |
/* (non-Javadoc)
|
185 |
* @see org.gvsig.publish.serversmodel.Server#getXMLEntity()
|
186 |
*/
|
187 |
|
188 |
public XMLEntity getXMLEntity() {
|
189 |
XMLEntity xml=super.getXMLEntity();
|
190 |
//put version and name
|
191 |
xml.setName(getClassName()); |
192 |
xml.putProperty("version", getVersion());
|
193 |
//put properties
|
194 |
xml.putProperty("configdir", getConfigDirectory());
|
195 |
//put config properties
|
196 |
xml.putProperty("max_features", getMaxFeatures());
|
197 |
xml.putProperty("login_level", getLogginLevel());
|
198 |
return xml;
|
199 |
} |
200 |
/* (non-Javadoc)
|
201 |
* @see org.gvsig.publish.serversmodel.Server#setXMLEntity(com.iver.utiles.XMLEntity)
|
202 |
*/
|
203 |
|
204 |
public void setXMLEntity(XMLEntity xml) { |
205 |
//check version
|
206 |
int version = xml.getIntProperty("version"); |
207 |
if (version != getVersion()){
|
208 |
PublishLogger.getLog().error("ERROR: " + getClassName() + ": the version doesn't match!"); |
209 |
return;
|
210 |
} |
211 |
super.setXMLEntity(xml);
|
212 |
//set properties
|
213 |
String file = xml.getStringProperty("configdir"); |
214 |
if (file !=null) |
215 |
setConfigDirectory(new File(file)); |
216 |
//set config properties
|
217 |
setMaxFeatures(xml.getIntProperty("max_features"));
|
218 |
setLogginLevel(xml.getStringProperty("login_level"));
|
219 |
} |
220 |
|
221 |
/**
|
222 |
* Return loginToFile
|
223 |
* @return boolean
|
224 |
*/
|
225 |
public boolean isLoginToFile() { |
226 |
return loginToFile;
|
227 |
} |
228 |
|
229 |
/**
|
230 |
* @param loginToFile the loginToFile to set
|
231 |
*/
|
232 |
public void setLoginToFile(boolean loginToFile) { |
233 |
this.loginToFile = loginToFile;
|
234 |
} |
235 |
|
236 |
/**
|
237 |
* @return the jaiMemoryCapacity
|
238 |
*/
|
239 |
public double getJaiMemoryCapacity() { |
240 |
return jaiMemoryCapacity;
|
241 |
} |
242 |
|
243 |
/**
|
244 |
* @param jaiMemoryCapacity the jaiMemoryCapacity to set
|
245 |
*/
|
246 |
public void setJaiMemoryCapacity(double jaiMemoryCapacity) { |
247 |
this.jaiMemoryCapacity = jaiMemoryCapacity;
|
248 |
} |
249 |
|
250 |
/**
|
251 |
* @return the jaiMemoryThreshold
|
252 |
*/
|
253 |
public double getJaiMemoryThreshold() { |
254 |
return jaiMemoryThreshold;
|
255 |
} |
256 |
|
257 |
/**
|
258 |
* @param jaiMemoryThreshold the jaiMemoryThreshold to set
|
259 |
*/
|
260 |
public void setJaiMemoryThreshold(double jaiMemoryThreshold) { |
261 |
this.jaiMemoryThreshold = jaiMemoryThreshold;
|
262 |
} |
263 |
|
264 |
/**
|
265 |
* @return the jaiTileThreads
|
266 |
*/
|
267 |
public int getJaiTileThreads() { |
268 |
return jaiTileThreads;
|
269 |
} |
270 |
|
271 |
/**
|
272 |
* @param jaiTileThreads the jaiTileThreads to set
|
273 |
*/
|
274 |
public void setJaiTileThreads(int jaiTileThreads) { |
275 |
this.jaiTileThreads = jaiTileThreads;
|
276 |
} |
277 |
|
278 |
/**
|
279 |
* @return the jaiTilePriority
|
280 |
*/
|
281 |
public int getJaiTilePriority() { |
282 |
return jaiTilePriority;
|
283 |
} |
284 |
|
285 |
/**
|
286 |
* @param jaiTilePriority the jaiTilePriority to set
|
287 |
*/
|
288 |
public void setJaiTilePriority(int jaiTilePriority) { |
289 |
this.jaiTilePriority = jaiTilePriority;
|
290 |
} |
291 |
|
292 |
/**
|
293 |
* @return the jaiRecycling
|
294 |
*/
|
295 |
public boolean isJaiRecycling() { |
296 |
return jaiRecycling;
|
297 |
} |
298 |
|
299 |
/**
|
300 |
* @param jaiRecycling the jaiRecycling to set
|
301 |
*/
|
302 |
public void setJaiRecycling(boolean jaiRecycling) { |
303 |
this.jaiRecycling = jaiRecycling;
|
304 |
} |
305 |
|
306 |
/**
|
307 |
* @return the imageIOCache
|
308 |
*/
|
309 |
public boolean isImageIOCache() { |
310 |
return ImageIOCache;
|
311 |
} |
312 |
|
313 |
/**
|
314 |
* @param imageIOCache the imageIOCache to set
|
315 |
*/
|
316 |
public void setImageIOCache(boolean imageIOCache) { |
317 |
ImageIOCache = imageIOCache; |
318 |
} |
319 |
|
320 |
/**
|
321 |
* @return the jaiJPEGNative
|
322 |
*/
|
323 |
public boolean isJaiJPEGNative() { |
324 |
return JaiJPEGNative;
|
325 |
} |
326 |
|
327 |
/**
|
328 |
* @param jaiJPEGNative the jaiJPEGNative to set
|
329 |
*/
|
330 |
public void setJaiJPEGNative(boolean jaiJPEGNative) { |
331 |
JaiJPEGNative = jaiJPEGNative; |
332 |
} |
333 |
|
334 |
/**
|
335 |
* @return the jaiPNGNative
|
336 |
*/
|
337 |
public boolean isJaiPNGNative() { |
338 |
return jaiPNGNative;
|
339 |
} |
340 |
|
341 |
/**
|
342 |
* @param jaiPNGNative the jaiPNGNative to set
|
343 |
*/
|
344 |
public void setJaiPNGNative(boolean jaiPNGNative) { |
345 |
this.jaiPNGNative = jaiPNGNative;
|
346 |
} |
347 |
|
348 |
/**
|
349 |
* @return the verbose
|
350 |
*/
|
351 |
public boolean isVerbose() { |
352 |
return verbose;
|
353 |
} |
354 |
|
355 |
/**
|
356 |
* Whether newlines and indents should be returned in
|
357 |
* XML responses. Default is false
|
358 |
* @param verbose
|
359 |
*/
|
360 |
public void setVerbose(boolean verbose) { |
361 |
this.verbose = verbose;
|
362 |
} |
363 |
|
364 |
/**
|
365 |
* @return the verboseExceptions
|
366 |
*/
|
367 |
public boolean isVerboseExceptions() { |
368 |
return verboseExceptions;
|
369 |
} |
370 |
|
371 |
/**
|
372 |
* @param verboseExceptions the verboseExceptions to set
|
373 |
*/
|
374 |
public void setVerboseExceptions(boolean verboseExceptions) { |
375 |
this.verboseExceptions = verboseExceptions;
|
376 |
} |
377 |
|
378 |
/**
|
379 |
* @return the numDecimals
|
380 |
*/
|
381 |
public int getNumDecimals() { |
382 |
return numDecimals;
|
383 |
} |
384 |
|
385 |
|
386 |
/**
|
387 |
* Sets the max number of decimal places past the zero returned in
|
388 |
* a GetFeature response. Default is 4
|
389 |
* @param mynumDecimals
|
390 |
*/
|
391 |
public void setNumDecimals(int numDecimals) { |
392 |
this.numDecimals = numDecimals;
|
393 |
} |
394 |
|
395 |
/**
|
396 |
* Return LoginLevel
|
397 |
* @return string SEVERE, WARNING, INFO, CONFIG, FINER, FINEST
|
398 |
*/
|
399 |
public String getLogginLevel() { |
400 |
return logginLevel;
|
401 |
} |
402 |
|
403 |
/**
|
404 |
* Defines the logging level. Common options are SEVERE,
|
405 |
* WARNING, INFO, CONFIG, FINER, FINEST, in order of
|
406 |
* Increasing statements logged.
|
407 |
* @see {@link Geoserver#LOG_CONFIG} , {@link Geoserver#LOG_INFO} , ...
|
408 |
* @param level SEVERE, WARNING, INFO, CONFIG, FINER, FINEST
|
409 |
*
|
410 |
*/
|
411 |
public void setLogginLevel(String logginLevel) { |
412 |
this.logginLevel = logginLevel;
|
413 |
} |
414 |
|
415 |
/**
|
416 |
* @return the maxFeatures
|
417 |
*/
|
418 |
public int getMaxFeatures() { |
419 |
return maxFeatures;
|
420 |
} |
421 |
|
422 |
/**
|
423 |
* Sets the max number of features the WFS service can return
|
424 |
* @param maxFeatures the maxFeatures to set
|
425 |
*/
|
426 |
public void setMaxFeatures(int maxFeatures) { |
427 |
this.maxFeatures = maxFeatures;
|
428 |
} |
429 |
|
430 |
/**
|
431 |
* This could use some more testing
|
432 |
* from international users, but what it does is sets the encoding
|
433 |
* globally for all postgis database connections (the charset tag
|
434 |
* in FeatureTypeConfig), as well as specifying the encoding in the return
|
435 |
* config.xml header and mime type. The default is UTF-8. Also be warned
|
436 |
* that GeoServer does not check if the CharSet is valid before
|
437 |
* attempting to use it, so it will fail miserably if a bad charset
|
438 |
* is used.
|
439 |
* @return charset
|
440 |
*/
|
441 |
|
442 |
public String getCharset() { |
443 |
return charset;
|
444 |
} |
445 |
|
446 |
|
447 |
/**
|
448 |
* @param charset the charset to set
|
449 |
*/
|
450 |
public void setCharset(String charset) { |
451 |
this.charset = charset;
|
452 |
} |
453 |
|
454 |
/**
|
455 |
* @return the administrator user
|
456 |
*/
|
457 |
public String getAdminUser() { |
458 |
return adminUser;
|
459 |
} |
460 |
|
461 |
/**
|
462 |
* Defines the user name of the administrator for log in
|
463 |
* to the web based administration tool.
|
464 |
* @param user
|
465 |
*/
|
466 |
|
467 |
public void setAdminUser(String user) { |
468 |
this.adminUser = user;
|
469 |
} |
470 |
|
471 |
/**
|
472 |
* @return the password
|
473 |
*/
|
474 |
public String getAdminPassword() { |
475 |
return adminPassword;
|
476 |
} |
477 |
|
478 |
/**
|
479 |
* @param password the password to set
|
480 |
*/
|
481 |
public void setAdminPassword(String password) { |
482 |
this.adminPassword = password;
|
483 |
} |
484 |
|
485 |
/**
|
486 |
* @return the configuration
|
487 |
*/
|
488 |
public GSConfiguration getConfiguration() {
|
489 |
return configuration;
|
490 |
} |
491 |
|
492 |
/**
|
493 |
* @param configuration the configuration to set
|
494 |
*/
|
495 |
public void setConfiguration(GSConfiguration configuration) { |
496 |
this.configuration = configuration;
|
497 |
} |
498 |
|
499 |
} |