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.krad.web.controller;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.kuali.rice.coreservice.framework.parameter.ParameterService;
20  import org.kuali.rice.coreservice.framework.CoreFrameworkServiceLocator;
21  import org.kuali.rice.krad.util.KRADConstants;
22  import org.kuali.rice.krad.web.form.UifFormBase;
23  import org.springframework.stereotype.Controller;
24  import org.springframework.web.bind.annotation.ModelAttribute;
25  import org.springframework.web.bind.annotation.RequestMapping;
26  import org.springframework.web.bind.annotation.RequestParam;
27  import org.springframework.web.servlet.ModelAndView;
28  
29  import javax.servlet.http.HttpServletRequest;
30  
31  /**
32   * Loads the module locked view when a user accesses a module which has been locked for maintenance
33   *
34   * @author Kuali Rice Team (rice.collab@kuali.org)
35   */
36  @Controller
37  public class ModuleLockedController extends UifControllerBase {
38      
39      public static final String MODULE_PARAMETER = "moduleNamespace";
40      
41      @Override
42      protected UifFormBase createInitialForm() {
43          return new UifFormBase();
44      }
45  
46      /**
47       * Retrieves the module locked message test from a system parameter and then returns the message view
48       */
49      @MethodAccessible
50      @RequestMapping(value = "/module-locked")
51      public ModelAndView moduleLocked(@ModelAttribute("KualiForm") UifFormBase form,
52              @RequestParam(value = MODULE_PARAMETER, required = true) String moduleNamespaceCode) {
53          ParameterService parameterSerivce = CoreFrameworkServiceLocator.getParameterService();
54          
55          String messageParamComponentCode = KRADConstants.DetailTypes.ALL_DETAIL_TYPE;
56          String messageParamName = KRADConstants.SystemGroupParameterNames.OLTP_LOCKOUT_MESSAGE_PARM;
57          String lockoutMessage = parameterSerivce.getParameterValueAsString(moduleNamespaceCode,
58                  messageParamComponentCode, messageParamName);
59  
60          if (StringUtils.isBlank(lockoutMessage)) {
61              String defaultMessageParamName = KRADConstants.SystemGroupParameterNames.OLTP_LOCKOUT_DEFAULT_MESSAGE;
62              lockoutMessage = parameterSerivce.getParameterValueAsString(KRADConstants.KNS_NAMESPACE,
63                      messageParamComponentCode, defaultMessageParamName);
64          }
65          
66          return getMessageView(form, "Module Locked", lockoutMessage);
67      }
68  
69  }