Package com.dtolabs.rundeck.core.common

Examples of com.dtolabs.rundeck.core.common.FileUpdaterException


        if ("http".equalsIgnoreCase(url.getProtocol()) || "https".equalsIgnoreCase(url.getProtocol())) {
            updateHTTPUrl(destinationFile);
        } else if ("file".equalsIgnoreCase(url.getProtocol())) {
            updateFileUrl(destinationFile);
        } else {
            throw new FileUpdaterException("Unsupported protocol: " + url);
        }
    }
View Full Code Here


                }
            }finally {
                in.close();
            }
        } catch (URISyntaxException e) {
            throw new FileUpdaterException("Invalid URI: " + url);
        } catch (FileNotFoundException e) {
            throw new FileUpdaterException(e);
        } catch (IOException e) {
            throw new FileUpdaterException(e);
        }
    }
View Full Code Here

                    AuthScope.ANY_REALM, "BASIC");
                cred = new UsernamePasswordCredentials(username + ":" + password);
                urlToUse = new URL(url.getProtocol(), url.getHost(), url.getPort(), url.getFile()).toExternalForm();
            }
        } catch (MalformedURLException e) {
            throw new FileUpdaterException("Failed to configure base URL for authentication: " + e.getMessage(),
                e);
        }
        if (doauth) {
            client.getParams().setAuthenticationPreemptive(true);
            client.getState().setCredentials(authscope, cred);
        }
        interaction.setClient(client);
        interaction.setMethod(new GetMethod(urlToUse));
        interaction.setFollowRedirects(true);
        if (null != acceptHeader) {
            interaction.setRequestHeader("Accept", acceptHeader);
        } else {
            interaction.setRequestHeader("Accept", "*/*");
        }

        if (useCaching) {
            applyCacheHeaders(cacheProperties, interaction);
        }

        logger.debug("Making remote request: " + cleanUrl);
        try {
            resultCode = interaction.executeMethod();
            reasonCode = interaction.getStatusText();
            if (useCaching && HttpStatus.SC_NOT_MODIFIED == resultCode) {
                logger.debug("Content NOT MODIFIED: file up to date");
            } else if (HttpStatus.SC_OK == resultCode) {
                determineContentType(interaction);

                //write to file
                FileOutputStream output=new FileOutputStream(destinationFile);
                try{
                    Streams.copyStream(interaction.getResponseBodyAsStream(), output);
                }finally{
                    output.close();
                }
                if (destinationFile.length() < 1) {
                    //file was empty!
                    if(!destinationFile.delete()) {
                        logger.warn("Failed to remove empty file: " + destinationFile.getAbsolutePath());
                    }
                }
                if (useCaching) {
                    cacheResponseInfo(interaction, cacheMetadata);
                }
            } else {
                throw new FileUpdaterException(
                    "Unable to retrieve content: result code: " + resultCode + " " + reasonCode);
            }
        } catch (HttpException e) {
            throw new FileUpdaterException(e);
        } catch (IOException e) {
            throw new FileUpdaterException(e);
        } finally {
            interaction.releaseConnection();
        }
    }
View Full Code Here

TOP

Related Classes of com.dtolabs.rundeck.core.common.FileUpdaterException

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.