diff options
author | sheetalm <sheetal.mudholkar@amdocs.com> | 2018-02-08 09:30:02 +0530 |
---|---|---|
committer | Avi Gaffa <avi.gaffa@amdocs.com> | 2018-02-08 12:38:37 +0000 |
commit | 2d2e0b503f915a81ae9a02dfa3afac3de369efde (patch) | |
tree | b05555ebaca90f1d620f4562067bf486731ee48c /openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java | |
parent | 89f96b17aed5c432be3df6d75a49a1f9ebc9120b (diff) |
Onboarding foundation changes
1. Adding OnboardingSessionContextFilter which sets tenant(kespace) for
onboarding application
2. Different services can extend SessionContextFilter to set their own
keyspace
3. These changes in onboarding are done to support services like
ActivitySpec
Change-Id: Ia62557354ab05235d027250af94a2835d741b7fa
Issue-ID: SDC-1005
Signed-off-by: sheetalm <sheetal.mudholkar@amdocs.com>
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java')
-rw-r--r-- | openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/filters/SessionContextFilter.java | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/filters/SessionContextFilter.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/filters/SessionContextFilter.java new file mode 100644 index 0000000000..f81cc4b586 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/filters/SessionContextFilter.java @@ -0,0 +1,47 @@ +package org.openecomp.sdcrests.filters; + +import org.openecomp.sdc.common.session.SessionContextProvider; +import org.openecomp.sdc.common.session.SessionContextProviderFactory; + +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 javax.servlet.http.HttpServletRequest; + +public abstract class SessionContextFilter implements Filter { + @Override + public void init(FilterConfig filterConfig) throws ServletException { + + } + + @Override + public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, + FilterChain filterChain) throws IOException, ServletException { + SessionContextProvider contextProvider = + SessionContextProviderFactory.getInstance().createInterface(); + + try { + if (servletRequest instanceof HttpServletRequest) { + + contextProvider.create(getUser(servletRequest),getTenant(servletRequest)); + } + + filterChain.doFilter(servletRequest, servletResponse); + } finally { + contextProvider.close(); + } + } + + @Override + public void destroy() { + + } + + public abstract String getUser(ServletRequest servletRequest); + + public abstract String getTenant(ServletRequest servletRequest); +} |