Package org.apache.oodt.cas.pushpull.exceptions

Examples of org.apache.oodt.cas.pushpull.exceptions.ProtocolException


  public void abortCurFileTransfer() throws ProtocolException {
      try {
          ftp.abort();
      } catch (Exception e) {
          throw new ProtocolException("Failed to abort file transfer : "
                  + e.getMessage());
      }
  }
View Full Code Here


                      new ProtocolPath(path + "/" + file.getName(), file
                              .isDirectory())));
          }
          return returnList;
      } catch (Exception e) {
          throw new ProtocolException("Failed to get list of files : "
                  + e.getMessage());
      }
  }
View Full Code Here

  public ProtocolFile getCurrentWorkingDir() throws ProtocolException {
      try {
          return new ProtocolFile(this.getRemoteSite(), new ProtocolPath(ftp
                  .getCurrentDir(), true));
      } catch (Exception e) {
          throw new ProtocolException("Failed to pwd : " + e.getMessage());
      }
  }
View Full Code Here

     */
    public void connect(String host, String username, String password)
            throws ProtocolException {
        // server cannot be null
        if (host == null) {
            throw new ProtocolException("Tried to connect to server == NULL");
        }

        try {
            ftp.connect(host);
            ftp.enterLocalPassiveMode();
        } catch (Exception e) {
            throw new ProtocolException("Failed to connect to server : "
                    + e.getMessage());
        }

        try {
            // try logging in
            if (!ftp.login(username, password)) {
                throw new ProtocolException("Failed logging into host " + host
                        + " as user " + username);
            }

            // set file type to binary
            ftp.setFileType(FTPClient.BINARY_FILE_TYPE);

        } catch (Exception e) {
            // login failed
            throw new ProtocolException(
                    "Exception thrown while logging into host " + host
                            + " as user " + username);
        }
    }
View Full Code Here

    public ProtocolFile getCurrentWorkingDir() throws ProtocolException {
        try {
            return new ProtocolFile(this.getRemoteSite(), new ProtocolPath(ftp
                    .printWorkingDirectory(), true));
        } catch (Exception e) {
            throw new ProtocolException("Failed to pwd : " + e.getMessage());
        }
    }
View Full Code Here

                                .isDirectory())));
            }
            // System.out.println("RETURN FILES: " + returnFiles);
            return returnFiles;
        } catch (Exception e) {
            throw new ProtocolException("Failed to get file list : "
                    + e.getMessage());
        }
    }
View Full Code Here

     */
    public void getFile(ProtocolFile file, File toLocalFile)
            throws ProtocolException {
        // file or toLocalFile cannot be null
        if (file == null || toLocalFile == null) {
            throw new ProtocolException(
                    "Can't download file -> ProtocolFile == null || toLocalFile == null");
        }

        // download file
        OutputStream os = null;
        try {
            os = new FileOutputStream(toLocalFile);
            if (ftp.retrieveFile(file.getName(), os))// {
                throw new ProtocolException("Failed to download file "
                        + file.getName());
            // }
        } catch (Exception e) {
            // download failed
            toLocalFile.delete();
            throw new ProtocolException("FAILED to download: " + file.getName()
                    + " : " + e.getMessage());
        } finally {
            // close output stream
            if (os != null)
                try {
                    os.close();
                } catch (Exception e) {
                    toLocalFile.delete();
                    throw new ProtocolException(
                            "Failed to close outputstream : " + e.getMessage());
                }
        }
    }
View Full Code Here

    public void abortCurFileTransfer() throws ProtocolException {
        try {
            ftp.abort();
        } catch (Exception e) {
            throw new ProtocolException("Failed to abort file transfer : "
                    + e.getMessage());
        }
    }
View Full Code Here

    protected void chDir(ProtocolPath path) throws ProtocolException {
        try {
            if (!ftp.changeWorkingDirectory(path.getPathString()))
                throw new Exception("Directory change method returned false");
        } catch (Exception e) {
            throw new ProtocolException("Failed to cd to " + path + " : "
                    + e.getMessage());
        }
    }
View Full Code Here

    @Override
    public void cdToRoot() throws ProtocolException {
        try {
            chDir(new ProtocolPath("/", true));
        } catch (Exception e) {
            throw new ProtocolException("Failed to cd to root : "
                    + e.getMessage());
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.oodt.cas.pushpull.exceptions.ProtocolException

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.