Package org.apache.webdav.lib.methods

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


  private Property getProperty(URI uri, String namespace, String name, Credentials credentials) throws IOException {
    String url = domain+uri.toString();
        Vector props = new Vector();
        props.add(new PropertyName(namespace, name));
        PropFindMethod propfindMethod = new PropFindMethod(url, 0, props.elements());
        propfindMethod.setDoAuthentication(true);
        HttpState httpState = new HttpState();
        httpState.setCredentials(null, host, credentials);
        int state = propfindMethod.execute(httpState, new HttpConnection(host, port, protocol));
        if ( state != HttpStatus.SC_MULTI_STATUS ) {
            throw new IOException("Received status code "+state+" when doing PROPFIND on URI="+url);
        }
        Enumeration propertyEnumeration = propfindMethod.getResponseProperties(url);
        if ( propertyEnumeration.hasMoreElements() ) {
          return (Property)propertyEnumeration.nextElement();
        }
        return null;
    }
View Full Code Here


        return null;
    }

    public ArrayValue getProperties(URI uri, Credentials credentials) throws IOException {
        String url = domain+uri.toString();
        PropFindMethod propfindMethod = new PropFindMethod(url, 0);
        propfindMethod.setDoAuthentication(true);
        HttpState httpState = new HttpState();
        httpState.setCredentials(null, host, credentials);
        int state = propfindMethod.execute(httpState, new HttpConnection(host, port, protocol));
        if ( state != HttpStatus.SC_MULTI_STATUS ) {
            throw new IOException("Received status code "+state+" when doing PROPFIND on URI="+url);
        }
        List arrayList = new ArrayList();
        for ( Enumeration propertyEnumeration = propfindMethod.getResponseProperties(url); propertyEnumeration.hasMoreElements(); ) {
            Map properties = new HashMap();
            Property property = (Property)propertyEnumeration.nextElement();
            properties.put("name", new StringValue(property.getLocalName()));
            properties.put("value", new StringValue(property.getPropertyAsString()));
            arrayList.add(new MapValue(properties));
View Full Code Here

    public ArrayValue getChildren(URI uri, Credentials credentials) throws IOException {
        String url = domain+uri.toString();
        if ( url.charAt(url.length()-1) == '/') {
          url = url.substring(0, url.length()-1);
        }
        PropFindMethod propfindMethod = new PropFindMethod(url, 0);
        propfindMethod.setDepth(1);
        propfindMethod.setDoAuthentication(true);
        HttpState httpState = new HttpState();
        httpState.setCredentials(null, host, credentials);
        int state = propfindMethod.execute(httpState, new HttpConnection(host, port, protocol));
        if ( state != HttpStatus.SC_MULTI_STATUS ) {
            throw new IOException("Received status code "+state+" when doing PROPFIND on URI="+url);
        }
        List children = new ArrayList();
        for ( Enumeration propertyEnumeration = propfindMethod.getAllResponseURLs(); propertyEnumeration.hasMoreElements(); ) {
          String childUrl = (String)propertyEnumeration.nextElement();
          if ( !childUrl.equals(url) ) {
          if ( childUrl.indexOf(domain) != -) {
            childUrl = childUrl.substring(childUrl.indexOf(domain)+domain.length());
          }
View Full Code Here

                throw new ScanException(
                    "Web server doesn't support PROPFIND; can't find resources");
            }

            // get a list of all resources from the given URL
            PropFindMethod propFind = new PropFindMethod();
            propFind.setPath(baseURL.getFile());
            propFind.setPropertyNames(PROPERTY_NAMES.elements());
            propFind.setType(PropFindMethod.NAMES);
            client.executeMethod(propFind);

            for (Enumeration e = propFind.getAllResponseURLs();
                 e.hasMoreElements(); ) {

                String href = (String) e.nextElement();

                for (Enumeration properties =
                        propFind.getResponseProperties(href);
                     properties.hasMoreElements(); ) {

                    try {
                        ResourceTypeProperty property =
                            (ResourceTypeProperty) properties.nextElement();
View Full Code Here

                throw new ScanException(
                    "Web server doesn't support PROPFIND; can't find resources");
            }

            // get a list of all resources from the given URL
            PropFindMethod propFind = new PropFindMethod();
            propFind.setPath(baseURL.getFile());
            propFind.setPropertyNames(PROPERTY_NAMES.elements());
            propFind.setType(PropFindMethod.NAMES);
            client.executeMethod(propFind);

            for (Enumeration e = propFind.getAllResponseURLs();
                 e.hasMoreElements(); ) {

                String href = (String) e.nextElement();

                for (Enumeration properties =
                        propFind.getResponseProperties(href);
                     properties.hasMoreElements(); ) {

                    try {
                        ResourceTypeProperty property =
                            (ResourceTypeProperty) properties.nextElement();
View Full Code Here

     * @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

        }
    }
   
    private boolean existsTest(String pathEncoded) throws IOException {
     
        final PropFindMethod propFindMethod = new PropFindMethod(pathEncoded);
        configureMethod(propFindMethod);
        try
        {
          propFindMethod.setFollowRedirects(true);
            final int status = fileSystem.getClient().executeMethod(propFindMethod);
            if (status < 200 || status > 299)
            {
                //injectType(FileType.IMAGINARY);
                return false;
            } else {
              return true;
            }
        }
        finally
        {
          propFindMethod.releaseConnection();
        }     
    }
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

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.