Example usage for com.amazonaws.services.route53.model ListHostedZonesResult setMarker

List of usage examples for com.amazonaws.services.route53.model ListHostedZonesResult setMarker

Introduction

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

Prototype


public void setMarker(String marker) 

Source Link

Document

For the second and subsequent calls to ListHostedZones, Marker is the value that you specified for the marker parameter in the request that produced the current response.

Usage

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

License:Apache License

public ListHostedZonesResult listHostedZones(ListHostedZonesRequest req)
        throws AmazonServiceException, AmazonClientException {
    Client c = Client.create();/*  ww  w  . j a  v  a2s .c o  m*/
    WebResource r = c.resource(this.serverURL);
    MultivaluedMap<String, String> paramMap = new MultivaluedMapImpl();
    if (req.getMarker() != null) {
        paramMap.add("marker", req.getMarker());
    }
    if (req.getMaxItems() != null) {
        paramMap.add("maxitems", req.getMaxItems());
    }

    ClientResponse response = r.queryParams(paramMap).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=")
            .get(ClientResponse.class);

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

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

    ListHostedZonesResult result = new ListHostedZonesResult();
    if (interResult.getHostedZones() != null) {
        Collection<HostedZone> hzs = new LinkedList<HostedZone>();
        for (HostedZonePOJO hz : interResult.getHostedZones()) {
            HostedZone temp = new HostedZone();
            temp.setCallerReference(hz.getCallerReference());
            temp.setId(hz.getId());
            temp.setName(hz.getName());
            temp.setResourceRecordSetCount(hz.getResourceRecordSetCount());
            if (hz.getConfig() != null) {
                HostedZoneConfig config = new HostedZoneConfig();
                if (hz.getConfig().getComment() != null) {
                    config.setComment(hz.getConfig().getComment());
                }
                temp.setConfig(config);
            }
            hzs.add(temp);
        }
        result.setHostedZones(hzs);
    }
    if (interResult.getMarker() != null) {
        result.setMarker(interResult.getMarker());
    }
    if (interResult.getMaxItems() != null) {
        result.setMaxItems(interResult.getMaxItems());
    }
    if (interResult.getNextMarker() != null) {
        result.setNextMarker(interResult.getNextMarker());
    }
    return result;
}