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

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


          for (FileInfo file : fileList) {
              returnList.add(new ProtocolFile(this.pwd(), file.getName(), file.isDirectory()));
          }
          return returnList;
      } catch (Exception e) {
          throw new ProtocolException("Failed to get list of files : "
                  + e.getMessage());
      }
  }
View Full Code Here


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

     */
  protected String getCurentDir() throws ProtocolException {
      try {
          return ftp.getCurrentDir();
      } catch (Exception e) {
          throw new ProtocolException("Failed to get current directory : "
                  + e.getMessage());
      }


  }
View Full Code Here

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

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

   */
  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

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.