Package com.volantis.shared.net.http

Examples of com.volantis.shared.net.http.HttpGetMethod


            Project project, String name)
            throws RepositoryException {

        PolicyBuilders builders;

        HttpGetMethod method = methodFactory.createGetMethod(name);
        try {
            method.addRequestHeader(
                    REQUEST_TYPE_HEADER_NAME,
                    "policySet");

            // todo The policy may not exist but the project may in which case
            // todo this should load the project and then try and load the
            // todo policy from a fallback (if any).
            HttpStatusCode code = method.execute();
            if (code == HttpStatusCode.OK) {

                project = updateProject(project, method);

                InputStream in = method.getResponseBodyAsStream();

                builders = parser.parsePolicyBuilders(in, name);
            } else {
                builders = null;
            }
        } catch (Exception e) {
            // If we get an error, we log it but don't throw an exception.
            // We just carry on as if we hadn't found the asset.
            logger.error("remote-component-not-available",
                    new Object[]{name}, e);
            builders = null;
        } finally {
            method.releaseConnection();
        }

        return new PolicyBuildersResponse(project, builders);
    }
View Full Code Here


        // If the name is project relative then make it absolute.
        if (name.startsWith("/")) {
            name = runtimeProject.makeAbsolutePolicyURL(name);
        }
       
        HttpGetMethod method = methodFactory.createGetMethod(name);
        Throwable throwable = null;
        try {
            method.addRequestHeader(REQUEST_TYPE_HEADER_NAME,
                    "singlePolicy");

            // todo The policy may not exist but the project may in which case
            // todo this should load the project and then try and load the
            // todo policy from a fallback (if any).
            HttpStatusCode code = method.execute();
            if (code == HttpStatusCode.OK) {

                project = updateProject(project, method);

                InputStream in = method.getResponseBodyAsStream();

                builder = parser.parsePolicyBuilder(in, name);
            } else {
                // Log the fact that the remote policy could not be found.
                logger.warn("remote-policy-not-found", new Object[]{
                    name, code
                });

                builder = null;
            }
        } catch (IOException e) {
            throwable = e;
        } catch (ResourceMigrationException e) {
            throwable = e;
        } finally {
            if (throwable != null) {
                // If we get an error, we log it but don't throw an exception.
                // We just carry on as if we hadn't found the asset.
                logger.error("remote-component-not-available",
                        new Object[]{name}, throwable);
            }
            method.releaseConnection();
        }

        return new PolicyBuilderResponse(project, builder);
    }
View Full Code Here

TOP

Related Classes of com.volantis.shared.net.http.HttpGetMethod

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.