// Path: src/main/java/org/esupportail/papercut/web/WebInterceptor.java
// public class WebInterceptor extends HandlerInterceptorAdapter {
// 	
// 	@Resource
// 	EsupPapercutConfig config;
// 	
// 	@Resource 
// 	EsupPaperCutService esupPaperCutService;
// 
// 	@Override
// 	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
// 			ModelAndView modelAndView) throws Exception {
// 
// 		String context = WebUtils.getContext(request);
// 
// 		if("webjars".equals(context) || "resources".equals(context)) {
// 			super.postHandle(request, response, handler, modelAndView);
// 		} else {
// 
// 			ContextHelper.setCurrentContext(context);
// 
// 			super.postHandle(request, response, handler, modelAndView);
// 
// 			if (modelAndView != null) {
// 				boolean isViewObject = modelAndView.getView() == null;
// 				boolean isRedirectView = !isViewObject && modelAndView.getView() instanceof RedirectView;
// 				boolean viewNameStartsWithRedirect = isViewObject && modelAndView.getViewName().startsWith(UrlBasedViewResolver.REDIRECT_URL_PREFIX);
// 
// 				if (!isRedirectView && !viewNameStartsWithRedirect && context != null) {
// 					EsupPapercutContext configContext = config.getContext(context);
// 					if (configContext != null) {
// 						modelAndView.addObject("title", configContext.getTitle());
// 						modelAndView.addObject("htmlFooter", configContext.getHtmlFooter());
// 						modelAndView.addObject("pContext", context);
// 					}
// 					modelAndView.addObject("isAdmin", WebUtils.isAdmin());
// 					modelAndView.addObject("isManager", WebUtils.isManager());
// 					modelAndView.addObject("availableContexts", WebUtils.availableContexts());
// 					modelAndView.addObject("payAvailable", !esupPaperCutService.getPayModes(configContext).isEmpty());
// 				}
// 			}
// 		}
// 
// 	}
// 
// }


import org.esupportail.papercut.web.WebInterceptor;
import org.springframework.boot.autoconfigure.web.ErrorProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.thymeleaf.dialect.springdata.SpringDataDialect;

/**
 * Licensed to EsupPortail under one or more contributor license
 * agreements. See the NOTICE file distributed with this work for
 * additional information regarding copyright ownership.
 *
 * EsupPortail licenses this file to you 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:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * 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.esupportail.papercut.config;  


@Configuration  
public class WebConfig implements WebMvcConfigurer {  
    
    @Bean

// Path: src/main/java/org/esupportail/papercut/web/WebInterceptor.java
// public class WebInterceptor extends HandlerInterceptorAdapter {
// 	
// 	@Resource
// 	EsupPapercutConfig config;
// 	
// 	@Resource 
// 	EsupPaperCutService esupPaperCutService;
// 
// 	@Override
// 	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
// 			ModelAndView modelAndView) throws Exception {
// 
// 		String context = WebUtils.getContext(request);
// 
// 		if("webjars".equals(context) || "resources".equals(context)) {
// 			super.postHandle(request, response, handler, modelAndView);
// 		} else {
// 
// 			ContextHelper.setCurrentContext(context);
// 
// 			super.postHandle(request, response, handler, modelAndView);
// 
// 			if (modelAndView != null) {
// 				boolean isViewObject = modelAndView.getView() == null;
// 				boolean isRedirectView = !isViewObject && modelAndView.getView() instanceof RedirectView;
// 				boolean viewNameStartsWithRedirect = isViewObject && modelAndView.getViewName().startsWith(UrlBasedViewResolver.REDIRECT_URL_PREFIX);
// 
// 				if (!isRedirectView && !viewNameStartsWithRedirect && context != null) {
// 					EsupPapercutContext configContext = config.getContext(context);
// 					if (configContext != null) {
// 						modelAndView.addObject("title", configContext.getTitle());
// 						modelAndView.addObject("htmlFooter", configContext.getHtmlFooter());
// 						modelAndView.addObject("pContext", context);
// 					}
// 					modelAndView.addObject("isAdmin", WebUtils.isAdmin());
// 					modelAndView.addObject("isManager", WebUtils.isManager());
// 					modelAndView.addObject("availableContexts", WebUtils.availableContexts());
// 					modelAndView.addObject("payAvailable", !esupPaperCutService.getPayModes(configContext).isEmpty());
// 				}
// 			}
// 		}
// 
// 	}
// 
// }


// Path: src/main/java/org/esupportail/papercut/config/WebConfig.java
import org.esupportail.papercut.web.WebInterceptor;
import org.springframework.boot.autoconfigure.web.ErrorProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.thymeleaf.dialect.springdata.SpringDataDialect;

/**
 * Licensed to EsupPortail under one or more contributor license
 * agreements. See the NOTICE file distributed with this work for
 * additional information regarding copyright ownership.
 *
 * EsupPortail licenses this file to you 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:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * 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.esupportail.papercut.config;  


@Configuration  
public class WebConfig implements WebMvcConfigurer {  
    
    @Bean

    public WebInterceptor webInterceptor() {
