Package org.openbel.framework.core.protocol

Examples of org.openbel.framework.core.protocol.ResourceDownloadError


            String resource1Hash = readFileToString(hashFile1, UTF_8);
            String resource2Hash = readFileToString(hashFile2, UTF_8);

            return resource1Hash.trim().equalsIgnoreCase(resource2Hash.trim());
        } catch (IOException e) {
            throw new ResourceDownloadError(remoteLocation, e.getMessage());
        }
    }
View Full Code Here


            localHashFile = new File(localHashPath);
            write(localHashFile, hashValue, UTF_8);
            return localHashFile;
        } catch (IOException e) {
            throw new ResourceDownloadError(remoteLocation, e.getMessage());
        }
    }
View Full Code Here

            } else {
                copyFile(resource, copy);
            }
        } catch (IOException e) {
            String msg = e.getMessage();
            ResourceDownloadError r =
                    new ResourceDownloadError(resourceLocation, msg);
            r.initCause(e);
            throw r;
        } finally {
            // clean up all I/O resources
            closeQuietly(fout);
            closeQuietly(gzipis);
View Full Code Here

            final int code = httpUrlConnection.getResponseCode();
            if (code != HttpURLConnection.HTTP_OK) {
                final String url = urlConnection.getURL().toString();
                final String msg = "Bad response code: " + code;
                throw new ResourceDownloadError(url, msg);
            }

            return super.downloadResource(httpUrlConnection,
                    namespaceDownloadLocation);
        } catch (InterruptedIOException e) {
            final String url = urlConnection.getURL().toString();
            final String msg = "Interrupted I/O";
            throw new ResourceDownloadError(url, msg, e);
        } catch (IOException e) {
            final String url = urlConnection.getURL().toString();
            final String msg = e.getMessage();
            throw new ResourceDownloadError(url, msg, e);
        }
    }
View Full Code Here

        try {
            ftpClient.connect(host, port);
        } catch (Exception e) {
            final String url = ftpUrl.toString();
            final String msg = e.getMessage();
            throw new ResourceDownloadError(url, msg, e);
        }

        //login to user account
        String userInfo = ftpUrl.getUserInfo();
        String username = DEFAULT_USER_NAME;
        String password = "";
        if (userInfo != null) {
            if (userInfo.contains(":")) {
                //provided username & password so parse
                String[] userInfoTokens = userInfo.split("\\:");
                if (userInfoTokens.length == 2) {
                    username = userInfoTokens[0];
                    password = userInfoTokens[1];
                }
            } else {
                //provided only username
                username = userInfo;

                //prompt for password
                char[] pwd;
                try {
                    pwd =
                            PasswordPrompter.getPassword(pwdInputStream,
                                    "Connecting to '" + ftpUrl.toString()
                                            + "'.  Enter password for user '"
                                            + username + "': ");
                } catch (IOException e) {
                    final String name = ftpUrl.toString();
                    final String msg = e.getMessage();
                    throw new ResourceDownloadError(name, msg, e);
                }
                if (pwd == null) {
                    password = "";
                } else {
                    password = String.valueOf(pwd);
                }
            }
        }

        try {
            if (!ftpClient.login(username, password)) {
                final String name = ftpUrl.toString();
                final String msg = "Login error for username and password";
                throw new ResourceDownloadError(name, msg);
            }
        } catch (IOException e) {
            final String name = ftpUrl.toString();
            final String msg = "Login error for username and password";
            throw new ResourceDownloadError(name, msg, e);
        }

        try {
            ftpClient.pasv();
            ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
        } catch (IOException e) {
            final String url = ftpUrl.toString();
            final String msg = "Error setting passive mode or transfer type";
            throw new ResourceDownloadError(url, msg, e);
        }
    }
View Full Code Here

            return downloadResource(httpsUrlConnection,
                    namespaceDownloadLocation);
        } catch (IOException e) {
            final String url = namespaceDownloadLocation;
            final String msg = e.getMessage();
            throw new ResourceDownloadError(url, msg, e);
        }
    }
View Full Code Here

                downloaded.deleteOnExit();
            }
        } catch (IOException e) {
            final String url = urlc.getURL().toString();
            final String msg = "I/O error";
            throw new ResourceDownloadError(url, msg, e);
        }

        return downloadFile;
    }
View Full Code Here

            return new File(namespaceDownloadLocation);
        } catch (UnknownHostException e) {
            final String url = namespaceDownloadLocation;
            final String msg = e.getMessage();
            throw new ResourceDownloadError(url, msg, e);
        } catch (MalformedURLException e) {
            final String url = namespaceDownloadLocation;
            final String msg = e.getMessage();
            throw new ResourceDownloadError(url, msg, e);
        } catch (IOException e) {
            final String url = namespaceDownloadLocation;
            final String msg = e.getMessage();
            throw new ResourceDownloadError(url, msg, e);
        }
    }
View Full Code Here

            return downloadResource(fileUrlConnection,
                    namespaceDownloadLocation);
        } catch (InterruptedIOException e) {
            final String url = namespaceDownloadLocation;
            final String msg = "Interrupted I/O";
            throw new ResourceDownloadError(url, msg, e);
        } catch (IOException e) {
            final String url = namespaceDownloadLocation;
            final String msg = e.getMessage();
            throw new ResourceDownloadError(url, msg, e);
        }
    }
View Full Code Here

            session.disconnect();

            return downloadFile;
        } catch (Exception e) {
            final String msg = "Error downloading namespace";
            throw new ResourceDownloadError(url, msg, e);
        }
    }
View Full Code Here

TOP

Related Classes of org.openbel.framework.core.protocol.ResourceDownloadError

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.