Package org.apache.webdav.lib.methods

Examples of org.apache.webdav.lib.methods.PropFindMethod


     * @param expect the return status expected.
     * @return the {@link HttpMethod} which contains the response.
     */
    protected HttpMethod propFind(String url, int depth, int expect)
    {
        PropFindMethod propFindMethod = new PropFindMethod(url);
        propFindMethod.setDoAuthentication(true);
        propFindMethod.setDepth(depth);
        testMethod(propFindMethod, expect);
        return propFindMethod;
    }
View Full Code Here


        Vector properties = new Vector();
        properties.addElement(AclProperty.TAG_NAME);

        // Default depth=0, type=by_name
        PropFindMethod method = new PropFindMethod(URIUtil.encodePath(path),
                                                   DepthSupport.DEPTH_0,
                                                   properties.elements());
        client.executeMethod(method);

        Enumeration responses = method.getResponses();
        if (responses.hasMoreElements()) {
            ResponseEntity response =
                (ResponseEntity) responses.nextElement();
            String href = response.getHref();

            // Set status code for this resource.
            if ((thisResource == true) && (response.getStatusCode() > 0))
                setStatusCode(response.getStatusCode());
            thisResource = false;

            Enumeration responseProperties =
                method.getResponseProperties(href);
            while (responseProperties.hasMoreElements()) {
                Property property =
                    (Property) responseProperties.nextElement();
                if (property instanceof AclProperty) {
                    acl = (AclProperty)property;
View Full Code Here

        Vector properties = new Vector();
        properties.addElement(PrincipalCollectionSetProperty.TAG_NAME);

        // Default depth=0, type=by_name
        PropFindMethod method = new PropFindMethod(URIUtil.encodePath(path),
                                                   DepthSupport.DEPTH_0,
                                                   properties.elements());
        client.executeMethod(method);

        Enumeration responses = method.getResponses();
        if (responses.hasMoreElements()) {
            ResponseEntity response =
                (ResponseEntity) responses.nextElement();
            String href = response.getHref();

            // Set status code for this resource.
            if ((thisResource == true) && (response.getStatusCode() > 0))
                setStatusCode(response.getStatusCode());
            thisResource = false;

            Enumeration responseProperties =
                method.getResponseProperties(href);
            while (responseProperties.hasMoreElements()) {
                Property property =
                    (Property) responseProperties.nextElement();
                if (property instanceof PrincipalCollectionSetProperty) {
                    set = (PrincipalCollectionSetProperty)property;
View Full Code Here

        Vector properties = new Vector();
        properties.addElement(LockDiscoveryProperty.TAG_NAME);

        // Default depth=0, type=by_name
        PropFindMethod method = new PropFindMethod(URIUtil.encodePath(path),
                                                   DepthSupport.DEPTH_0,
                                                   properties.elements());
        client.executeMethod(method);

        Enumeration responses = method.getResponses();
        if (responses.hasMoreElements()) {
            ResponseEntity response =
                (ResponseEntity) responses.nextElement();
            String href = response.getHref();

            // Set status code for this resource.
            if ((thisResource == true) && (response.getStatusCode() > 0))
                setStatusCode(response.getStatusCode());
            thisResource = false;

            Enumeration responseProperties =
                method.getResponseProperties(href);
            while (responseProperties.hasMoreElements()) {
                Property property =
                    (Property) responseProperties.nextElement();
                if (property instanceof LockDiscoveryProperty) {
                    set = (LockDiscoveryProperty)property;
View Full Code Here

    public Enumeration propfindMethod(String path, int depth)
        throws HttpException, IOException {

        setClient();
        // Change the depth for allprop
        PropFindMethod method = new PropFindMethod(URIUtil.encodePath(path),
                                                   depth);
        // Default depth=infinity, type=allprop
        int status = client.executeMethod(method);

        // Set status code for this resource.
        if (thisResource == true) {
            setStatusCode(status);
        }
        // Also accept OK sent by buggy servers.
        if (status != HttpStatus.SC_MULTI_STATUS
            && status != HttpStatus.SC_OK) {
            HttpException ex = new HttpException();
            ex.setReasonCode(status);
            throw ex;
        }
        thisResource = false;

        return method.getResponses();
    }
View Full Code Here

                                      Vector properties)
        throws HttpException, IOException {

        setClient();
        // Change the depth for prop
        PropFindMethod method = new PropFindMethod(URIUtil.encodePath(path),
                                                   depth,
                                                   properties.elements());
        int status = client.executeMethod(method);

        // Set status code for this resource.
        if (thisResource == true) {
            // Set the status code.
            setStatusCode(method.getStatusLine().getStatusCode());
        }
        // Also accept OK sent by buggy servers.
        if (status != HttpStatus.SC_MULTI_STATUS
            && status != HttpStatus.SC_OK) {
            HttpException ex = new HttpException();
            ex.setReasonCode(status);
            throw ex;
        }
        thisResource = false;

        return method.getResponses();
    }
View Full Code Here

    public Enumeration propfindMethod(String path, Vector properties)
        throws HttpException, IOException {

        setClient();
        // Default depth=0, type=by_name
        PropFindMethod method = new PropFindMethod(URIUtil.encodePath(path),
                                                   DepthSupport.DEPTH_0,
                                                   properties.elements());
        int status = client.executeMethod(method);

        // Also accept OK sent by buggy servers.
        if (status != HttpStatus.SC_MULTI_STATUS
            && status != HttpStatus.SC_OK) {
            HttpException ex = new HttpException();
            ex.setReasonCode(status);
            throw ex;
        }

        // It contains the results.
        Vector results = new Vector();

        Enumeration responses = method.getResponses();
        if (responses.hasMoreElements()) {
            ResponseEntity response =
                (ResponseEntity) responses.nextElement();
            String href = response.getHref();

            // Set status code for this resource.
            if ((thisResource == true) && (response.getStatusCode() > 0))
                setStatusCode(response.getStatusCode());
            thisResource = false;

            Enumeration responseProperties =
                method.getResponseProperties(href);
            while (responseProperties.hasMoreElements()) {
                Property property =
                    (Property) responseProperties.nextElement();
                results.addElement(property.getPropertyAsString());
            }
View Full Code Here

   public static boolean collectionExists(HttpClient client, HttpURL httpURL)
      throws IOException, HttpException
   {
      Vector props = new Vector(1);
      props.add(RESOURCETYPE);
      PropFindMethod propFind = new PropFindMethod(httpURL.getURI(),
                                                    0, PropFindMethod.BY_NAME);
      propFind.setFollowRedirects(true);
      propFind.setPropertyNames(props.elements());
      int status = client.executeMethod(propFind);
      switch (status) {
         case WebdavStatus.SC_MULTI_STATUS:
            Property p = findProperty(propFind, RESOURCETYPE, httpURL.getPath());
            if (p instanceof ResourceTypeProperty) {
               return ((ResourceTypeProperty)p).isCollection();
            } else {
               throw new WebdavException("PROPFFIND does not return resourcetype");
            }
         case WebdavStatus.SC_NOT_FOUND:
            return false;
         default:
            HttpException ex = new HttpException();
            ex.setReasonCode(status);
            ex.setReason(propFind.getStatusText());
            throw ex;
      }
   }
View Full Code Here

   public static long getLastModified(HttpClient client, HttpURL url)
      throws IOException, HttpException
   {
      Vector props = new Vector(1);
      props.add(GETLASTMODIFIED);
      PropFindMethod propFind = new PropFindMethod(url.getURI(), 0);
      propFind.setPropertyNames(props.elements());
      propFind.setFollowRedirects(true);
     
      int status = client.executeMethod(propFind);
      switch (status) {
         case WebdavStatus.SC_MULTI_STATUS:
            Property p = findProperty(propFind, GETLASTMODIFIED, url.getPath());
            if (p != null) {
               try {
                  Date d = GETLASTMODIFIED_FORMAT.parse(p.getPropertyAsString());
                  return d.getTime();
               }
               catch (ParseException e) {
                  throw new HttpException("Invalid lastmodified property: " +
                        p.getPropertyAsString());
               }
            }
            throw new HttpException("PROPFIND does not return lastmodified.");
         default:
            HttpException ex = new HttpException();
            ex.setReasonCode(status);
            ex.setReason(propFind.getStatusText());
            throw ex;
      }
   }
View Full Code Here

         collURL = Utils.createHttpURL(collURL, "");
         collURL.setPath(collURL.getPath() + SEPARATOR);
      }
     
      // get a list of all resources from the given URL
      PropFindMethod propFind = new PropFindMethod(collURL.getURI(),
                                                   DepthSupport.DEPTH_1,
                                                   PropFindMethod.BY_NAME);
      propFind.setPropertyNames(propertyNames.elements());
      propFind.setFollowRedirects(true);
      try {
         this.client.executeMethod(propFind);
      }
      catch (IOException e) {
         Utils.makeBuildException("Can't read collection content!", e);
      }
     
      List subCollections = new ArrayList();
      this.properties.storeProperties(propFind);
     
      // this collection
      addResource(collURL.getPath(), true);
     
      // for each content element, check resource type and classify
      for (Enumeration e = propFind.getAllResponseURLs(); e.hasMoreElements(); )
      {
         String href = (String) e.nextElement();
        
         ResourceTypeProperty property =
                                this.properties.getResourceType(collURL, href);
View Full Code Here

TOP

Related Classes of org.apache.webdav.lib.methods.PropFindMethod

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.