Package ca.pgon.saviorlib.Exceptions

Examples of ca.pgon.saviorlib.Exceptions.FileSystemException


        this.user = user;
    }

    public void checkIfValid() {
        if (basePath == null) {
            throw new FileSystemException("No base path defined");
        }
       
        if (hostname == null) {
            throw new FileSystemException("No host defined");
        }
       
        if (user == null) {
            throw new FileSystemException("No login defined");
        }
       
        if (pass == null) {
            throw new FileSystemException("No password defined");
        }
       
        connectIfNotConnected();
       
        try {
            if (!ftpClient.changeWorkingDirectory(basePath)) {
                throw new FileSystemException("The basepath is invalid");
            }
        } catch (IOException ex) {
            throw new FileSystemException("The basepath is invalid");
        }
    }
View Full Code Here


    }

    public void createDirectory(FileEntry directory) {
        try {
            if (!ftpClient.makeDirectory(FileSystemTools.getAbsolutePath(directory, basePath))) {
                throw new FileSystemException("Could not create the directory");
            }
        } catch (Exception ex) {
            throw new FileSystemException("Could not create the directory", ex);
        }
    }
View Full Code Here

        }
       
        // Delete the current dir
        try {
            if (!ftpClient.removeDirectory(FileSystemTools.getAbsolutePath(directory, basePath))) {
                throw new FileSystemException("Could not delete the directory");
            }
        } catch (Exception e) {
            throw new FileSystemException("Could not delete the directory", e);
        }
    }
View Full Code Here

    public OutputStream createFile(FileEntry file) {
        try {
            return new WritingAutoComplete(ftpClient.storeFileStream(FileSystemTools.getAbsolutePath(file, basePath)));
        } catch (Exception ex) {
            throw new FileSystemException("Could not create the file", ex);
        }
    }
View Full Code Here

    public OutputStream appendFile(FileEntry file) {
        try {
            return new WritingAutoComplete(ftpClient.appendFileStream(FileSystemTools.getAbsolutePath(file, basePath)));
        } catch (Exception ex) {
            throw new FileSystemException("Could not append to the file", ex);
        }
    }
View Full Code Here

    }

    public void deleteFile(FileEntry file) {
        try {
            if (!ftpClient.deleteFile(FileSystemTools.getAbsolutePath(file, basePath))) {
                throw new FileSystemException("Could not delete the file");
            }
        } catch (Exception ex) {
            throw new FileSystemException("Could not delete the file", ex);
        }
    }
View Full Code Here

    public InputStream readFile(FileEntry file) {
        try {
            return new ReadingAutoComplete(ftpClient.retrieveFileStream(FileSystemTools.getAbsolutePath(file, basePath)));
        } catch (Exception ex) {
            throw new FileSystemException("Could not read the file ", ex);
        }
    }
View Full Code Here

    public InputStream readFileFrom(FileEntry file, long offset) {
        try {
            ftpClient.setRestartOffset(offset);
            return new ReadingAutoComplete(ftpClient.retrieveFileStream(FileSystemTools.getAbsolutePath(file, basePath)));
        } catch (Exception ex) {
            throw new FileSystemException("Could not read the file ", ex);
        }
    }
View Full Code Here

            throw new FileSystemException("Could not read the file ", ex);
        }
    }

    public void changeFileModificationTime(FileEntry file, long time) {
        throw new FileSystemException("Not possible on FTP");
    }
View Full Code Here

       
        // Connect
        try {
            ftpClient.connect(hostname, port);
        } catch (Exception ex) {
            throw new FileSystemException("Could not connect to the host", ex);
        }       
        if(!FTPReply.isPositiveCompletion(ftpClient.getReplyCode())) {
            disconnect();
            throw new FileSystemException("The host refused the connection");
        }
       
        // Login
        try {
            if (!ftpClient.login(user, pass)) {
                throw new FileSystemException("The user/pass combinaison is invalid on this host");
            }
        } catch (IOException ex) {
            throw new FileSystemException("The host disconnected while logging in");
        }
       
        // Set up the connection
        try {
            ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
        } catch (IOException ex) {
            throw new FileSystemException("Could not set up the connection with the host", ex);
        }
    }
View Full Code Here

TOP

Related Classes of ca.pgon.saviorlib.Exceptions.FileSystemException

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.