You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by ju...@apache.org on 2002/04/03 13:57:31 UTC

cvs commit: jakarta-slide/src/webdav/server/org/apache/slide/webdav/util VersioningHelper.java

juergen     02/04/03 03:57:31

  Modified:    src/webdav/server/org/apache/slide/webdav/util
                        VersioningHelper.java
  Log:
  PreconditionViolationException now also provides the URI of the resource that caused it.
  Added static methods retrieveRevisionDescriptors() and retrieveLatestRevisionDescriptor() for usage outside of WebdavMethods (where no servlet request and response is available).
  (ralf)
  
  Revision  Changes    Path
  1.16      +79 -33    jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/VersioningHelper.java
  
  Index: VersioningHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/VersioningHelper.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- VersioningHelper.java	28 Mar 2002 06:12:13 -0000	1.15
  +++ VersioningHelper.java	3 Apr 2002 11:57:31 -0000	1.16
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/VersioningHelper.java,v 1.15 2002/03/28 06:12:13 jericho Exp $
  - * $Revision: 1.15 $
  - * $Date: 2002/03/28 06:12:13 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/VersioningHelper.java,v 1.16 2002/04/03 11:57:31 juergen Exp $
  + * $Revision: 1.16 $
  + * $Date: 2002/04/03 11:57:31 $
    *
    * ====================================================================
    *
  @@ -170,15 +170,7 @@
       public NodeRevisionDescriptors
       retrieveRevisionDescriptors( String resourcePath ) throws SlideException {
           
  -        NodeRevisionDescriptors rNrds = null;
  -        UriHandler rUh = UriHandler.getUriHandler( nsaToken, resourcePath );
  -        
  -        if( rUh.isVersionUri() )
  -            rNrds = content.retrieve( sToken, rUh.getAssociatedHistoryUri() );
  -        else
  -            rNrds = content.retrieve( sToken, resourcePath );
  -        
  -        return rNrds;
  +        return retrieveRevisionDescriptors(nsaToken, sToken, content, resourcePath);
       }
       
       /**
  @@ -188,22 +180,7 @@
       public NodeRevisionDescriptor
       retrieveLatestRevisionDescriptor( String resourcePath, NodeRevisionDescriptors rNrds ) throws SlideException {
           
  -        NodeRevisionDescriptor rNrd = null;
  -        UriHandler rUh = UriHandler.getUriHandler( nsaToken, resourcePath );
  -        
  -        if( rUh.isHistoryUri() ) {
  -            rNrd = content.retrieve( sToken, rNrds,
  -                                 new NodeRevisionNumber(0, 0) );
  -        }
  -        else if( rUh.isVersionUri() ) {
  -            rNrd = content.retrieve( sToken, rNrds,
  -                                 new NodeRevisionNumber(rUh.getVersionName()) );
  -        }
  -        else {
  -            rNrd = content.retrieve( sToken, rNrds );
  -        }
  -        
  -        return rNrd;
  +        return retrieveLatestRevisionDescriptor(nsaToken, sToken, content, resourcePath, rNrds);
       }
       
       /**
  @@ -335,7 +312,7 @@
           if( !rRk.isSupportedMethod(req.getMethod()) ) {
               // check precondition C_MUST_BE_CHECKED_IN
               if( rRk instanceof CheckedOut ) {
  -                throw new PreconditionViolationException(new ViolatedPrecondition(C_MUST_BE_CHECKED_IN, WebdavStatus.SC_CONFLICT));
  +                throw new PreconditionViolationException(new ViolatedPrecondition(C_MUST_BE_CHECKED_IN, WebdavStatus.SC_CONFLICT), rNrds.getUri());
               }
               resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
               return;
  @@ -354,7 +331,7 @@
               
               ViolatedPrecondition violatedPrecondition = getCheckoutPreconditionViolation(cinNrds, cinNrd, forkOk);
               if (violatedPrecondition != null) {
  -                throw new PreconditionViolationException(violatedPrecondition);
  +                throw new PreconditionViolationException(violatedPrecondition, rNrds.getUri());
               }
               
               NodeRevisionDescriptors vhrNrds = content.retrieve(sToken, cinUri);
  @@ -471,7 +448,9 @@
           
           // check precondition C_MUST_BE_CHECKED_OUT_VERSION_CONTROLLED_RESOURCE
           if ( ! (rRk instanceof CheckedOutVersionControlled) ) {
  -            throw new PreconditionViolationException(new ViolatedPrecondition(C_MUST_BE_CHECKED_OUT_VERSION_CONTROLLED_RESOURCE, WebdavStatus.SC_CONFLICT));
  +            throw new PreconditionViolationException(new ViolatedPrecondition(C_MUST_BE_CHECKED_OUT_VERSION_CONTROLLED_RESOURCE,
  +                                                                              WebdavStatus.SC_CONFLICT),
  +                                                     rNrds.getUri());
           }
           
           if( !rRk.isSupportedMethod(req.getMethod()) ) {
  @@ -532,7 +511,9 @@
           if( !rRk.isSupportedMethod(req.getMethod()) ) {
               // check precondition C_MUST_BE_CHECKED_OUT
               if( !(rRk instanceof CheckedOut) ) {
  -                throw new PreconditionViolationException(new ViolatedPrecondition(C_MUST_BE_CHECKED_OUT, WebdavStatus.SC_CONFLICT));
  +                throw new PreconditionViolationException(new ViolatedPrecondition(C_MUST_BE_CHECKED_OUT,
  +                                                                                  WebdavStatus.SC_CONFLICT),
  +                                                         rNrds.getUri());
               }
               resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
               return;
  @@ -557,7 +538,7 @@
               
               ViolatedPrecondition violatedPrecondition = getCheckinPreconditionViolation(predSetProp, vhrNrds, forkOk);
               if (violatedPrecondition != null) {
  -                throw new PreconditionViolationException(violatedPrecondition);
  +                throw new PreconditionViolationException(violatedPrecondition, rNrds.getUri());
               }
               
               // update <checkout-set>
  @@ -832,6 +813,71 @@
               saxBuilder = new SAXBuilder();
           }
           return saxBuilder;
  +    }
  +    
  +    /**
  +     * Retrieve the DeltaV-compliant NRDS instance for the specified resource path.
  +     *
  +     * @param      nsaToken      the NamespaceAccessToken to use.
  +     * @param      sToken        the SlideToken to use.
  +     * @param      content       the Content helper to use.
  +     * @param      resourcePath  the path of the resource for which to retrieve
  +     *                           the NRDS.
  +     *
  +     * @return     the DeltaV-compliant NRDS instance for the specified resource path.
  +     */
  +    public static NodeRevisionDescriptors retrieveRevisionDescriptors(NamespaceAccessToken nsaToken,
  +                                                                      SlideToken sToken,
  +                                                                      Content content,
  +                                                                      String resourcePath ) throws SlideException {
  +        
  +        NodeRevisionDescriptors rNrds = null;
  +        UriHandler rUh = UriHandler.getUriHandler( nsaToken, resourcePath );
  +        
  +        if( rUh.isVersionUri() )
  +            rNrds = content.retrieve( sToken, rUh.getAssociatedHistoryUri() );
  +        else
  +            rNrds = content.retrieve( sToken, resourcePath );
  +        
  +        return rNrds;
  +    }
  +    
  +    /**
  +     * Retrieve the latest DeltaV-compliant NRD instance for the specified
  +     * resource path and associated to the specified NRDS instance.
  +     *
  +     * @param      nsaToken      the NamespaceAccessToken to use.
  +     * @param      sToken        the SlideToken to use.
  +     * @param      content       the Content helper to use.
  +     * @param      resourcePath  the path of the resource for which to retrieve
  +     *                           the NRD.
  +     * @param      rNrds         the NodeRevisionDescriptors of the resource.
  +     *
  +     * @return     the latest DeltaV-compliant NRD instance for the specified
  +     *             resource path and associated to the specified NRDS instance.
  +     */
  +    public static NodeRevisionDescriptor retrieveLatestRevisionDescriptor(NamespaceAccessToken nsaToken,
  +                                                                          SlideToken sToken,
  +                                                                          Content content,
  +                                                                          String resourcePath,
  +                                                                          NodeRevisionDescriptors rNrds) throws SlideException {
  +        
  +        NodeRevisionDescriptor rNrd = null;
  +        UriHandler rUh = UriHandler.getUriHandler( nsaToken, resourcePath );
  +        
  +        if( rUh.isHistoryUri() ) {
  +            rNrd = content.retrieve( sToken, rNrds,
  +                                    new NodeRevisionNumber(0, 0) );
  +        }
  +        else if( rUh.isVersionUri() ) {
  +            rNrd = content.retrieve( sToken, rNrds,
  +                                    new NodeRevisionNumber(rUh.getVersionName()) );
  +        }
  +        else {
  +            rNrd = content.retrieve( sToken, rNrds );
  +        }
  +        
  +        return rNrd;
       }
       
       /**
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>