Example usage for com.amazonaws.services.route53.model DeleteHostedZoneRequest getId

List of usage examples for com.amazonaws.services.route53.model DeleteHostedZoneRequest getId

Introduction

In this page you can find the example usage for com.amazonaws.services.route53.model DeleteHostedZoneRequest getId.

Prototype


public String getId() 

Source Link

Document

The ID of the hosted zone you want to delete.

Usage

From source file:com.msi.dns53.client.DNS53Client.java

License:Apache License

public DeleteHostedZoneResult deleteHostedZone(DeleteHostedZoneRequest req)
        throws AmazonServiceException, AmazonClientException {
    Client c = Client.create();/*from ww  w.j a  va2s . com*/
    WebResource r = c.resource(this.serverURL);
    ClientResponse response = r.path(req.getId()).type(MediaType.APPLICATION_XML_TYPE)
            .accept(MediaType.TEXT_XML)
            .header("X-Amzn-Authorization",
                    "AWS3 AWSAccessKeyId=" + this.accessKey + "," + "Algorithm=HmacSHA256,"
                            + "SignedHeaders=Host;X-Amz-Date," + "Signature=THISISANEXAMPLESIGNATURE=")
            .delete(ClientResponse.class);

    String resultXml = response.getEntity(String.class);
    if (response.getStatus() != 200) {
        exceptionMapper(response, resultXml);
    }

    DeleteHostedZoneResponsePOJO interResult = null;
    try {
        StringReader reader = new StringReader(resultXml);
        JAXBContext context = JAXBContext.newInstance(DeleteHostedZoneResponsePOJO.class);
        Unmarshaller unmarshaller = context.createUnmarshaller();
        interResult = (DeleteHostedZoneResponsePOJO) unmarshaller.unmarshal(reader);
    } catch (JAXBException e) {
        e.printStackTrace();
        return null;
    }
    if (interResult == null) {
        return null;
    }

    DeleteHostedZoneResult result = new DeleteHostedZoneResult();
    if (interResult.getChangeInfo() != null) {
        ChangeInfo ci = new ChangeInfo();
        if (interResult.getChangeInfo().getId() != null) {
            ci.setId(interResult.getChangeInfo().getId());
        }
        if (interResult.getChangeInfo().getStatus() != null) {
            ci.setStatus(interResult.getChangeInfo().getStatus());
        }
        if (interResult.getChangeInfo().getSubmittedAt() != null) {
            ci.setSubmittedAt(interResult.getChangeInfo().getSubmittedAt());
        }
        if (interResult.getChangeInfo().getComment() != null) {
            ci.setComment(interResult.getChangeInfo().getComment());
        }
        result.setChangeInfo(ci);
    }
    return result;
}

From source file:com.msi.dns53.server.query.DeleteHostedZone.java

License:Apache License

private DeleteHostedZoneResult deleteHostedZone(DeleteHostedZoneRequest request) throws ErrorResponse {
    String zoneId = request.getId();
    logger.debug("Delete target: " + zoneId);
    Date submittedAt = new Date();
    DeleteHostedZoneResult result = new DeleteHostedZoneResult();
    AccessMySQL sqlaccess = AccessMySQL.getInstance();
    String tableName = sqlaccess.getTableName(zoneId, this.getAccountId());
    if (tableName.equals("FAILED")) {
        throw DNS53Faults.NoSuchHostedZone(zoneId);
    } else {//from   w  ww. j av a 2s .com
        String callerReference = sqlaccess.getCallerReference(zoneId, this.getAccountId());
        sqlaccess.deleteHostedZone(zoneId, tableName, callerReference);
        String changeID = RequestHandler.writeChange(sqlaccess, "PENDING", submittedAt.toString(), tableName,
                "DELETE");
        ChangeInfo changeInfo = new ChangeInfo();
        changeInfo.setId(changeID);
        changeInfo.setStatus("PENDING");
        changeInfo.setSubmittedAt(submittedAt);
        result.setChangeInfo(changeInfo);
    }
    return result;
}