mirror of https://github.com/apache/jclouds.git
JCLOUDS-1038: Fix date deserialization in EC2 apis
This commit is contained in:
parent
02b79106c3
commit
86dadc3a75
|
@ -22,8 +22,7 @@ import javax.annotation.Resource;
|
|||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.aws.util.AWSUtils;
|
||||
import org.jclouds.date.DateCodec;
|
||||
import org.jclouds.date.DateCodecFactory;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.ec2.domain.Attachment;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.location.Region;
|
||||
|
@ -36,12 +35,12 @@ public class AttachmentHandler extends ParseSax.HandlerForGeneratedRequestWithRe
|
|||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
protected final DateCodec dateCodec;
|
||||
protected final DateService dateService;
|
||||
protected final Supplier<String> defaultRegion;
|
||||
|
||||
@Inject
|
||||
AttachmentHandler(DateCodecFactory dateCodecFactory, @Region Supplier<String> defaultRegion) {
|
||||
this.dateCodec = dateCodecFactory.iso8601();
|
||||
AttachmentHandler(DateService dateService, @Region Supplier<String> defaultRegion) {
|
||||
this.dateService = dateService;
|
||||
this.defaultRegion = defaultRegion;
|
||||
}
|
||||
|
||||
|
@ -71,7 +70,7 @@ public class AttachmentHandler extends ParseSax.HandlerForGeneratedRequestWithRe
|
|||
} else if (qName.equals("device")) {
|
||||
device = currentText.toString().trim();
|
||||
} else if (qName.equals("attachTime")) {
|
||||
attachTime = dateCodec.toDate(currentText.toString().trim());
|
||||
attachTime = dateService.iso8601DateOrSecondsDateParse(currentText.toString().trim());
|
||||
}
|
||||
currentText.setLength(0);
|
||||
}
|
||||
|
|
|
@ -25,8 +25,7 @@ import java.util.Set;
|
|||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.aws.util.AWSUtils;
|
||||
import org.jclouds.date.DateCodec;
|
||||
import org.jclouds.date.DateCodecFactory;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.ec2.domain.Attachment;
|
||||
import org.jclouds.ec2.domain.BlockDevice;
|
||||
import org.jclouds.ec2.domain.InstanceState;
|
||||
|
@ -43,12 +42,12 @@ import com.google.common.collect.Sets;
|
|||
|
||||
public abstract class BaseReservationHandler<T> extends HandlerForGeneratedRequestWithResult<T> {
|
||||
|
||||
protected final DateCodec dateCodec;
|
||||
protected final DateService dateService;
|
||||
protected final Supplier<String> defaultRegion;
|
||||
|
||||
@Inject
|
||||
public BaseReservationHandler(DateCodecFactory dateCodecFactory, @Region Supplier<String> defaultRegion) {
|
||||
this.dateCodec = dateCodecFactory.iso8601();
|
||||
public BaseReservationHandler(DateService dateService, @Region Supplier<String> defaultRegion) {
|
||||
this.dateService = dateService;
|
||||
this.defaultRegion = defaultRegion;
|
||||
}
|
||||
|
||||
|
@ -141,7 +140,7 @@ public abstract class BaseReservationHandler<T> extends HandlerForGeneratedReque
|
|||
} else if (equalsOrSuffix(qName, "keyName")) {
|
||||
builder.keyName(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "launchTime")) {
|
||||
builder.launchTime(dateCodec.toDate(currentOrNull(currentText)));
|
||||
builder.launchTime(dateService.iso8601DateOrSecondsDateParse(currentOrNull(currentText)));
|
||||
} else if (equalsOrSuffix(qName, "availabilityZone")) {
|
||||
builder.availabilityZone(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "virtualizationType")) {
|
||||
|
@ -167,7 +166,7 @@ public abstract class BaseReservationHandler<T> extends HandlerForGeneratedReque
|
|||
} else if (equalsOrSuffix(qName, "status")) {
|
||||
attachmentStatus = Attachment.Status.fromValue(currentText.toString().trim());
|
||||
} else if (equalsOrSuffix(qName, "attachTime")) {
|
||||
attachTime = dateCodec.toDate(currentOrNull(currentText));
|
||||
attachTime = dateService.iso8601DateOrSecondsDateParse(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "deleteOnTermination")) {
|
||||
deleteOnTermination = Boolean.parseBoolean(currentText.toString().trim());
|
||||
} else if (equalsOrSuffix(qName, "ebs")) {
|
||||
|
|
|
@ -19,8 +19,7 @@ package org.jclouds.ec2.xml;
|
|||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.date.DateCodec;
|
||||
import org.jclouds.date.DateCodecFactory;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.ec2.domain.Attachment;
|
||||
import org.jclouds.ec2.domain.BlockDevice;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
|
@ -39,11 +38,11 @@ public class BlockDeviceMappingHandler extends
|
|||
private Attachment.Status attachmentStatus;
|
||||
private Date attachTime;
|
||||
|
||||
protected final DateCodec dateCodec;
|
||||
protected final DateService dateService;
|
||||
|
||||
@Inject
|
||||
public BlockDeviceMappingHandler(DateCodecFactory dateCodecFactory) {
|
||||
this.dateCodec = dateCodecFactory.iso8601();
|
||||
public BlockDeviceMappingHandler(DateService dateService) {
|
||||
this.dateService = dateService;
|
||||
}
|
||||
|
||||
public Map<String, BlockDevice> getResult() {
|
||||
|
@ -60,7 +59,7 @@ public class BlockDeviceMappingHandler extends
|
|||
} else if (qName.equals("status")) {
|
||||
attachmentStatus = Attachment.Status.fromValue(currentText.toString().trim());
|
||||
} else if (qName.equals("attachTime")) {
|
||||
attachTime = dateCodec.toDate(currentText.toString().trim());
|
||||
attachTime = dateService.iso8601DateOrSecondsDateParse(currentText.toString().trim());
|
||||
} else if (qName.equals("item")) {
|
||||
ebsBlockDevices.put(deviceName, new BlockDevice(volumeId, attachmentStatus, attachTime, deleteOnTermination));
|
||||
this.volumeId = null;
|
||||
|
|
|
@ -21,8 +21,7 @@ import java.util.Date;
|
|||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.aws.util.AWSUtils;
|
||||
import org.jclouds.date.DateCodec;
|
||||
import org.jclouds.date.DateCodecFactory;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.ec2.domain.BundleTask;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.location.Region;
|
||||
|
@ -30,12 +29,12 @@ import org.jclouds.location.Region;
|
|||
import com.google.common.base.Supplier;
|
||||
|
||||
public class BundleTaskHandler extends ParseSax.HandlerForGeneratedRequestWithResult<BundleTask> {
|
||||
protected final DateCodec dateCodec;
|
||||
protected final DateService dateService;
|
||||
protected final Supplier<String> defaultRegion;
|
||||
|
||||
@Inject
|
||||
protected BundleTaskHandler(DateCodecFactory dateCodecFactory, @Region Supplier<String> defaultRegion) {
|
||||
this.dateCodec = dateCodecFactory.iso8601();
|
||||
protected BundleTaskHandler(DateService dateService, @Region Supplier<String> defaultRegion) {
|
||||
this.dateService = dateService;
|
||||
this.defaultRegion = defaultRegion;
|
||||
}
|
||||
|
||||
|
@ -88,7 +87,7 @@ public class BundleTaskHandler extends ParseSax.HandlerForGeneratedRequestWithRe
|
|||
temp = temp.substring(0, temp.length() - 1);
|
||||
progress = Integer.parseInt(temp);
|
||||
} else if (qName.equals("startTime")) {
|
||||
startTime = dateCodec.toDate(currentText.toString().trim());
|
||||
startTime = dateService.iso8601DateOrSecondsDateParse(currentText.toString().trim());
|
||||
} else if (qName.equals("state")) {
|
||||
state = currentText.toString().trim();
|
||||
} else if (qName.equals("bucket")) {
|
||||
|
@ -96,7 +95,7 @@ public class BundleTaskHandler extends ParseSax.HandlerForGeneratedRequestWithRe
|
|||
} else if (qName.equals("prefix")) {
|
||||
prefix = currentText.toString().trim();
|
||||
} else if (qName.equals("updateTime")) {
|
||||
updateTime = dateCodec.toDate(currentText.toString().trim());
|
||||
updateTime = dateService.iso8601DateOrSecondsDateParse(currentText.toString().trim());
|
||||
}
|
||||
currentText.setLength(0);
|
||||
}
|
||||
|
|
|
@ -18,19 +18,15 @@ package org.jclouds.ec2.xml;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.aws.util.AWSUtils;
|
||||
import org.jclouds.date.DateCodec;
|
||||
import org.jclouds.date.DateCodecFactory;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.ec2.domain.Attachment;
|
||||
import org.jclouds.ec2.domain.Volume;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
|
@ -40,17 +36,22 @@ import org.jclouds.location.Zone;
|
|||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
public class CreateVolumeResponseHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Volume> {
|
||||
protected final DateCodec dateCodec;
|
||||
protected final DateService dateService;
|
||||
protected final Supplier<String> defaultRegion;
|
||||
protected final Supplier<Map<String, Supplier<Set<String>>>> regionToZonesSupplier;
|
||||
protected final Supplier<Set<String>> zonesSupplier;
|
||||
|
||||
@Inject
|
||||
protected CreateVolumeResponseHandler(DateCodecFactory dateCodecFactory, @Region Supplier<String> defaultRegion,
|
||||
protected CreateVolumeResponseHandler(DateService dateService, @Region Supplier<String> defaultRegion,
|
||||
@Zone Supplier<Map<String, Supplier<Set<String>>>> regionToZonesSupplier,
|
||||
@Zone Supplier<Set<String>> zonesSupplier) {
|
||||
this.dateCodec = dateCodecFactory.iso8601();
|
||||
this.dateService = dateService;
|
||||
this.defaultRegion = defaultRegion;
|
||||
this.regionToZonesSupplier = regionToZonesSupplier;
|
||||
this.zonesSupplier = zonesSupplier;
|
||||
|
@ -113,7 +114,7 @@ public class CreateVolumeResponseHandler extends ParseSax.HandlerForGeneratedReq
|
|||
volumeStatus = Volume.Status.fromValue(currentText.toString().trim());
|
||||
}
|
||||
} else if (qName.equals("createTime")) {
|
||||
createTime = dateCodec.toDate(currentText.toString().trim());
|
||||
createTime = dateService.iso8601DateOrSecondsDateParse(currentText.toString().trim());
|
||||
} else if (qName.equals("attachmentSet")) {
|
||||
inAttachmentSet = false;
|
||||
} else if (qName.equals("instanceId")) {
|
||||
|
@ -125,7 +126,7 @@ public class CreateVolumeResponseHandler extends ParseSax.HandlerForGeneratedReq
|
|||
} else if (qName.equals("device")) {
|
||||
device = currentText.toString().trim();
|
||||
} else if (qName.equals("attachTime")) {
|
||||
attachTime = dateCodec.toDate(currentText.toString().trim());
|
||||
attachTime = dateService.iso8601DateOrSecondsDateParse(currentText.toString().trim());
|
||||
} else if (qName.equals("volumeType")) {
|
||||
volumeType = currentText.toString().trim();
|
||||
if (volumeType.equals(""))
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.Set;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.date.DateCodecFactory;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.ec2.domain.Reservation;
|
||||
import org.jclouds.ec2.domain.RunningInstance;
|
||||
import org.jclouds.location.Region;
|
||||
|
@ -47,9 +47,9 @@ public class DescribeInstancesResponseHandler extends
|
|||
private boolean inTagSet;
|
||||
|
||||
@Inject
|
||||
DescribeInstancesResponseHandler(DateCodecFactory dateCodecFactory, @Region Supplier<String> defaultRegion,
|
||||
DescribeInstancesResponseHandler(DateService dateService, @Region Supplier<String> defaultRegion,
|
||||
TagSetHandler tagSetHandler) {
|
||||
super(dateCodecFactory, defaultRegion);
|
||||
super(dateService, defaultRegion);
|
||||
this.tagSetHandler = tagSetHandler;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,18 +18,17 @@ package org.jclouds.ec2.xml;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.date.DateCodec;
|
||||
import org.jclouds.date.DateCodecFactory;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.ec2.domain.PasswordData;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
|
||||
public class GetPasswordDataResponseHandler extends ParseSax.HandlerWithResult<PasswordData> {
|
||||
protected final DateCodec dateCodec;
|
||||
protected final DateService dateService;
|
||||
|
||||
|
||||
@Inject
|
||||
protected GetPasswordDataResponseHandler(DateCodecFactory dateCodecFactory) {
|
||||
this.dateCodec = dateCodecFactory.iso8601();
|
||||
protected GetPasswordDataResponseHandler(DateService dateService) {
|
||||
this.dateService = dateService;
|
||||
}
|
||||
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
|
@ -44,7 +43,7 @@ public class GetPasswordDataResponseHandler extends ParseSax.HandlerWithResult<P
|
|||
if (qName.equals("instanceId")) {
|
||||
builder.instanceId(currentText.toString().trim());
|
||||
} else if (qName.equals("timestamp")) {
|
||||
builder.timestamp(dateCodec.toDate(currentText.toString().trim()));
|
||||
builder.timestamp(dateService.iso8601DateOrSecondsDateParse(currentText.toString().trim()));
|
||||
} else if (qName.equals("passwordData")) {
|
||||
builder.passwordData(currentText.toString().trim());
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ package org.jclouds.ec2.xml;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.date.DateCodecFactory;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.ec2.domain.Reservation;
|
||||
import org.jclouds.ec2.domain.RunningInstance;
|
||||
import org.jclouds.location.Region;
|
||||
|
@ -35,8 +35,8 @@ import com.google.common.base.Supplier;
|
|||
public class RunInstancesResponseHandler extends BaseReservationHandler<Reservation<? extends RunningInstance>> {
|
||||
|
||||
@Inject
|
||||
public RunInstancesResponseHandler(DateCodecFactory dateCodecFactory, @Region Supplier<String> defaultRegion) {
|
||||
super(dateCodecFactory, defaultRegion);
|
||||
public RunInstancesResponseHandler(DateService dateService, @Region Supplier<String> defaultRegion) {
|
||||
super(dateService, defaultRegion);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,8 +21,7 @@ import java.util.Date;
|
|||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.aws.util.AWSUtils;
|
||||
import org.jclouds.date.DateCodec;
|
||||
import org.jclouds.date.DateCodecFactory;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.ec2.domain.Snapshot;
|
||||
import org.jclouds.ec2.domain.Snapshot.Status;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
|
@ -33,7 +32,7 @@ import com.google.common.base.Supplier;
|
|||
public class SnapshotHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Snapshot> {
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
|
||||
protected final DateCodec dateCodec;
|
||||
protected final DateService dateService;
|
||||
protected final Supplier<String> defaultRegion;
|
||||
|
||||
private String id;
|
||||
|
@ -47,8 +46,8 @@ public class SnapshotHandler extends ParseSax.HandlerForGeneratedRequestWithResu
|
|||
private String ownerAlias;
|
||||
|
||||
@Inject
|
||||
public SnapshotHandler(DateCodecFactory dateCodecFactory, @Region Supplier<String> defaultRegion) {
|
||||
this.dateCodec = dateCodecFactory.iso8601();
|
||||
public SnapshotHandler(DateService dateService, @Region Supplier<String> defaultRegion) {
|
||||
this.dateService = dateService;
|
||||
this.defaultRegion = defaultRegion;
|
||||
}
|
||||
|
||||
|
@ -80,7 +79,7 @@ public class SnapshotHandler extends ParseSax.HandlerForGeneratedRequestWithResu
|
|||
} else if (qName.equals("status")) {
|
||||
status = Snapshot.Status.fromValue(currentText.toString().trim());
|
||||
} else if (qName.equals("startTime")) {
|
||||
startTime = dateCodec.toDate(currentText.toString().trim());
|
||||
startTime = dateService.iso8601DateOrSecondsDateParse(currentText.toString().trim());
|
||||
} else if (qName.equals("progress")) {
|
||||
String progressString = currentText.toString().trim();
|
||||
if (!progressString.equals("")) {
|
||||
|
|
|
@ -71,7 +71,29 @@ public class DescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest {
|
|||
"ec2-174-129-81-68.compute-1.amazonaws.com").imageId("ami-82e4b5c7").instanceId("i-0799056f")
|
||||
.instanceState(InstanceState.RUNNING).rawState("running").instanceType(InstanceType.M1_SMALL)
|
||||
.ipAddress("174.129.81.68").kernelId("aki-a71cf9ce").keyName("adriancole.ec21").launchTime(
|
||||
dateService.iso8601DateParse("2009-11-09T03:00:34.000Z"))
|
||||
dateService.iso8601DateOrSecondsDateParse("2009-11-09T03:00:34.000Z"))
|
||||
// MonitoringState.DISABLED,
|
||||
.availabilityZone("us-east-1c").virtualizationType("paravirtual").privateDnsName(
|
||||
"ip-10-243-42-70.ec2.internal").privateIpAddress("10.243.42.70").ramdiskId(
|
||||
"ari-a51cf9cc").rootDeviceType(RootDeviceType.INSTANCE_STORE).build()),
|
||||
"993194456877", null, "r-a3c508cb"));
|
||||
|
||||
Set<Reservation<? extends RunningInstance>> result = parseRunningInstances("/describe_instances_running.xml");
|
||||
|
||||
assertEquals(result.toString(), contents.toString());
|
||||
assertEquals(get(get(result, 0), 0).getInstanceState(), InstanceState.RUNNING);
|
||||
assertEquals(get(get(result, 0), 0).getRawState(), "running");
|
||||
}
|
||||
|
||||
public void testWhenRunningAndSecondsDate() throws UnknownHostException {
|
||||
|
||||
Set<Reservation<RunningInstance>> contents = ImmutableSet.of(new Reservation<RunningInstance>(defaultRegion,
|
||||
ImmutableSet.of("adriancole.ec2ingress"), ImmutableSet.of(RunningInstance.builder().region(
|
||||
defaultRegion).groupName("adriancole.ec2ingress").amiLaunchIndex("0").dnsName(
|
||||
"ec2-174-129-81-68.compute-1.amazonaws.com").imageId("ami-82e4b5c7").instanceId("i-0799056f")
|
||||
.instanceState(InstanceState.RUNNING).rawState("running").instanceType(InstanceType.M1_SMALL)
|
||||
.ipAddress("174.129.81.68").kernelId("aki-a71cf9ce").keyName("adriancole.ec21").launchTime(
|
||||
dateService.iso8601DateOrSecondsDateParse("2009-11-09T03:00:34+0000"))
|
||||
// MonitoringState.DISABLED,
|
||||
.availabilityZone("us-east-1c").virtualizationType("paravirtual").privateDnsName(
|
||||
"ip-10-243-42-70.ec2.internal").privateIpAddress("10.243.42.70").ramdiskId(
|
||||
|
@ -92,7 +114,7 @@ public class DescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest {
|
|||
"default").amiLaunchIndex("23").dnsName("ec2-72-44-33-4.compute-1.amazonaws.com").imageId(
|
||||
"ami-6ea54007").instanceId("i-28a64341").instanceState(InstanceState.RUNNING).rawState(
|
||||
"running").instanceType(InstanceType.M1_LARGE).kernelId("aki-ba3adfd3").keyName(
|
||||
"example-key-name").launchTime(dateService.iso8601DateParse("2007-08-07T11:54:42.000Z"))
|
||||
"example-key-name").launchTime(dateService.iso8601DateOrSecondsDateParse("2007-08-07T11:54:42.000Z"))
|
||||
// MonitoringState.DISABLED,
|
||||
.availabilityZone("us-east-1b").virtualizationType("paravirtual").privateDnsName(
|
||||
"10-251-50-132.ec2.internal")// product codes
|
||||
|
@ -104,7 +126,7 @@ public class DescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest {
|
|||
"i-28a64435").instanceState(InstanceState.RUNNING).rawState("running")
|
||||
.instanceType(InstanceType.M1_LARGE).kernelId("aki-ba3adfd3").keyName(
|
||||
"example-key-name").launchTime(
|
||||
dateService.iso8601DateParse("2007-08-07T11:54:42.000Z"))
|
||||
dateService.iso8601DateOrSecondsDateParse("2007-08-07T11:54:42.000Z"))
|
||||
// MonitoringState.DISABLED,
|
||||
.availabilityZone("us-east-1b").virtualizationType("paravirtual").privateDnsName(
|
||||
"10-251-50-134.ec2.internal")// product codes
|
||||
|
@ -129,7 +151,7 @@ public class DescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest {
|
|||
.instanceState(InstanceState.RUNNING).rawState("running").instanceType(InstanceType.M1_SMALL)
|
||||
.ipAddress("75.101.203.146").kernelId("aki-a71cf9ce")
|
||||
.keyName("adriancole.ec2ebs1")
|
||||
.launchTime(dateService.iso8601DateParse("2009-12-30T04:06:23.000Z"))
|
||||
.launchTime(dateService.iso8601DateOrSecondsDateParse("2009-12-30T04:06:23.000Z"))
|
||||
// MonitoringState.DISABLED
|
||||
.availabilityZone("us-east-1b")
|
||||
// "placement"
|
||||
|
@ -138,7 +160,7 @@ public class DescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest {
|
|||
.rootDeviceType(RootDeviceType.EBS).rootDeviceName("/dev/sda1").device(
|
||||
"/dev/sda1",
|
||||
new BlockDevice("vol-dc6ca8b5", Attachment.Status.ATTACHED, dateService
|
||||
.iso8601DateParse("2009-12-30T04:06:29.000Z"), true)).build()),
|
||||
.iso8601DateOrSecondsDateParse("2009-12-30T04:06:29.000Z"), true)).build()),
|
||||
"993194456877", null, "r-596dd731"));
|
||||
|
||||
Set<Reservation<? extends RunningInstance>> result = parseRunningInstances("/describe_instances_ebs.xml");
|
||||
|
|
|
@ -21,7 +21,7 @@ import java.util.Set;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.date.DateCodecFactory;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.ec2.domain.Attachment;
|
||||
import org.jclouds.ec2.domain.Volume;
|
||||
import org.jclouds.ec2.xml.CreateVolumeResponseHandler;
|
||||
|
@ -33,10 +33,10 @@ import com.google.common.base.Supplier;
|
|||
public class NovaCreateVolumeResponseHandler extends CreateVolumeResponseHandler {
|
||||
|
||||
@Inject
|
||||
protected NovaCreateVolumeResponseHandler(DateCodecFactory dateCodecFactory, @Region Supplier<String> defaultRegion,
|
||||
protected NovaCreateVolumeResponseHandler(DateService dateService, @Region Supplier<String> defaultRegion,
|
||||
@Zone Supplier<Map<String, Supplier<Set<String>>>> regionToZonesSupplier,
|
||||
@Zone Supplier<Set<String>> zonesSupplier) {
|
||||
super(dateCodecFactory, defaultRegion, regionToZonesSupplier, zonesSupplier);
|
||||
super(dateService, defaultRegion, regionToZonesSupplier, zonesSupplier);
|
||||
}
|
||||
|
||||
public void endElement(String uri, String name, String qName) {
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.Set;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.date.DateCodecFactory;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.ec2.domain.Reservation;
|
||||
import org.jclouds.ec2.domain.RunningInstance;
|
||||
import org.jclouds.ec2.xml.TagSetHandler;
|
||||
|
@ -48,9 +48,9 @@ public class AWSDescribeInstancesResponseHandler extends
|
|||
private boolean inTagSet;
|
||||
|
||||
@Inject
|
||||
AWSDescribeInstancesResponseHandler(DateCodecFactory dateCodecFactory, @Region Supplier<String> defaultRegion,
|
||||
AWSDescribeInstancesResponseHandler(DateService dateService, @Region Supplier<String> defaultRegion,
|
||||
TagSetHandler tagSetHandler) {
|
||||
super(dateCodecFactory, defaultRegion);
|
||||
super(dateService, defaultRegion);
|
||||
this.tagSetHandler = tagSetHandler;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ package org.jclouds.aws.ec2.xml;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.date.DateCodecFactory;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.ec2.domain.Reservation;
|
||||
import org.jclouds.ec2.domain.RunningInstance;
|
||||
import org.jclouds.location.Region;
|
||||
|
@ -35,8 +35,8 @@ import com.google.common.base.Supplier;
|
|||
public class AWSRunInstancesResponseHandler extends BaseAWSReservationHandler<Reservation<? extends RunningInstance>> {
|
||||
|
||||
@Inject
|
||||
AWSRunInstancesResponseHandler(DateCodecFactory dateCodecFactory, @Region Supplier<String> defaultRegion) {
|
||||
super(dateCodecFactory, defaultRegion);
|
||||
AWSRunInstancesResponseHandler(DateService dateService, @Region Supplier<String> defaultRegion) {
|
||||
super(dateService, defaultRegion);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -29,8 +29,7 @@ import javax.inject.Inject;
|
|||
import org.jclouds.aws.ec2.domain.AWSRunningInstance;
|
||||
import org.jclouds.aws.ec2.domain.MonitoringState;
|
||||
import org.jclouds.aws.util.AWSUtils;
|
||||
import org.jclouds.date.DateCodec;
|
||||
import org.jclouds.date.DateCodecFactory;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.ec2.domain.Attachment;
|
||||
import org.jclouds.ec2.domain.BlockDevice;
|
||||
import org.jclouds.ec2.domain.Hypervisor;
|
||||
|
@ -53,12 +52,12 @@ public abstract class BaseAWSReservationHandler<T> extends HandlerForGeneratedRe
|
|||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
protected final DateCodec dateCodec;
|
||||
protected final DateService dateService;
|
||||
protected final Supplier<String> defaultRegion;
|
||||
|
||||
@Inject
|
||||
public BaseAWSReservationHandler(DateCodecFactory dateCodecFactory, @Region Supplier<String> defaultRegion) {
|
||||
this.dateCodec = dateCodecFactory.iso8601();
|
||||
public BaseAWSReservationHandler(DateService dateService, @Region Supplier<String> defaultRegion) {
|
||||
this.dateService = dateService;
|
||||
this.defaultRegion = defaultRegion;
|
||||
}
|
||||
|
||||
|
@ -171,7 +170,7 @@ public abstract class BaseAWSReservationHandler<T> extends HandlerForGeneratedRe
|
|||
} else if (equalsOrSuffix(qName, "keyName")) {
|
||||
builder.keyName(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "launchTime")) {
|
||||
builder.launchTime(dateCodec.toDate(currentOrNull(currentText)));
|
||||
builder.launchTime(dateService.iso8601DateOrSecondsDateParse(currentOrNull(currentText)));
|
||||
} else if (equalsOrSuffix(qName, "availabilityZone")) {
|
||||
builder.availabilityZone(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "virtualizationType")) {
|
||||
|
@ -197,7 +196,7 @@ public abstract class BaseAWSReservationHandler<T> extends HandlerForGeneratedRe
|
|||
} else if (equalsOrSuffix(qName, "status")) {
|
||||
attachmentStatus = Attachment.Status.fromValue(currentText.toString().trim());
|
||||
} else if (equalsOrSuffix(qName, "attachTime")) {
|
||||
attachTime = dateCodec.toDate(currentOrNull(currentText));
|
||||
attachTime = dateService.iso8601DateOrSecondsDateParse(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "deleteOnTermination")) {
|
||||
deleteOnTermination = Boolean.parseBoolean(currentText.toString().trim());
|
||||
} else if (equalsOrSuffix(qName, "ebs")) {
|
||||
|
|
|
@ -23,8 +23,6 @@ import javax.inject.Inject;
|
|||
|
||||
import org.jclouds.aws.ec2.domain.LaunchSpecification;
|
||||
import org.jclouds.aws.ec2.domain.LaunchSpecification.Builder;
|
||||
import org.jclouds.date.DateCodec;
|
||||
import org.jclouds.date.DateCodecFactory;
|
||||
import org.jclouds.ec2.domain.BlockDeviceMapping;
|
||||
import org.jclouds.http.functions.ParseSax.HandlerForGeneratedRequestWithResult;
|
||||
import org.jclouds.logging.Logger;
|
||||
|
@ -35,14 +33,11 @@ public class LaunchSpecificationHandler extends HandlerForGeneratedRequestWithRe
|
|||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
protected final DateCodec dateCodec;
|
||||
protected final Builder builder;
|
||||
protected final BlockDeviceMapping.Builder blockDeviceMappingBuilder;
|
||||
|
||||
@Inject
|
||||
public LaunchSpecificationHandler(DateCodecFactory dateCodecFactory, LaunchSpecification.Builder builder,
|
||||
BlockDeviceMapping.Builder blockDeviceMappingBuilder) {
|
||||
this.dateCodec = dateCodecFactory.iso8601();
|
||||
public LaunchSpecificationHandler(LaunchSpecification.Builder builder, BlockDeviceMapping.Builder blockDeviceMappingBuilder) {
|
||||
this.builder = builder;
|
||||
this.blockDeviceMappingBuilder = blockDeviceMappingBuilder;
|
||||
}
|
||||
|
|
|
@ -20,8 +20,7 @@ import javax.inject.Inject;
|
|||
|
||||
import org.jclouds.aws.ec2.domain.Spot;
|
||||
import org.jclouds.aws.util.AWSUtils;
|
||||
import org.jclouds.date.DateCodec;
|
||||
import org.jclouds.date.DateCodecFactory;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.location.Region;
|
||||
|
||||
|
@ -30,12 +29,12 @@ import com.google.common.base.Supplier;
|
|||
public class SpotHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Spot> {
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
|
||||
protected final DateCodec dateCodec;
|
||||
protected final DateService dateService;
|
||||
protected final Supplier<String> defaultRegion;
|
||||
|
||||
@Inject
|
||||
public SpotHandler(DateCodecFactory dateCodecFactory, @Region Supplier<String> defaultRegion) {
|
||||
this.dateCodec = dateCodecFactory.iso8601();
|
||||
public SpotHandler(DateService dateService, @Region Supplier<String> defaultRegion) {
|
||||
this.dateService = dateService;
|
||||
this.defaultRegion = defaultRegion;
|
||||
}
|
||||
|
||||
|
@ -60,7 +59,7 @@ public class SpotHandler extends ParseSax.HandlerForGeneratedRequestWithResult<S
|
|||
} else if (qName.equals("spotPrice")) {
|
||||
builder.spotPrice(Float.parseFloat(currentText.toString().trim()));
|
||||
} else if (qName.equals("timestamp")) {
|
||||
builder.timestamp(dateCodec.toDate(currentText.toString().trim()));
|
||||
builder.timestamp(dateService.iso8601DateOrSecondsDateParse(currentText.toString().trim()));
|
||||
} else if (qName.equals("availabilityZone")) {
|
||||
builder.availabilityZone(currentText.toString().trim());
|
||||
}
|
||||
|
|
|
@ -24,8 +24,7 @@ import javax.inject.Inject;
|
|||
import org.jclouds.aws.ec2.domain.SpotInstanceRequest;
|
||||
import org.jclouds.aws.ec2.domain.SpotInstanceRequest.Builder;
|
||||
import org.jclouds.aws.util.AWSUtils;
|
||||
import org.jclouds.date.DateCodec;
|
||||
import org.jclouds.date.DateCodecFactory;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.ec2.xml.TagSetHandler;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.location.Region;
|
||||
|
@ -37,7 +36,7 @@ import com.google.common.base.Supplier;
|
|||
public class SpotInstanceHandler extends ParseSax.HandlerForGeneratedRequestWithResult<SpotInstanceRequest> {
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
|
||||
protected final DateCodec dateCodec;
|
||||
protected final DateService dateService;
|
||||
protected final Supplier<String> defaultRegion;
|
||||
protected final Builder builder;
|
||||
protected boolean inFault;
|
||||
|
@ -48,10 +47,10 @@ public class SpotInstanceHandler extends ParseSax.HandlerForGeneratedRequestWith
|
|||
protected final TagSetHandler tagSetHandler;
|
||||
|
||||
@Inject
|
||||
public SpotInstanceHandler(DateCodecFactory dateCodecFactory, @Region Supplier<String> defaultRegion,
|
||||
public SpotInstanceHandler(DateService dateService, @Region Supplier<String> defaultRegion,
|
||||
LaunchSpecificationHandler launchSpecificationHandler, TagSetHandler tagSetHandler,
|
||||
SpotInstanceRequest.Builder builder) {
|
||||
this.dateCodec = dateCodecFactory.iso8601();
|
||||
this.dateService = dateService;
|
||||
this.defaultRegion = defaultRegion;
|
||||
this.launchSpecificationHandler = launchSpecificationHandler;
|
||||
this.tagSetHandler = tagSetHandler;
|
||||
|
@ -138,7 +137,7 @@ public class SpotInstanceHandler extends ParseSax.HandlerForGeneratedRequestWith
|
|||
} else if (qName.equals("createTime")) {
|
||||
String createTime = currentOrNull(currentText);
|
||||
if (createTime != null)
|
||||
builder.createTime(dateCodec.toDate(createTime));
|
||||
builder.createTime(dateService.iso8601DateOrSecondsDateParse(createTime));
|
||||
} else if (qName.equals("productDescription")) {
|
||||
builder.productDescription(currentOrNull(currentText));
|
||||
} else if (inFault) {
|
||||
|
@ -155,16 +154,16 @@ public class SpotInstanceHandler extends ParseSax.HandlerForGeneratedRequestWith
|
|||
} else if (qName.equals("updateTime")) {
|
||||
String updateTime = currentOrNull(currentText);
|
||||
if (updateTime != null)
|
||||
builder.statusUpdateTime(dateCodec.toDate(updateTime));
|
||||
builder.statusUpdateTime(dateService.iso8601DateOrSecondsDateParse(updateTime));
|
||||
}
|
||||
} else if (qName.equals("validFrom")) {
|
||||
String validFrom = currentOrNull(currentText);
|
||||
if (validFrom != null)
|
||||
builder.validFrom(dateCodec.toDate(validFrom));
|
||||
builder.validFrom(dateService.iso8601DateOrSecondsDateParse(validFrom));
|
||||
} else if (qName.equals("validUntil")) {
|
||||
String validUntil = currentOrNull(currentText);
|
||||
if (validUntil != null)
|
||||
builder.validUntil(dateCodec.toDate(validUntil));
|
||||
builder.validUntil(dateService.iso8601DateOrSecondsDateParse(validUntil));
|
||||
}
|
||||
currentText.setLength(0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue