/**
   * @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest,
   *     javax.servlet.http.HttpServletResponse)
   */
  protected void service(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    if (!initParams.getEnabled()) {
      response.sendError(HttpServletResponse.SC_NOT_FOUND);
      return;
    }

    long startTime = 0;
    if (logger.isTraceEnabled()) {
      startTime = System.currentTimeMillis();
    }

    FileFilterMode.setClient(Client.webdav);

    try {
      // Create the appropriate WebDAV method for the request and execute it
      final WebDAVMethod method = createMethod(request, response);

      if (method == null) {
        if (logger.isErrorEnabled())
          logger.error("WebDAV method not implemented - " + request.getMethod());

        // Return an error status

        response.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED);
        return;
      } else if (method.getRootNodeRef() == null) {
        if (logger.isDebugEnabled()) {
          logger.debug(
              "No root node for request ["
                  + request.getMethod()
                  + " "
                  + request.getRequestURI()
                  + "]");
        }

        // Return an error status
        response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        return;
      }

      // Execute the WebDAV request, which must take care of its own transaction
      method.execute();
    } catch (Throwable e) {
      ExceptionHandler exHandler = new ExceptionHandler(e, request, response);
      exHandler.handle();
    } finally {
      if (logger.isTraceEnabled()) {
        logger.trace(
            request.getMethod()
                + " took "
                + (System.currentTimeMillis() - startTime)
                + "ms to execute ["
                + request.getRequestURI()
                + "]");
      }

      FileFilterMode.clearClient();
    }
  }
 @Override
 public SearchContext startSearch(
     SrvSession sess, TreeConnection tree, String searchPath, int attrib)
     throws FileNotFoundException {
   FileFilterMode.setClient(ClientHelper.getClient(sess));
   try {
     SearchContext context = diskInterface.startSearch(sess, tree, searchPath, attrib);
     return context;
   } finally {
     FileFilterMode.clearClient();
   }
 }
 @Override
 public FileInfo getFileInformation(SrvSession sess, TreeConnection tree, String path)
     throws IOException {
   if (logger.isDebugEnabled()) {
     logger.debug("getFileInformation:" + path);
   }
   FileFilterMode.setClient(ClientHelper.getClient(sess));
   try {
     FileInfo info = diskInterface.getFileInformation(sess, tree, path);
     return info;
   } finally {
     FileFilterMode.clearClient();
   }
 }
 @Override
 public void createDirectory(SrvSession sess, TreeConnection tree, FileOpenParams params)
     throws IOException {
   try {
     FileFilterMode.setClient(ClientHelper.getClient(sess));
     try {
       diskInterface.createDirectory(sess, tree, params);
     } finally {
       FileFilterMode.clearClient();
     }
   } catch (org.alfresco.repo.security.permissions.AccessDeniedException ade) {
     throw new AccessDeniedException("Unable to create directory " + params.getPath(), ade);
   }
 }