View Javadoc

1   /**
2    * Copyright 2005-2012 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(HttpServletRequest request) {
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      @RequestMapping(value = "/module-locked")
50      public ModelAndView moduleLocked(@ModelAttribute("KualiForm") UifFormBase form,
51              @RequestParam(value = MODULE_PARAMETER, required = true) String moduleNamespaceCode) {
52          ParameterService parameterSerivce = CoreFrameworkServiceLocator.getParameterService();
53          
54          String messageParamComponentCode = KRADConstants.DetailTypes.ALL_DETAIL_TYPE;
55          String messageParamName = KRADConstants.SystemGroupParameterNames.OLTP_LOCKOUT_MESSAGE_PARM;
56          String lockoutMessage = parameterSerivce.getParameterValueAsString(moduleNamespaceCode,
57                  messageParamComponentCode, messageParamName);
58  
59          if (StringUtils.isBlank(lockoutMessage)) {
60              String defaultMessageParamName = KRADConstants.SystemGroupParameterNames.OLTP_LOCKOUT_DEFAULT_MESSAGE;
61              lockoutMessage = parameterSerivce.getParameterValueAsString(KRADConstants.KNS_NAMESPACE,
62                      messageParamComponentCode, defaultMessageParamName);
63          }
64          
65          return getMessageView(form, "Module Locked", lockoutMessage);
66      }
67  
68  }