1 /**
2 * Copyright 2005-2013 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
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.
15 */
16 package org.kuali.rice.kns.web.struts.config;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.apache.struts.config.ControllerConfig;
20 import org.kuali.rice.coreservice.framework.CoreFrameworkServiceLocator;
21 import org.kuali.rice.krad.util.KRADConstants;
22
23 /**
24 * Kuali customization of ControllerConfig which delegates max upload size lookup to
25 * parameter service: KRADConstants.KNS_NAMESPACE, KRADConstants.DetailTypes.ALL_DETAIL_TYPE, KRADConstants.MAX_UPLOAD_SIZE_PARM_NM
26 * The value must be a string compatible with Struts maxFileSize attribute.
27 */
28 public class KualiControllerConfig extends ControllerConfigWrapper {
29 public KualiControllerConfig(ControllerConfig config) {
30 super(config);
31 }
32
33 /**
34 * Returns the global max file upload size, which is dynamically derived from the Rice parameter service.
35 * This technically breaks the implicit contract in ControllerConfig that the config is frozen after startup.
36 * @return the global max file upload size
37 */
38 @Override
39 public String getMaxFileSize() {
40 String maxFileSize = CoreFrameworkServiceLocator.getParameterService().getParameterValueAsString(KRADConstants.KNS_NAMESPACE, KRADConstants.DetailTypes.ALL_DETAIL_TYPE, KRADConstants.MAX_UPLOAD_SIZE_PARM_NM);
41 if (StringUtils.isNotBlank(maxFileSize)) {
42 return maxFileSize;
43 }
44 return super.getMaxFileSize();
45 }
46
47 /**
48 * Overridden to throw an UnsupportedOperationException. Once our KualiControllerConfig is
49 * in place, it does not make sense to support this setter.
50 */
51 @Override
52 public void setMaxFileSize(String s) {
53 throw new UnsupportedOperationException("Cannot set max file size through KualiControllerConfig");
54 }
55 }