blob: 4a417dd44cf1b4779d4ea04593e1296fb8d1a035 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2016 Parasoft.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Janusz Studzizba - initial API and implementation
* Dariusz Oszczedlowski - initial API and implementation
* Magdalena Gniewek - initial API and implementation
* Michal Wlodarczyk - initial API and implementation
*******************************************************************************/
package org.eclipse.opencert.storage.cdo.web;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import org.eclipse.opencert.storage.cdo.session.ThreadLocalCDOSessionProvider;
public class OpenCDOSessionInViewFilter
implements Filter
{
@Override
public void destroy() {}
@Override
public void init(FilterConfig fc) throws ServletException {}
@Override
public void doFilter(ServletRequest req, ServletResponse res,
FilterChain chain) throws IOException, ServletException
{
ThreadLocalCDOSessionProvider threadLocalCDOSessionProvider = new ThreadLocalCDOSessionProvider();
try {
chain.doFilter(req, res);
} catch (Exception e) {
e.printStackTrace();
} finally {
threadLocalCDOSessionProvider.close();
}
}
}