001: /*
002: * Created on Jan 27, 2004
003: *
004: * To change the template for this generated file go to
005: * Window - Preferences - Java - Code Generation - Code and Comments
006: */
007: package org.vfny.geoserver.form.global;
008:
009: import org.apache.struts.action.ActionError;
010: import org.apache.struts.action.ActionErrors;
011: import org.apache.struts.action.ActionForm;
012: import org.apache.struts.action.ActionMapping;
013: import org.vfny.geoserver.config.ContactConfig;
014: import org.vfny.geoserver.config.GlobalConfig;
015: import org.vfny.geoserver.global.GeoServer;
016: import org.vfny.geoserver.global.dto.GeoServerDTO;
017: import org.vfny.geoserver.global.dto.GeoServerDTO.Defaults;
018: import java.util.logging.Level;
019: import javax.servlet.http.HttpServletRequest;
020:
021: /**
022: * GeoServerConfigurationForm purpose.
023: * <p>
024: * Description of GeoServerConfigurationForm ...
025: * </p>
026: *
027: * <p>
028: * Capabilities:
029: * </p>
030: * <ul>
031: * <li>
032: * Feature: description
033: * </li>
034: * </ul>
035: * <p>
036: * Example Use:
037: * </p>
038: * <pre><code>
039: * GeoServerConfigurationForm x = new GeoServerConfigurationForm(...);
040: * </code></pre>
041: *
042: * @author User, Refractions Research, Inc.
043: * @author $Author: cholmesny $ (last modification)
044: * @version $Id: GeoServerConfigurationForm.java 7226 2007-07-10 19:28:46Z saul.farber $
045: */
046: public class GeoServerConfigurationForm extends ActionForm {
047: private int maxFeatures;
048: private boolean verbose;
049: private int numDecimals;
050: private String charset;
051: private String proxyBaseUrl;
052: private String schemaBaseURL;
053: private String log4jConfigFile;
054: private String adminUserName;
055: private String adminPassword;
056: private boolean verboseExceptions;
057:
058: /** The name of the contact person */
059: private String contactPerson;
060:
061: /** The name of the organization with which the contact is affiliated. */
062: private String contactOrganization;
063:
064: /** The position of the contact within their organization. */
065: private String contactPosition;
066:
067: /** The type of address specified, such as postal. */
068: private String addressType;
069:
070: /** The actual street address. */
071: private String address;
072:
073: /** The city of the address. */
074: private String addressCity;
075:
076: /** The state/prov. of the address. */
077: private String addressState;
078:
079: /** The postal code for the address. */
080: private String addressPostalCode;
081:
082: /** The country of the address. */
083: private String addressCountry;
084:
085: /** The contact phone number. */
086: private String contactVoice;
087:
088: /** The contact Fax number. */
089: private String contactFacsimile;
090:
091: /** The contact email address. */
092: private String contactEmail;
093: private boolean verboseChecked;
094: private boolean verboseExceptionsChecked;
095:
096: /** log to disk ? **/
097: private boolean suppressStdOutLogging;
098: private boolean suppressStdOutLoggingChecked;
099: private String logLocation;
100: private double jaiMemoryCapacity;
101: private double jaiMemoryThreshold;
102: private int jaiTileThreads;
103: private int jaiTilePriority;
104: private boolean jaiRecycling;
105: private boolean jaiRecyclingChecked;
106: private boolean imageIOCache;
107: private boolean imageIOCacheChecked;
108: private boolean jaiJPEGNative;
109: private boolean jaiJPEGNativeChecked;
110: private boolean jaiPNGNative;
111: private boolean jaiPNGNativeChecked;
112:
113: /** tile cache location, full url or relative path */
114: private String tileCache;
115:
116: public void reset(ActionMapping arg0, HttpServletRequest request) {
117: super .reset(arg0, request);
118:
119: GlobalConfig globalConfig = (GlobalConfig) getServlet()
120: .getServletContext().getAttribute(
121: GlobalConfig.CONFIG_KEY);
122:
123: maxFeatures = globalConfig.getMaxFeatures();
124: verbose = globalConfig.isVerbose();
125: verboseExceptions = globalConfig.isVerboseExceptions();
126: verboseChecked = false;
127: verboseExceptionsChecked = false;
128: numDecimals = globalConfig.getNumDecimals();
129: charset = globalConfig.getCharSet().name();
130: proxyBaseUrl = globalConfig.getProxyBaseUrl();
131: schemaBaseURL = globalConfig.getSchemaBaseUrl();
132: adminUserName = globalConfig.getAdminUserName();
133: adminPassword = globalConfig.getAdminPassword();
134:
135: log4jConfigFile = globalConfig.getLog4jConfigFile();
136:
137: suppressStdOutLogging = globalConfig.getSuppressStdOutLogging();
138: suppressStdOutLoggingChecked = false;
139: logLocation = globalConfig.getLogLocation();
140:
141: jaiMemoryCapacity = globalConfig.getJaiMemoryCapacity();
142: jaiMemoryThreshold = globalConfig.getJaiMemoryThreshold();
143: jaiTileThreads = globalConfig.getJaiTileThreads();
144: jaiTilePriority = globalConfig.getJaiTilePriority();
145: jaiRecycling = globalConfig.isJaiRecycling();
146: jaiRecyclingChecked = false;
147: imageIOCache = globalConfig.isImageIOCache();
148: imageIOCacheChecked = false;
149: jaiJPEGNative = globalConfig.isJaiJPEGNative();
150: jaiJPEGNativeChecked = false;
151: jaiPNGNative = globalConfig.isJaiPNGNative();
152: jaiPNGNativeChecked = false;
153:
154: tileCache = globalConfig.getTileCache();
155:
156: ContactConfig contactConfig = globalConfig.getContact();
157: contactPerson = contactConfig.getContactPerson();
158: contactOrganization = contactConfig.getContactOrganization();
159: contactPosition = contactConfig.getContactPosition();
160:
161: addressType = contactConfig.getAddressType();
162: address = contactConfig.getAddress();
163: addressCity = contactConfig.getAddressCity();
164: addressCountry = contactConfig.getAddressCountry();
165: addressPostalCode = contactConfig.getAddressPostalCode();
166: addressState = contactConfig.getAddressState();
167:
168: contactVoice = contactConfig.getContactVoice();
169: contactFacsimile = contactConfig.getContactFacsimile();
170: contactEmail = contactConfig.getContactEmail();
171: }
172:
173: public ActionErrors validate(ActionMapping mapping,
174: HttpServletRequest request) {
175: ActionErrors errors = new ActionErrors();
176:
177: final long maxMemoryAvailable = Runtime.getRuntime()
178: .maxMemory()
179: - (4 * 1024 * 1024);
180:
181: if ((jaiMemoryCapacity < 0)
182: || (jaiMemoryCapacity > Defaults.JaiMemoryCapacity)) {
183: errors.add("jaiMemCapacity", new ActionError(
184: "error.geoserver.JAIMemCapacity", new Long(
185: Defaults.JaiMemoryCapacity)));
186: }
187:
188: if ((jaiMemoryThreshold < 0.0) || (jaiMemoryThreshold > 1.0)) {
189: errors.add("jaiMemThreshold", new ActionError(
190: "error.geoserver.JAIMemThreshold"));
191: }
192:
193: if ((jaiTileThreads < 0) || (jaiTileThreads > 100)) {
194: errors.add("jaiTileThreads", new ActionError(
195: "error.geoserver.JAITileThreads"));
196: }
197:
198: if ((jaiTilePriority < 1) || (jaiTilePriority > 10)) {
199: errors.add("jaiTilePriority", new ActionError(
200: "error.geoserver.JAITilePriority"));
201: }
202:
203: return errors;
204: }
205:
206: /**
207: * Access maxFeatures property.
208: *
209: * @return Returns the maxFeatures.
210: */
211: public int getMaxFeatures() {
212: return maxFeatures;
213: }
214:
215: /**
216: * Set maxFeatures to maxFeatures.
217: *
218: * @param maxFeatures The maxFeatures to set.
219: */
220: public void setMaxFeatures(int maxFeatures) {
221: this .maxFeatures = maxFeatures;
222: }
223:
224: /**
225: * Access verbose property.
226: *
227: * @return Returns the verbose.
228: */
229: public boolean isVerbose() {
230: return verbose;
231: }
232:
233: /**
234: * Set verbose to verbose.
235: *
236: * @param verbose The verbose to set.
237: */
238: public void setVerbose(boolean verbose) {
239: verboseChecked = true;
240: this .verbose = verbose;
241: }
242:
243: /**
244: * Access verboseChecked property.
245: *
246: * @return Returns the verboseChecked.
247: */
248: public boolean isVerboseChecked() {
249: return verboseChecked;
250: }
251:
252: /**
253: * Set verboseChecked to verboseChecked.
254: *
255: * @param verboseChecked The verboseChecked to set.
256: */
257: public void setVerboseChecked(boolean verboseChecked) {
258: this .verboseChecked = verboseChecked;
259: }
260:
261: /**
262: * Access verboseChecked property.
263: *
264: * @return Returns the verboseChecked.
265: */
266: public boolean isVerboseExceptionsChecked() {
267: return verboseExceptionsChecked;
268: }
269:
270: /**
271: * Set verboseChecked to verboseChecked.
272: *
273: * @param verboseChecked The verboseChecked to set.
274: */
275: public void setVerboseExceptionsChecked(
276: boolean verboseExceptionsChecked) {
277: this .verboseExceptionsChecked = verboseExceptionsChecked;
278: }
279:
280: /**
281: * Access verboseExceptions property.
282: *
283: * @return Returns the verboseExceptions.
284: */
285: public boolean isVerboseExceptions() {
286: return verboseExceptions;
287: }
288:
289: /**
290: * Set verboseExceptions to verboseExceptions.
291: *
292: * @param verboseExceptions The verboseExceptions to set.
293: */
294: public void setVerboseExceptions(boolean verboseExceptions) {
295: verboseExceptionsChecked = true;
296: this .verboseExceptions = verboseExceptions;
297: }
298:
299: /**
300: * Access numDecimals property.
301: *
302: * @return Returns the numDecimals.
303: */
304: public int getNumDecimals() {
305: return numDecimals;
306: }
307:
308: /**
309: * Set numDecimals to numDecimals.
310: *
311: * @param numDecimals The numDecimals to set.
312: */
313: public void setNumDecimals(int numDecimals) {
314: this .numDecimals = numDecimals;
315: }
316:
317: /**
318: * Access charset property.
319: *
320: * @return Returns the charset.
321: */
322: public String getCharset() {
323: return charset;
324: }
325:
326: /**
327: * Set charset to charset.
328: *
329: * @param charset The charset to set.
330: */
331: public void setCharset(String charset) {
332: this .charset = charset;
333: }
334:
335: /**
336: * Access baseURL property.
337: *
338: * @return Returns the baseURL.
339: */
340: public String getProxyBaseUrl() {
341: return "".equals(proxyBaseUrl) ? null : proxyBaseUrl;
342: }
343:
344: /**
345: * Set baseURL to baseURL.
346: *
347: * @param baseURL The baseURL to set.
348: */
349: public void setProxyBaseUrl(String baseURL) {
350: this .proxyBaseUrl = baseURL;
351: }
352:
353: /**
354: * Access schemaBaseURL property.
355: *
356: * @return Returns the schemaBaseURL.
357: */
358: public String getSchemaBaseURL() {
359: return schemaBaseURL;
360: }
361:
362: /**
363: * Set schemaBaseURL to schemaBaseURL.
364: *
365: * @param schemaBaseURL The schemaBaseURL to set.
366: */
367: public void setSchemaBaseURL(String schemaBaseURL) {
368: this .schemaBaseURL = schemaBaseURL;
369: }
370:
371: /**
372: * Access loggingLevel property.
373: *
374: * @return Returns the loggingLevel.
375: */
376: public String getLog4jConfigFile() {
377: return log4jConfigFile;
378: }
379:
380: /**
381: * Set loggingLevel to loggingLevel.
382: *
383: * @param loggingLevel The loggingLevel to set.
384: */
385: public void setLog4jConfigFile(String s) {
386: this .log4jConfigFile = s;
387: }
388:
389: /**
390: * Access address property.
391: *
392: * @return Returns the address.
393: */
394: public String getAddress() {
395: return address;
396: }
397:
398: /**
399: * Set address to address.
400: *
401: * @param address The address to set.
402: */
403: public void setAddress(String address) {
404: this .address = address;
405: }
406:
407: /**
408: * Access addressCity property.
409: *
410: * @return Returns the addressCity.
411: */
412: public String getAddressCity() {
413: return addressCity;
414: }
415:
416: /**
417: * Set addressCity to addressCity.
418: *
419: * @param addressCity The addressCity to set.
420: */
421: public void setAddressCity(String addressCity) {
422: this .addressCity = addressCity;
423: }
424:
425: /**
426: * Access addressCountry property.
427: *
428: * @return Returns the addressCountry.
429: */
430: public String getAddressCountry() {
431: return addressCountry;
432: }
433:
434: /**
435: * Set addressCountry to addressCountry.
436: *
437: * @param addressCountry The addressCountry to set.
438: */
439: public void setAddressCountry(String addressCountry) {
440: this .addressCountry = addressCountry;
441: }
442:
443: /**
444: * Access addressPostalCode property.
445: *
446: * @return Returns the addressPostalCode.
447: */
448: public String getAddressPostalCode() {
449: return addressPostalCode;
450: }
451:
452: /**
453: * Set addressPostalCode to addressPostalCode.
454: *
455: * @param addressPostalCode The addressPostalCode to set.
456: */
457: public void setAddressPostalCode(String addressPostalCode) {
458: this .addressPostalCode = addressPostalCode;
459: }
460:
461: /**
462: * Access addressState property.
463: *
464: * @return Returns the addressState.
465: */
466: public String getAddressState() {
467: return addressState;
468: }
469:
470: /**
471: * Set addressState to addressState.
472: *
473: * @param addressState The addressState to set.
474: */
475: public void setAddressState(String addressState) {
476: this .addressState = addressState;
477: }
478:
479: /**
480: * Access addressType property.
481: *
482: * @return Returns the addressType.
483: */
484: public String getAddressType() {
485: return addressType;
486: }
487:
488: /**
489: * Set addressType to addressType.
490: *
491: * @param addressType The addressType to set.
492: */
493: public void setAddressType(String addressType) {
494: this .addressType = addressType;
495: }
496:
497: /**
498: * Access contactEmail property.
499: *
500: * @return Returns the contactEmail.
501: */
502: public String getContactEmail() {
503: return contactEmail;
504: }
505:
506: /**
507: * Set contactEmail to contactEmail.
508: *
509: * @param contactEmail The contactEmail to set.
510: */
511: public void setContactEmail(String contactEmail) {
512: this .contactEmail = contactEmail;
513: }
514:
515: /**
516: * Access contactFacsimile property.
517: *
518: * @return Returns the contactFacsimile.
519: */
520: public String getContactFacsimile() {
521: return contactFacsimile;
522: }
523:
524: /**
525: * Set contactFacsimile to contactFacsimile.
526: *
527: * @param contactFacsimile The contactFacsimile to set.
528: */
529: public void setContactFacsimile(String contactFacsimile) {
530: this .contactFacsimile = contactFacsimile;
531: }
532:
533: /**
534: * Access contactOrganization property.
535: *
536: * @return Returns the contactOrganization.
537: */
538: public String getContactOrganization() {
539: return contactOrganization;
540: }
541:
542: /**
543: * Set contactOrganization to contactOrganization.
544: *
545: * @param contactOrganization The contactOrganization to set.
546: */
547: public void setContactOrganization(String contactOrganization) {
548: this .contactOrganization = contactOrganization;
549: }
550:
551: /**
552: * Access contactPerson property.
553: *
554: * @return Returns the contactPerson.
555: */
556: public String getContactPerson() {
557: return contactPerson;
558: }
559:
560: /**
561: * Set contactPerson to contactPerson.
562: *
563: * @param contactPerson The contactPerson to set.
564: */
565: public void setContactPerson(String contactPerson) {
566: this .contactPerson = contactPerson;
567: }
568:
569: /**
570: * Access contactPosition property.
571: *
572: * @return Returns the contactPosition.
573: */
574: public String getContactPosition() {
575: return contactPosition;
576: }
577:
578: /**
579: * Set contactPosition to contactPosition.
580: *
581: * @param contactPosition The contactPosition to set.
582: */
583: public void setContactPosition(String contactPosition) {
584: this .contactPosition = contactPosition;
585: }
586:
587: /**
588: * Access contactVoice property.
589: *
590: * @return Returns the contactVoice.
591: */
592: public String getContactVoice() {
593: return contactVoice;
594: }
595:
596: /**
597: * Set contactVoice to contactVoice.
598: *
599: * @param contactVoice The contactVoice to set.
600: */
601: public void setContactVoice(String contactVoice) {
602: this .contactVoice = contactVoice;
603: }
604:
605: //No sets yet, they will be needed for login config page though.
606: public String getAdminUserName() {
607: return adminUserName;
608: }
609:
610: public String getAdminPassword() {
611: return adminPassword;
612: }
613:
614: /**
615: * @return The string representation of the path on disk in which the
616: * server logs to.
617: */
618: public String getLogLocation() {
619: return logLocation;
620: }
621:
622: /**
623: * @param logLocation The string representation of the path on disk in which
624: * the server logs to.
625: */
626: public void setLogLocation(String logLocation) {
627: this .logLocation = logLocation;
628: }
629:
630: /**
631: * Set loggingToFile to loggingToFile.
632: *
633: * @param verbose The loggingToFile to set.
634: */
635: public void setSuppressStdOutLogging(boolean b) {
636: suppressStdOutLoggingChecked = true;
637: this .suppressStdOutLogging = b;
638: }
639:
640: /**
641: * Access loggingToFile property.
642: *
643: * @return Returns the loggingToFile.
644: */
645: public boolean isSuppressStdOutLogging() {
646: return suppressStdOutLogging;
647: }
648:
649: /**
650: * Access loggingToFileChecked property.
651: *
652: * @return Returns the loggingToFileChecked.
653: */
654: public boolean isSuppressStdOutLoggingChecked() {
655: return suppressStdOutLoggingChecked;
656: }
657:
658: /**
659: * Set loggingToFileChecked to loggingToFileChecked.
660: *
661: * @param loggingToFileChecked The loggingToFileChecked to set.
662: */
663: public void setSuppressStdOutLoggingChecked(boolean b) {
664: this .suppressStdOutLoggingChecked = b;
665: }
666:
667: public double getJaiMemoryCapacity() {
668: return jaiMemoryCapacity;
669: }
670:
671: public void setJaiMemoryCapacity(double jaiMemoryCapacity) {
672: this .jaiMemoryCapacity = jaiMemoryCapacity;
673: }
674:
675: public boolean getJaiRecycling() {
676: return jaiRecycling;
677: }
678:
679: public void setJaiRecycling(boolean jaiRecycling) {
680: jaiRecyclingChecked = true;
681: this .jaiRecycling = jaiRecycling;
682: }
683:
684: public boolean getJaiJPEGNative() {
685: return jaiJPEGNative;
686: }
687:
688: public void setJaiJPEGNative(boolean jaiJPEGNative) {
689: jaiJPEGNativeChecked = true;
690: this .jaiJPEGNative = jaiJPEGNative;
691: }
692:
693: public boolean getJaiPNGNative() {
694: return jaiPNGNative;
695: }
696:
697: public void setJaiPNGNative(boolean jaiPNGNative) {
698: jaiPNGNativeChecked = true;
699: this .jaiPNGNative = jaiPNGNative;
700: }
701:
702: /**
703: * Access recyclingChecked property.
704: *
705: * @return Returns the recyclingChecked.
706: */
707: public boolean isJaiRecyclingChecked() {
708: return jaiRecyclingChecked;
709: }
710:
711: /**
712: * Access nativeChecked property.
713: *
714: * @return Returns the nativeChecked.
715: */
716: public boolean isJaiJPEGNativeChecked() {
717: return jaiJPEGNativeChecked;
718: }
719:
720: /**
721: * Access nativeChecked property.
722: *
723: * @return Returns the nativeChecked.
724: */
725: public boolean isJaiPNGNativeChecked() {
726: return jaiPNGNativeChecked;
727: }
728:
729: /**
730: * Set recyclingChecked to recyclingChecked.
731: *
732: * @param recyclingChecked The recyclingChecked to set.
733: */
734: public void setJaiRecyclingChecked(boolean jaiRecyclingChecked) {
735: this .jaiRecyclingChecked = jaiRecyclingChecked;
736: }
737:
738: /**
739: * Set nativeChecked to nativeChecked.
740: *
741: * @param nativeChecked The nativeChecked to set.
742: */
743: public void setJaiJPEGNativeChecked(boolean jaiJPEGNativeChecked) {
744: this .jaiJPEGNativeChecked = jaiJPEGNativeChecked;
745: }
746:
747: /**
748: * Set nativeChecked to nativeChecked.
749: *
750: * @param nativeChecked The nativeChecked to set.
751: */
752: public void setJaiPNGNativeChecked(boolean jaiPNGNativeChecked) {
753: this .jaiPNGNativeChecked = jaiPNGNativeChecked;
754: }
755:
756: public boolean getImageIOCache() {
757: return imageIOCache;
758: }
759:
760: public void setImageIOCache(boolean imageIOCache) {
761: imageIOCacheChecked = true;
762: this .imageIOCache = imageIOCache;
763: }
764:
765: /**
766: * Access verboseChecked property.
767: *
768: * @return Returns the verboseChecked.
769: */
770: public boolean isImageIOCacheChecked() {
771: return imageIOCacheChecked;
772: }
773:
774: /**
775: * Set verboseChecked to verboseChecked.
776: *
777: * @param verboseChecked The verboseChecked to set.
778: */
779: public void setImageIOCacheChecked(boolean imageIOCacheChecked) {
780: this .imageIOCacheChecked = imageIOCacheChecked;
781: }
782:
783: public double getJaiMemoryThreshold() {
784: return jaiMemoryThreshold;
785: }
786:
787: public void setJaiMemoryThreshold(double jaiMemoryThreshold) {
788: this .jaiMemoryThreshold = jaiMemoryThreshold;
789: }
790:
791: public int getJaiTilePriority() {
792: return jaiTilePriority;
793: }
794:
795: public void setJaiTilePriority(int jaiTilePriority) {
796: this .jaiTilePriority = jaiTilePriority;
797: }
798:
799: public int getJaiTileThreads() {
800: return jaiTileThreads;
801: }
802:
803: public void setJaiTileThreads(int jaiTileThreads) {
804: this .jaiTileThreads = jaiTileThreads;
805: }
806:
807: /**
808: * tile cache parameter
809: * @see GeoServer#getTileCache()
810: */
811: public String getTileCache() {
812: return tileCache;
813: }
814:
815: public void setTileCache(String tileCache) {
816: this.tileCache = tileCache;
817: }
818: }
|