View Javadoc
1   /**
2    * Copyright 2005-2015 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   * @deprecated KNS Struts deprecated, use KRAD and the Spring MVC framework.
29   */
30  @Deprecated
31  public class KualiControllerConfig extends ControllerConfigWrapper {
32      public KualiControllerConfig(ControllerConfig config) {
33          super(config);
34      }
35  
36      /**
37       * Returns the global max file upload size, which is dynamically derived from the Rice parameter service.
38       * This technically breaks the implicit contract in ControllerConfig that the config is frozen after startup.
39       * @return the global max file upload size
40       */
41      @Override
42      public String getMaxFileSize() {
43          String maxFileSize = CoreFrameworkServiceLocator.getParameterService().getParameterValueAsString(KRADConstants.KNS_NAMESPACE, KRADConstants.DetailTypes.ALL_DETAIL_TYPE, KRADConstants.MAX_UPLOAD_SIZE_PARM_NM);
44          if (StringUtils.isNotBlank(maxFileSize)) {
45              return maxFileSize;
46          }
47          return super.getMaxFileSize();
48      }
49  
50      /**
51       * Overridden to throw an UnsupportedOperationException.  Once our KualiControllerConfig is
52       * in place, it does not make sense to support this setter.
53       */
54      @Override
55      public void setMaxFileSize(String s) {
56          throw new UnsupportedOperationException("Cannot set max file size through KualiControllerConfig");
57      }
58  }