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 pn...@apache.org on 2002/02/26 12:56:21 UTC

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

pnever      02/02/26 03:56:21

  Modified:    src/webdav/server/org/apache/slide/webdav/util
                        UriHandler.java
  Log:
  Refactoring: splitted out HistoryPathHandler
  
  Revision  Changes    Path
  1.3       +24 -36    jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/UriHandler.java
  
  Index: UriHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/UriHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- UriHandler.java	22 Feb 2002 17:41:06 -0000	1.2
  +++ UriHandler.java	26 Feb 2002 11:56:21 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/UriHandler.java,v 1.2 2002/02/22 17:41:06 pnever Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/02/22 17:41:06 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/UriHandler.java,v 1.3 2002/02/26 11:56:21 pnever Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/02/26 11:56:21 $
    *
    * ====================================================================
    *
  @@ -80,61 +80,48 @@
   import org.apache.slide.security.AccessDeniedException;
   
   
  -
  -public class UriHandler implements DeltavConstants {
  -    
  -    // Cache for history path handlers:
  -    // namespace_name -> URI_handler_for_history_path
  -    private static Map hpathHandlers = new HashMap();
  -
       /**
  -     * Return the history path handler for the specified namespace.
  + * Helper class for the handling of URIs
        */
  -    public static UriHandler
  -    getHistoryPathHandler( NamespaceAccessToken nsaToken ) {
  +public class UriHandler implements DeltavConstants, AclConstants, DaslConstants {
           
  -        String nsName = nsaToken.getName();
  -        UriHandler result = (UriHandler)hpathHandlers.get( nsName );
  -        
  -        if( result == null ) {
  -        String hpath = nsaToken.getNamespaceConfig().getHistoryPath();
  -            result = new UriHandler( nsName, hpath );
  -            hpathHandlers.put( nsName, result );
  -        }
  -        return result;
  -    }
  +    // Cache for history path handlers:
  +    // namespace_name -> URI_handler_for_history_path
  +    protected static Map hpathHandlers = new HashMap();
           
       /**
  -     * Return an URI handler for the specified namespace and resource path.
  +     * Factory method.
        */
       public static UriHandler
       getUriHandler( NamespaceAccessToken nsaToken, String resourcePath ) {
           
           String nsName = nsaToken.getName();
  -        UriHandler hpathHandler = getHistoryPathHandler( nsaToken );
  +        UriHandler hpathHandler =
  +            HistoryPathHandler.getHistoryPathHandler( nsaToken );
           return new UriHandler( nsName, resourcePath );
           }
   
       /**
  -     * Return an URI handler for the specified namespace and resource path.
  +     * Generates the next available history URI and returns an URI handler for it.
        */
       public static UriHandler
  -    createNextHistoryUri( SlideToken slideToken, NamespaceAccessToken nsaToken )
  +    createNextHistoryUri( SlideToken sToken, NamespaceAccessToken nsaToken )
       throws ObjectNotFoundException, AccessDeniedException, ObjectLockedException,
       LinkedObjectNotFoundException, ServiceAccessException,
       RevisionDescriptorNotFoundException, RevisionNotFoundException {
           
           UriHandler result = null;
           String nsName = nsaToken.getName();
  -        UriHandler hpathHandler = getHistoryPathHandler( nsaToken );
  +        UriHandler hpathHandler =
  +            HistoryPathHandler.getHistoryPathHandler( nsaToken );
           Content content = nsaToken.getContentHelper();
           String hpath = hpathHandler.toString();
           
           NodeRevisionDescriptors hpathNrds =
  -            content.retrieve( slideToken, hpath );
  +            content.retrieve( sToken, hpath );
           
           NodeRevisionDescriptor hpathNrd =
  -            content.retrieve( slideToken, hpathNrds );
  +            content.retrieve( sToken, hpathNrds );
           
           NodeProperty nextHnProp = hpathNrd.getProperty( I_NEXT_HISTORY_NAME );
           if( nextHnProp == null || nextHnProp.getValue() == null ) {
  @@ -152,13 +139,14 @@
               I_NEXT_HISTORY_NAME, String.valueOf(nextHnLong + 1) );
           hpathNrd.setProperty( nextHnProp );
           
  -        content.store( slideToken, hpath, hpathNrd, null ); //revisionContent = null
  +        content.store( sToken, hpath, hpathNrd, null ); //revisionContent = null
                         
           return result;
       }
       
       /**
  -     *
  +     * Creates a VR URI for the specified version in the specified history and
  +     * returns an URI handler for it.
        */
       public static UriHandler
       createVersionUri( NamespaceAccessToken nsaToken, UriHandler vhrUri, String version ) {
  @@ -172,9 +160,9 @@
       
       
       /**
  -     * Default constructor
  +     * Protected constructor
        */
  -    private UriHandler( String nsName, String uri ) {
  +    protected UriHandler( String nsName, String uri ) {
           this.uri = uri;
           this.nsName = nsName;
           
  @@ -186,9 +174,9 @@
       }
       
       /**
  -     * Version URI constructor
  +     * Protected constructor for VR URIs
        */
  -    private UriHandler( String nsName, UriHandler vhrUri, String versionName ) {
  +    protected UriHandler( String nsName, UriHandler vhrUri, String versionName ) {
           this.nsName = nsName;
           int n = vhrUri.getUriTokens().length;
           this.uriTokens = new String[n + 1];
  
  
  

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