diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/xml/AttachmentHandler.java b/apis/ec2/src/main/java/org/jclouds/ec2/xml/AttachmentHandler.java index 7bb31f79fa..b624310943 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/xml/AttachmentHandler.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/xml/AttachmentHandler.java @@ -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 defaultRegion; @Inject - AttachmentHandler(DateCodecFactory dateCodecFactory, @Region Supplier defaultRegion) { - this.dateCodec = dateCodecFactory.iso8601(); + AttachmentHandler(DateService dateService, @Region Supplier 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); } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/xml/BaseReservationHandler.java b/apis/ec2/src/main/java/org/jclouds/ec2/xml/BaseReservationHandler.java index 4422da2699..6b18ae8165 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/xml/BaseReservationHandler.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/xml/BaseReservationHandler.java @@ -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 extends HandlerForGeneratedRequestWithResult { - protected final DateCodec dateCodec; + protected final DateService dateService; protected final Supplier defaultRegion; @Inject - public BaseReservationHandler(DateCodecFactory dateCodecFactory, @Region Supplier defaultRegion) { - this.dateCodec = dateCodecFactory.iso8601(); + public BaseReservationHandler(DateService dateService, @Region Supplier defaultRegion) { + this.dateService = dateService; this.defaultRegion = defaultRegion; } @@ -141,7 +140,7 @@ public abstract class BaseReservationHandler 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 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")) { diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/xml/BlockDeviceMappingHandler.java b/apis/ec2/src/main/java/org/jclouds/ec2/xml/BlockDeviceMappingHandler.java index 6078df76b7..f663aed757 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/xml/BlockDeviceMappingHandler.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/xml/BlockDeviceMappingHandler.java @@ -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 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; diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/xml/BundleTaskHandler.java b/apis/ec2/src/main/java/org/jclouds/ec2/xml/BundleTaskHandler.java index dd3dd0efc3..4312eb35c9 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/xml/BundleTaskHandler.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/xml/BundleTaskHandler.java @@ -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 { - protected final DateCodec dateCodec; + protected final DateService dateService; protected final Supplier defaultRegion; @Inject - protected BundleTaskHandler(DateCodecFactory dateCodecFactory, @Region Supplier defaultRegion) { - this.dateCodec = dateCodecFactory.iso8601(); + protected BundleTaskHandler(DateService dateService, @Region Supplier 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); } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/xml/CreateVolumeResponseHandler.java b/apis/ec2/src/main/java/org/jclouds/ec2/xml/CreateVolumeResponseHandler.java index db6ae45c2a..49bd805e8a 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/xml/CreateVolumeResponseHandler.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/xml/CreateVolumeResponseHandler.java @@ -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 { - protected final DateCodec dateCodec; + protected final DateService dateService; protected final Supplier defaultRegion; protected final Supplier>>> regionToZonesSupplier; protected final Supplier> zonesSupplier; @Inject - protected CreateVolumeResponseHandler(DateCodecFactory dateCodecFactory, @Region Supplier defaultRegion, + protected CreateVolumeResponseHandler(DateService dateService, @Region Supplier defaultRegion, @Zone Supplier>>> regionToZonesSupplier, @Zone Supplier> 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("")) diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandler.java b/apis/ec2/src/main/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandler.java index f154fe40d8..03e54f119d 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandler.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandler.java @@ -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 defaultRegion, + DescribeInstancesResponseHandler(DateService dateService, @Region Supplier defaultRegion, TagSetHandler tagSetHandler) { - super(dateCodecFactory, defaultRegion); + super(dateService, defaultRegion); this.tagSetHandler = tagSetHandler; } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/xml/GetPasswordDataResponseHandler.java b/apis/ec2/src/main/java/org/jclouds/ec2/xml/GetPasswordDataResponseHandler.java index 89126d9cac..b446d8e489 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/xml/GetPasswordDataResponseHandler.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/xml/GetPasswordDataResponseHandler.java @@ -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 { - 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

> { @Inject - public RunInstancesResponseHandler(DateCodecFactory dateCodecFactory, @Region Supplier defaultRegion) { - super(dateCodecFactory, defaultRegion); + public RunInstancesResponseHandler(DateService dateService, @Region Supplier defaultRegion) { + super(dateService, defaultRegion); } @Override diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/xml/SnapshotHandler.java b/apis/ec2/src/main/java/org/jclouds/ec2/xml/SnapshotHandler.java index f8ac96b0a3..b80914d0e7 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/xml/SnapshotHandler.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/xml/SnapshotHandler.java @@ -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 { private StringBuilder currentText = new StringBuilder(); - protected final DateCodec dateCodec; + protected final DateService dateService; protected final Supplier defaultRegion; private String id; @@ -47,8 +46,8 @@ public class SnapshotHandler extends ParseSax.HandlerForGeneratedRequestWithResu private String ownerAlias; @Inject - public SnapshotHandler(DateCodecFactory dateCodecFactory, @Region Supplier defaultRegion) { - this.dateCodec = dateCodecFactory.iso8601(); + public SnapshotHandler(DateService dateService, @Region Supplier 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("")) { diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandlerTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandlerTest.java index 862388fdd8..b9931fdac1 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandlerTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandlerTest.java @@ -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> 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> contents = ImmutableSet.of(new Reservation(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> result = parseRunningInstances("/describe_instances_ebs.xml"); diff --git a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/xml/NovaCreateVolumeResponseHandler.java b/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/xml/NovaCreateVolumeResponseHandler.java index 8de1f1e05c..3041b09f97 100644 --- a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/xml/NovaCreateVolumeResponseHandler.java +++ b/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/xml/NovaCreateVolumeResponseHandler.java @@ -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 defaultRegion, + protected NovaCreateVolumeResponseHandler(DateService dateService, @Region Supplier defaultRegion, @Zone Supplier>>> regionToZonesSupplier, @Zone Supplier> zonesSupplier) { - super(dateCodecFactory, defaultRegion, regionToZonesSupplier, zonesSupplier); + super(dateService, defaultRegion, regionToZonesSupplier, zonesSupplier); } public void endElement(String uri, String name, String qName) { diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandler.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandler.java index abb2ab2bd7..7c321b7546 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandler.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandler.java @@ -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 defaultRegion, + AWSDescribeInstancesResponseHandler(DateService dateService, @Region Supplier defaultRegion, TagSetHandler tagSetHandler) { - super(dateCodecFactory, defaultRegion); + super(dateService, defaultRegion); this.tagSetHandler = tagSetHandler; } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/AWSRunInstancesResponseHandler.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/AWSRunInstancesResponseHandler.java index ae8d87966d..2712d6c145 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/AWSRunInstancesResponseHandler.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/AWSRunInstancesResponseHandler.java @@ -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> { @Inject - AWSRunInstancesResponseHandler(DateCodecFactory dateCodecFactory, @Region Supplier defaultRegion) { - super(dateCodecFactory, defaultRegion); + AWSRunInstancesResponseHandler(DateService dateService, @Region Supplier defaultRegion) { + super(dateService, defaultRegion); } @Override diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/BaseAWSReservationHandler.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/BaseAWSReservationHandler.java index e394fdaebc..141eb1858f 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/BaseAWSReservationHandler.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/BaseAWSReservationHandler.java @@ -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 extends HandlerForGeneratedRe @Resource protected Logger logger = Logger.NULL; - protected final DateCodec dateCodec; + protected final DateService dateService; protected final Supplier defaultRegion; @Inject - public BaseAWSReservationHandler(DateCodecFactory dateCodecFactory, @Region Supplier defaultRegion) { - this.dateCodec = dateCodecFactory.iso8601(); + public BaseAWSReservationHandler(DateService dateService, @Region Supplier defaultRegion) { + this.dateService = dateService; this.defaultRegion = defaultRegion; } @@ -171,7 +170,7 @@ public abstract class BaseAWSReservationHandler 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 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")) { diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/LaunchSpecificationHandler.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/LaunchSpecificationHandler.java index 81a9662a4d..68bed2db84 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/LaunchSpecificationHandler.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/LaunchSpecificationHandler.java @@ -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; } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/SpotHandler.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/SpotHandler.java index 4b3d9c740b..a040d69069 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/SpotHandler.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/SpotHandler.java @@ -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 { private StringBuilder currentText = new StringBuilder(); - protected final DateCodec dateCodec; + protected final DateService dateService; protected final Supplier defaultRegion; @Inject - public SpotHandler(DateCodecFactory dateCodecFactory, @Region Supplier defaultRegion) { - this.dateCodec = dateCodecFactory.iso8601(); + public SpotHandler(DateService dateService, @Region Supplier defaultRegion) { + this.dateService = dateService; this.defaultRegion = defaultRegion; } @@ -60,7 +59,7 @@ public class SpotHandler extends ParseSax.HandlerForGeneratedRequestWithResult { private StringBuilder currentText = new StringBuilder(); - protected final DateCodec dateCodec; + protected final DateService dateService; protected final Supplier 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 defaultRegion, + public SpotInstanceHandler(DateService dateService, @Region Supplier 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); }