Package org.apache.webdav.lib.methods

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


     */
    public boolean proppatchMethod(String path, Hashtable properties,
                                   boolean action) throws HttpException, IOException {

        setClient();
        PropPatchMethod method = new PropPatchMethod(URIUtil.encodePath(path));
        generateIfHeader(method);
        Enumeration names = properties.keys();
        boolean hasSomething = false;
        if (names.hasMoreElements()) {
            hasSomething = true;
        }
        while (names.hasMoreElements()) {
            Object item = names.nextElement();
            if (item instanceof String) {
                String name = (String) item;
                String value = (String) properties.get(item);
                if (action) {
                    method.addPropertyToSet(name, value);
                } else {
                    method.addPropertyToRemove(name);
                }
            } else if (item instanceof PropertyName) {
                String name         = ((PropertyName) item).getLocalName();
                String namespaceURI = ((PropertyName) item).getNamespaceURI();
                String value        = (String) properties.get(item);
                if (action) {
                    method.addPropertyToSet(name, value, null, namespaceURI);
                } else {
                    method.addPropertyToRemove(name, null, namespaceURI);
                }
            } else {
                // unknown type, debug or ignore it
            }
        }
View Full Code Here


  
   protected void proppatch(HttpURL url, String logName)
      throws IOException, HttpException
   {
      log(logName, ifVerbose());
      PropPatchMethod propPatch = new PropPatchMethod(url.getURI());
      if (this.locktoken != null) {
         Utils.generateIfHeader(propPatch, this.locktoken);
      }
     
      int c = 1;
      for(Iterator i = toRemove.iterator(); i.hasNext(); ) {
         Remove r = (Remove)i.next();
         propPatch.addPropertyToRemove(r.name,
               r.abbrev != null ? r.abbrev : "NS"+(c++),
               r.namespace);
      }
      for(Iterator i = toSet.iterator(); i.hasNext(); ) {
         Set a = (Set)i.next();
         propPatch.addPropertyToSet(a.name,
               a.getValue(),
               a.abbrev != null ? a.abbrev : "NS"+(c++),
               a.namespace);
      }
     
      int status = getHttpClient().executeMethod(propPatch);
      count++;
     
      switch (status) {
         case WebdavStatus.SC_OK:
            // ok
            break;
         case WebdavStatus.SC_MULTI_STATUS:
            for(Enumeration e = propPatch.getResponses(); e.hasMoreElements();) {
               ResponseEntity response = (ResponseEntity)e.nextElement();
              
               if (response.getStatusCode() > 400) {
                  throw Utils.makeBuildException("Error while PROPPATCH",
                        propPatch.getResponses());
               }
            }
            break;
           
         default:
View Full Code Here

        int contentLength = Integer.parseInt(getMethod.getResponseHeader("Content-length").getValue());
        return new InputStreamValue(stream, contentType, characterEncoding, contentLength, true);
    }

    public void setProperty(URI uri, String namespace, String name, String value, Credentials credentials) throws IOException {
        PropPatchMethod proppatchMethod = new PropPatchMethod(domain+uri.toString());
        proppatchMethod.setDoAuthentication(true);
        HttpState httpState = new HttpState();
        httpState.setCredentials(null, host, credentials);
        proppatchMethod.addPropertyToSet(name, value, "S", namespace);
        int state = proppatchMethod.execute(httpState, new HttpConnection(host, port, protocol));
        if ( state != HttpStatus.SC_MULTI_STATUS ) {
          throw new IOException("Received status code "+state+" when doing PROPPATH on URI="+uri);
        }
    }
View Full Code Here

     */
    public boolean proppatchMethod(String path, Hashtable properties,
                                   boolean action) throws HttpException, IOException {

        setClient();
        PropPatchMethod method = new PropPatchMethod(URIUtil.encodePath(path));
        generateIfHeader(method);
        Enumeration names = properties.keys();
        boolean hasSomething = false;
        if (names.hasMoreElements()) {
            hasSomething = true;
        }
        while (names.hasMoreElements()) {
            Object item = names.nextElement();
            if (item instanceof String) {
                String name = (String) item;
                String value = (String) properties.get(item);
                if (action) {
                    method.addPropertyToSet(name, value);
                } else {
                    method.addPropertyToRemove(name);
                }
            } else if (item instanceof PropertyName) {
                String name         = ((PropertyName) item).getLocalName();
                String namespaceURI = ((PropertyName) item).getNamespaceURI();
                String value        = (String) properties.get(item);
                if (action) {
                    method.addPropertyToSet(name, value, null, namespaceURI);
                } else {
                    method.addPropertyToRemove(name, null, namespaceURI);
                }
            } else {
                // unknown type, debug or ignore it
            }
        }
View Full Code Here

TOP

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

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.