Java tutorial
/** * Copyright 2017 Otto (GmbH & Co KG) * <p> * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * <p> * http://www.apache.org/licenses/LICENSE-2.0 * <p> * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.schedoscope.metascope.controller; import org.schedoscope.metascope.config.MetascopeConfig; import org.schedoscope.metascope.service.MetascopeUserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; @Controller public class MetascopeErrorController { @Autowired private MetascopeUserService metascopeUserService; @Autowired private MetascopeConfig config; @RequestMapping("/accessdenied") public ModelAndView accessdenied(HttpServletRequest request) { return showErrorView("accessdenied"); } @RequestMapping("/notfound") public ModelAndView notfound(HttpServletRequest request) { return showErrorView("notfound"); } @RequestMapping("/expired") public ModelAndView expired(HttpServletRequest request) { return showErrorView("expired"); } private ModelAndView showErrorView(String view) { ModelAndView mav = new ModelAndView("util/" + view); mav.addObject("userEntityService", metascopeUserService); if (metascopeUserService.isAuthenticated()) { mav.addObject("admin", metascopeUserService.isAdmin()); mav.addObject("userMgmnt", config.withUserManagement()); } return mav; } }