Example usage for com.google.common.net MediaType APPLICATION_XML_UTF_8

List of usage examples for com.google.common.net MediaType APPLICATION_XML_UTF_8

Introduction

In this page you can find the example usage for com.google.common.net MediaType APPLICATION_XML_UTF_8.

Prototype

MediaType APPLICATION_XML_UTF_8

To view the source code for com.google.common.net MediaType APPLICATION_XML_UTF_8.

Click Source Link

Document

As described in <a href="http://www.ietf.org/rfc/rfc3023.txt">RFC 3023</a>, this constant ( application/xml ) is used for XML documents that are "unreadable by casual users."

Usage

From source file:eu.seaclouds.policy.SeaCloudsManagementPolicy.java

private void installSLA() {
    LOG.info("SeaCloudsInitializerPolicy is installing SLA Agreements for " + entity.getId());

    HttpToolResponse response = post(getConfig(SLA_ENDPOINT) + "/seaclouds/agreements",
            MediaType.APPLICATION_XML_UTF_8.toString(), getConfig(SLA_USERNAME), getConfig(SLA_PASSWORD),
            BaseEncoding.base64().decode(getConfig(SLA_AGREEMENT)));

    if (!HttpTool.isStatusCodeHealthy(response.getResponseCode())) {
        throw new RuntimeException("Something went wrong during the SLA Agreements installation. "
                + "Invalid response code, " + response.getResponseCode() + ":" + response.getContentAsString());
    } else {// w  ww.j a  va  2  s  . co  m
        entity.sensors().set(SLA_ID, agreement.getAgreementId());
    }

}

From source file:eu.seaclouds.policy.SeaCloudsManagementPolicy.java

private void notifyRulesReady() {
    LOG.info("SeaCloudsInitializerPolicy is starting to enforce SLA Agreements for " + entity.getId());

    HttpToolResponse response = post(/* w w  w. jav a 2s  .c o m*/
            getConfig(SLA_ENDPOINT) + "/seaclouds/commands/rulesready?agreementId="
                    + agreement.getAgreementId(),
            MediaType.APPLICATION_XML_UTF_8.toString(), getConfig(SLA_USERNAME), getConfig(SLA_PASSWORD),
            "".getBytes());

    if (!HttpTool.isStatusCodeHealthy(response.getResponseCode())) {
        throw new RuntimeException("Something went wrong during the SLA Agreements installation. "
                + "Invalid response code, " + response.getResponseCode() + ":" + response.getContentAsString());
    }
}

From source file:eu.seaclouds.policy.SeaCloudsManagementPolicy.java

private void installMonitoringRules() {
    LOG.info("SeaCloudsInitializerPolicy is installing T4C Monitoring Rules for " + entity.getId());

    HttpToolResponse response = post(getConfig(T4C_ENDPOINT) + "/v1/monitoring-rules",
            MediaType.APPLICATION_XML_UTF_8.toString(), getConfig(T4C_USERNAME), getConfig(T4C_PASSWORD),
            BaseEncoding.base64().decode(getConfig(T4C_RULES)));

    if (!HttpTool.isStatusCodeHealthy(response.getResponseCode())) {
        throw new RuntimeException("Something went wrong while the monitoring rules installation. "
                + "Invalid response code, " + response.getResponseCode() + ":" + response.getContentAsString());
    } else {// w ww. jav a 2 s  . c  om
        List<String> ruleIds = new ArrayList<>();

        for (MonitoringRule rule : monitoringRules.getMonitoringRules()) {
            ruleIds.add(rule.getId());
        }
        entity.sensors().set(T4C_IDS, ruleIds);
    }
}

From source file:eu.seaclouds.policy.SeaCloudsManagementPolicy.java

private void removeSlaAgreement() {
    LOG.info("SeaCloudsInitializerPolicy is removing SLA Agreeement for " + entity.getId());

    HttpToolResponse response = delete(getConfig(SLA_ENDPOINT) + "/agreements/" + agreement.getAgreementId(),
            MediaType.APPLICATION_XML_UTF_8.toString(), getConfig(SLA_USERNAME), getConfig(SLA_PASSWORD));

    if (!HttpTool.isStatusCodeHealthy(response.getResponseCode())) {
        throw new RuntimeException("Something went wrong while removing the SLA Agreements. "
                + "Invalid response code, " + response.getResponseCode() + ":" + response.getContentAsString());
    }//from   ww w  .j  a  va  2 s .  com
}