use of org.polymap.core.runtime.session.DefaultSessionContextProvider in project polymap4-core by Polymap4.
the class WebDavServer method service.
public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
Timer timer = new Timer();
HttpServletRequest req = (HttpServletRequest) servletRequest;
HttpServletResponse resp = (HttpServletResponse) servletResponse;
DefaultSessionContextProvider contextProvider = FsPlugin.getDefault().sessionContextProvider;
try {
Request request = new io.milton.servlet.ServletRequest(req, servletRequest.getServletContext());
Response response = new io.milton.servlet.ServletResponse(resp);
threadRequest.set(request);
threadResponse.set(response);
Auth auth = request.getAuthorization();
log.debug("Auth: " + auth);
// map/create session context
req.getSession(true);
if (auth != null) {
contextProvider.mapContext(auth.getUser(), true);
log.debug("SessionContext: " + SessionContext.current());
}
httpManager.process(request, response);
log.debug("Request: " + Request.Header.ACCEPT_ENCODING.code + ": " + request.getHeaders().get(Request.Header.ACCEPT_ENCODING.code) + " --> Response: " + Response.Header.CONTENT_ENCODING.code + ": " + response.getHeaders().get(Response.Header.CONTENT_ENCODING.code));
log.debug("Response: " + response.getStatus());
} finally {
if (contextProvider.currentContext() != null) {
contextProvider.unmapContext();
}
threadRequest.set(null);
threadResponse.set(null);
servletResponse.getOutputStream().flush();
servletResponse.flushBuffer();
}
log.info("WebDAV request: " + timer.elapsedTime() + "ms");
}
use of org.polymap.core.runtime.session.DefaultSessionContextProvider in project polymap4-core by Polymap4.
the class FsPlugin method start.
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
// init cacheDir
cacheDir = new File(CorePlugin.getDataLocation(this), "cache");
log.info("Cleaning cache dir: " + cacheDir.getAbsolutePath() + " ...");
FileUtils.deleteDirectory(cacheDir);
cacheDir.mkdirs();
// register session context provider
this.sessionContextProvider = new DefaultSessionContextProvider();
SessionContext.addProvider(sessionContextProvider);
// // start WorkbenchState listener
// log.info( "Starting " + WorkbenchState.class.getSimpleName() + " listener ..." );
// WorkbenchState.startup();
}
Aggregations