001/** 002 * Copyright 2005-2016 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.krad.web.controller; 017 018import org.apache.commons.lang.StringUtils; 019import org.kuali.rice.coreservice.framework.parameter.ParameterService; 020import org.kuali.rice.coreservice.framework.CoreFrameworkServiceLocator; 021import org.kuali.rice.krad.util.KRADConstants; 022import org.springframework.stereotype.Controller; 023import org.springframework.web.bind.annotation.RequestMapping; 024import org.springframework.web.bind.annotation.RequestParam; 025import org.springframework.web.servlet.ModelAndView; 026 027/** 028 * This simple controller loads the module locked view when a user accesses a 029 * module which has been locked for maintenance. 030 * 031 * @author Kuali Rice Team (rice.collab@kuali.org) 032 */ 033@Controller 034public class ModuleLockedController { 035 036 /** 037 * Constant defined to match with method call in moduleLocked.jsp which is 038 * set to a message that is displayed when the module is locked. 039 */ 040 public static final String MODULE_LOCKED_MESSAGE = "moduleLockedMessage"; 041 public static final String MODULE_PARAMETER = "moduleNamespace"; 042 043 @RequestMapping(value = "/module-locked") 044 public ModelAndView moduleLocked(@RequestParam(value = MODULE_PARAMETER, required = true) String moduleNamespaceCode) { 045 ModelAndView modelAndView = new ModelAndView("moduleLocked"); 046 ParameterService parameterSerivce = CoreFrameworkServiceLocator.getParameterService(); 047 String messageParamComponentCode = KRADConstants.DetailTypes.ALL_DETAIL_TYPE; 048 String messageParamName = KRADConstants.SystemGroupParameterNames.OLTP_LOCKOUT_MESSAGE_PARM; 049 String lockoutMessage = parameterSerivce.getParameterValueAsString(moduleNamespaceCode, messageParamComponentCode, messageParamName); 050 051 if(StringUtils.isBlank(lockoutMessage)) { 052 String defaultMessageParamName = KRADConstants.SystemGroupParameterNames.OLTP_LOCKOUT_DEFAULT_MESSAGE; 053 lockoutMessage = parameterSerivce.getParameterValueAsString(KRADConstants.KNS_NAMESPACE, messageParamComponentCode, defaultMessageParamName); 054 } 055 modelAndView.addObject(MODULE_LOCKED_MESSAGE, lockoutMessage); 056 return modelAndView; 057 } 058}