Examples of WebdavResource


Examples of org.apache.webdav.lib.WebdavResource

  /*public HashMap cdUP() {   
    return changeDirectory("..");   
  }
   */
  public void removeFile(String file) {
    WebdavResource wdr = null;
    try   {

      wdr = connect(file);
      if(wdr.deleteMethod()){
        if (logtext != nulllogtext.append("..webdav server reply [delete file=" + file + "], [status= "  + wdr.getStatusMessage());
       
      }else {
        hasError = true;
        new ErrorLog("error in " + sos.util.SOSClassUtil.getMethodName() + " ; could not delete file [" + file+ "], [status= "  + wdr.getStatusMessage());
        if(logtext != nulllogtext.append("..webdav server reply [could not delete] , [status= "  + wdr.getStatusMessage());
      }

      wdr.close();
    } catch (Exception e) {
     
      try {       
        new ErrorLog("error in " + sos.util.SOSClassUtil.getMethodName() + " ; could not delete file [" + file+ "]", e);
        if(wdr != null)
          wdr.close();
      } catch(Exception ee) {
        //tu nichts
      }
      if(logtext != nulllogtext.append("could not delete file [" + file+ "] cause:" + e.getMessage() );
      hasError = true;
View Full Code Here

Examples of org.apache.webdav.lib.WebdavResource

    }
  }

  private WebdavResource connect(String url){

    WebdavResource wdr = null;
    String user     = null;
    String password = null;
    String host     = null;
    String port     = null;

    try {

      //selfsigned; wenn selbssignierte Certifikate ber�cksichtigt werden sollen
      //es gilt jetzt nur die offizielle
      //System.getProperties().put("javax.net.ssl.trustStore","C:/scheduler/webdav_keystore/.keystore");
      //System.getProperties().put("javax.net.ssl.trustStorePassword","changeit");


      user = sosString.parseToString(currProfile.get("user"));
      password = sosString.parseToString(currProfile.get("password"));
     
      String proxyHost = sosString.parseToString(currProfile.get("proxy_server"));
      int proxyPort    = 21;
      if(sosString.parseToString(currProfile.get("proxy_port")).length() > 0)
        proxyPort = Integer.parseInt(sosString.parseToString(currProfile.get("proxy_port")));
     
     
     
      String key = Options.getProperty("profile.timestamp." + currProfileName);

      if(key != null && key.length() > 8) {
        key = key.substring(key.length()-8);
      }
      if(password.length() > 0 && sosString.parseToString(key).length() > 0) {
        password = SOSCrypt.decrypt(key, password);
      }
      if(password.length() == 0 ) {
        Shell shell = new Shell();
        shell.pack();         
        Dialog dialog = new Dialog(shell);   
        dialog.setText("Password");
        dialog.open(this);

        while (!shell.isDisposed()) {
          if (!shell.getDisplay().readAndDispatch())
            shell.getDisplay().sleep();
        }
        //shell.getDisplay().dispose();
        //shell.dispose();
        password = getPassword()
      }


      HttpURL hrl = new HttpURL(url);     

      hrl.setUserinfo(user,password);
      if(proxyHost.length() > 0)
        wdr = new WebdavResource(hrl, proxyHost, proxyPort);
      else
        wdr = new WebdavResource(hrl);

      wdr.setDebug(9);
      if(logtext != nulllogtext.append("..webdav server reply [connect] [status= "  + wdr.getStatusMessage() );
      Options.setProperty("last_webdav_profile" , currProfileName);
      Options.saveProperties();
     
    } catch (Exception ex) {
View Full Code Here

Examples of org.apache.webdav.lib.WebdavResource

  public HashMap changeDirectory(String directory) { 
    HashMap listnames = new HashMap();
    try {
     
      WebdavResource wdr = connect(directory);

      if(wdr == null)
        throw new Exception ("could not connect to WebDav Server");

      WebdavResources e = wdr.getChildResources();
      java.util.Enumeration en = e.getResources();
      while(en.hasMoreElements()) {
        WebdavResource cr = (WebdavResource)en.nextElement();               
        System.out.println(cr);
        if(cr.isCollection())
          listnames.put(cr, "dir");
        else
          listnames.put(cr, "file");
      }
      if(logtext != nulllogtext.append("..webdav server reply [changeDirectory] [status= "  + wdr.getStatusMessage() );
View Full Code Here

Examples of org.apache.webdav.lib.WebdavResource

  public void saveAs(String source, String url) {

    source = source.replaceAll("\\\\", "/");
    boolean retVal = false;
    WebdavResource wdr = null;
    try {

      wdr = connect(url);                   

      if(wdr.putMethod(new java.io.File(source))) {
        retVal = true;               
      }
      hasError = !retVal;

      if(logtext != null)  {
        if(hasError)
          logtext.append(source + " could not transfer to " + url );
        else
          logtext.append(source + " transfer to " + url );
      }
      if(logtext != nulllogtext.append("..webdav server reply: saveas[url=" + url +  "], [status= "  + wdr.getStatusMessage());
    } catch(Exception e) {
      try {
        new ErrorLog("error in " + sos.util.SOSClassUtil.getMethodName() + " ; ..webdav server reply, [status= "  + wdr.getStatusMessage() + "]", e);
      } catch(Exception ee) {
        //tu nichts
      }
      if(logtext != nulllogtext.append("..webdav server reply: ");
      hasError = true;
View Full Code Here

Examples of org.apache.webdav.lib.WebdavResource

    try {   

      if(!path.endsWith("/"))
        path = path + "/";

      WebdavResource wr = connect(path);
      if (wr.mkcolMethod()) {
       
        if(logtext != nulllogtext.append("..webdav server reply [mkdir] [path=" + path + "], [status= "  + wr.getStatusMessage() );
      } else {
        throw new Exception("..webdav server reply [mkdir failed] [path=" + path+ "]: "  );       
      }

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

            throw new UnknownError();
        }
    }
    public void connect() throws java.lang.IllegalAccessError {
        try {
            this.webdavResource = new WebdavResource(this.rootURL);
        } catch (Exception e) {
            System.err.println(e.toString());
            throw new IllegalAccessError();
        }
    }
View Full Code Here

Examples of org.apache.webdav.lib.WebdavResource

        protected HttpURL rootUrl = null;

        public WebdavFile(HttpURL pathUrl, HttpURL rootUrl) throws
            URIException, IOException {
            super(pathUrl);
            this.webdavResource = new WebdavResource(pathUrl);
            this.rootUrl = rootUrl;
        }
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);
               
                // is not a collection?
                if (!((ResourceTypeProperty)webdavResource.getResourceType()).isCollection()) {
                    webdavResource = null;
                    httpURL = null;
                    out.println("Error: " + uri + " is not a collection! Use open/connect only for collections!");
                }
               
            } else {
                webdavResource.close();
                webdavResource.setHttpURL(httpURL);
            }
            setPath(webdavResource.getPath());
        }
        catch (HttpException we) {
            out.print("HttpException.getReasonCode(): "+ we.getReasonCode());
            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());


                    if (!((ResourceTypeProperty)webdavResource.getResourceType()).isCollection()) {
View Full Code Here

Examples of org.apache.webdav.lib.WebdavResource

    }

    protected void open(WebDAVConnectionSpec webDAVConnectionSpec) throws IOException, URIException {
        this.webDAVConnectionSpec = webDAVConnectionSpec;
        System.out.println("Opening: "+webDAVConnectionSpec.getHttpURL()); // FIXME
        webdavResource = new WebdavResource(webDAVConnectionSpec.getHttpURL());
        System.out.println("Opened"); // FIXME
        String owner = webDAVConnectionSpec.getHttpURL().getUser();
        if (owner == null)
            owner = "WebDAV Connector";
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.