01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. The ASF licenses this file to You
04: * under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License. For additional information regarding
15: * copyright in this work, please see the NOTICE file in the top level
16: * directory of this distribution.
17: */
18:
19: package org.apache.roller.ui.authoring.struts.formbeans;
20:
21: import javax.servlet.http.HttpServletRequest;
22:
23: import org.apache.struts.action.ActionMapping;
24: import org.apache.roller.RollerException;
25: import org.apache.roller.pojos.RollerConfigData;
26: import org.apache.roller.ui.authoring.struts.forms.RollerConfigForm;
27:
28: /**
29: * These properties are not persistent and are only needed for the UI.
30: *
31: * @struts.form name="rollerConfigFormEx"
32: * @author Lance Lavandowska
33: */
34: public class RollerConfigFormEx extends RollerConfigForm {
35: public RollerConfigFormEx() {
36: }
37:
38: public RollerConfigFormEx(RollerConfigData config,
39: java.util.Locale locale) throws RollerException {
40: super (config, locale);
41: }
42:
43: /**
44: * Override for non-primitive values
45: */
46: public void copyFrom(
47: org.apache.roller.pojos.RollerConfigData dataHolder,
48: java.util.Locale locale) throws RollerException {
49: super .copyFrom(dataHolder, locale);
50: fixNulls();
51: this .uploadMaxFileMB = dataHolder.getUploadMaxFileMB();
52: this .uploadMaxDirMB = dataHolder.getUploadMaxDirMB();
53: }
54:
55: /**
56: * Override for non-primitive values
57: */
58: public void copyTo(
59: org.apache.roller.pojos.RollerConfigData dataHolder,
60: java.util.Locale locale) throws RollerException {
61: fixNulls();
62: super .copyTo(dataHolder, locale);
63: dataHolder.setUploadMaxFileMB(this .uploadMaxFileMB);
64: dataHolder.setUploadMaxDirMB(this .uploadMaxDirMB);
65: }
66:
67: /**
68: * Method allows Struts to handle empty checkboxes for booleans
69: */
70: public void reset(ActionMapping mapping, HttpServletRequest request) {
71: setAbsoluteURL(null);
72: fixNulls();
73: }
74:
75: private void fixNulls() {
76: if (getRssUseCache() == null)
77: setRssUseCache(Boolean.FALSE);
78: if (getNewUserAllowed() == null)
79: setNewUserAllowed(Boolean.FALSE);
80: if (getEnableAggregator() == null)
81: setEnableAggregator(Boolean.FALSE);
82: if (getUploadEnabled() == null)
83: setUploadEnabled(Boolean.FALSE);
84: if (getMemDebug() == null)
85: setMemDebug(Boolean.FALSE);
86: if (getAutoformatComments() == null)
87: setAutoformatComments(Boolean.FALSE);
88: if (getEscapeCommentHtml() == null)
89: setEscapeCommentHtml(Boolean.FALSE);
90: if (getEmailComments() == null)
91: setEmailComments(Boolean.FALSE);
92: if (getEnableLinkback() == null)
93: setEnableLinkback(Boolean.FALSE);
94: if (getEncryptPasswords() == null)
95: setEncryptPasswords(Boolean.FALSE);
96: }
97: }
|