archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/RepositoryServlet.java
/**
     * Service the given request. This method has been overridden and copy/pasted to allow better exception handling and
     * to support different realms
     *
     * @param request
     * @param response
     * @throws ServletException
     * @throws java.io.IOException
     */
Service the given request. This method has been overridden and copy/pasted to allow better exception handling and
to support different realms

@param request
@param response
@throws ServletException
@throws java.io.IOException
Service the given request . This method has been overridden and copy / pasted to allow better exception handling and to support different realms @param request @param response @throws ServletException @throws java . io . IOException
@Override
    protected void service( HttpServletRequest request, HttpServletResponse response )
        throws ServletException, IOException
    {
        WebdavRequest webdavRequest = new WebdavRequestImpl( request, getLocatorFactory() );
        int methodCode = DavMethods.getMethodCode( request.getMethod() );
        boolean noCache = DavMethods.isDeltaVMethod( webdavRequest ) && !( DavMethods.DAV_VERSION_CONTROL == methodCode
            || DavMethods.DAV_REPORT == methodCode );
        WebdavResponse webdavResponse = new WebdavResponseImpl( response, noCache );
        DavResource resource = null;
        try
        {
            if ( !getDavSessionProvider().attachSession( webdavRequest ) )
            {
                return;
            }
            resource =
                getResourceFactory().createResource( webdavRequest.getRequestLocator(), webdavRequest, webdavResponse );
            if ( !isPreconditionValid( webdavRequest, resource ) )
            {
                webdavResponse.sendError( DavServletResponse.SC_PRECONDITION_FAILED );
                return;
            }
            if ( !execute( webdavRequest, webdavResponse, methodCode, resource ) )
            {
                super.service( request, response );
            }
        }
        catch ( UnauthorizedDavException e )
        {
            webdavResponse.setHeader( "WWW-Authenticate", getAuthenticateHeaderValue( e.getRepositoryName() ) );
            webdavResponse.sendError( e.getErrorCode(), e.getStatusPhrase() );
        }
        catch ( BrowserRedirectException e )
        {
            response.sendRedirect( e.getLocation() );
        }
        catch ( DavException e )
        {
            if ( e.getErrorCode() == HttpServletResponse.SC_UNAUTHORIZED )
            {
                final String msg = "Should throw " + UnauthorizedDavException.class.getName();
                log.error( msg );
                webdavResponse.sendError( e.getErrorCode(), msg );
            }
            else if ( e.getCause() != null )
            {
                webdavResponse.sendError( e.getErrorCode(), e.getCause().getMessage() );
            }
            else
            {
                webdavResponse.sendError( e.getErrorCode(), e.getMessage() );
            }
        }
        finally
        {
            getDavSessionProvider().releaseSession( webdavRequest );
        }
    }
@ Override protected void service ( HttpServletRequest request , HttpServletResponse response ) throws ServletException , IOException { WebdavRequest webdavRequest = new WebdavRequestImpl ( request , getLocatorFactory ( ) ) ; int methodCode = DavMethods . getMethodCode ( request . getMethod ( ) ) ; boolean noCache = DavMethods . isDeltaVMethod ( webdavRequest ) && ! ( DavMethods . DAV_VERSION_CONTROL == methodCode || DavMethods . DAV_REPORT == methodCode ) ; WebdavResponse webdavResponse = new WebdavResponseImpl ( response , noCache ) ; DavResource resource = null ; try { if ( ! getDavSessionProvider ( ) . attachSession ( webdavRequest ) ) { return ; } resource = getResourceFactory ( ) . createResource ( webdavRequest . getRequestLocator ( ) , webdavRequest , webdavResponse ) ; if ( ! isPreconditionValid ( webdavRequest , resource ) ) { webdavResponse . sendError ( DavServletResponse . SC_PRECONDITION_FAILED ) ; return ; } if ( ! execute ( webdavRequest , webdavResponse , methodCode , resource ) ) { super . service ( request , response ) ; } } catch ( UnauthorizedDavException e ) { webdavResponse . setHeader ( "WWW-Authenticate" , getAuthenticateHeaderValue ( e . getRepositoryName ( ) ) ) ; webdavResponse . sendError ( e . getErrorCode ( ) , e . getStatusPhrase ( ) ) ; } catch ( BrowserRedirectException e ) { response . sendRedirect ( e . getLocation ( ) ) ; } catch ( DavException e ) { if ( e . getErrorCode ( ) == HttpServletResponse . SC_UNAUTHORIZED ) { final String msg = "Should throw " + UnauthorizedDavException . class . getName ( ) ; log . error ( msg ) ; webdavResponse . sendError ( e . getErrorCode ( ) , msg ) ; } else if ( e . getCause ( ) != null ) { webdavResponse . sendError ( e . getErrorCode ( ) , e . getCause ( ) . getMessage ( ) ) ; } else { webdavResponse . sendError ( e . getErrorCode ( ) , e . getMessage ( ) ) ; } } finally { getDavSessionProvider ( ) . releaseSession ( webdavRequest ) ; } }
Service the given request.
Service the given request .
// DeltaV requires 'Cache-Control' header for all methods except 'VERSION-CONTROL' and 'REPORT'. // make sure there is a authenticated user // check matching if=header for lock-token relevant operations