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 2003/08/18 08:59:12 UTC

cvs commit: jakarta-slide/src/webdav/server/org/apache/slide/webdav/method PropFindMethod.java ReportMethod.java SearchMethod.java

pnever      2003/08/17 23:59:12

  Modified:    src/webdav/server/org/apache/slide/webdav/method
                        PropFindMethod.java ReportMethod.java
                        SearchMethod.java
  Log:
  Init-parameter extendedAllprop and prepared for binding
  
  Revision  Changes    Path
  1.90      +117 -115  jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java
  
  Index: PropFindMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java,v
  retrieving revision 1.89
  retrieving revision 1.90
  diff -u -r1.89 -r1.90
  --- PropFindMethod.java	21 May 2003 15:49:46 -0000	1.89
  +++ PropFindMethod.java	18 Aug 2003 06:59:12 -0000	1.90
  @@ -109,90 +109,90 @@
    * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
    */
   public class PropFindMethod extends AbstractWebdavMethod implements DeltavConstants, AclConstants {
  -
  -
  +    
  +    
       // -------------------------------------------------------------- Constants
  -
  -
  -
  +    
  +    
  +    
       /**
        * Default depth is infite.
        */
       protected static final int INFINITY = Integer.MAX_VALUE;
  -
  -
  +    
  +    
       /**
        * Specify a property mask.
        */
       protected static final int FIND_BY_PROPERTY = 0;
  -
  -
  +    
  +    
       /**
        * Display all properties.
        */
       protected static final int FIND_ALL_PROP = 1;
  -
  -
  +    
  +    
       /**
        * Return property names.
        */
       protected static final int FIND_PROPERTY_NAMES = 2;
  -
  +    
       // ----------------------------------------------------- Instance Variables
  -
  -
  +    
  +    
       /**
        * Depth.
        */
       protected int depth;
  -
  -
  +    
  +    
       /**
        * Type of the PROPFIND method.
        */
       protected int propFindType;
  -
  +    
       /** if true, an ALL_PROP request will include computed props */
  -    protected boolean allpropIncludesDeltav = false;
  -
  -
  -
  +    protected boolean extendedAllprop = false;
  +    
  +    
  +    
       /**
        ** The SAXBuilder used to create JDOM Documents.
        **/
       protected static SAXBuilder saxBuilder = null;
  -
  +    
       /**
        * The list of requested properties.
        */
       protected RequestedProperties requestedProperties = null;
  -
  -
  +    
  +    
       /**
        * Resource to be retrieved.
        */
       protected String resourcePath;
  -
  +    
       /**
        * The VersioningHelper used by this instance.
        */
       protected VersioningHelper versioningHelper = null;
  -
  +    
       /**
        * The value of the <code>Label</code> header.
        */
       protected String labelHeader = null;
  -
  +    
       /**
        * If set <code>true</code>, instead of creating the complete response document
        * in memory and then sending it to the client, available parts of the response
        * are send immediatly in order to reduce the memory footprint.
        */
       protected boolean outputOptimized = true;
  -
  +    
       // ----------------------------------------------------------- Constructors
  -
  -
  +    
  +    
       /**
        * Constructor.
        *
  @@ -203,45 +203,45 @@
                             WebdavServletConfig config) {
           super(token, config);
       }
  -
  -
  +    
  +    
       // ------------------------------------------------------ Protected Methods
  -
  -
  +    
  +    
       /**
        * Parse the request.
        *
        * @exception WebdavException Bad request
        */
       protected void parseRequest() throws WebdavException {
  -
  +        
           versioningHelper =  VersioningHelper.getVersioningHelper(
               slideToken, token, req, resp, getConfig() );
           readRequestContent();
  -
  +        
           depth = INFINITY;
           propFindType = FIND_ALL_PROP;
  -        allpropIncludesDeltav = getBooleanInitParameter( "allpropIncludesDeltav" );
  +        extendedAllprop = getBooleanInitParameter( "extendedAllprop" );
           outputOptimized = getBooleanInitParameter( "optimizePropfindOutput" );
  -
  +        
           resourcePath = requestUri;
           if (resourcePath == null) {
               resourcePath = "/";
           }
  -
  +        
           labelHeader = WebdavUtils.fixTomcatHeader(req.getHeader(DeltavConstants.H_LABEL), "UTF-8");
  -
  +        
           retrieveDepth();
  -
  +        
           if (req.getContentLength() == 0) {
               requestedProperties = new RequestedPropertiesImpl();
               requestedProperties.setIsAllProp(true);
               propFindType = FIND_ALL_PROP;
           }
           else {
  -
  +            
               try {
  -
  +                
                   Element element = parseRequestContent(E_PROPFIND);
                   try {
                       element = (Element)element.getChildren().get(0);
  @@ -251,7 +251,7 @@
                       sendError( statusCode, getClass().getName()+".missingRootElementChildren", new Object[]{"DAV:"+E_PROPFIND} );
                       throw new WebdavException( statusCode );
                   }
  -
  +                
                   if (element.getName().equalsIgnoreCase(E_PROPNAME)){
                       propFindType = FIND_PROPERTY_NAMES;
                   }
  @@ -268,7 +268,7 @@
                       sendError( statusCode, getClass().getName()+".invalidChildOfRootElement", new Object[]{element.getNamespace()+":"+element.getName(),"DAV:"+E_PROPFIND} );
                       throw new WebdavException( statusCode );
                   }
  -
  +                
               }
               catch (JDOMException  e){
                   int statusCode = WebdavStatus.SC_BAD_REQUEST;
  @@ -287,12 +287,12 @@
               }
           }
       }
  -
  +    
       /**
        * Retrieves the <code>Depth</code> header from the request.
        */
       private void retrieveDepth() {
  -
  +        
           String depthStr = req.getHeader("Depth");
           if (depthStr == null) {
               depth = INFINITY;
  @@ -312,29 +312,29 @@
                   depth = INFINITY;
               }
           }
  -
  +        
           // limit tree browsing a bit
           if (depth > getConfig().getDepthLimit()) {
               depth = getConfig().getDepthLimit();
           }
       }
  -
  -
  -
  +    
  +    
  +    
       /**
        * Execute the request.
        *
        * @exception WebdavException
        */
       protected void executeRequest() throws IOException, WebdavException {
  -
  +        
           resp.setStatus(WebdavStatus.SC_MULTI_STATUS);
  -
  +        
           // Loads the associated object from the store.
  -
  +        
           // Get the object from Data.
           ObjectNode resource = null;
  -
  +        
           try {
               resource = structure.retrieve(slideToken, resourcePath);
           } catch (StructureException e) {
  @@ -346,13 +346,13 @@
               sendError( statusCode, e );
               throw new WebdavException( statusCode );
           }
  -
  +        
           resp.setContentType(TEXT_XML_UTF_8);
  -
  +        
           // Create multistatus object
           Element multistatusElement = new Element(E_MULTISTATUS, NamespaceCache.DEFAULT_NAMESPACE);
           XMLOutputter xmlOutputter = new XMLOutputter(XML_REPONSE_INDENT, true);
  -
  +        
           if (resource != null) {
               if (depth == 0) {
                   multistatusElement.addContent(getPropertiesOfObject(resource.getUri()));
  @@ -361,13 +361,13 @@
                   // The stack always contains the object of the current level
                   Stack stack = new Stack();
                   stack.push(resource);
  -
  +                
                   // Stack of the objects one level below
                   Stack stackBelow = new Stack();
  -
  +                
                   StringBuffer buffer = new StringBuffer();
                   if (outputOptimized) {
  -
  +                    
                       resp.getWriter().write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                       resp.getWriter().write("\n");
                       String namespacePrefix = multistatusElement.getNamespacePrefix();
  @@ -394,9 +394,9 @@
                       resp.getWriter().write(buffer.toString());
                       resp.getWriter().write("\n");
                   }
  -
  +                
                   while ((!stack.isEmpty()) && (depth >= 0)) {
  -
  +                    
                       ObjectNode cur = (ObjectNode) stack.pop();
                       Element response = getPropertiesOfObject(cur.getUri());
                       if (outputOptimized) {
  @@ -405,11 +405,11 @@
                       else {
                           multistatusElement.addContent(response);
                       }
  -
  +                    
                       if (depth > 0) {
  -
  +                        
                           Enumeration enum = null;
  -
  +                        
                           try {
                               enum = structure.getChildren(slideToken, cur);
                           } catch (Exception e) {
  @@ -417,21 +417,21 @@
                               sendError( statusCode, e );
                               throw new WebdavException( statusCode );
                           }
  -
  +                        
                           while (enum.hasMoreElements()) {
                               stackBelow.push(enum.nextElement());
                           }
  -
  +                        
                       }
  -
  +                    
                       if (stack.isEmpty()) {
                           depth--;
                           stack = stackBelow;
                           stackBelow = new Stack();
                       }
  -
  +                    
                   }
  -
  +                
                   if (outputOptimized) {
                       resp.getWriter().write("\n");
                       buffer.setLength(0);
  @@ -446,10 +446,10 @@
                   }
               }
           }
  -
  +        
       }
  -
  -
  +    
  +    
       /**
        * Return the properties of an object as a <code>&lt;response&gt;</code>.
        *
  @@ -461,7 +461,7 @@
        */
       protected Element getPropertiesOfObject(String resourceUri)
           throws WebdavException {
  -
  +        
           // evaluate "Label" header
           if (Configuration.useVersionControl()) {
               try {
  @@ -478,7 +478,7 @@
                   return getErrorResponse(resourceUri, getErrorCode(e), null);
               }
           }
  -
  +        
           ObjectNode object = null;
           try {
               object = structure.retrieve(slideToken, resourceUri);
  @@ -486,66 +486,68 @@
           catch (SlideException e) {
               return getErrorResponse(resourceUri, getErrorCode(e), null);
           }
  -
  +        
           Element responseElement = new Element(E_RESPONSE, NamespaceCache.DEFAULT_NAMESPACE);
  -
  +        
           String status = new String(HTTP_VERSION + WebdavStatus.SC_OK + " "
                                          + WebdavStatus.getStatusText
                                          (WebdavStatus.SC_OK));
           NodeRevisionDescriptors revisionDescriptors = null;
           NodeRevisionDescriptor revisionDescriptor = null;
  -
  +        
           boolean isCollection = false;
  -
  +        
           NodeLock objectLockToken = null;
           String serverURL = HTTP_PROTOCOL + req.getServerName()+ ":" + req.getServerPort();
  -
  +        
           try {
               Element hrefElement = new Element(E_HREF, NamespaceCache.DEFAULT_NAMESPACE);
  -
  +            
               VersioningHelper vHelp =  VersioningHelper.getVersioningHelper(
                   slideToken, token, req, resp, getConfig() );
               String resourcePath = object.getUri();
  -
  +            
               revisionDescriptors =
                   content.retrieve(slideToken, resourcePath);
  -
  +            
               try {
                   revisionDescriptor = content.retrieve(slideToken,
                                                         revisionDescriptors);
  -
  +                
                   isCollection = WebdavUtils.isCollection(revisionDescriptor);
  -
  +                
                   hrefElement.setText(
                       WebdavUtils.getAbsolutePath(object.getUri(), req,
                                                   getConfig()));
  -
  +                
               } catch (RevisionDescriptorNotFoundException e) {
  -
  +                
                   // The object doesn't have any revision, we create a dummy
                   // NodeRevisionDescriptor object
                   isCollection = true;
                   revisionDescriptor = new NodeRevisionDescriptor(0);
  -
  -                String resourceName = object.getUri();
  -                int lastSlash = resourceName.lastIndexOf('/');
  -                if (lastSlash != -1)
  -                    resourceName = resourceName.substring(lastSlash + 1);
  -                revisionDescriptor.setName(resourceName);
  -
  +                
  +                if (!Configuration.useBinding(token.getUri(slideToken, object.getUri()).getStore())) {
  +                    String resourceName = object.getUri();
  +                    int lastSlash = resourceName.lastIndexOf('/');
  +                    if (lastSlash != -1)
  +                        resourceName = resourceName.substring(lastSlash + 1);
  +                    revisionDescriptor.setName(resourceName);
  +                }
  +                
                   hrefElement.setText(
                       WebdavUtils.getAbsolutePath(object.getUri(), req,
                                                   getConfig()));
               }
  -
  +            
               responseElement.addContent(hrefElement);
  -
  +            
               Enumeration lockTokens = lock.enumerateLocks(slideToken, object.getUri(), true);
  -
  +            
               if (lockTokens.hasMoreElements()) {
                   objectLockToken = (NodeLock) lockTokens.nextElement();
               }
  -
  +            
           } catch (AccessDeniedException e) {
               if (revisionDescriptor == null) {
                   revisionDescriptor = new NodeRevisionDescriptor(0);
  @@ -554,15 +556,15 @@
               e.printStackTrace();
               responseElement = getErrorResponse(object.getUri(), getErrorCode(e), null);
           }
  -
  +        
           Vector propertiesParser = null;
  -
  +        
           switch (propFindType) {
               case FIND_ALL_PROP :
               case FIND_BY_PROPERTY :
                   try {
                       PropertyRetriever propertyRetriever = new PropertyRetrieverImpl(token, slideToken, getConfig());
  -                    List propstatList= propertyRetriever.getPropertiesOfObject(requestedProperties, revisionDescriptors, revisionDescriptor, req.getContextPath(), serverURL, allpropIncludesDeltav);
  +                    List propstatList= propertyRetriever.getPropertiesOfObject(requestedProperties, revisionDescriptors, revisionDescriptor, req.getContextPath(), serverURL, extendedAllprop);
                       Iterator iterator = propstatList.iterator();
                       while (iterator.hasNext()) {
                           responseElement.addContent((Element)iterator.next());
  @@ -581,10 +583,10 @@
                   status = new String("HTTP/1.1 " + WebdavStatus.SC_OK
                                           + " " + WebdavStatus.getStatusText
                                           (WebdavStatus.SC_OK));
  -
  +                
                   Element propstatElement = new Element(E_PROPSTAT, NamespaceCache.DEFAULT_NAMESPACE);
                   responseElement.addContent(propstatElement);
  -
  +                
                   // add the live properties
                   ResourceKind resourceKind = AbstractResourceKind.determineResourceKind(token, object.getUri(), revisionDescriptor);
                   String[] excludedFeatures = new String[0];
  @@ -597,7 +599,7 @@
                       Element propertyElement = new Element(iterator.next().toString(), NamespaceCache.DEFAULT_NAMESPACE);
                       propstatElement.addContent(propertyElement);
                   }
  -
  +                
                   // add this resource's properties
                   Enumeration propertyList = revisionDescriptor.enumerateProperties();
                   while (propertyList.hasMoreElements()) {
  @@ -607,15 +609,15 @@
                                                             NamespaceCache.getNamespace(currentProperty.getNamespace()));
                       propstatElement.addContent(propertyElement);
                   }
  -
  +                
                   Element statusElement = new Element(E_STATUS, NamespaceCache.DEFAULT_NAMESPACE);
                   propstatElement.addContent(statusElement);
                   break;
           }
  -
  +        
           return responseElement;
       }
  -
  +    
       /**
        * Returns the appropriate <code>&lt;response&gt;</code> due to the given
        * <code>exception</code> to the <code>generatedXML</code>
  @@ -626,9 +628,9 @@
        * @param      condition      the condition that has been violated.
        */
       private Element getErrorResponse(String resourcePath, int errorCode, String condition) {
  -
  +        
           Element response = new Element(E_RESPONSE, NamespaceCache.DEFAULT_NAMESPACE);
  -
  +        
           Element href = new Element(E_HREF, NamespaceCache.DEFAULT_NAMESPACE);
           href.setText(HTTP_PROTOCOL +
                            req.getServerName()+ ":" +
  @@ -638,11 +640,11 @@
           response.addContent(href);
           Element propStat = new Element(E_PROPSTAT, NamespaceCache.DEFAULT_NAMESPACE);
           response.addContent(propStat);
  -
  +        
           Element status = new Element(E_STATUS, NamespaceCache.DEFAULT_NAMESPACE);
           status.setText(HTTP_VERSION + " " + errorCode  + " " + WebdavStatus.getStatusText(errorCode));
           propStat.addContent(status);
  -
  +        
           if (condition != null) {
               Element responseDescriptiont = new Element(E_RESPONSEDESCRIPTION, NamespaceCache.DEFAULT_NAMESPACE);
               Element errorElement = new Element(E_ERROR, NamespaceCache.DEFAULT_NAMESPACE);
  
  
  
  1.54      +14 -12    jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/ReportMethod.java
  
  Index: ReportMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/ReportMethod.java,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- ReportMethod.java	5 Aug 2003 08:54:59 -0000	1.53
  +++ ReportMethod.java	18 Aug 2003 06:59:12 -0000	1.54
  @@ -965,11 +965,13 @@
                   // NodeRevisionDescriptor object
                   revisionDescriptor = new NodeRevisionDescriptor(0);
                   
  -                String resourceName = requestUri;
  -                int lastSlash = resourceName.lastIndexOf('/');
  -                if (lastSlash != -1)
  -                    resourceName = resourceName.substring(lastSlash + 1);
  -                revisionDescriptor.setName(resourceName);
  +                if (!Configuration.useBinding(token.getUri(slideToken, requestUri).getStore())) {
  +                    String resourceName = requestUri;
  +                    int lastSlash = resourceName.lastIndexOf('/');
  +                    if (lastSlash != -1)
  +                        resourceName = resourceName.substring(lastSlash + 1);
  +                    revisionDescriptor.setName(resourceName);
  +                }
               }
           } catch (AccessDeniedException e) {
               if (revisionDescriptor == null) {
  @@ -1102,7 +1104,7 @@
           String userPrefix = "/";
           String configParam = token.getNamespaceConfig().getParameter(AclConstants.P_USER_COLLECTION);
           if ( configParam != null ) {
  -        if ( configParam.length() > 0 )
  +            if ( configParam.length() > 0 )
                   userpath = userpath + "/" + configParam +"/";
           }
           
  @@ -1192,11 +1194,11 @@
               // remove not matching principals
               if ((uri != null)) {
                   if (uri.endsWith("/" + userID)) {
  -                        getPropertiesForResponse(currentIntUrl, parentElement);
  -                    }
  +                    getPropertiesForResponse(currentIntUrl, parentElement);
                   }
               }
           }
  +    }
       
       /**
        * Executes a requested <code>principal-search-property</code> report.
  
  
  
  1.32      +6 -6      jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/SearchMethod.java
  
  Index: SearchMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/SearchMethod.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- SearchMethod.java	21 May 2003 15:49:46 -0000	1.31
  +++ SearchMethod.java	18 Aug 2003 06:59:12 -0000	1.32
  @@ -138,7 +138,7 @@
       private PropertyRetriever retriever;
       
       /** if true, an ALL_PROP request will include computed props */
  -    protected boolean allpropIncludesDeltav = false;
  +    protected boolean extendedAllprop = false;
       
       // ----------------------------------------------------------- Constructors
       
  @@ -165,7 +165,7 @@
           retriever = new PropertyRetrieverImpl(token, slideToken, getConfig());
           String slidePath = null;
   
  -        allpropIncludesDeltav = getBooleanInitParameter( "allpropIncludesDeltav" );
  +        extendedAllprop = getBooleanInitParameter( "extendedAllprop" );
           
           if (Configuration.useSearch ()) {
               try {
  @@ -469,7 +469,7 @@
                                                                       resource,
                                                                       req.getContextPath(),
                                                                       serverURL,
  -                                                                    allpropIncludesDeltav);
  +                                                                    extendedAllprop);
                   Iterator iterator = propstatList.iterator();
                   while (iterator.hasNext()) {
                       responseElement.addContent((org.jdom.Element)iterator.next());