Package org.apache.oodt.cas.protocol.exceptions

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


   */
  public void connect(String host, Authentication auth)
      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(auth.getUser(), auth.getPass())) {
        throw new ProtocolException("Failed logging into host " + host
            + " as user " + auth.getUser());
      }

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

      homeDir = ftp.printWorkingDirectory();
    } catch (Exception e) {
      // login failed
      throw new ProtocolException("Exception thrown while logging into host "
          + host + " as user " + auth.getUser());
    }
  }
View Full Code Here


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

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

          returnFiles.add(pFile);
        }
      }
      return returnFiles;
    } catch (Exception e) {
      throw new ProtocolException("Failed to get file list : " + e.getMessage());
    }
  }
View Full Code Here

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

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

   */
  public void put(File fromFile, ProtocolFile toFile) throws ProtocolException {
    try {
      ftp.storeFile(toFile.getPath(), new FileInputStream(fromFile));
    } catch (Exception e) {
      throw new ProtocolException("Failed to put file '" + fromFile + "' : "
          + e.getMessage(), e);
    }
  }
View Full Code Here

  public void cd(ProtocolFile file) throws ProtocolException {
    try {
      if (!ftp.changeWorkingDirectory(file.getPath()))
        throw new Exception("Directory change method returned false");
    } catch (Exception e) {
      throw new ProtocolException("Failed to cd to " + file.getPath() + " : "
          + e.getMessage());
    }
  }
View Full Code Here

   */
  public void close() throws ProtocolException {
    try {
      ftp.disconnect();
    } catch (Exception e) {
      throw new ProtocolException("Failed to disconnect from server");
    }
  }
View Full Code Here

   */
  public void delete(ProtocolFile file) throws ProtocolException {
    try {
      ftp.deleteFile(file.getPath());
    } catch (Exception e) {
      throw new ProtocolException("Failed to delete file '" + file.getPath()
          + "' : " + e.getMessage(), e);
    }
  }
View Full Code Here

        homeFolder = currentFolder = store.getDefaultFolder();
      else {
        homeFolder = currentFolder = store.getFolder(remotePath);
      }
    } catch (Exception e) {
      throw new ProtocolException("Failed to change directory to '"
          + file + "' : " + e.getMessage(), e);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.oodt.cas.protocol.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.