Examples of WebdavResource


Examples of org.apache.webdav.lib.WebdavResource

       
        HttpURL httpURL = new HttpURL(this.systemId);
        httpURL.setUserInfo(principal, password);
       
        if (createNew) {
            this.resource = new WebdavResource(httpURL,
                WebdavResource.NOACTION,
                DepthSupport.DEPTH_1);
        }
        else {
            this.resource = new WebdavResource(httpURL);
        }
       
    }
View Full Code Here

Examples of org.apache.webdav.lib.WebdavResource

     * Refresh the content of this object after the underlying data
     * content has changed.
     */
    public void refresh() {
        try {
            this.resource = new WebdavResource(this.systemId);

            if (sourcecredential != null)
                resource.setUserInfo(
                    sourcecredential.getPrincipal(),
                    sourcecredential.getPassword());
View Full Code Here

Examples of org.apache.webdav.lib.WebdavResource

        try {
            HttpURL httpURL = new HttpURL(this.systemId);
            httpURL.setUserInfo(
                sourcecredential.getPrincipal(),
                sourcecredential.getPassword());
            this.resource = new WebdavResource(httpURL);
        } catch (HttpException he) {
            throw new SourceException("Could not set credentials", he);
        } catch (IOException ioe) {
            throw new IllegalStateException(ioe.getMessage());
        }
View Full Code Here

Examples of org.apache.webdav.lib.WebdavResource

        try {
            // Set up for processing WebDAV resources
            httpURL = uriToHttpURL(uri);
            if (webdavResource == null) {
                webdavResource = new WebdavResource(httpURL);
                webdavResource.setDebug(debugLevel);
            } else {
                webdavResource.close();
                webdavResource.setHttpURL(httpURL);
            }
            setPath(webdavResource.getPath());
        }
        catch (HttpException we) {
            if (we.getReasonCode() == HttpStatus.SC_UNAUTHORIZED) {
                try {
                    out.print("UserName: ");
                    BufferedReader in =
                        new BufferedReader(new InputStreamReader(System.in));
                    String userName = in.readLine();
                    if ((userName==null) || (userName.length()==0)) {
                        disconnect();
                        return;
                    }
                    userName = userName.trim();
                    System.out.print("Password: ");
                    String password = in.readLine();
                    if (password != null)
                        password= password.trim();
                    try {
                        if (webdavResource != null)
                            webdavResource.close();
                    } catch (IOException e) {
                    } finally {
                        httpURL = null;
                        webdavResource = null;
                    }
                    httpURL = uriToHttpURL(uri);
                    // It should be used like this way.
                    httpURL.setUserinfo(userName, password);
                    webdavResource = new WebdavResource(httpURL);
                    webdavResource.setDebug(debugLevel);
                    setPath(webdavResource.getPath());
                }
                catch (Exception ex) {
                    handleException(ex);
View Full Code Here

Examples of org.apache.webdav.lib.WebdavResource

  /**
   * Sample creating Draft mail in Exchange repository
   */
  public void addDraftMail() {
    HttpURL url = null;
    WebdavResource resource = null;

    try {
      /* Set XML Namespace collection */
      Hashtable<String, String> namespace = new Hashtable<String, String>();
      namespace.put("a", "DAV:");
      namespace
          .put("b", "urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/");
      namespace.put("g", "http://schemas.microsoft.com/mapi/");
      namespace.put("e", "urn:schemas:httpmail:");
      namespace.put("d", "urn:schemas:mailheader:");
      namespace.put("c", "xml:");
      namespace.put("f", "http://schemas.microsoft.com/mapi/proptag/");
      namespace.put("h", "http://schemas.microsoft.com/exchange/");
      namespace.put("i", "urn:schemas-microsoft-com:office:office");
      namespace.put("k", "http://schemas.microsoft.com/repl/");
      namespace.put("j", "urn:schemas:calendar:");
      namespace.put("l", "urn:schemas-microsoft-com:exch-data:");

      /* Connect to Exchange webdav repository */
      url = new HttpURL(Constant.DAV_URL);
      url.setUserinfo(Constant.APPLICATION_USER_ACCOUNT_NAME,
          Constant.APPLICATION_USER_PASSWORD);
      resource = new WebdavResource(url);
      resource.setDebug(Constant.DEBUG_LEVEL);

      /* Create draft mail (XML request) */
      Hashtable<Object, String> props = new Hashtable<Object, String>();
      // <a:contentclass>urn:content-classes:message</a:contentclass>
      props.put(new PropertyName(namespace.get("a"), "contentclass"),
          "urn:content-classes:message");
      // <h:outlookmessageclass>IPM.Note</h:outlookmessageclass>
      props.put(new PropertyName(namespace.get("h"),
          "outlookmessageclass"), "IPM.Note");
      // <d:to>foo@foobar.com</d:to>
      props.put(new PropertyName(namespace.get("d"), "to"),
          "dominique.righetto@laposte.net");
      // <d:cc>bar@foobar.com</d:cc>
      props.put(new PropertyName(namespace.get("d"), "cc"),
          "neotux@laposte.net");
      // <d:importance>High</d:importance>
      props.put(new PropertyName(namespace.get("d"), "importance"),
          "High");
      // <d:bcc>bob@aol.com</d:bcc>
      props
          .put(new PropertyName(namespace.get("d"), "bcc"),
              "dri@flc.be");
      // <g:subject>$subject</g:subject>
      props.put(new PropertyName(namespace.get("g"), "subject"), "Test");
      // <e:htmldescription>This is spam. Please delete this
      // email.</e:htmldescription>
      props.put(new PropertyName(namespace.get("e"), "htmldescription"),
          "This is spam. Please delete this email.");

      /* Send webdav request and read response... */
      if (resource.proppatchMethod(Constant.DAV_URL + "Drafts/Test_"
          + idDateFormat.format(new Date()) + ".EML", props, true)) {
        System.out.printf(
            "Draft mail creation OK - Status code returned: %s",
            resource.getStatusMessage());
      } else {
        System.out.printf("Request failed, Status code returned: %s",
            resource.getStatusMessage());
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    } finally {
      try {
        // Release connection...
        if (resource != null)
          resource.close();
      } catch (IOException ioe) {
        ioe.printStackTrace();
      }
    }
  }
View Full Code Here

Examples of org.apache.webdav.lib.WebdavResource

  /**
   * Sample creating Task in Exchange repository
   */
  public void addTask() {
    HttpURL url = null;
    WebdavResource resource = null;

    try {
      /* Set XML Namespace collection */
      Hashtable<String, String> namespace = new Hashtable<String, String>();
      namespace.put("a", "DAV:");
      namespace
          .put("b", "urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/");
      namespace.put("g", "http://schemas.microsoft.com/mapi/");
      namespace.put("e", "urn:schemas:httpmail:");
      namespace.put("d", "urn:schemas:mailheader:");
      namespace.put("c", "xml:");
      namespace.put("f", "http://schemas.microsoft.com/mapi/proptag/");
      namespace.put("h", "http://schemas.microsoft.com/exchange/");
      namespace.put("i", "urn:schemas-microsoft-com:office:office");
      namespace.put("k", "http://schemas.microsoft.com/repl/");
      namespace.put("j", "urn:schemas:calendar:");
      namespace.put("l", "urn:schemas-microsoft-com:exch-data:");
      namespace.put("m", "http://schemas.microsoft.com/exchange/tasks/");

      /* Connect to Exchange webdav repository */
      url = new HttpURL(Constant.DAV_URL);
      url.setUserinfo(Constant.APPLICATION_USER_ACCOUNT_NAME,
          Constant.APPLICATION_USER_PASSWORD);
      resource = new WebdavResource(url);
      resource.setDebug(Constant.DEBUG_LEVEL);

      /* Create task (XML request) */
      Hashtable<Object, String> props = new Hashtable<Object, String>();
      props.put(new PropertyName(namespace.get("a"), "contentclass"),
          "urn:content-classes:task");
      props.put(new PropertyName(namespace.get("h"),
          "outlookmessageclass"), "IPM.Task");
      props.put(new PropertyName(namespace.get("d"), "subject"),
          "TestTask");
      props.put(new PropertyName(namespace.get("d"), "importance"),
          "High");
      props.put(new PropertyName(namespace.get("e"), "textdescription"),
          "This is spam Task. Please delete this task.");
      // Priority : 0 = Low ; 1 = Normal ; 2 = High
      props.put(new PropertyName(namespace.get("h"), "x-priority-long"),
          "1");     
      props.put(new PropertyName(namespace.get("m"), "dtdue"), dateFormat
          .format(new Date()));
      props.put(new PropertyName(namespace.get("m"), "dtstart"),
          dateFormat.format(new Date()));
      props.put(new PropertyName(namespace.get("m"), "percentcomplete"),
          "0.5");
      // Status : 0 = Not Started ; 1 = In Progress ; 2 = Completed ;
      // 3 = Waiting on someone else ; 4 = Deferred
      props.put(new PropertyName(namespace.get("m"), "status"), "2");
      props.put(new PropertyName(namespace.get("g"), "reminderset"), "1");
      props.put(new PropertyName(namespace.get("g"), "remindertime"),
          dateFormat.format(new Date()));

      /* Send webdav request and read response... */
      if (resource.proppatchMethod(Constant.DAV_URL + "Tasks/Test_"
          + idDateFormat.format(new Date()) + ".EML", props, true)) {
        System.out.printf(
            "Task creation OK - Status code returned: %s", resource
                .getStatusMessage());
      } else {
        System.out.printf("Request failed, Status code returned: %s",
            resource.getStatusMessage());
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    } finally {
      try {
        // Release connection...
        if (resource != null)
          resource.close();
      } catch (IOException ioe) {
        ioe.printStackTrace();
      }
    }
  }
View Full Code Here

Examples of org.apache.webdav.lib.WebdavResource

        //try {
            HttpURL httpURL = new HttpURL(this.systemId);
            httpURL.setUserInfo(principal, password);
           
            if (createNew)
               this.resource = new WebdavResource(httpURL,
                   WebdavResource.NOACTION,
                   DepthSupport.DEPTH_1);
            else
               this.resource = new WebdavResource(httpURL);
           
            WebdavResource.setGetUseDisk(false);
        //} catch (IOException ioe) {
        //    throw new IllegalStateException(ioe.getMessage());
        //}
View Full Code Here

Examples of org.apache.webdav.lib.WebdavResource

     * Refresh the content of this object after the underlying data
     * content has changed.
     */
    public void refresh() {
        try {
            this.resource = new WebdavResource(this.systemId);

            if (sourcecredential != null)
                resource.setUserInfo(
                    sourcecredential.getPrincipal(),
                    sourcecredential.getPassword());
View Full Code Here

Examples of org.apache.webdav.lib.WebdavResource

        try {
            HttpURL httpURL = new HttpURL(this.systemId);
            httpURL.setUserInfo(
                sourcecredential.getPrincipal(),
                sourcecredential.getPassword());
            this.resource = new WebdavResource(httpURL);
        } catch (HttpException he) {
            throw new SourceException("Could not set credentials", he);
        } catch (IOException ioe) {
            throw new IllegalStateException(ioe.getMessage());
        }
View Full Code Here

Examples of org.apache.webdav.lib.WebdavResource

        //try {
            HttpURL httpURL = new HttpURL(this.systemId);
            httpURL.setUserInfo(principal, password);
           
            if (createNew)
               this.resource = new WebdavResource(httpURL,
                   WebdavResource.NOACTION,
                   DepthSupport.DEPTH_1);
            else
               this.resource = new WebdavResource(httpURL);
           
            WebdavResource.setGetUseDisk(false);
        //} catch (IOException ioe) {
        //    throw new IllegalStateException(ioe.getMessage());
        //}
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.