* @see javax.servlet.Servlet#service(javax.servlet.ServletRequest,
* javax.servlet.ServletResponse)
*/
public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
HttpServletRequest req = (HttpServletRequest) request;
HttpServletResponse res = (HttpServletResponse) response;
debugRequest(req);
DAVTransaction transaction = null;
try {
transaction = new DAVTransaction(req, res);
DAVProcessor processor = null;
try {
processor = DAVServlet.getDAVProcessor(req);
} catch (CoreException e) {
ActionMessages mesgs = (ActionMessages) request.getAttribute(Globals.ERROR_KEY);
if (mesgs == null) {
mesgs = new ActionMessages();
request.setAttribute(Globals.ERROR_KEY, mesgs);
}
mesgs.add(Globals.MESSAGE_KEY, e.getBundleActionMessage());
return;
} catch (Exception e1) {
throw new IOException(e1.getMessage());
}
/**
* LDP - JB I have removed the authentication code here and instead
* placed in DAVTransaction. This allows the transaction to
* correctly obtain sessionInfo through WEBDav.
*/
/* Mark our presence */
res.setHeader("Server", this.context.getServerInfo() + " WebDAV");
res.setHeader("MS-Author-Via", "DAV");
res.setHeader("DAV", "1");
/*
* Get the current SessionInfo if possible, but do not request
* authentication yet This is because the VFSResource that we want
* is in a mount that does not require Adito authentication
* (required for some ActiveX and Applet extensions).
*
* SessionInfo will be null if session can yet be determined
*/
if (!transaction.attemptToAuthorize()) {
return;
}
SessionInfo sessionInfo = transaction.getSessionInfo();
// Timeout block is not needed if we have no session
int timeoutId = sessionInfo == null ? -1 : LogonControllerFactory.getInstance().addSessionTimeoutBlock(
transaction.getSessionInfo().getHttpSession(), "DAV Transaction");
;
try {
processor.process(transaction);
} catch (DAVAuthenticationRequiredException dare) {
/*
* If the session is temporary, then we are probably dealing
* with a client that doesn't support cookies. This means that
* secondary authentication that may be required for some mounts
* won't work as we cannot have two different sets of
* credentials without session tracking
*/
if (sessionInfo != null && sessionInfo.isTemporary()) {
throw new IOException("Mount requires further authentication. This cannot work "
+ "on WebDAV clients that do not support cookies.");
} else {
throw dare;
}
} finally {
if (timeoutId != -1)
LogonControllerFactory.getInstance().removeSessionTimeoutBlock(transaction.getSessionInfo().getHttpSession(),
timeoutId);
}
} catch (DAVRedirection redir) {
String redirPath = "/fs" + redir.getLocation().getFullPath();
req.getRequestDispatcher(redirPath).forward(req, res);
} catch (DAVAuthenticationRequiredException e) {
// We need to be able to authenticate the Adito session was
// well
// sendAuthorizationError(req, res, e.getMount().getMountString());
sendAuthorizationError(req, res, e.getHttpRealm());
} catch (DAVBundleActionMessageException ex) {
log.error("Network Places Request Failed: " + req.getPathInfo(), ex);
BundleActionMessage bam = ex.getBundleActionMessage();
MessageResources mr = CoreUtil.getMessageResources(req.getSession(), bam.getBundle());
// TODO locale
String val = mr == null ? null : mr.getMessage(bam.getKey());
res.sendError(DAVStatus.SC_INTERNAL_SERVER_ERROR, val == null ? (ex.getMessage() == null ? "No message supplied." : ex
.getMessage()) : val);
} catch (DAVException ex) {
res.setStatus(ex.getStatus());
} catch (LockedException ex) {
res.sendError(DAVStatus.SC_LOCKED, ex.getMessage());
} catch (Throwable t) {
log.error("Network Places Request Failed: " + req.getPathInfo(), t);
res.sendError(DAVStatus.SC_INTERNAL_SERVER_ERROR, t.getMessage() == null ? "<null>" : t.getMessage());
} finally {
if (transaction != null && transaction.getSessionInfo() != null && transaction.getSessionInfo().isTemporary()) {
transaction.getSessionInfo().getHttpSession().invalidate();
}
}