mirror of https://github.com/apache/jclouds.git
renamed IDHandler in ultradns to TextHandler as it isn't limited to ids
This commit is contained in:
parent
818a6f2c6f
commit
bc52b54945
|
@ -35,7 +35,7 @@ import org.jclouds.ultradns.ws.binders.ZoneAndResourceRecordToXML;
|
|||
import org.jclouds.ultradns.ws.domain.ResourceRecord;
|
||||
import org.jclouds.ultradns.ws.domain.ResourceRecordMetadata;
|
||||
import org.jclouds.ultradns.ws.filters.SOAPWrapWithPasswordAuth;
|
||||
import org.jclouds.ultradns.ws.xml.IDHandler;
|
||||
import org.jclouds.ultradns.ws.xml.TextHandler;
|
||||
import org.jclouds.ultradns.ws.xml.ResourceRecordListHandler;
|
||||
|
||||
import com.google.common.collect.FluentIterable;
|
||||
|
@ -56,7 +56,7 @@ public interface ResourceRecordAsyncApi {
|
|||
*/
|
||||
@Named("createResourceRecord")
|
||||
@POST
|
||||
@XMLResponseParser(IDHandler.Guid.class)
|
||||
@XMLResponseParser(TextHandler.Guid.class)
|
||||
@MapBinder(ZoneAndResourceRecordToXML.class)
|
||||
ListenableFuture<String> create(@PayloadParam("resourceRecord") ResourceRecord toCreate)
|
||||
throws ResourceAlreadyExistsException;
|
||||
|
|
|
@ -33,7 +33,7 @@ import org.jclouds.ultradns.ws.UltraDNSWSExceptions.ResourceAlreadyExistsExcepti
|
|||
import org.jclouds.ultradns.ws.domain.ResourceRecord;
|
||||
import org.jclouds.ultradns.ws.domain.RoundRobinPool;
|
||||
import org.jclouds.ultradns.ws.filters.SOAPWrapWithPasswordAuth;
|
||||
import org.jclouds.ultradns.ws.xml.IDHandler;
|
||||
import org.jclouds.ultradns.ws.xml.TextHandler;
|
||||
import org.jclouds.ultradns.ws.xml.ResourceRecordListHandler;
|
||||
import org.jclouds.ultradns.ws.xml.RoundRobinPoolListHandler;
|
||||
|
||||
|
@ -74,7 +74,7 @@ public interface RoundRobinPoolAsyncApi {
|
|||
*/
|
||||
@Named("addRRLBPool")
|
||||
@POST
|
||||
@XMLResponseParser(IDHandler.RRPool.class)
|
||||
@XMLResponseParser(TextHandler.RRPoolID.class)
|
||||
@Payload("<v01:addRRLBPool><transactionID /><zoneName>{zoneName}</zoneName><hostName>{hostName}</hostName><description>{description}</description><poolRecordType>1</poolRecordType><rrGUID /></v01:addRRLBPool>")
|
||||
ListenableFuture<String> createAPoolForHostname(@PayloadParam("description") String name,
|
||||
@PayloadParam("hostName") String hostname) throws ResourceAlreadyExistsException;
|
||||
|
@ -84,7 +84,7 @@ public interface RoundRobinPoolAsyncApi {
|
|||
*/
|
||||
@Named("addRecordToRRPool")
|
||||
@POST
|
||||
@XMLResponseParser(IDHandler.Guid.class)
|
||||
@XMLResponseParser(TextHandler.Guid.class)
|
||||
@Payload("<v01:addRecordToRRPool><transactionID /><roundRobinRecord lbPoolID=\"{lbPoolID}\" info1Value=\"{address}\" ZoneName=\"{zoneName}\" Type=\"1\" TTL=\"{ttl}\"/></v01:addRecordToRRPool>")
|
||||
ListenableFuture<String> addARecordWithAddressAndTTL(@PayloadParam("lbPoolID") String lbPoolID,
|
||||
@PayloadParam("address") String ipv4Address, @PayloadParam("ttl") int ttl)
|
||||
|
@ -114,7 +114,7 @@ public interface RoundRobinPoolAsyncApi {
|
|||
*/
|
||||
@Named("addRRLBPool")
|
||||
@POST
|
||||
@XMLResponseParser(IDHandler.RRPool.class)
|
||||
@XMLResponseParser(TextHandler.RRPoolID.class)
|
||||
@Payload("<v01:addRRLBPool><transactionID /><zoneName>{zoneName}</zoneName><hostName>{hostName}</hostName><description>{description}</description><poolRecordType>28</poolRecordType><rrGUID /></v01:addRRLBPool>")
|
||||
ListenableFuture<String> createAAAAPoolForHostname(@PayloadParam("description") String name,
|
||||
@PayloadParam("hostName") String hostname) throws ResourceAlreadyExistsException;
|
||||
|
@ -124,7 +124,7 @@ public interface RoundRobinPoolAsyncApi {
|
|||
*/
|
||||
@Named("addRecordToRRPool")
|
||||
@POST
|
||||
@XMLResponseParser(IDHandler.Guid.class)
|
||||
@XMLResponseParser(TextHandler.Guid.class)
|
||||
@Payload("<v01:addRecordToRRPool><transactionID /><roundRobinRecord lbPoolID=\"{lbPoolID}\" info1Value=\"{address}\" ZoneName=\"{zoneName}\" Type=\"28\" TTL=\"{ttl}\"/></v01:addRecordToRRPool>")
|
||||
ListenableFuture<String> addAAAARecordWithAddressAndTTL(@PayloadParam("lbPoolID") String lbPoolID,
|
||||
@PayloadParam("address") String ipv6Address, @PayloadParam("ttl") int ttl)
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.jclouds.rest.annotations.VirtualHost;
|
|||
import org.jclouds.rest.annotations.XMLResponseParser;
|
||||
import org.jclouds.ultradns.ws.domain.Task;
|
||||
import org.jclouds.ultradns.ws.filters.SOAPWrapWithPasswordAuth;
|
||||
import org.jclouds.ultradns.ws.xml.IDHandler;
|
||||
import org.jclouds.ultradns.ws.xml.TextHandler;
|
||||
import org.jclouds.ultradns.ws.xml.TaskHandler;
|
||||
import org.jclouds.ultradns.ws.xml.TaskListHandler;
|
||||
|
||||
|
@ -52,7 +52,7 @@ public interface TaskAsyncApi {
|
|||
*/
|
||||
@Named("runTest")
|
||||
@POST
|
||||
@XMLResponseParser(IDHandler.Guid.class)
|
||||
@XMLResponseParser(TextHandler.Guid.class)
|
||||
@Payload("<v01:runTest><value>{value}</value></v01:runTest>")
|
||||
ListenableFuture<String> runTest(@PayloadParam("value") String value);
|
||||
|
||||
|
|
|
@ -35,8 +35,8 @@ import org.jclouds.ultradns.ws.domain.PoolRecordSpec;
|
|||
import org.jclouds.ultradns.ws.domain.TrafficControllerPool;
|
||||
import org.jclouds.ultradns.ws.domain.TrafficControllerPoolRecord;
|
||||
import org.jclouds.ultradns.ws.filters.SOAPWrapWithPasswordAuth;
|
||||
import org.jclouds.ultradns.ws.xml.IDHandler;
|
||||
import org.jclouds.ultradns.ws.xml.PoolRecordSpecHandler;
|
||||
import org.jclouds.ultradns.ws.xml.TextHandler;
|
||||
import org.jclouds.ultradns.ws.xml.TrafficControllerPoolListHandler;
|
||||
import org.jclouds.ultradns.ws.xml.TrafficControllerPoolRecordListHandler;
|
||||
|
||||
|
@ -58,7 +58,7 @@ public interface TrafficControllerPoolAsyncApi {
|
|||
*/
|
||||
@Named("addTCLBPool")
|
||||
@POST
|
||||
@XMLResponseParser(IDHandler.TCPool.class)
|
||||
@XMLResponseParser(TextHandler.TCPoolID.class)
|
||||
@Payload("<v01:addTCLBPool><transactionID /><zoneName>{zoneName}</zoneName><hostName>{hostName}</hostName><description>{description}</description><poolRecordType>1</poolRecordType><failOver>Enabled</failOver><probing>Enabled</probing><maxActive>0</maxActive><rrGUID /></v01:addTCLBPool>")
|
||||
ListenableFuture<String> createPoolForHostname(@PayloadParam("description") String name,
|
||||
@PayloadParam("hostName") String hostname) throws ResourceAlreadyExistsException;
|
||||
|
@ -96,7 +96,7 @@ public interface TrafficControllerPoolAsyncApi {
|
|||
*/
|
||||
@Named("addPoolRecord")
|
||||
@POST
|
||||
@XMLResponseParser(IDHandler.PoolRecord.class)
|
||||
@XMLResponseParser(TextHandler.PoolRecordID.class)
|
||||
@Payload("<v01:addPoolRecord><transactionID /><poolID>{poolID}</poolID><pointsTo>{pointsTo}</pointsTo><priority /><failOverDelay /><ttl>{ttl}</ttl><weight /><mode /><threshold /></v01:addPoolRecord>")
|
||||
ListenableFuture<String> addRecordToPoolWithTTL(@PayloadParam("pointsTo") String pointsTo,
|
||||
@PayloadParam("poolID") String lbPoolID, @PayloadParam("ttl") int ttl) throws ResourceAlreadyExistsException;
|
||||
|
|
|
@ -28,54 +28,54 @@ import org.jclouds.http.functions.ParseSax;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public abstract class IDHandler extends ParseSax.HandlerForGeneratedRequestWithResult<String> {
|
||||
public abstract class TextHandler extends ParseSax.HandlerForGeneratedRequestWithResult<String> {
|
||||
|
||||
public static class Guid extends IDHandler {
|
||||
public static class Guid extends TextHandler {
|
||||
public Guid() {
|
||||
super("guid");
|
||||
}
|
||||
}
|
||||
|
||||
public static class RRPool extends IDHandler {
|
||||
public RRPool() {
|
||||
public static class RRPoolID extends TextHandler {
|
||||
public RRPoolID() {
|
||||
super("RRPoolID");
|
||||
}
|
||||
}
|
||||
|
||||
public static class TCPool extends IDHandler {
|
||||
public TCPool() {
|
||||
public static class TCPoolID extends TextHandler {
|
||||
public TCPoolID() {
|
||||
super("TCPoolID");
|
||||
}
|
||||
}
|
||||
|
||||
public static class PoolRecord extends IDHandler {
|
||||
public PoolRecord() {
|
||||
public static class PoolRecordID extends TextHandler {
|
||||
public PoolRecordID() {
|
||||
super("poolRecordID");
|
||||
}
|
||||
}
|
||||
|
||||
private String idElement;
|
||||
private String textElement;
|
||||
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
private String id = null;
|
||||
private String text = null;
|
||||
|
||||
private IDHandler(String idElement) {
|
||||
this.idElement = checkNotNull(idElement, "idElement");
|
||||
private TextHandler(String textElement) {
|
||||
this.textElement = checkNotNull(textElement, "textElement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getResult() {
|
||||
try {
|
||||
return checkNotNull(id, "%s not present in the response", idElement);
|
||||
return checkNotNull(text, "%s not present in the response", textElement);
|
||||
} finally {
|
||||
id = null;
|
||||
text = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endElement(String uri, String name, String qName) {
|
||||
if (equalsOrSuffix(qName, idElement)) {
|
||||
id = currentOrNull(currentText);
|
||||
if (equalsOrSuffix(qName, textElement)) {
|
||||
text = currentOrNull(currentText);
|
||||
}
|
||||
currentText = new StringBuilder();
|
||||
}
|
|
@ -23,7 +23,7 @@ import static org.testng.Assert.assertEquals;
|
|||
import java.io.InputStream;
|
||||
|
||||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.jclouds.ultradns.ws.xml.IDHandler;
|
||||
import org.jclouds.ultradns.ws.xml.TextHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
|
@ -35,7 +35,7 @@ public class RunTestResponseTest extends BaseHandlerTest {
|
|||
public void test() {
|
||||
InputStream is = getClass().getResourceAsStream("/taskid.xml");
|
||||
|
||||
IDHandler.Guid handler = injector.getInstance(IDHandler.Guid.class);
|
||||
TextHandler.Guid handler = injector.getInstance(TextHandler.Guid.class);
|
||||
assertEquals(factory.create(handler).parse(is), "8d7a1725-4f4a-4b70-affa-f01dcce1526e");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue