public HostedZoneConfig unmarshall(StaxUnmarshallerContext context) throws Exception { HostedZoneConfig hostedZoneConfig = new HostedZoneConfig(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return hostedZoneConfig; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("Comment", targetDepth)) { hostedZoneConfig.setComment(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return hostedZoneConfig; } } } }
/** * Returns hashmap of <KEY: zoneID, VALUE: String[] of ID, name, caller reference, and comment> * * @param marker_tableName table name of the marker * @param maxItems number of items returned when the actual number of list exceeds maxItems * @return Hashmap of <KEY: zoneID, VALUE: String[] of ID, name, caller reference, and comment> * @throws InternalErrorException */ @Override public ListHostedZonesResult listHostedZones(String marker, int maxItems, long accId) throws ErrorResponse { ListHostedZonesResult result = new ListHostedZonesResult(); Collection<HostedZone> hostedZones = new LinkedList<HostedZone>(); int lim = maxItems; try { ResultSet rs = null; String query = null; Statement stmt = this.sqlConnection.createStatement(); if (marker == null) { logger.debug("No marker is given."); query = "SELECT * FROM msi.zones WHERE accountId = " + accId + ";"; } else { logger.debug("Marker is assigned."); query = "SELECT * FROM msi.zones WHERE accountId = " + accId + " AND ID >= \'" + marker + "\';"; } rs = stmt.executeQuery(query); while (lim != 0 && rs.next()) { HostedZone hz = new HostedZone( rs.getString("ID"), rs.getString("name"), rs.getString("callerReference")); HostedZoneConfig config = new HostedZoneConfig(); config.setComment(rs.getString("comment")); hz.setConfig(config); --lim; hostedZones.add(hz); } if (marker != null && hostedZones.size() == 0) { // TODO throw an exception for marker not existing (test against // AWS to see which exception is being returned) } boolean truncated = rs.next(); logger.debug("Relative Limit = " + lim + "; MaxItems = " + maxItems); logger.debug("Truncated = " + truncated); if (lim == 0 && truncated) { truncated = true; } result.setHostedZones(hostedZones); result.setMaxItems(String.valueOf(maxItems)); result.setIsTruncated(truncated); if (truncated) { result.setNextMarker(rs.getString("ID")); } } catch (SQLException e) { System.err.println("Failed to get zone informations for listHostedZone request."); e.printStackTrace(); throw DNS53Faults.InternalError(); } logger.debug("Returning " + hostedZones.size() + " hosted zones information."); return result; }