List of usage examples for com.amazonaws.services.route53.model CreateHostedZoneRequest toString
@Override
public String toString()
From source file:com.msi.dns53.server.query.CreateHostedZone.java
License:Apache License
public CreateHostedZoneRequest unmarshall(HttpServletRequest req) throws IOException, ParserConfigurationException, SAXException { final CreateHostedZoneRequest request = new CreateHostedZoneRequest(); StringBuilder stringBuilder = new StringBuilder(1000); Scanner scanner = new Scanner(req.getInputStream()); while (scanner.hasNextLine()) { stringBuilder.append(scanner.nextLine()); }/*from w w w .j av a 2 s. c o m*/ String body = stringBuilder.toString(); logger.debug("XML Body Content: " + body); DefaultHandler handler = new DefaultHandler() { private boolean createHostedZoneRequest = false; private boolean hostedZoneConfig = false; private CharArrayWriter contents = new CharArrayWriter(); public void startElement(String uri, String localName, String nodeName, Attributes attributes) throws SAXException { contents.reset(); if (!uri.equals(DNS53Constants.XMLNS_VALUE)) { throw DNS53Faults.InvalidInput("The XML you provided did not have the correct namespace."); } if (nodeName.equals(DNS53Constants.CREATEHOSTEDZONEREQUEST)) { createHostedZoneRequest = true; } if (nodeName.equals(DNS53Constants.HOSTEDZONECONFIG)) { hostedZoneConfig = true; } } public void endElement(String uri, String localName, String nodeName) throws SAXException { if (createHostedZoneRequest && localName.equals(DNS53Constants.CREATEHOSTEDZONEREQUEST)) { createHostedZoneRequest = false; } if (createHostedZoneRequest && hostedZoneConfig && localName.equals(DNS53Constants.HOSTEDZONECONFIG)) { hostedZoneConfig = false; } if (createHostedZoneRequest && localName.equals(DNS53Constants.NAME)) { request.setName(contents.toString()); } if (createHostedZoneRequest && localName.equals(DNS53Constants.CALLERREFERENCE)) { request.setCallerReference(contents.toString()); } if (createHostedZoneRequest && hostedZoneConfig && localName.equals(DNS53Constants.COMMENT)) { HostedZoneConfig config = new HostedZoneConfig(); config.setComment(contents.toString()); request.setHostedZoneConfig(config); } } public void characters(char ch[], int start, int length) throws SAXException { this.contents.write(ch, start, length); } }; XMLReader xr = XMLReaderFactory.createXMLReader(); xr.setContentHandler(handler); xr.parse(new InputSource(new StringReader(body))); logger.debug("Unmarshalling complete: " + request.toString()); return request; }