diff --git a/atmos/src/main/java/org/jclouds/atmosonline/saas/domain/SystemMetadata.java b/atmos/src/main/java/org/jclouds/atmosonline/saas/domain/SystemMetadata.java index b3d5ca38d8..bff2ba73c5 100644 --- a/atmos/src/main/java/org/jclouds/atmosonline/saas/domain/SystemMetadata.java +++ b/atmos/src/main/java/org/jclouds/atmosonline/saas/domain/SystemMetadata.java @@ -23,7 +23,7 @@ */ package org.jclouds.atmosonline.saas.domain; -import org.joda.time.DateTime; +import java.util.Date; /** * Metadata of a Atmos Online object @@ -32,19 +32,18 @@ import org.joda.time.DateTime; */ public class SystemMetadata extends DirectoryEntry { - private final DateTime atime; - private final DateTime ctime; + private final Date atime; + private final Date ctime; private final String gid; - private final DateTime itime; - private final DateTime mtime; + private final Date itime; + private final Date mtime; private final int nlink; private final String policyname; private final long size; private final String uid; - public SystemMetadata(DateTime atime, DateTime ctime, String gid, DateTime itime, - DateTime mtime, int nlink, String objectid, String objname, String policyname, - long size, FileType type, String uid) { + public SystemMetadata(Date atime, Date ctime, String gid, Date itime, Date mtime, int nlink, + String objectid, String objname, String policyname, long size, FileType type, String uid) { super(objectid, type, objname); this.atime = atime; this.ctime = ctime; @@ -65,19 +64,19 @@ public class SystemMetadata extends DirectoryEntry { return nlink; } - public DateTime getInceptionTime() { + public Date getInceptionTime() { return itime; } - public DateTime getLastAccessTime() { + public Date getLastAccessTime() { return atime; } - public DateTime getLastMetadataModification() { + public Date getLastMetadataModification() { return mtime; } - public DateTime getLastUserDataModification() { + public Date getLastUserDataModification() { return ctime; } diff --git a/atmos/src/test/java/org/jclouds/atmosonline/saas/config/AtmosStorageRestClientModuleTest.java b/atmos/src/test/java/org/jclouds/atmosonline/saas/config/AtmosStorageRestClientModuleTest.java index c74296dfec..226e11ca43 100644 --- a/atmos/src/test/java/org/jclouds/atmosonline/saas/config/AtmosStorageRestClientModuleTest.java +++ b/atmos/src/test/java/org/jclouds/atmosonline/saas/config/AtmosStorageRestClientModuleTest.java @@ -36,8 +36,8 @@ import org.jclouds.http.functions.config.ParserModule; import org.jclouds.http.handlers.DelegatingErrorHandler; import org.jclouds.http.handlers.DelegatingRetryHandler; import org.jclouds.http.handlers.RedirectionRetryHandler; -import org.jclouds.util.DateService; import org.jclouds.util.Jsr330; +import org.jclouds.util.internal.SimpleDateFormatDateService; import org.testng.annotations.Test; import com.google.common.base.Supplier; @@ -73,7 +73,7 @@ public class AtmosStorageRestClientModuleTest { void testUpdatesOnlyOncePerSecond() throws NoSuchMethodException, InterruptedException { AtmosStorageRestClientModule module = new AtmosStorageRestClientModule(); - Supplier map = module.provideTimeStampCache(1, new DateService()); + Supplier map = module.provideTimeStampCache(1, new SimpleDateFormatDateService()); String timeStamp = map.get(); for (int i = 0; i < 10; i++) map.get(); diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/config/EC2ContextModule.java b/aws/core/src/main/java/org/jclouds/aws/ec2/config/EC2ContextModule.java index e50fc8f12f..2515ccee5e 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/config/EC2ContextModule.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/config/EC2ContextModule.java @@ -32,8 +32,8 @@ import org.jclouds.aws.ec2.EC2; import org.jclouds.aws.ec2.EC2AsyncClient; import org.jclouds.aws.ec2.EC2Client; import org.jclouds.aws.reference.AWSConstants; -import org.jclouds.http.functions.config.ParserModule.CDateTimeAdapter; -import org.jclouds.http.functions.config.ParserModule.DateTimeAdapter; +import org.jclouds.http.functions.config.ParserModule.CDateAdapter; +import org.jclouds.http.functions.config.ParserModule.DateAdapter; import org.jclouds.lifecycle.Closer; import org.jclouds.rest.RestContext; import org.jclouds.rest.internal.RestContextImpl; @@ -49,7 +49,7 @@ import com.google.inject.Provides; public class EC2ContextModule extends AbstractModule { @Override protected void configure() { - bind(DateTimeAdapter.class).to(CDateTimeAdapter.class); + bind(DateAdapter.class).to(CDateAdapter.class); } @Provides diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/config/EC2RestClientModule.java b/aws/core/src/main/java/org/jclouds/aws/ec2/config/EC2RestClientModule.java index 8536f5561a..353d12e9e5 100755 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/config/EC2RestClientModule.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/config/EC2RestClientModule.java @@ -24,6 +24,7 @@ package org.jclouds.aws.ec2.config; import java.net.URI; +import java.util.Date; import javax.inject.Named; import javax.inject.Singleton; @@ -48,7 +49,6 @@ import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.RestClientFactory; import org.jclouds.util.DateService; import org.jclouds.util.TimeStamp; -import org.joda.time.DateTime; import com.google.inject.AbstractModule; import com.google.inject.Provides; @@ -72,7 +72,8 @@ public class EC2RestClientModule extends AbstractModule { @TimeStamp protected String provideTimeStamp(final DateService dateService, @Named(EC2Constants.PROPERTY_EC2_EXPIREINTERVAL) final int expiration) { - return dateService.iso8601DateFormat(new DateTime().plusSeconds(expiration)); + return dateService.iso8601DateFormat(new Date(System.currentTimeMillis() + + (expiration * 1000))); } @Provides diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/RunningInstance.java b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/RunningInstance.java index 8267449581..7baca31731 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/RunningInstance.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/RunningInstance.java @@ -26,10 +26,9 @@ package org.jclouds.aws.ec2.domain; import static com.google.common.base.Preconditions.checkNotNull; import java.net.InetAddress; +import java.util.Date; import java.util.Set; -import org.joda.time.DateTime; - import com.google.inject.internal.Nullable; /** @@ -52,7 +51,7 @@ public class RunningInstance implements Comparable { private final String kernelId; @Nullable private final String keyName; - private final DateTime launchTime; + private final Date launchTime; private final boolean monitoring; @Nullable private final String availabilityZone; @@ -79,7 +78,7 @@ public class RunningInstance implements Comparable { public RunningInstance(String amiLaunchIndex, @Nullable String dnsName, String imageId, String instanceId, InstanceState instanceState, InstanceType instanceType, @Nullable InetAddress ipAddress, @Nullable String kernelId, @Nullable String keyName, - DateTime launchTime, boolean monitoring, @Nullable String availabilityZone, + Date launchTime, boolean monitoring, @Nullable String availabilityZone, @Nullable String platform, @Nullable String privateDnsName, @Nullable InetAddress privateIpAddress, Set productCodes, @Nullable String ramdiskId, @Nullable String reason, @Nullable String subnetId, @@ -177,7 +176,7 @@ public class RunningInstance implements Comparable { /** * The time the instance launched. */ - public DateTime getLaunchTime() { + public Date getLaunchTime() { return launchTime; } diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/xml/BaseReservationHandler.java b/aws/core/src/main/java/org/jclouds/aws/ec2/xml/BaseReservationHandler.java index f3f1ae3410..bcbbec9007 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/xml/BaseReservationHandler.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/xml/BaseReservationHandler.java @@ -25,6 +25,7 @@ package org.jclouds.aws.ec2.xml; import java.net.InetAddress; import java.net.UnknownHostException; +import java.util.Date; import java.util.Set; import java.util.SortedSet; @@ -37,7 +38,6 @@ import org.jclouds.aws.ec2.domain.RunningInstance; import org.jclouds.http.functions.ParseSax.HandlerWithResult; import org.jclouds.logging.Logger; import org.jclouds.util.DateService; -import org.joda.time.DateTime; import org.xml.sax.Attributes; import com.google.common.collect.Sets; @@ -67,7 +67,7 @@ public abstract class BaseReservationHandler extends HandlerWithResult { private InetAddress ipAddress; private String kernelId; private String keyName; - private DateTime launchTime; + private Date launchTime; private boolean monitoring; private String availabilityZone; private String platform; diff --git a/aws/core/src/main/java/org/jclouds/aws/s3/domain/BucketMetadata.java b/aws/core/src/main/java/org/jclouds/aws/s3/domain/BucketMetadata.java index 602ef523f5..784b3f9f7e 100644 --- a/aws/core/src/main/java/org/jclouds/aws/s3/domain/BucketMetadata.java +++ b/aws/core/src/main/java/org/jclouds/aws/s3/domain/BucketMetadata.java @@ -23,7 +23,7 @@ */ package org.jclouds.aws.s3.domain; -import org.joda.time.DateTime; +import java.util.Date; /** * System metadata of the S3Bucket @@ -33,7 +33,7 @@ import org.joda.time.DateTime; public class BucketMetadata implements Comparable { /** The serialVersionUID */ private static final long serialVersionUID = -6965068835316857535L; - private final DateTime creationDate; + private final Date creationDate; private final CanonicalUser owner; private final String name; @@ -48,7 +48,7 @@ public class BucketMetadata implements Comparable { EU } - public BucketMetadata(String name, DateTime creationDate, CanonicalUser owner) { + public BucketMetadata(String name, Date creationDate, CanonicalUser owner) { this.name = name; this.creationDate = creationDate; this.owner = owner; @@ -63,7 +63,7 @@ public class BucketMetadata implements Comparable { return owner; } - public DateTime getCreationDate() { + public Date getCreationDate() { return creationDate; } diff --git a/aws/core/src/main/java/org/jclouds/aws/s3/domain/MutableObjectMetadata.java b/aws/core/src/main/java/org/jclouds/aws/s3/domain/MutableObjectMetadata.java index 6b1ab38778..c5c1498672 100644 --- a/aws/core/src/main/java/org/jclouds/aws/s3/domain/MutableObjectMetadata.java +++ b/aws/core/src/main/java/org/jclouds/aws/s3/domain/MutableObjectMetadata.java @@ -23,10 +23,10 @@ */ package org.jclouds.aws.s3.domain; +import java.util.Date; import java.util.Map; import org.jclouds.aws.s3.domain.internal.MutableObjectMetadataImpl; -import org.joda.time.DateTime; import com.google.inject.ImplementedBy; @@ -107,7 +107,7 @@ public interface MutableObjectMetadata extends ObjectMetadata { */ void setContentMD5(byte[] md5); - void setLastModified(DateTime lastModified); + void setLastModified(Date lastModified); void setETag(String eTag); diff --git a/aws/core/src/main/java/org/jclouds/aws/s3/domain/ObjectMetadata.java b/aws/core/src/main/java/org/jclouds/aws/s3/domain/ObjectMetadata.java index 8697172ac2..47e682b6cc 100644 --- a/aws/core/src/main/java/org/jclouds/aws/s3/domain/ObjectMetadata.java +++ b/aws/core/src/main/java/org/jclouds/aws/s3/domain/ObjectMetadata.java @@ -23,10 +23,9 @@ */ package org.jclouds.aws.s3.domain; +import java.util.Date; import java.util.Map; -import org.joda.time.DateTime; - /** * /** Amazon S3 is designed to store objects. Objects are stored in {@link S3BucketListing buckets} * and consist of a {@link org.jclouds.aws.s3.domain.S3Object#getData() value}, a @@ -107,7 +106,7 @@ public interface ObjectMetadata extends Comparable { */ byte[] getContentMD5(); - DateTime getLastModified(); + Date getLastModified(); String getETag(); diff --git a/aws/core/src/main/java/org/jclouds/aws/s3/domain/internal/BucketListObjectMetadata.java b/aws/core/src/main/java/org/jclouds/aws/s3/domain/internal/BucketListObjectMetadata.java index ce60794002..6ba9fbebdc 100644 --- a/aws/core/src/main/java/org/jclouds/aws/s3/domain/internal/BucketListObjectMetadata.java +++ b/aws/core/src/main/java/org/jclouds/aws/s3/domain/internal/BucketListObjectMetadata.java @@ -25,11 +25,11 @@ package org.jclouds.aws.s3.domain.internal; import java.io.Serializable; import java.util.Arrays; +import java.util.Date; import java.util.Map; import org.jclouds.aws.s3.domain.CanonicalUser; import org.jclouds.aws.s3.domain.ObjectMetadata; -import org.joda.time.DateTime; import com.google.common.collect.Maps; @@ -44,7 +44,7 @@ public class BucketListObjectMetadata implements Serializable, ObjectMetadata { private static final long serialVersionUID = -4415449798024051115L; private final String key; - private final DateTime lastModified; + private final Date lastModified; private final String eTag; private final long size; private final CanonicalUser owner; @@ -56,7 +56,7 @@ public class BucketListObjectMetadata implements Serializable, ObjectMetadata { private final String contentEncoding; private final Map userMetadata; - public BucketListObjectMetadata(String key, DateTime lastModified, String eTag, byte[] md5, + public BucketListObjectMetadata(String key, Date lastModified, String eTag, byte[] md5, long size, CanonicalUser owner, StorageClass storageClass) { this.key = key; this.lastModified = lastModified; @@ -124,7 +124,7 @@ public class BucketListObjectMetadata implements Serializable, ObjectMetadata { /** *{@inheritDoc} */ - public DateTime getLastModified() { + public Date getLastModified() { return lastModified; } diff --git a/aws/core/src/main/java/org/jclouds/aws/s3/domain/internal/CopyObjectResult.java b/aws/core/src/main/java/org/jclouds/aws/s3/domain/internal/CopyObjectResult.java index bc39cce2ab..14ab37c1d0 100644 --- a/aws/core/src/main/java/org/jclouds/aws/s3/domain/internal/CopyObjectResult.java +++ b/aws/core/src/main/java/org/jclouds/aws/s3/domain/internal/CopyObjectResult.java @@ -25,11 +25,11 @@ package org.jclouds.aws.s3.domain.internal; import java.io.Serializable; import java.util.Arrays; +import java.util.Date; import java.util.Map; import org.jclouds.aws.s3.domain.CanonicalUser; import org.jclouds.aws.s3.domain.ObjectMetadata; -import org.joda.time.DateTime; /** * Returns the metadata parsable from a bucket listing @@ -42,7 +42,7 @@ public class CopyObjectResult implements Serializable, ObjectMetadata { private static final long serialVersionUID = -4415449798024051115L; private final String key; - private final DateTime lastModified; + private final Date lastModified; private final String eTag; private final Long size; private final CanonicalUser owner; @@ -54,7 +54,7 @@ public class CopyObjectResult implements Serializable, ObjectMetadata { private final String contentEncoding; private final Map userMetadata; - public CopyObjectResult(DateTime lastModified, String eTag) { + public CopyObjectResult(Date lastModified, String eTag) { this.key = null; this.lastModified = lastModified; this.eTag = eTag; @@ -121,7 +121,7 @@ public class CopyObjectResult implements Serializable, ObjectMetadata { /** *{@inheritDoc} */ - public DateTime getLastModified() { + public Date getLastModified() { return lastModified; } @@ -248,5 +248,4 @@ public class CopyObjectResult implements Serializable, ObjectMetadata { return true; } - } \ No newline at end of file diff --git a/aws/core/src/main/java/org/jclouds/aws/s3/domain/internal/MutableObjectMetadataImpl.java b/aws/core/src/main/java/org/jclouds/aws/s3/domain/internal/MutableObjectMetadataImpl.java index 7dce7bab14..a2e2de5081 100644 --- a/aws/core/src/main/java/org/jclouds/aws/s3/domain/internal/MutableObjectMetadataImpl.java +++ b/aws/core/src/main/java/org/jclouds/aws/s3/domain/internal/MutableObjectMetadataImpl.java @@ -25,12 +25,12 @@ package org.jclouds.aws.s3.domain.internal; import java.io.Serializable; import java.util.Arrays; +import java.util.Date; import java.util.Map; import org.jclouds.aws.s3.domain.CanonicalUser; import org.jclouds.aws.s3.domain.MutableObjectMetadata; import org.jclouds.aws.s3.domain.ObjectMetadata; -import org.joda.time.DateTime; import com.google.common.collect.Maps; @@ -45,7 +45,7 @@ public class MutableObjectMetadataImpl implements Serializable, MutableObjectMet private static final long serialVersionUID = -4648755473986695062L; private String key; - private DateTime lastModified; + private Date lastModified; private String eTag; private long size; private CanonicalUser owner; @@ -113,7 +113,7 @@ public class MutableObjectMetadataImpl implements Serializable, MutableObjectMet /** *{@inheritDoc} */ - public DateTime getLastModified() { + public Date getLastModified() { return lastModified; } @@ -214,7 +214,7 @@ public class MutableObjectMetadataImpl implements Serializable, MutableObjectMet /** *{@inheritDoc} */ - public void setLastModified(DateTime lastModified) { + public void setLastModified(Date lastModified) { this.lastModified = lastModified; } diff --git a/aws/core/src/main/java/org/jclouds/aws/s3/options/CopyObjectOptions.java b/aws/core/src/main/java/org/jclouds/aws/s3/options/CopyObjectOptions.java index ac46ce68b5..afba941b0f 100755 --- a/aws/core/src/main/java/org/jclouds/aws/s3/options/CopyObjectOptions.java +++ b/aws/core/src/main/java/org/jclouds/aws/s3/options/CopyObjectOptions.java @@ -28,6 +28,7 @@ import static com.google.common.base.Preconditions.checkState; import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX; import java.io.UnsupportedEncodingException; +import java.util.Date; import java.util.Map; import javax.inject.Inject; @@ -37,7 +38,7 @@ import org.jclouds.aws.s3.domain.CannedAccessPolicy; import org.jclouds.aws.s3.reference.S3Headers; import org.jclouds.http.options.BaseHttpRequestOptions; import org.jclouds.util.DateService; -import org.joda.time.DateTime; +import org.jclouds.util.internal.SimpleDateFormatDateService; import com.google.common.base.Preconditions; import com.google.common.collect.LinkedHashMultimap; @@ -63,7 +64,7 @@ import com.google.common.collect.Multimap; * Future object = connection.copyObject("sourceBucket", "objectName", * "destinationBucket", "destinationName", * overrideMetadataWith(meta). - * ifSourceModifiedSince(new DateTime().minusDays(1)) + * ifSourceModifiedSince(new Date().minusDays(1)) * ); * * @@ -73,7 +74,7 @@ import com.google.common.collect.Multimap; * /> */ public class CopyObjectOptions extends BaseHttpRequestOptions { - private final static DateService dateService = new DateService(); + private final static DateService dateService = new SimpleDateFormatDateService(); public static final CopyObjectOptions NONE = new CopyObjectOptions(); @@ -118,7 +119,7 @@ public class CopyObjectOptions extends BaseHttpRequestOptions { * * @return valid HTTP date * @see - * @see CopyObjectOptions#ifSourceModifiedSince(DateTime) + * @see CopyObjectOptions#ifSourceModifiedSince(Date) */ public String getIfModifiedSince() { return getFirstHeaderOrNull("x-amz-copy-source-if-modified-since"); @@ -135,7 +136,7 @@ public class CopyObjectOptions extends BaseHttpRequestOptions { * * @return valid HTTP date * @see - * @see CopyObjectOptions#ifSourceUnmodifiedSince(DateTime) + * @see CopyObjectOptions#ifSourceUnmodifiedSince(Date) */ public String getIfUnmodifiedSince() { return getFirstHeaderOrNull("x-amz-copy-source-if-unmodified-since"); @@ -185,9 +186,9 @@ public class CopyObjectOptions extends BaseHttpRequestOptions { * Only return the object if it has changed since this time. *

* Not compatible with {@link #ifSourceETagMatches(String)} or - * {@link #ifSourceUnmodifiedSince(DateTime)} + * {@link #ifSourceUnmodifiedSince(Date)} */ - public CopyObjectOptions ifSourceModifiedSince(DateTime ifModifiedSince) { + public CopyObjectOptions ifSourceModifiedSince(Date ifModifiedSince) { checkState(getIfMatch() == null, "ifETagMatches() is not compatible with ifModifiedSince()"); checkState(getIfUnmodifiedSince() == null, "ifUnmodifiedSince() is not compatible with ifModifiedSince()"); @@ -200,9 +201,9 @@ public class CopyObjectOptions extends BaseHttpRequestOptions { * Only return the object if it hasn't changed since this time. *

* Not compatible with {@link #ifSourceETagDoesntMatch(String)} or - * {@link #ifSourceModifiedSince(DateTime)} + * {@link #ifSourceModifiedSince(Date)} */ - public CopyObjectOptions ifSourceUnmodifiedSince(DateTime ifUnmodifiedSince) { + public CopyObjectOptions ifSourceUnmodifiedSince(Date ifUnmodifiedSince) { checkState(getIfNoneMatch() == null, "ifETagDoesntMatch() is not compatible with ifUnmodifiedSince()"); checkState(getIfModifiedSince() == null, @@ -217,7 +218,7 @@ public class CopyObjectOptions extends BaseHttpRequestOptions { *

*

* Not compatible with {@link #ifSourceETagDoesntMatch(String)} or - * {@link #ifSourceModifiedSince(DateTime)} + * {@link #ifSourceModifiedSince(Date)} * * @param eTag * hash representing the entity @@ -236,7 +237,7 @@ public class CopyObjectOptions extends BaseHttpRequestOptions { * The object should not have a eTag hash corresponding with the parameter eTag. *

* Not compatible with {@link #ifSourceETagMatches(String)} or - * {@link #ifSourceUnmodifiedSince(DateTime)} + * {@link #ifSourceUnmodifiedSince(Date)} * * @param eTag * hash representing the entity @@ -289,15 +290,15 @@ public class CopyObjectOptions extends BaseHttpRequestOptions { /** * @see CopyObjectOptions#getIfModifiedSince() */ - public static CopyObjectOptions ifSourceModifiedSince(DateTime ifModifiedSince) { + public static CopyObjectOptions ifSourceModifiedSince(Date ifModifiedSince) { CopyObjectOptions options = new CopyObjectOptions(); return options.ifSourceModifiedSince(ifModifiedSince); } /** - * @see CopyObjectOptions#ifSourceUnmodifiedSince(DateTime) + * @see CopyObjectOptions#ifSourceUnmodifiedSince(Date) */ - public static CopyObjectOptions ifSourceUnmodifiedSince(DateTime ifUnmodifiedSince) { + public static CopyObjectOptions ifSourceUnmodifiedSince(Date ifUnmodifiedSince) { CopyObjectOptions options = new CopyObjectOptions(); return options.ifSourceUnmodifiedSince(ifUnmodifiedSince); } diff --git a/aws/core/src/main/java/org/jclouds/aws/s3/xml/CopyObjectHandler.java b/aws/core/src/main/java/org/jclouds/aws/s3/xml/CopyObjectHandler.java index 53066f58c8..caf859daeb 100755 --- a/aws/core/src/main/java/org/jclouds/aws/s3/xml/CopyObjectHandler.java +++ b/aws/core/src/main/java/org/jclouds/aws/s3/xml/CopyObjectHandler.java @@ -23,13 +23,14 @@ */ package org.jclouds.aws.s3.xml; +import java.util.Date; + import javax.inject.Inject; import org.jclouds.aws.s3.domain.ObjectMetadata; import org.jclouds.aws.s3.domain.internal.CopyObjectResult; import org.jclouds.http.functions.ParseSax; import org.jclouds.util.DateService; -import org.joda.time.DateTime; /** * Parses the response from Amazon S3 COPY Object command. @@ -45,7 +46,7 @@ public class CopyObjectHandler extends ParseSax.HandlerWithResult list = context.getApi().listOwnedBuckets(); BucketMetadata firstContainer = list.first(); - BucketMetadata toMatch = new BucketMetadata(containerName, new DateTime(), firstContainer + BucketMetadata toMatch = new BucketMetadata(containerName, new Date(), firstContainer .getOwner()); assert list.contains(toMatch); } finally { diff --git a/aws/core/src/test/java/org/jclouds/aws/s3/config/S3RestClientModuleTest.java b/aws/core/src/test/java/org/jclouds/aws/s3/config/S3RestClientModuleTest.java index f7fc519312..5516a01dfd 100644 --- a/aws/core/src/test/java/org/jclouds/aws/s3/config/S3RestClientModuleTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/s3/config/S3RestClientModuleTest.java @@ -35,8 +35,8 @@ import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.http.functions.config.ParserModule; import org.jclouds.http.handlers.DelegatingErrorHandler; import org.jclouds.http.handlers.DelegatingRetryHandler; -import org.jclouds.util.DateService; import org.jclouds.util.Jsr330; +import org.jclouds.util.internal.SimpleDateFormatDateService; import org.testng.annotations.Test; import com.google.common.base.Supplier; @@ -71,7 +71,7 @@ public class S3RestClientModuleTest { void testUpdatesOnlyOncePerSecond() throws NoSuchMethodException, InterruptedException { S3RestClientModule module = new S3RestClientModule(); - Supplier map = module.provideTimeStampCache(1, new DateService()); + Supplier map = module.provideTimeStampCache(1, new SimpleDateFormatDateService()); String timeStamp = map.get(); for (int i = 0; i < 10; i++) map.get(); diff --git a/aws/core/src/test/java/org/jclouds/aws/s3/functions/ParseObjectMetadataFromHeadersTest.java b/aws/core/src/test/java/org/jclouds/aws/s3/functions/ParseObjectMetadataFromHeadersTest.java index 1d6f474d84..13d8f02f05 100644 --- a/aws/core/src/test/java/org/jclouds/aws/s3/functions/ParseObjectMetadataFromHeadersTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/s3/functions/ParseObjectMetadataFromHeadersTest.java @@ -28,6 +28,7 @@ import static org.easymock.classextension.EasyMock.createMock; import static org.easymock.classextension.EasyMock.replay; import static org.testng.Assert.assertEquals; +import java.util.Date; import java.util.Map; import javax.ws.rs.core.HttpHeaders; @@ -42,7 +43,6 @@ import org.jclouds.blobstore.domain.internal.MutableBlobMetadataImpl; import org.jclouds.blobstore.functions.ParseSystemAndUserMetadataFromHeaders; import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpUtils; -import org.joda.time.DateTime; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -81,7 +81,7 @@ public class ParseObjectMetadataFromHeadersTest { assertEquals(response, expects); } - DateTime now = new DateTime(); + Date now = new Date(); Map userMetadata = ImmutableMap.of("foo", "bar"); private MutableObjectMetadataImpl expects; BlobToObjectMetadata blobToObjectMetadata; diff --git a/aws/core/src/test/java/org/jclouds/aws/s3/internal/StubS3AsyncClient.java b/aws/core/src/test/java/org/jclouds/aws/s3/internal/StubS3AsyncClient.java index 823f8bebac..213f98bd6d 100755 --- a/aws/core/src/test/java/org/jclouds/aws/s3/internal/StubS3AsyncClient.java +++ b/aws/core/src/test/java/org/jclouds/aws/s3/internal/StubS3AsyncClient.java @@ -25,6 +25,7 @@ package org.jclouds.aws.s3.internal; import static com.google.common.base.Preconditions.checkNotNull; +import java.util.Date; import java.util.Map; import java.util.SortedSet; import java.util.concurrent.ConcurrentHashMap; @@ -68,7 +69,6 @@ import org.jclouds.concurrent.FutureFunctionWrapper; import org.jclouds.http.options.GetOptions; import org.jclouds.logging.Logger.LoggerFactory; import org.jclouds.util.DateService; -import org.joda.time.DateTime; import com.google.common.base.Function; import com.google.common.collect.Iterables; @@ -168,16 +168,15 @@ public class StubS3AsyncClient implements S3AsyncClient { blobStore.throwResponseException(412); } if (options.getIfModifiedSince() != null) { - DateTime modifiedSince = dateService - .rfc822DateParse(options.getIfModifiedSince()); - if (modifiedSince.isAfter(object.getMetadata().getLastModified())) + Date modifiedSince = dateService.rfc822DateParse(options.getIfModifiedSince()); + if (modifiedSince.after(object.getMetadata().getLastModified())) blobStore.throwResponseException(412); } if (options.getIfUnmodifiedSince() != null) { - DateTime unmodifiedSince = dateService.rfc822DateParse(options - .getIfUnmodifiedSince()); - if (unmodifiedSince.isBefore(object.getMetadata().getLastModified())) + Date unmodifiedSince = dateService + .rfc822DateParse(options.getIfUnmodifiedSince()); + if (unmodifiedSince.before(object.getMetadata().getLastModified())) blobStore.throwResponseException(412); } Blob sourceS3 = source.get(sourceObject); @@ -186,7 +185,7 @@ public class StubS3AsyncClient implements S3AsyncClient { if (options.getAcl() != null) keyToAcl.put(destinationBucket + "/" + destinationObject, options.getAcl()); - newMd.setLastModified(new DateTime()); + newMd.setLastModified(new Date()); Blob newBlob = blobProvider.create(newMd); newBlob.setData(sourceS3.getData()); dest.put(destinationObject, newBlob); diff --git a/aws/core/src/test/java/org/jclouds/aws/s3/options/CopyObjectOptionsTest.java b/aws/core/src/test/java/org/jclouds/aws/s3/options/CopyObjectOptionsTest.java index 854756c8bd..242c7d1e39 100755 --- a/aws/core/src/test/java/org/jclouds/aws/s3/options/CopyObjectOptionsTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/s3/options/CopyObjectOptionsTest.java @@ -34,12 +34,12 @@ import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import java.io.UnsupportedEncodingException; +import java.util.Date; import java.util.Map; import org.jclouds.aws.s3.domain.CannedAccessPolicy; import org.jclouds.aws.s3.reference.S3Headers; -import org.jclouds.util.DateService; -import org.joda.time.DateTime; +import org.jclouds.util.internal.SimpleDateFormatDateService; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -55,7 +55,7 @@ import com.google.common.collect.Multimap; public class CopyObjectOptionsTest { private String etag; - private DateTime now; + private Date now; private String nowExpected; private Map goodMeta; private Map badMeta; @@ -66,9 +66,8 @@ public class CopyObjectOptionsTest { goodMeta.put("x-amz-meta-adrian", "foo"); badMeta = Maps.newHashMap(); badMeta.put("x-google-meta-adrian", "foo"); - - now = new DateTime(); - nowExpected = new DateService().rfc822DateFormat(now); + now = new Date(); + nowExpected = new SimpleDateFormatDateService().rfc822DateFormat(now); etag = "mama"; } @@ -288,7 +287,7 @@ public class CopyObjectOptionsTest { Multimap headers = options.buildRequestHeaders(); assertEquals(headers.get("x-amz-copy-source-if-modified-since").iterator().next(), - new DateService().rfc822DateFormat(now)); + new SimpleDateFormatDateService().rfc822DateFormat(now)); assertEquals(headers.get("x-amz-copy-source-if-none-match").iterator().next(), "\"" + etag + "\""); for (String value : goodMeta.values()) diff --git a/aws/core/src/test/java/org/jclouds/aws/s3/xml/CopyObjectHandlerTest.java b/aws/core/src/test/java/org/jclouds/aws/s3/xml/CopyObjectHandlerTest.java index 5fc22f1b01..4ffa7dd596 100644 --- a/aws/core/src/test/java/org/jclouds/aws/s3/xml/CopyObjectHandlerTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/s3/xml/CopyObjectHandlerTest.java @@ -31,6 +31,7 @@ import org.jclouds.aws.s3.domain.ObjectMetadata; import org.jclouds.aws.s3.domain.internal.CopyObjectResult; import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.util.DateService; +import org.jclouds.util.internal.SimpleDateFormatDateService; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -54,8 +55,9 @@ public class CopyObjectHandlerTest extends BaseHandlerTest { public void testApplyInputStream() { InputStream is = getClass().getResourceAsStream("/s3/copy_object.xml"); - ObjectMetadata expected = new CopyObjectResult(new DateService() - .iso8601DateParse("2009-03-19T13:23:27.000Z"), "\"92836a3ea45a6984d1b4d23a747d46bb\""); + ObjectMetadata expected = new CopyObjectResult(new SimpleDateFormatDateService() + .iso8601DateParse("2009-03-19T13:23:27.000Z"), + "\"92836a3ea45a6984d1b4d23a747d46bb\""); ObjectMetadata result = (ObjectMetadata) factory.create( injector.getInstance(CopyObjectHandler.class)).parse(is); diff --git a/aws/core/src/test/java/org/jclouds/aws/s3/xml/S3ParserTest.java b/aws/core/src/test/java/org/jclouds/aws/s3/xml/S3ParserTest.java index 0bac73dcb8..333f6492cf 100755 --- a/aws/core/src/test/java/org/jclouds/aws/s3/xml/S3ParserTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/s3/xml/S3ParserTest.java @@ -27,6 +27,7 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.io.UnsupportedEncodingException; +import java.util.Date; import java.util.SortedSet; import java.util.concurrent.Callable; import java.util.concurrent.CompletionService; @@ -43,7 +44,7 @@ import org.jclouds.aws.s3.domain.ObjectMetadata.StorageClass; import org.jclouds.http.HttpException; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.config.ParserModule; -import org.joda.time.DateTime; +import org.jclouds.util.internal.SimpleDateFormatDateService; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -109,13 +110,13 @@ public class S3ParserTest extends PerformanceTest { SortedSet s3Buckets = runParseListAllMyBuckets(); BucketMetadata container1 = s3Buckets.first(); assert container1.getName().equals("adrianjbosstest"); - DateTime expectedDate1 = new DateTime("2009-03-12T02:00:07.000Z"); - DateTime date1 = container1.getCreationDate(); + Date expectedDate1 = new SimpleDateFormatDateService().iso8601DateParse("2009-03-12T02:00:07.000Z"); + Date date1 = container1.getCreationDate(); assert date1.equals(expectedDate1); BucketMetadata container2 = (BucketMetadata) s3Buckets.toArray()[1]; assert container2.getName().equals("adrianjbosstest2"); - DateTime expectedDate2 = new DateTime("2009-03-12T02:00:09.000Z"); - DateTime date2 = container2.getCreationDate(); + Date expectedDate2 = new SimpleDateFormatDateService().iso8601DateParse("2009-03-12T02:00:09.000Z"); + Date date2 = container2.getCreationDate(); assert date2.equals(expectedDate2); assert s3Buckets.size() == 2; CanonicalUser owner = new CanonicalUser( @@ -133,7 +134,7 @@ public class S3ParserTest extends PerformanceTest { assert container.size() == 1; ObjectMetadata object = container.iterator().next(); assert object.getKey().equals("3366"); - DateTime expected = new DateTime("2009-03-12T02:00:13.000Z"); + Date expected = new SimpleDateFormatDateService().iso8601DateParse("2009-03-12T02:00:13.000Z"); assert object.getLastModified().equals(expected) : String.format( "expected %1$s, but got %1$s", expected, object.getLastModified()); assertEquals(object.getETag(), "\"9d7bb64e8e18ee34eec06dd2cf37b766\""); @@ -159,7 +160,8 @@ public class S3ParserTest extends PerformanceTest { public void testCanParseCopyObjectResult() throws HttpException, UnsupportedEncodingException { ObjectMetadata metadata = runParseCopyObjectResult(); - DateTime expected = new DateTime("2009-03-19T13:23:27.000Z"); + Date expected = new SimpleDateFormatDateService() + .iso8601DateParse("2009-03-19T13:23:27.000Z"); assertEquals(metadata.getLastModified(), expected); assertEquals(metadata.getETag(), "\"92836a3ea45a6984d1b4d23a747d46bb\""); } diff --git a/aws/demos/googleappengine/pom.xml b/aws/demos/googleappengine/pom.xml index 92c171169f..a5e4c4f302 100644 --- a/aws/demos/googleappengine/pom.xml +++ b/aws/demos/googleappengine/pom.xml @@ -47,6 +47,11 @@ + + ${project.groupId} + jclouds-blobstore + ${project.version} + ${project.groupId} jclouds-azure diff --git a/aws/extensions/jets3t/src/main/java/org/jclouds/aws/s3/jets3t/JCloudsS3Service.java b/aws/extensions/jets3t/src/main/java/org/jclouds/aws/s3/jets3t/JCloudsS3Service.java index 37648149e7..24e14072b2 100755 --- a/aws/extensions/jets3t/src/main/java/org/jclouds/aws/s3/jets3t/JCloudsS3Service.java +++ b/aws/extensions/jets3t/src/main/java/org/jclouds/aws/s3/jets3t/JCloudsS3Service.java @@ -108,7 +108,7 @@ public class JCloudsS3Service extends S3Service { Map map = new HashMap(); // Result fields returned when copy is successful. - map.put("Last-Modified", jcObjectMetadata.getLastModified().toDate()); + map.put("Last-Modified", jcObjectMetadata.getLastModified()); map.put("ETag", jcObjectMetadata.getETag()); return map; } catch (Exception e) { diff --git a/aws/extensions/jets3t/src/main/java/org/jclouds/aws/s3/jets3t/Util.java b/aws/extensions/jets3t/src/main/java/org/jclouds/aws/s3/jets3t/Util.java index 16c375476f..a74af90649 100755 --- a/aws/extensions/jets3t/src/main/java/org/jclouds/aws/s3/jets3t/Util.java +++ b/aws/extensions/jets3t/src/main/java/org/jclouds/aws/s3/jets3t/Util.java @@ -46,6 +46,7 @@ import org.jclouds.aws.s3.options.ListBucketOptions; import org.jclouds.aws.s3.options.PutObjectOptions; import org.jclouds.http.options.GetOptions; import org.jclouds.util.DateService; +import org.jclouds.util.internal.SimpleDateFormatDateService; import org.jets3t.service.S3ServiceException; import org.jets3t.service.acl.AccessControlList; import org.jets3t.service.acl.CanonicalGrantee; @@ -58,7 +59,6 @@ import org.jets3t.service.model.S3Bucket; import org.jets3t.service.model.S3Object; import org.jets3t.service.model.S3Owner; import org.jets3t.service.utils.RestUtils; -import org.joda.time.DateTime; import com.google.common.collect.Maps; @@ -104,11 +104,11 @@ public class Util { jsObject.setContentLength(jcObjectMD.getSize()); jsObject.setContentDisposition(jcObjectMD.getContentDisposition()); jsObject.setContentEncoding(jcObjectMD.getContentEncoding()); - jsObject.setLastModifiedDate(jcObjectMD.getLastModified().toDate()); + jsObject.setLastModifiedDate(jcObjectMD.getLastModified()); jsObject.setETag(jcObjectMD.getETag()); jsObject.setMd5Hash(jcObjectMD.getContentMD5()); jsObject.addAllMetadata(jcObjectMD.getUserMetadata()); - jsObject.addMetadata(S3Object.METADATA_HEADER_DATE, jcObjectMD.getLastModified().toDate()); + jsObject.addMetadata(S3Object.METADATA_HEADER_DATE, jcObjectMD.getLastModified()); return jsObject; } @@ -135,7 +135,7 @@ public class Util { jcObject.getMetadata().setCacheControl((String) jsObject.getMetadata("Cache-Control")); jcObject.getMetadata().setContentDisposition(jsObject.getContentDisposition()); jcObject.getMetadata().setContentEncoding(jsObject.getContentEncoding()); - jcObject.getMetadata().setLastModified(new DateTime(jsObject.getLastModifiedDate())); + jcObject.getMetadata().setLastModified(jsObject.getLastModifiedDate()); jcObject.setContentLength(jsObject.getContentLength()); if (jsObject.getStorageClass() != null) jcObject.getMetadata().setStorageClass(StorageClass.valueOf(jsObject.getStorageClass())); @@ -163,7 +163,7 @@ public class Util { } // User metadata - DateService dateService = new DateService(); + DateService dateService = new SimpleDateFormatDateService(); for (Object maybeUserMetadataObj : jsObject.getMetadataMap().entrySet()) { String name = ((Entry) maybeUserMetadataObj).getKey(); Object value = ((Entry) maybeUserMetadataObj).getValue(); @@ -183,10 +183,10 @@ public class Util { throws UnsupportedEncodingException { GetOptions options = new GetOptions(); if (ifModifiedSince != null) { - options.ifModifiedSince(new DateTime(ifModifiedSince)); + options.ifModifiedSince(ifModifiedSince.getTime()); } if (ifUnmodifiedSince != null) { - options.ifUnmodifiedSince(new DateTime(ifUnmodifiedSince)); + options.ifUnmodifiedSince(ifUnmodifiedSince.getTime()); } // TODO: options.ifETagMatches should accept multiple match tags if (ifMatchTags != null && ifMatchTags.length > 0) { @@ -331,10 +331,10 @@ public class Util { options.overrideAcl(convertACLToCannedAccessPolicy(acl)); } if (ifModifiedSince != null) { - options.ifSourceModifiedSince(new DateTime(ifModifiedSince)); + options.ifSourceModifiedSince(ifModifiedSince.getTime()); } if (ifUnmodifiedSince != null) { - options.ifSourceUnmodifiedSince(new DateTime(ifUnmodifiedSince)); + options.ifSourceUnmodifiedSince(ifUnmodifiedSince.getTime()); } // TODO: options.ifETagMatches should accept multiple match tags if (ifMatchTags != null && ifMatchTags.length > 0) { diff --git a/aws/perftest/src/test/java/com/amazon/s3/S3ParserTest.java b/aws/perftest/src/test/java/com/amazon/s3/S3ParserTest.java index d888619abc..2225b5b9e6 100755 --- a/aws/perftest/src/test/java/com/amazon/s3/S3ParserTest.java +++ b/aws/perftest/src/test/java/com/amazon/s3/S3ParserTest.java @@ -34,7 +34,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorCompletionService; import org.apache.commons.io.IOUtils; -import org.joda.time.DateTime; +import org.jclouds.util.internal.SimpleDateFormatDateService; import org.testng.annotations.Test; /** @@ -103,12 +103,14 @@ public class S3ParserTest extends org.jclouds.aws.s3.xml.S3ParserTest { List buckets = response.entries; Bucket bucket1 = (Bucket) buckets.get(0); assert bucket1.name.equals("adrianjbosstest"); - Date expectedDate1 = new DateTime("2009-03-12T02:00:07.000Z").toDate(); + Date expectedDate1 = new SimpleDateFormatDateService() + .iso8601DateParse("2009-03-12T02:00:07.000Z"); Date date1 = bucket1.creationDate; assert date1.toString().equals(expectedDate1.toString()); Bucket bucket2 = (Bucket) buckets.get(1); assert bucket2.name.equals("adrianjbosstest2"); - Date expectedDate2 = new DateTime("2009-03-12T02:00:09.000Z").toDate(); + Date expectedDate2 = new SimpleDateFormatDateService() + .iso8601DateParse("2009-03-12T02:00:09.000Z"); Date date2 = bucket2.creationDate; assert date2.toString().equals(expectedDate2.toString()); assert buckets.size() == 2; @@ -125,7 +127,8 @@ public class S3ParserTest extends org.jclouds.aws.s3.xml.S3ParserTest { ListBucketResponse response = runAmazonParseListBucketResult(); ListEntry content = (ListEntry) response.entries.get(0); assert content.key.equals("3366"); - assert content.lastModified.equals(new DateTime("2009-03-12T02:00:13.000Z").toDate()); + assert content.lastModified.equals(new SimpleDateFormatDateService() + .iso8601DateParse("2009-03-12T02:00:13.000Z")); assert content.eTag.equals("\"9d7bb64e8e18ee34eec06dd2cf37b766\""); assert content.size == 136; assert content.owner.id diff --git a/azure/src/main/java/org/jclouds/azure/storage/blob/domain/ListableBlobProperties.java b/azure/src/main/java/org/jclouds/azure/storage/blob/domain/ListableBlobProperties.java index 41cd25c585..5727ffd30d 100644 --- a/azure/src/main/java/org/jclouds/azure/storage/blob/domain/ListableBlobProperties.java +++ b/azure/src/main/java/org/jclouds/azure/storage/blob/domain/ListableBlobProperties.java @@ -24,8 +24,7 @@ package org.jclouds.azure.storage.blob.domain; import java.net.URI; - -import org.joda.time.DateTime; +import java.util.Date; /** * @@ -37,7 +36,7 @@ public interface ListableBlobProperties extends Comparable { +public interface ListableContainerProperties extends Comparable { URI getUrl(); String getName(); - DateTime getLastModified(); + Date getLastModified(); String getETag(); } diff --git a/azure/src/main/java/org/jclouds/azure/storage/blob/domain/MutableBlobProperties.java b/azure/src/main/java/org/jclouds/azure/storage/blob/domain/MutableBlobProperties.java index f8779203d9..b993263f0f 100644 --- a/azure/src/main/java/org/jclouds/azure/storage/blob/domain/MutableBlobProperties.java +++ b/azure/src/main/java/org/jclouds/azure/storage/blob/domain/MutableBlobProperties.java @@ -24,10 +24,10 @@ package org.jclouds.azure.storage.blob.domain; import java.net.URI; +import java.util.Date; import java.util.Map; import org.jclouds.azure.storage.blob.domain.internal.MutableBlobPropertiesImpl; -import org.joda.time.DateTime; import com.google.inject.ImplementedBy; @@ -51,7 +51,7 @@ public interface MutableBlobProperties extends BlobProperties { /** * @see ListableContainerProperties#setLastModified */ - void setLastModified(DateTime lastModified); + void setLastModified(Date lastModified); /** * @see ListableContainerProperties#setETag diff --git a/azure/src/main/java/org/jclouds/azure/storage/blob/domain/MutableContainerPropertiesWithMetadata.java b/azure/src/main/java/org/jclouds/azure/storage/blob/domain/MutableContainerPropertiesWithMetadata.java index bee00a34f4..15c5192efb 100644 --- a/azure/src/main/java/org/jclouds/azure/storage/blob/domain/MutableContainerPropertiesWithMetadata.java +++ b/azure/src/main/java/org/jclouds/azure/storage/blob/domain/MutableContainerPropertiesWithMetadata.java @@ -24,10 +24,10 @@ package org.jclouds.azure.storage.blob.domain; import java.net.URI; +import java.util.Date; import java.util.Map; import org.jclouds.azure.storage.blob.domain.internal.MutableContainerPropertiesWithMetadataImpl; -import org.joda.time.DateTime; import com.google.inject.ImplementedBy; @@ -51,7 +51,7 @@ public interface MutableContainerPropertiesWithMetadata extends ContainerPropert /** * @see ListableContainerProperties#setLastModified */ - void setLastModified(DateTime lastModified); + void setLastModified(Date lastModified); /** * @see ListableContainerProperties#setETag diff --git a/azure/src/main/java/org/jclouds/azure/storage/blob/domain/internal/ListableBlobPropertiesImpl.java b/azure/src/main/java/org/jclouds/azure/storage/blob/domain/internal/ListableBlobPropertiesImpl.java index bbaf48afe6..a62ed5cdb6 100644 --- a/azure/src/main/java/org/jclouds/azure/storage/blob/domain/internal/ListableBlobPropertiesImpl.java +++ b/azure/src/main/java/org/jclouds/azure/storage/blob/domain/internal/ListableBlobPropertiesImpl.java @@ -27,9 +27,9 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.io.Serializable; import java.net.URI; +import java.util.Date; import org.jclouds.azure.storage.blob.domain.ListableBlobProperties; -import org.joda.time.DateTime; import com.google.inject.internal.Nullable; @@ -45,14 +45,14 @@ public class ListableBlobPropertiesImpl implements Serializable, ListableBlobPro private final String name; private final URI url; - private final DateTime lastModified; + private final Date lastModified; private final String eTag; private final long size; private final String contentType; private final String contentEncoding; private final String contentLanguage; - public ListableBlobPropertiesImpl(String name, URI url, DateTime lastModified, String eTag, + public ListableBlobPropertiesImpl(String name, URI url, Date lastModified, String eTag, long size, String contentType, @Nullable String contentEncoding, @Nullable String contentLanguage) { this.name = checkNotNull(name, "name"); @@ -89,7 +89,7 @@ public class ListableBlobPropertiesImpl implements Serializable, ListableBlobPro /** *{@inheritDoc} */ - public DateTime getLastModified() { + public Date getLastModified() { return lastModified; } diff --git a/azure/src/main/java/org/jclouds/azure/storage/blob/domain/internal/ListableContainerPropertiesImpl.java b/azure/src/main/java/org/jclouds/azure/storage/blob/domain/internal/ListableContainerPropertiesImpl.java index 64015e7831..81e844c74b 100644 --- a/azure/src/main/java/org/jclouds/azure/storage/blob/domain/internal/ListableContainerPropertiesImpl.java +++ b/azure/src/main/java/org/jclouds/azure/storage/blob/domain/internal/ListableContainerPropertiesImpl.java @@ -27,9 +27,9 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.io.Serializable; import java.net.URI; +import java.util.Date; import org.jclouds.azure.storage.blob.domain.ListableContainerProperties; -import org.joda.time.DateTime; /** * Allows you to manipulate metadata. @@ -43,10 +43,10 @@ public class ListableContainerPropertiesImpl implements Serializable, ListableCo private final String name; private final URI url; - private final DateTime lastModified; + private final Date lastModified; private final String eTag; - public ListableContainerPropertiesImpl(URI url, DateTime lastModified, String eTag) { + public ListableContainerPropertiesImpl(URI url, Date lastModified, String eTag) { this.url = checkNotNull(url, "url"); this.name = checkNotNull(url.getPath(), "url.getPath()").replaceFirst("/", ""); this.lastModified = checkNotNull(lastModified, "lastModified"); @@ -63,7 +63,7 @@ public class ListableContainerPropertiesImpl implements Serializable, ListableCo /** *{@inheritDoc} */ - public DateTime getLastModified() { + public Date getLastModified() { return lastModified; } diff --git a/azure/src/main/java/org/jclouds/azure/storage/blob/domain/internal/MutableBlobPropertiesImpl.java b/azure/src/main/java/org/jclouds/azure/storage/blob/domain/internal/MutableBlobPropertiesImpl.java index bc37945e17..31b97760f9 100644 --- a/azure/src/main/java/org/jclouds/azure/storage/blob/domain/internal/MutableBlobPropertiesImpl.java +++ b/azure/src/main/java/org/jclouds/azure/storage/blob/domain/internal/MutableBlobPropertiesImpl.java @@ -26,11 +26,11 @@ package org.jclouds.azure.storage.blob.domain.internal; import java.io.Serializable; import java.net.URI; import java.util.Arrays; +import java.util.Date; import java.util.Map; import org.jclouds.azure.storage.blob.domain.ListableBlobProperties; import org.jclouds.azure.storage.blob.domain.MutableBlobProperties; -import org.joda.time.DateTime; import com.google.common.collect.Maps; @@ -46,7 +46,7 @@ public class MutableBlobPropertiesImpl implements Serializable, MutableBlobPrope private String name; private URI url; - private DateTime lastModified; + private Date lastModified; private String eTag; private long size; private String contentType; @@ -82,7 +82,7 @@ public class MutableBlobPropertiesImpl implements Serializable, MutableBlobPrope /** *{@inheritDoc} */ - public DateTime getLastModified() { + public Date getLastModified() { return lastModified; } @@ -169,7 +169,7 @@ public class MutableBlobPropertiesImpl implements Serializable, MutableBlobPrope /** *{@inheritDoc} */ - public void setLastModified(DateTime lastModified) { + public void setLastModified(Date lastModified) { this.lastModified = lastModified; } diff --git a/azure/src/main/java/org/jclouds/azure/storage/blob/domain/internal/MutableContainerPropertiesWithMetadataImpl.java b/azure/src/main/java/org/jclouds/azure/storage/blob/domain/internal/MutableContainerPropertiesWithMetadataImpl.java index c5cf26a2ac..ae758dbba9 100644 --- a/azure/src/main/java/org/jclouds/azure/storage/blob/domain/internal/MutableContainerPropertiesWithMetadataImpl.java +++ b/azure/src/main/java/org/jclouds/azure/storage/blob/domain/internal/MutableContainerPropertiesWithMetadataImpl.java @@ -25,11 +25,11 @@ package org.jclouds.azure.storage.blob.domain.internal; import java.io.Serializable; import java.net.URI; +import java.util.Date; import java.util.Map; import org.jclouds.azure.storage.blob.domain.ListableContainerProperties; import org.jclouds.azure.storage.blob.domain.MutableContainerPropertiesWithMetadata; -import org.joda.time.DateTime; import com.google.common.collect.Maps; @@ -38,14 +38,15 @@ import com.google.common.collect.Maps; * * @author Adrian Cole */ -public class MutableContainerPropertiesWithMetadataImpl implements Serializable, MutableContainerPropertiesWithMetadata { +public class MutableContainerPropertiesWithMetadataImpl implements Serializable, + MutableContainerPropertiesWithMetadata { /** The serialVersionUID */ private static final long serialVersionUID = -4648755473986695062L; private String name; private URI url; - private DateTime lastModified; + private Date lastModified; private String eTag; private Map metadata = Maps.newHashMap(); @@ -59,10 +60,11 @@ public class MutableContainerPropertiesWithMetadataImpl implements Serializable, public String getName() { return name; } + /** *{@inheritDoc} */ - public DateTime getLastModified() { + public Date getLastModified() { return lastModified; } @@ -73,7 +75,6 @@ public class MutableContainerPropertiesWithMetadataImpl implements Serializable, return eTag; } - /** *{@inheritDoc} */ @@ -105,7 +106,7 @@ public class MutableContainerPropertiesWithMetadataImpl implements Serializable, /** *{@inheritDoc} */ - public void setLastModified(DateTime lastModified) { + public void setLastModified(Date lastModified) { this.lastModified = lastModified; } diff --git a/azure/src/main/java/org/jclouds/azure/storage/blob/xml/AccountNameEnumerationResultsHandler.java b/azure/src/main/java/org/jclouds/azure/storage/blob/xml/AccountNameEnumerationResultsHandler.java index 5d8fec708d..390aeb6656 100755 --- a/azure/src/main/java/org/jclouds/azure/storage/blob/xml/AccountNameEnumerationResultsHandler.java +++ b/azure/src/main/java/org/jclouds/azure/storage/blob/xml/AccountNameEnumerationResultsHandler.java @@ -24,6 +24,7 @@ package org.jclouds.azure.storage.blob.xml; import java.net.URI; +import java.util.Date; import java.util.SortedSet; import javax.inject.Inject; @@ -34,7 +35,6 @@ import org.jclouds.azure.storage.domain.BoundedSortedSet; import org.jclouds.azure.storage.domain.internal.BoundedTreeSet; import org.jclouds.http.functions.ParseSax; import org.jclouds.util.DateService; -import org.joda.time.DateTime; import com.google.common.collect.Sets; @@ -55,7 +55,7 @@ public class AccountNameEnumerationResultsHandler extends private int maxResults; private String nextMarker; private URI currentUrl; - private DateTime currentLastModified; + private Date currentLastModified; private String currentETag; private StringBuilder currentText = new StringBuilder(); @@ -68,8 +68,8 @@ public class AccountNameEnumerationResultsHandler extends } public BoundedSortedSet getResult() { - return new BoundedTreeSet(containerMetadata, currentUrl, prefix, marker, - maxResults, nextMarker); + return new BoundedTreeSet(containerMetadata, currentUrl, prefix, + marker, maxResults, nextMarker); } public void endElement(String uri, String name, String qName) { diff --git a/azure/src/main/java/org/jclouds/azure/storage/blob/xml/ContainerNameEnumerationResultsHandler.java b/azure/src/main/java/org/jclouds/azure/storage/blob/xml/ContainerNameEnumerationResultsHandler.java index 8a2c34a1f4..044531c7d5 100644 --- a/azure/src/main/java/org/jclouds/azure/storage/blob/xml/ContainerNameEnumerationResultsHandler.java +++ b/azure/src/main/java/org/jclouds/azure/storage/blob/xml/ContainerNameEnumerationResultsHandler.java @@ -24,6 +24,7 @@ package org.jclouds.azure.storage.blob.xml; import java.net.URI; +import java.util.Date; import java.util.SortedSet; import javax.inject.Inject; @@ -35,7 +36,6 @@ import org.jclouds.azure.storage.blob.domain.internal.TreeSetListBlobsResponse; import org.jclouds.http.HttpUtils; import org.jclouds.http.functions.ParseSax; import org.jclouds.util.DateService; -import org.joda.time.DateTime; import org.xml.sax.Attributes; import org.xml.sax.SAXException; @@ -59,7 +59,7 @@ public class ContainerNameEnumerationResultsHandler extends private String nextMarker; private URI currentUrl; private URI containerUrl; - private DateTime currentLastModified; + private Date currentLastModified; private String currentETag; private StringBuilder currentText = new StringBuilder(); diff --git a/azure/src/test/java/org/jclouds/azure/storage/blob/internal/StubAzureBlobAsyncClient.java b/azure/src/test/java/org/jclouds/azure/storage/blob/internal/StubAzureBlobAsyncClient.java index 7805d286c7..14b71b6677 100644 --- a/azure/src/test/java/org/jclouds/azure/storage/blob/internal/StubAzureBlobAsyncClient.java +++ b/azure/src/test/java/org/jclouds/azure/storage/blob/internal/StubAzureBlobAsyncClient.java @@ -26,6 +26,7 @@ package org.jclouds.azure.storage.blob.internal; import static com.google.common.base.Preconditions.checkNotNull; import java.net.URI; +import java.util.Date; import java.util.Map; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ExecutionException; @@ -59,7 +60,6 @@ import org.jclouds.blobstore.integration.internal.StubAsyncBlobStore.FutureBase; import org.jclouds.concurrent.FutureFunctionWrapper; import org.jclouds.http.options.GetOptions; import org.jclouds.logging.Logger.LoggerFactory; -import org.joda.time.DateTime; import com.google.common.base.Function; import com.google.common.collect.Iterables; @@ -176,7 +176,7 @@ public class StubAzureBlobAsyncClient implements AzureBlobAsyncClient { new Function() { public ListableContainerProperties apply(String name) { return new ListableContainerPropertiesImpl(URI.create("http://stub/" - + name), new DateTime(), ""); + + name), new Date(), ""); } }), null, null, null, null, null); diff --git a/azure/src/test/java/org/jclouds/azure/storage/config/AzureStorageRestClientModuleTest.java b/azure/src/test/java/org/jclouds/azure/storage/config/AzureStorageRestClientModuleTest.java index 3fa30276d3..6ae46e3aa4 100644 --- a/azure/src/test/java/org/jclouds/azure/storage/config/AzureStorageRestClientModuleTest.java +++ b/azure/src/test/java/org/jclouds/azure/storage/config/AzureStorageRestClientModuleTest.java @@ -37,8 +37,8 @@ import org.jclouds.http.functions.config.ParserModule; import org.jclouds.http.handlers.DelegatingErrorHandler; import org.jclouds.http.handlers.DelegatingRetryHandler; import org.jclouds.http.handlers.RedirectionRetryHandler; -import org.jclouds.util.DateService; import org.jclouds.util.Jsr330; +import org.jclouds.util.internal.SimpleDateFormatDateService; import org.testng.annotations.Test; import com.google.common.base.Supplier; @@ -69,7 +69,7 @@ public class AzureStorageRestClientModuleTest { void testUpdatesOnlyOncePerSecond() throws NoSuchMethodException, InterruptedException { AzureStorageRestClientModule module = new AzureStorageRestClientModule(); - Supplier map = module.provideTimeStampCache(1, new DateService()); + Supplier map = module.provideTimeStampCache(1, new SimpleDateFormatDateService()); String timeStamp = map.get(); for (int i = 0; i < 10; i++) map.get(); diff --git a/blobstore/src/main/java/org/jclouds/blobstore/domain/MutableResourceMetadata.java b/blobstore/src/main/java/org/jclouds/blobstore/domain/MutableResourceMetadata.java index a1388ffd60..23a87102e6 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/domain/MutableResourceMetadata.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/domain/MutableResourceMetadata.java @@ -24,10 +24,10 @@ package org.jclouds.blobstore.domain; import java.net.URI; +import java.util.Date; import java.util.Map; import org.jclouds.blobstore.domain.internal.MutableResourceMetadataImpl; -import org.joda.time.DateTime; import com.google.inject.ImplementedBy; @@ -77,7 +77,7 @@ public interface MutableResourceMetadata extends ResourceMetadata { * @see org.jclouds.blobstore.attr.ContainerCapability#BLOB_LAST_MODIFIED * @see org.jclouds.blobstore.attr.ContainerCapability#MILLISECOND_PRECISION */ - void setLastModified(DateTime lastModified); + void setLastModified(Date lastModified); /** * Any key-value pairs associated with the resource. diff --git a/blobstore/src/main/java/org/jclouds/blobstore/domain/ResourceMetadata.java b/blobstore/src/main/java/org/jclouds/blobstore/domain/ResourceMetadata.java index 81e8b61509..fddaaca468 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/domain/ResourceMetadata.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/domain/ResourceMetadata.java @@ -24,10 +24,10 @@ package org.jclouds.blobstore.domain; import java.net.URI; +import java.util.Date; import java.util.Map; import org.jclouds.blobstore.domain.internal.ResourceMetadataImpl; -import org.joda.time.DateTime; import com.google.inject.ImplementedBy; @@ -43,7 +43,7 @@ public interface ResourceMetadata extends Comparable { * Whether this resource is a container, file, etc. */ ResourceType getType(); - + /** * Unique identifier of this resource within its enclosing namespace. In some scenarios, this id * is not user assignable. For files, this may be an system generated key, or the full path to @@ -72,14 +72,14 @@ public interface ResourceMetadata extends Comparable { * @see org.jclouds.blobstore.attr.ContainerCapability#BLOB_ETAG */ String getETag(); - + /** * Size of the resource in bytes * * @see org.jclouds.blobstore.attr.ContainerCapability#CONTAINER_SIZE * @see org.jclouds.blobstore.attr.ContainerCapability#BLOB_SIZE */ - public Long getSize(); + Long getSize(); /** * Last modification time of the resource @@ -88,7 +88,7 @@ public interface ResourceMetadata extends Comparable { * @see org.jclouds.blobstore.attr.ContainerCapability#BLOB_LAST_MODIFIED * @see org.jclouds.blobstore.attr.ContainerCapability#MILLISECOND_PRECISION */ - public DateTime getLastModified(); + Date getLastModified(); /** * Any key-value pairs associated with the resource. @@ -98,6 +98,4 @@ public interface ResourceMetadata extends Comparable { */ Map getUserMetadata(); - - } \ No newline at end of file diff --git a/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/BlobMetadataImpl.java b/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/BlobMetadataImpl.java index aa9c58835a..6348272e58 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/BlobMetadataImpl.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/BlobMetadataImpl.java @@ -25,12 +25,12 @@ package org.jclouds.blobstore.domain.internal; import java.io.Serializable; import java.net.URI; +import java.util.Date; import java.util.Map; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.BlobMetadata; import org.jclouds.blobstore.domain.ResourceType; -import org.joda.time.DateTime; /** * System and user Metadata for the {@link Blob}. @@ -44,8 +44,8 @@ public class BlobMetadataImpl extends ResourceMetadataImpl implements Serializab private final String contentType; private final byte[] contentMD5; - public BlobMetadataImpl(String id, String name, URI location, String eTag, - Long size, DateTime lastModified, Map userMetadata, String contentType, + public BlobMetadataImpl(String id, String name, URI location, String eTag, Long size, + Date lastModified, Map userMetadata, String contentType, byte[] contentMD5) { super(ResourceType.BLOB, id, name, location, eTag, size, lastModified, userMetadata); this.contentType = contentType; diff --git a/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/MutableResourceMetadataImpl.java b/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/MutableResourceMetadataImpl.java index a859de04fe..0ec4797f0e 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/MutableResourceMetadataImpl.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/MutableResourceMetadataImpl.java @@ -25,12 +25,12 @@ package org.jclouds.blobstore.domain.internal; import java.io.Serializable; import java.net.URI; +import java.util.Date; import java.util.Map; import org.jclouds.blobstore.domain.MutableResourceMetadata; import org.jclouds.blobstore.domain.ResourceMetadata; import org.jclouds.blobstore.domain.ResourceType; -import org.joda.time.DateTime; import com.google.common.collect.Maps; @@ -50,7 +50,7 @@ public class MutableResourceMetadataImpl implements MutableResourceMetadata, Ser private URI location; private String eTag; private Long size; - private DateTime lastModified; + private Date lastModified; private Map userMetadata; public MutableResourceMetadataImpl() { @@ -98,7 +98,7 @@ public class MutableResourceMetadataImpl implements MutableResourceMetadata, Ser return size; } - public DateTime getLastModified() { + public Date getLastModified() { return lastModified; } @@ -173,7 +173,7 @@ public class MutableResourceMetadataImpl implements MutableResourceMetadata, Ser return true; } - public void setLastModified(DateTime lastModified) { + public void setLastModified(Date lastModified) { this.lastModified = lastModified; } diff --git a/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/ResourceMetadataImpl.java b/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/ResourceMetadataImpl.java index a3a18d8fe0..69ba903628 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/ResourceMetadataImpl.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/ResourceMetadataImpl.java @@ -27,11 +27,11 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.io.Serializable; import java.net.URI; +import java.util.Date; import java.util.Map; import org.jclouds.blobstore.domain.ResourceMetadata; import org.jclouds.blobstore.domain.ResourceType; -import org.joda.time.DateTime; import com.google.inject.internal.Nullable; @@ -57,12 +57,12 @@ public class ResourceMetadataImpl implements ResourceMetadata, Serializable { private final @Nullable Long size; private final @Nullable - DateTime lastModified; + Date lastModified; private final Map userMetadata; public ResourceMetadataImpl(ResourceType type, @Nullable String id, @Nullable String name, @Nullable URI location, @Nullable String eTag, @Nullable Long size, - @Nullable DateTime lastModified, Map userMetadata) { + @Nullable Date lastModified, Map userMetadata) { this.type = checkNotNull(type, "type"); this.id = id; this.name = name; @@ -103,7 +103,7 @@ public class ResourceMetadataImpl implements ResourceMetadata, Serializable { return size; } - public DateTime getLastModified() { + public Date getLastModified() { return lastModified; } diff --git a/blobstore/src/main/java/org/jclouds/blobstore/functions/HttpGetOptionsListToGetOptions.java b/blobstore/src/main/java/org/jclouds/blobstore/functions/HttpGetOptionsListToGetOptions.java index aa6e374112..bfb4ed65ac 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/functions/HttpGetOptionsListToGetOptions.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/functions/HttpGetOptionsListToGetOptions.java @@ -23,11 +23,12 @@ */ package org.jclouds.blobstore.functions; +import java.util.Date; + import javax.inject.Inject; import org.jclouds.blobstore.options.GetOptions; import org.jclouds.util.DateService; -import org.joda.time.DateTime; import com.google.common.base.Function; @@ -47,14 +48,14 @@ public class HttpGetOptionsListToGetOptions implements to.ifETagMatches(from[0].getIfMatch().replaceAll("\"", "")); } if (from[0].getIfModifiedSince() != null) { - DateTime time = dateService.rfc822DateParse(from[0].getIfModifiedSince()); + Date time = dateService.rfc822DateParse(from[0].getIfModifiedSince()); to.ifModifiedSince(time); } if (from[0].getIfNoneMatch() != null) { to.ifETagDoesntMatch(from[0].getIfNoneMatch().replaceAll("\"", "")); } if (from[0].getIfUnmodifiedSince() != null) { - DateTime time = dateService.rfc822DateParse(from[0].getIfUnmodifiedSince()); + Date time = dateService.rfc822DateParse(from[0].getIfUnmodifiedSince()); to.ifUnmodifiedSince(time); } for (String range : from[0].getRanges()) { diff --git a/blobstore/src/main/java/org/jclouds/blobstore/options/GetOptions.java b/blobstore/src/main/java/org/jclouds/blobstore/options/GetOptions.java index 8080c2a57c..2d16debde0 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/options/GetOptions.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/options/GetOptions.java @@ -23,14 +23,14 @@ */ package org.jclouds.blobstore.options; -import static com.google.common.base.Preconditions.*; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; import java.io.UnsupportedEncodingException; import java.util.ArrayList; +import java.util.Date; import java.util.List; -import org.joda.time.DateTime; - /** * Contains options supported for HTTP GET operations.

* Usage

The recommended way to instantiate a GetObjectOptions object is to statically import @@ -42,7 +42,7 @@ import org.joda.time.DateTime; * * * // this will get the first megabyte of an object, provided it wasn't modified since yesterday - * Future object = client.get("objectName",range(0,1024).ifUnmodifiedSince(new DateTime().minusDays(1))); + * Future object = client.get("objectName",range(0,1024).ifUnmodifiedSince(new Date().minusDays(1))); * * * @author Adrian Cole @@ -50,8 +50,8 @@ import org.joda.time.DateTime; */ public class GetOptions { private final List ranges = new ArrayList(); - private DateTime ifModifiedSince; - private DateTime ifUnmodifiedSince; + private Date ifModifiedSince; + private Date ifUnmodifiedSince; private String ifMatch; private String ifNoneMatch; @@ -77,9 +77,9 @@ public class GetOptions { /** * Only return the object if it has changed since this time. *

- * Not compatible with {@link #ifETagMatches(String)} or {@link #ifUnmodifiedSince(DateTime)} + * Not compatible with {@link #ifETagMatches(String)} or {@link #ifUnmodifiedSince(Date)} */ - public GetOptions ifModifiedSince(DateTime ifModifiedSince) { + public GetOptions ifModifiedSince(Date ifModifiedSince) { checkArgument(getIfMatch() == null, "ifETagMatches() is not compatible with ifModifiedSince()"); checkArgument(getIfUnmodifiedSince() == null, @@ -94,18 +94,18 @@ public class GetOptions { * Return the object only if it has been modified since the specified time, otherwise return a * 304 (not modified). * - * @see GetOptions#ifModifiedSince(DateTime) + * @see GetOptions#ifModifiedSince(Date) */ - public DateTime getIfModifiedSince() { + public Date getIfModifiedSince() { return this.ifModifiedSince; } /** * Only return the object if it hasn't changed since this time. *

- * Not compatible with {@link #ifETagDoesntMatch(String)} or {@link #ifModifiedSince(DateTime)} + * Not compatible with {@link #ifETagDoesntMatch(String)} or {@link #ifModifiedSince(Date)} */ - public GetOptions ifUnmodifiedSince(DateTime ifUnmodifiedSince) { + public GetOptions ifUnmodifiedSince(Date ifUnmodifiedSince) { checkArgument(getIfNoneMatch() == null, "ifETagDoesntMatch() is not compatible with ifUnmodifiedSince()"); checkArgument(getIfModifiedSince() == null, @@ -120,9 +120,9 @@ public class GetOptions { * Return the object only if it has not been modified since the specified time, otherwise return * a 412 (precondition failed). * - * @see GetOptions#ifUnmodifiedSince(DateTime) + * @see GetOptions#ifUnmodifiedSince(Date) */ - public DateTime getIfUnmodifiedSince() { + public Date getIfUnmodifiedSince() { return this.ifUnmodifiedSince; } @@ -130,7 +130,7 @@ public class GetOptions { * The object's eTag hash should match the parameter eTag. * *

- * Not compatible with {@link #ifETagDoesntMatch(String)} or {@link #ifModifiedSince(DateTime)} + * Not compatible with {@link #ifETagDoesntMatch(String)} or {@link #ifModifiedSince(Date)} * * @param eTag * hash representing the entity @@ -159,7 +159,7 @@ public class GetOptions { /** * The object should not have a eTag hash corresponding with the parameter eTag. *

- * Not compatible with {@link #ifETagMatches(String)} or {@link #ifUnmodifiedSince(DateTime)} + * Not compatible with {@link #ifETagMatches(String)} or {@link #ifUnmodifiedSince(Date)} * * @param eTag * hash representing the entity @@ -202,15 +202,15 @@ public class GetOptions { /** * @see GetOptions#getIfModifiedSince() */ - public static GetOptions ifModifiedSince(DateTime ifModifiedSince) { + public static GetOptions ifModifiedSince(Date ifModifiedSince) { GetOptions options = new GetOptions(); return options.ifModifiedSince(ifModifiedSince); } /** - * @see GetOptions#ifUnmodifiedSince(DateTime) + * @see GetOptions#ifUnmodifiedSince(Date) */ - public static GetOptions ifUnmodifiedSince(DateTime ifUnmodifiedSince) { + public static GetOptions ifUnmodifiedSince(Date ifUnmodifiedSince) { GetOptions options = new GetOptions(); return options.ifUnmodifiedSince(ifUnmodifiedSince); } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/functions/ParseBlobMetadataFromHeadersTest.java b/blobstore/src/test/java/org/jclouds/blobstore/functions/ParseBlobMetadataFromHeadersTest.java index aa9db55540..d4b59fd549 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/functions/ParseBlobMetadataFromHeadersTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/functions/ParseBlobMetadataFromHeadersTest.java @@ -40,7 +40,7 @@ import org.jclouds.blobstore.domain.internal.MutableBlobMetadataImpl; import org.jclouds.http.HttpException; import org.jclouds.http.HttpResponse; import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.util.DateService; +import org.jclouds.util.internal.SimpleDateFormatDateService; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -61,8 +61,8 @@ public class ParseBlobMetadataFromHeadersTest { @BeforeTest void setUp() { - parser = new ParseSystemAndUserMetadataFromHeaders(blobMetadataProvider, new DateService(), - "prefix"); + parser = new ParseSystemAndUserMetadataFromHeaders(blobMetadataProvider, + new SimpleDateFormatDateService(), "prefix"); GeneratedHttpRequest request = createMock(GeneratedHttpRequest.class); expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes(); @@ -118,7 +118,7 @@ public class ParseBlobMetadataFromHeadersTest { from.getHeaders().put(HttpHeaders.LAST_MODIFIED, "Wed, 09 Sep 2009 19:50:23 GMT"); MutableBlobMetadata metadata = blobMetadataProvider.get(); parser.parseLastModifiedOrThrowException(from, metadata); - assertEquals(metadata.getLastModified(), new DateService() + assertEquals(metadata.getLastModified(), new SimpleDateFormatDateService() .rfc822DateParse("Wed, 09 Sep 2009 19:50:23 GMT")); } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobIntegrationTest.java index a742f41eb9..32efa4a542 100755 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobIntegrationTest.java @@ -36,6 +36,7 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; +import java.util.Date; import java.util.SortedSet; import org.apache.commons.io.IOUtils; @@ -46,7 +47,6 @@ import org.jclouds.blobstore.domain.ResourceMetadata; import org.jclouds.blobstore.util.BlobStoreUtils; import org.jclouds.http.HttpResponseException; import org.jclouds.http.HttpUtils; -import org.joda.time.DateTime; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -61,12 +61,12 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest< try { String key = "apples"; - DateTime before = new DateTime().minusSeconds(1); + Date before = new Date(System.currentTimeMillis() - 1000); // first create the object addObjectAndValidateContent(containerName, key); // now, modify it addObjectAndValidateContent(containerName, key); - DateTime after = new DateTime().plusSeconds(1); + Date after = new Date(System.currentTimeMillis() + 1000); context.getBlobStore().getBlob(containerName, key, ifModifiedSince(before)); validateContent(containerName, key); @@ -90,9 +90,9 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest< String key = "apples"; - DateTime before = new DateTime().minusSeconds(1); + Date before = new Date(System.currentTimeMillis() - 1000); addObjectAndValidateContent(containerName, key); - DateTime after = new DateTime().plusSeconds(1); + Date after = new Date(System.currentTimeMillis() + 1000); context.getBlobStore().getBlob(containerName, key, ifUnmodifiedSince(after)); validateContent(containerName, key); diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/StubAsyncBlobStore.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/StubAsyncBlobStore.java index 6f8bf2b3ab..59169f40b0 100755 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/StubAsyncBlobStore.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/StubAsyncBlobStore.java @@ -36,6 +36,7 @@ import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.net.URI; import java.util.Collection; +import java.util.Date; import java.util.List; import java.util.Map; import java.util.SortedSet; @@ -85,7 +86,6 @@ import org.jclouds.http.HttpUtils; import org.jclouds.http.options.HttpRequestOptions; import org.jclouds.util.DateService; import org.jclouds.util.Utils; -import org.joda.time.DateTime; import com.google.common.base.Function; import com.google.common.base.Predicate; @@ -513,7 +513,7 @@ public class StubAsyncBlobStore implements AsyncBlobStore { byte[] data = toByteArray(object.getData()); object.getMetadata().setSize(data.length); MutableBlobMetadata newMd = copy(object.getMetadata()); - newMd.setLastModified(new DateTime()); + newMd.setLastModified(new Date()); final byte[] md5 = HttpUtils.md5(data); final String eTag = HttpUtils.toHexString(md5); newMd.setETag(eTag); @@ -567,8 +567,8 @@ public class StubAsyncBlobStore implements AsyncBlobStore { throwResponseException(304); } if (options.getIfModifiedSince() != null) { - DateTime modifiedSince = options.getIfModifiedSince(); - if (object.getMetadata().getLastModified().isBefore(modifiedSince)) { + Date modifiedSince = options.getIfModifiedSince(); + if (object.getMetadata().getLastModified().before(modifiedSince)) { HttpResponse response = new HttpResponse(); response.setStatusCode(304); throw new ExecutionException(new HttpResponseException(String.format( @@ -578,8 +578,8 @@ public class StubAsyncBlobStore implements AsyncBlobStore { } if (options.getIfUnmodifiedSince() != null) { - DateTime unmodifiedSince = options.getIfUnmodifiedSince(); - if (object.getMetadata().getLastModified().isAfter(unmodifiedSince)) { + Date unmodifiedSince = options.getIfUnmodifiedSince(); + if (object.getMetadata().getLastModified().after(unmodifiedSince)) { HttpResponse response = new HttpResponse(); response.setStatusCode(412); throw new ExecutionException(new HttpResponseException(String.format( @@ -597,7 +597,7 @@ public class StubAsyncBlobStore implements AsyncBlobStore { int length = Integer.parseInt(s.substring(1)); out.write(data, data.length - length, length); } else if (s.endsWith("-")) { - int offset = Integer.parseInt(s.substring(0, s.length()-1)); + int offset = Integer.parseInt(s.substring(0, s.length() - 1)); out.write(data, offset, data.length - offset); } else if (s.contains("-")) { String[] firstLast = s.split("\\-"); diff --git a/blobstore/src/test/java/org/jclouds/blobstore/options/GetOptionsTest.java b/blobstore/src/test/java/org/jclouds/blobstore/options/GetOptionsTest.java index b071146c9b..360bb95f24 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/options/GetOptionsTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/options/GetOptionsTest.java @@ -32,8 +32,8 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNull; import java.io.UnsupportedEncodingException; +import java.util.Date; -import org.joda.time.DateTime; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -48,11 +48,11 @@ import com.google.common.collect.ImmutableList; public class GetOptionsTest { private String etag; - private DateTime now; + private Date now; @BeforeTest void setUp() { - now = new DateTime(); + now = new Date(); etag = "yrdy"; } @@ -144,7 +144,7 @@ public class GetOptionsTest { @Test public void testNoRange() { GetOptions options = new GetOptions(); - assertEquals(options.getRanges().size(),0); + assertEquals(options.getRanges().size(), 0); } @Test diff --git a/core/pom.xml b/core/pom.xml index 67fd9f602a..f5f6329504 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -94,11 +94,6 @@ 7.0.0pre3 test - - joda-time - joda-time - 1.6 - org.bouncycastle bcprov-jdk15 diff --git a/core/src/main/java/org/jclouds/http/functions/config/ParserModule.java b/core/src/main/java/org/jclouds/http/functions/config/ParserModule.java index 7216efcd3c..6c893a47fb 100755 --- a/core/src/main/java/org/jclouds/http/functions/config/ParserModule.java +++ b/core/src/main/java/org/jclouds/http/functions/config/ParserModule.java @@ -27,6 +27,7 @@ import java.lang.reflect.Type; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.Comparator; +import java.util.Date; import java.util.SortedSet; import javax.inject.Inject; @@ -37,7 +38,6 @@ import javax.xml.parsers.SAXParserFactory; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax.HandlerWithResult; import org.jclouds.util.DateService; -import org.joda.time.DateTime; import org.xml.sax.XMLReader; import com.google.common.collect.Sets; @@ -132,60 +132,62 @@ public class ParserModule extends AbstractModule { @Provides @Singleton - Gson provideGson(DateTimeAdapter adapter, SortedSetOfInetAddressCreator addressSetCreator) { + Gson provideGson(DateAdapter adapter, SortedSetOfInetAddressCreator addressSetCreator) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapter(InetAddress.class, new InetAddressAdapter()); - gson.registerTypeAdapter(DateTime.class, adapter); + gson.registerTypeAdapter(Date.class, adapter); gson.registerTypeAdapter(new TypeToken>() { }.getType(), addressSetCreator); return gson.create(); } - @ImplementedBy(Iso8601DateTimeAdapter.class) - public static interface DateTimeAdapter extends JsonSerializer, - JsonDeserializer { + @ImplementedBy(Iso8601DateAdapter.class) + public static interface DateAdapter extends JsonSerializer, JsonDeserializer { } @Singleton - public static class Iso8601DateTimeAdapter implements DateTimeAdapter { + public static class Iso8601DateAdapter implements DateAdapter { private final DateService dateService; @Inject - private Iso8601DateTimeAdapter(DateService dateService) { + private Iso8601DateAdapter(DateService dateService) { this.dateService = dateService; } - public JsonElement serialize(DateTime src, Type typeOfSrc, JsonSerializationContext context) { + public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context) { return new JsonPrimitive(dateService.iso8601DateFormat(src)); } - public DateTime deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) + public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { String toParse = json.getAsJsonPrimitive().getAsString(); - DateTime toReturn = dateService.jodaIso8601DateParse(toParse); - return toReturn; + try { + return dateService.iso8601DateParse(toParse); + } catch (RuntimeException e) { + return dateService.iso8601SecondsDateParse(toParse); + } } } @Singleton - public static class CDateTimeAdapter implements DateTimeAdapter { + public static class CDateAdapter implements DateAdapter { private final DateService dateService; @Inject - private CDateTimeAdapter(DateService dateService) { + private CDateAdapter(DateService dateService) { this.dateService = dateService; } - public JsonElement serialize(DateTime src, Type typeOfSrc, JsonSerializationContext context) { + public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context) { return new JsonPrimitive(dateService.cDateFormat(src)); } - public DateTime deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) + public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { String toParse = json.getAsJsonPrimitive().getAsString(); - DateTime toReturn = dateService.cDateParse(toParse); + Date toReturn = dateService.cDateParse(toParse); return toReturn; } diff --git a/core/src/main/java/org/jclouds/http/options/GetOptions.java b/core/src/main/java/org/jclouds/http/options/GetOptions.java index 7091212dbf..d0dc21a0e6 100644 --- a/core/src/main/java/org/jclouds/http/options/GetOptions.java +++ b/core/src/main/java/org/jclouds/http/options/GetOptions.java @@ -28,12 +28,13 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.io.UnsupportedEncodingException; import java.util.ArrayList; +import java.util.Date; import java.util.List; import javax.ws.rs.core.HttpHeaders; import org.jclouds.util.DateService; -import org.joda.time.DateTime; +import org.jclouds.util.internal.SimpleDateFormatDateService; import com.google.common.base.Joiner; import com.google.common.collect.Multimap; @@ -49,14 +50,14 @@ import com.google.common.collect.Multimap; * * * // this will get the first megabyte of an object, provided it wasn't modified since yesterday - * Future object = client.get("objectName",range(0,1024).ifUnmodifiedSince(new DateTime().minusDays(1))); + * Future object = client.get("objectName",range(0,1024).ifUnmodifiedSince(new Date().minusDays(1))); * * * @author Adrian Cole * */ public class GetOptions extends BaseHttpRequestOptions { - private final static DateService dateService = new DateService(); + private final static DateService dateService = new SimpleDateFormatDateService(); public static final GetOptions NONE = new GetOptions(); private final List ranges = new ArrayList(); @@ -110,9 +111,9 @@ public class GetOptions extends BaseHttpRequestOptions { /** * Only return the object if it has changed since this time. *

- * Not compatible with {@link #ifETagMatches(byte[])} or {@link #ifUnmodifiedSince(DateTime)} + * Not compatible with {@link #ifETagMatches(byte[])} or {@link #ifUnmodifiedSince(Date)} */ - public GetOptions ifModifiedSince(DateTime ifModifiedSince) { + public GetOptions ifModifiedSince(Date ifModifiedSince) { checkArgument(getIfMatch() == null, "ifETagMatches() is not compatible with ifModifiedSince()"); checkArgument(getIfUnmodifiedSince() == null, @@ -128,7 +129,7 @@ public class GetOptions extends BaseHttpRequestOptions { * Return the object only if it has been modified since the specified time, otherwise return a * 304 (not modified). * - * @see GetOptions#ifModifiedSince(DateTime) + * @see GetOptions#ifModifiedSince(Date) */ public String getIfModifiedSince() { return this.getFirstHeaderOrNull(HttpHeaders.IF_MODIFIED_SINCE); @@ -137,9 +138,9 @@ public class GetOptions extends BaseHttpRequestOptions { /** * Only return the object if it hasn't changed since this time. *

- * Not compatible with {@link #ifETagDoesntMatch(byte[])} or {@link #ifModifiedSince(DateTime)} + * Not compatible with {@link #ifETagDoesntMatch(byte[])} or {@link #ifModifiedSince(Date)} */ - public GetOptions ifUnmodifiedSince(DateTime ifUnmodifiedSince) { + public GetOptions ifUnmodifiedSince(Date ifUnmodifiedSince) { checkArgument(getIfNoneMatch() == null, "ifETagDoesntMatch() is not compatible with ifUnmodifiedSince()"); checkArgument(getIfModifiedSince() == null, @@ -155,7 +156,7 @@ public class GetOptions extends BaseHttpRequestOptions { * Return the object only if it has not been modified since the specified time, otherwise return * a 412 (precondition failed). * - * @see GetOptions#ifUnmodifiedSince(DateTime) + * @see GetOptions#ifUnmodifiedSince(Date) */ public String getIfUnmodifiedSince() { return this.getFirstHeaderOrNull(HttpHeaders.IF_UNMODIFIED_SINCE); @@ -165,7 +166,7 @@ public class GetOptions extends BaseHttpRequestOptions { * The object's eTag hash should match the parameter eTag. * *

- * Not compatible with {@link #ifETagDoesntMatch(byte[])} or {@link #ifModifiedSince(DateTime)} + * Not compatible with {@link #ifETagDoesntMatch(byte[])} or {@link #ifModifiedSince(Date)} * * @param eTag * hash representing the entity @@ -196,7 +197,7 @@ public class GetOptions extends BaseHttpRequestOptions { /** * The object should not have a eTag hash corresponding with the parameter eTag. *

- * Not compatible with {@link #ifETagMatches(String)} or {@link #ifUnmodifiedSince(DateTime)} + * Not compatible with {@link #ifETagMatches(String)} or {@link #ifUnmodifiedSince(Date)} * * @param eTag * hash representing the entity @@ -258,15 +259,15 @@ public class GetOptions extends BaseHttpRequestOptions { /** * @see GetOptions#getIfModifiedSince() */ - public static GetOptions ifModifiedSince(DateTime ifModifiedSince) { + public static GetOptions ifModifiedSince(Date ifModifiedSince) { GetOptions options = new GetOptions(); return options.ifModifiedSince(ifModifiedSince); } /** - * @see GetOptions#ifUnmodifiedSince(DateTime) + * @see GetOptions#ifUnmodifiedSince(Date) */ - public static GetOptions ifUnmodifiedSince(DateTime ifUnmodifiedSince) { + public static GetOptions ifUnmodifiedSince(Date ifUnmodifiedSince) { GetOptions options = new GetOptions(); return options.ifUnmodifiedSince(ifUnmodifiedSince); } diff --git a/core/src/main/java/org/jclouds/predicates/RetryablePredicate.java b/core/src/main/java/org/jclouds/predicates/RetryablePredicate.java index d83b1a4b91..0807ae26c9 100644 --- a/core/src/main/java/org/jclouds/predicates/RetryablePredicate.java +++ b/core/src/main/java/org/jclouds/predicates/RetryablePredicate.java @@ -23,12 +23,12 @@ */ package org.jclouds.predicates; +import java.util.Date; import java.util.concurrent.TimeUnit; import javax.annotation.Resource; import org.jclouds.logging.Logger; -import org.joda.time.DateTime; import com.google.common.base.Predicate; @@ -55,7 +55,7 @@ public class RetryablePredicate implements Predicate { @Override public boolean apply(T input) { try { - for (DateTime end = new DateTime().plusMillis(maxWait); before(end); Thread + for (Date end = new Date(System.currentTimeMillis() + maxWait); before(end); Thread .sleep(checkInterval)) { if (predicate.apply(input)) { return true; @@ -69,11 +69,11 @@ public class RetryablePredicate implements Predicate { return false; } - boolean before(DateTime end) { - return new DateTime().compareTo(end) <= 1; + boolean before(Date end) { + return new Date().compareTo(end) <= 1; } - boolean atOrAfter(DateTime end) { - return new DateTime().compareTo(end) >= 0; + boolean atOrAfter(Date end) { + return new Date().compareTo(end) >= 0; } } diff --git a/core/src/main/java/org/jclouds/util/DateService.java b/core/src/main/java/org/jclouds/util/DateService.java index 208e853829..fa1003d39b 100644 --- a/core/src/main/java/org/jclouds/util/DateService.java +++ b/core/src/main/java/org/jclouds/util/DateService.java @@ -23,186 +23,46 @@ */ package org.jclouds.util; -import java.text.ParseException; -import java.text.SimpleDateFormat; import java.util.Date; -import java.util.Locale; -import java.util.SimpleTimeZone; -import net.jcip.annotations.GuardedBy; -import net.jcip.annotations.ThreadSafe; +import org.jclouds.util.internal.SimpleDateFormatDateService; -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; -import org.joda.time.format.DateTimeFormat; -import org.joda.time.format.DateTimeFormatter; - -import com.google.common.annotations.VisibleForTesting; +import com.google.inject.ImplementedBy; /** - * Parses and formats the ISO8601 and RFC822 date formats found in XML responses and HTTP response - * headers. - *

- * Either {@link SimpleDateFormat} or {@link DateTimeFormatter} classes are used internally, - * depending on which version gives the best performance. + * Parses and formats the ISO8601, C, and RFC822 date formats found in XML responses and HTTP + * response headers. * * @author Adrian Cole * @author James Murty */ -@ThreadSafe -public class DateService { - /* - * Use default Java Date/SimpleDateFormat classes for date manipulation, but be *very* careful to - * guard against the lack of thread safety. - */ - @GuardedBy("this") - private static final SimpleDateFormat iso8601SecondsSimpleDateFormat = new SimpleDateFormat( - "yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US); +@ImplementedBy(SimpleDateFormatDateService.class) +public interface DateService { - @GuardedBy("this") - private static final SimpleDateFormat iso8601SimpleDateFormat = new SimpleDateFormat( - "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US); + Date fromSeconds(long seconds); - @GuardedBy("this") - private static final SimpleDateFormat rfc822SimpleDateFormat = new SimpleDateFormat( - "EEE, dd MMM yyyy HH:mm:ss z", Locale.US); + String cDateFormat(Date date); - private static final DateTimeFormatter rfc822DateTimeFormatter = DateTimeFormat.forPattern( - "EEE, dd MMM yyyy HH:mm:ss 'GMT'").withLocale(Locale.US).withZone( - DateTimeZone.forID("GMT")); + String cDateFormat(); - @GuardedBy("this") - private static final SimpleDateFormat cSimpleDateFormat = new SimpleDateFormat( - "EEE MMM dd HH:mm:ss '+0000' yyyy", Locale.US); + Date cDateParse(String toParse); - private static final DateTimeFormatter cDateTimeFormatter = DateTimeFormat.forPattern( - "EEE MMM dd HH:mm:ss '+0000' yyyy").withLocale(Locale.US).withZone( - DateTimeZone.forID("GMT")); + String rfc822DateFormat(Date date); - private static final DateTimeFormatter iso8601SecondsDateTimeFormatter = DateTimeFormat - .forPattern("yyyy-MM-dd'T'HH:mm:ss'Z'").withLocale(Locale.US).withZone( - DateTimeZone.forID("GMT")); + String rfc822DateFormat(); - private static final DateTimeFormatter iso8601DateTimeFormatter = DateTimeFormat.forPattern( - "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").withLocale(Locale.US).withZone( - DateTimeZone.forID("GMT")); + Date rfc822DateParse(String toParse); - static { - iso8601SimpleDateFormat.setTimeZone(new SimpleTimeZone(0, "GMT")); - iso8601SecondsSimpleDateFormat.setTimeZone(new SimpleTimeZone(0, "GMT")); - rfc822SimpleDateFormat.setTimeZone(new SimpleTimeZone(0, "GMT")); - cSimpleDateFormat.setTimeZone(new SimpleTimeZone(0, "GMT")); - } + String iso8601SecondsDateFormat(Date dateTime); - public final DateTime fromSeconds(long seconds) { - return new DateTime(seconds * 1000); - } + String iso8601SecondsDateFormat(); - public final String cDateFormat(DateTime dateTime) { - return cDateTimeFormatter.print(dateTime); - } + String iso8601DateFormat(Date date); - public final String cDateFormat(Date date) { - return cDateFormat(new DateTime(date)); - } + String iso8601DateFormat(); - public final String cDateFormat() { - return cDateFormat(new DateTime()); - } + Date iso8601DateParse(String toParse); - public final DateTime cDateParse(String toParse) { - synchronized (cSimpleDateFormat) { - try { - return new DateTime(cSimpleDateFormat.parse(toParse)); - } catch (ParseException e) { - throw new RuntimeException(e); - } - } - } + Date iso8601SecondsDateParse(String toParse); - public final String rfc822DateFormat(DateTime dateTime) { - return rfc822DateTimeFormatter.print(dateTime); - } - - public final String rfc822DateFormat(Date date) { - return rfc822DateFormat(new DateTime(date)); - } - - public final String rfc822DateFormat() { - return rfc822DateFormat(new DateTime()); - } - - public final DateTime rfc822DateParse(String toParse) { - synchronized (rfc822SimpleDateFormat) { - try { - return new DateTime(rfc822SimpleDateFormat.parse(toParse)); - } catch (ParseException e) { - throw new RuntimeException(e); - } - } - } - - public final String iso8601DateFormat(DateTime dateTime) { - return iso8601DateTimeFormatter.print(dateTime); - } - - public final String iso8601SecondsDateFormat(DateTime dateTime) { - return iso8601SecondsDateTimeFormatter.print(dateTime); - } - - public final String iso8601SecondsDateFormat() { - return iso8601SecondsDateFormat(new DateTime()); - } - - public final String iso8601DateFormat(Date date) { - return iso8601DateFormat(new DateTime(date)); - } - - public final String iso8601DateFormat() { - return iso8601DateFormat(new DateTime()); - } - - public final DateTime iso8601DateParse(String toParse) { - synchronized (iso8601SimpleDateFormat) { - try { - return new DateTime(iso8601SimpleDateFormat.parse(toParse)); - } catch (ParseException e) { - throw new RuntimeException(e); - } - } - } - - public final DateTime iso8601SecondsDateParse(String toParse) { - synchronized (iso8601SecondsSimpleDateFormat) { - try { - return new DateTime(iso8601SecondsSimpleDateFormat.parse(toParse)); - } catch (ParseException e) { - throw new RuntimeException(e); - } - } - } - - /* - * Alternative implementations of Format and Parse -- used to test relative speeds. TODO: Remove - * methods below once sufficient performance testing is complete. - */ - - @VisibleForTesting - public final DateTime jodaIso8601DateParse(String toParse) { - return new DateTime(toParse); - } - - @VisibleForTesting - public final String sdfIso8601DateFormat(DateTime dateTime) { - synchronized (iso8601SimpleDateFormat) { - return iso8601SimpleDateFormat.format(dateTime.toDate()); - } - } - - @VisibleForTesting - public final String sdfIso8601SecondsDateFormat(DateTime dateTime) { - synchronized (iso8601SecondsSimpleDateFormat) { - return iso8601SecondsSimpleDateFormat.format(dateTime.toDate()); - } - } } \ No newline at end of file diff --git a/core/src/test/java/org/jclouds/http/options/GetOptionsTest.java b/core/src/test/java/org/jclouds/http/options/GetOptionsTest.java index 0a9e2d00d0..07b6e26c0d 100644 --- a/core/src/test/java/org/jclouds/http/options/GetOptionsTest.java +++ b/core/src/test/java/org/jclouds/http/options/GetOptionsTest.java @@ -34,9 +34,9 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNull; import java.io.UnsupportedEncodingException; +import java.util.Date; -import org.jclouds.util.DateService; -import org.joda.time.DateTime; +import org.jclouds.util.internal.SimpleDateFormatDateService; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -49,13 +49,13 @@ import org.testng.annotations.Test; public class GetOptionsTest { private String etag; - private DateTime now; + private Date now; private String nowExpected; @BeforeTest void setUp() { - now = new DateTime(); - nowExpected = new DateService().rfc822DateFormat(now); + now = new Date(); + nowExpected = new SimpleDateFormatDateService().rfc822DateFormat(now); etag = "yrdy"; } diff --git a/core/src/test/java/org/jclouds/predicates/RetryablePredicateTest.java b/core/src/test/java/org/jclouds/predicates/RetryablePredicateTest.java index 057f0904f2..cbf8f0f9e7 100644 --- a/core/src/test/java/org/jclouds/predicates/RetryablePredicateTest.java +++ b/core/src/test/java/org/jclouds/predicates/RetryablePredicateTest.java @@ -23,9 +23,9 @@ */ package org.jclouds.predicates; +import java.util.Date; import java.util.concurrent.TimeUnit; -import org.joda.time.DateTime; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -43,23 +43,25 @@ public class RetryablePredicateTest { void testAlwaysTrue() { RetryablePredicate predicate = new RetryablePredicate(Predicates . alwaysTrue(), 3, 1, TimeUnit.SECONDS); - DateTime start = new DateTime(); + Date startPlusSecond = new Date(System.currentTimeMillis() + 1000); predicate.apply(""); - DateTime now = new DateTime(); - assert now.compareTo(start.plusSeconds(1)) < 0 : String.format("%s should be less than %s", - now, start.plusSeconds(1)); } + Date now = new Date(); + assert now.compareTo(startPlusSecond) < 0 : String.format("%s should be less than %s", now, + startPlusSecond); + } @Test void testAlwaysFalseMillis() { RetryablePredicate predicate = new RetryablePredicate(Predicates . alwaysFalse(), 3, 1, TimeUnit.SECONDS); - DateTime start = new DateTime(); + Date startPlus3Seconds = new Date(System.currentTimeMillis() + 3000); + Date startPlus4Seconds = new Date(System.currentTimeMillis() + 4000); predicate.apply(""); - DateTime now = new DateTime(); - assert now.compareTo(start.plusSeconds(3)) >= 0 : String.format("%s should be less than %s", - start.plusSeconds(3), now); - assert now.compareTo(start.plusSeconds(4)) <= 0 : String.format( - "%s should be greater than %s", start.plusSeconds(6), now); + Date now = new Date(); + assert now.compareTo(startPlus3Seconds) >= 0 : String.format("%s should be less than %s", + startPlus3Seconds, now); + assert now.compareTo(startPlus4Seconds) <= 0 : String.format("%s should be greater than %s", + startPlus4Seconds, now); } @@ -79,13 +81,15 @@ public class RetryablePredicateTest { RetryablePredicate predicate = new RetryablePredicate(new SecondTimeTrue(), 3, 1, TimeUnit.SECONDS); - DateTime start = new DateTime(); + Date startPlusSecond = new Date(System.currentTimeMillis() + 1000); + Date startPlus2Seconds = new Date(System.currentTimeMillis() + 2000); + predicate.apply(""); - DateTime now = new DateTime(); - assert now.compareTo(start.plusSeconds(1)) >= 0 : String.format("%s should be greater than %s", - now,start.plusSeconds(1)); - assert now.compareTo(start.plusSeconds(2)) <= 0 : String.format( - "%s should be greater than %s", start.plusSeconds(2), now); + Date now = new Date(); + assert now.compareTo(startPlusSecond) >= 0 : String.format("%s should be greater than %s", + now, startPlusSecond); + assert now.compareTo(startPlus2Seconds) <= 0 : String.format("%s should be greater than %s", + startPlus2Seconds, now); } } \ No newline at end of file diff --git a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java index 8c2f37ac46..32d7c864f2 100755 --- a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java @@ -40,6 +40,7 @@ import java.net.URI; import java.net.URLEncoder; import java.util.Collection; import java.util.Collections; +import java.util.Date; import java.util.Map; import java.util.concurrent.Future; @@ -100,7 +101,7 @@ import org.jclouds.rest.binders.BindToStringEntity; import org.jclouds.rest.config.RestModule; import org.jclouds.util.DateService; import org.jclouds.util.Jsr330; -import org.joda.time.DateTime; +import org.jclouds.util.internal.SimpleDateFormatDateService; import org.mortbay.jetty.HttpHeaders; import org.testng.annotations.BeforeClass; import org.testng.annotations.DataProvider; @@ -1171,7 +1172,7 @@ public class RestAnnotationProcessorTest { public void testCreateGetVarArgOptionsThatProducesHeaders() throws SecurityException, NoSuchMethodException { - DateTime date = new DateTime(); + Date date = new Date(); GetOptions options = GetOptions.Builder.ifModifiedSince(date); HttpRequestOptions[] optionsHolder = new HttpRequestOptions[] {}; Method method = TestRequest.class.getMethod("get", String.class, optionsHolder.getClass()); @@ -1189,7 +1190,7 @@ public class RestAnnotationProcessorTest { public void testCreateGetOptionsThatProducesHeaders() throws SecurityException, NoSuchMethodException { - DateTime date = new DateTime(); + Date date = new Date(); GetOptions options = GetOptions.Builder.ifModifiedSince(date); Method method = TestRequest.class.getMethod("get", String.class, HttpRequestOptions.class); GeneratedHttpRequest httpMethod = factory(TestRequest.class).createRequest(method, @@ -1622,7 +1623,7 @@ public class RestAnnotationProcessorTest { } Injector injector; - DateService dateService = new DateService(); + DateService dateService = new SimpleDateFormatDateService(); @BeforeClass void setupFactory() { diff --git a/core/src/test/java/org/jclouds/util/DateServiceTest.java b/core/src/test/java/org/jclouds/util/DateServiceTest.java index 54b84e8d74..d97f534ba9 100644 --- a/core/src/test/java/org/jclouds/util/DateServiceTest.java +++ b/core/src/test/java/org/jclouds/util/DateServiceTest.java @@ -26,11 +26,12 @@ package org.jclouds.util; import static org.testng.Assert.assertEquals; import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.concurrent.ExecutionException; import org.jclouds.PerformanceTest; -import org.joda.time.DateTime; +import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import com.google.inject.Guice; @@ -47,11 +48,15 @@ import com.google.inject.Injector; * @author Adrian Cole * @author James Murty */ -@Test(sequential = true, timeOut = 2 * 60 * 1000, testName = "s3.DateTest") +@Test(sequential = true, timeOut = 2 * 60 * 1000, testName = "core.DateTest") public class DateServiceTest extends PerformanceTest { - Injector i = Guice.createInjector(); + protected DateService dateService; - DateService dateService = i.getInstance(DateService.class); + @BeforeTest + protected void createDateService() { + Injector i = Guice.createInjector(); + dateService = i.getInstance(DateService.class); + } protected TestData[] testData; @@ -60,14 +65,15 @@ public class DateServiceTest extends PerformanceTest { public final String iso8601SecondsDateString; public final String rfc822DateString; public final String cDateString; - - public final DateTime date; - TestData(String iso8601, String iso8601Seconds, String rfc822, String cDateString, DateTime dateTime) { + public final Date date; + + TestData(String iso8601, String iso8601Seconds, String rfc822, String cDateString, + Date dateTime) { this.iso8601DateString = iso8601; this.iso8601SecondsDateString = iso8601Seconds; this.rfc822DateString = rfc822; - this.cDateString= cDateString; + this.cDateString = cDateString; this.date = dateTime; } } @@ -76,38 +82,43 @@ public class DateServiceTest extends PerformanceTest { // Constant time test values, each TestData item must contain matching times! testData = new TestData[] { new TestData("2009-03-12T02:00:07.000Z", "2009-03-12T02:00:07Z", - "Thu, 12 Mar 2009 02:00:07 GMT", "Thu Mar 12 02:00:07 +0000 2009", new DateTime(1236823207000l)), + "Thu, 12 Mar 2009 02:00:07 GMT", "Thu Mar 12 02:00:07 +0000 2009", + new Date(1236823207000l)), new TestData("2009-03-14T04:00:07.000Z", "2009-03-14T04:00:07Z", - "Sat, 14 Mar 2009 04:00:07 GMT", "Thu Mar 14 04:00:07 +0000 2009",new DateTime(1237003207000l)), + "Sat, 14 Mar 2009 04:00:07 GMT", "Thu Mar 14 04:00:07 +0000 2009", + new Date(1237003207000l)), new TestData("2009-03-16T06:00:07.000Z", "2009-03-16T06:00:07Z", - "Mon, 16 Mar 2009 06:00:07 GMT", "Thu Mar 16 06:00:07 +0000 2009",new DateTime(1237183207000l)), + "Mon, 16 Mar 2009 06:00:07 GMT", "Thu Mar 16 06:00:07 +0000 2009", + new Date(1237183207000l)), new TestData("2009-03-18T08:00:07.000Z", "2009-03-18T08:00:07Z", - "Wed, 18 Mar 2009 08:00:07 GMT", "Thu Mar 18 08:00:07 +0000 2009",new DateTime(1237363207000l)), + "Wed, 18 Mar 2009 08:00:07 GMT", "Thu Mar 18 08:00:07 +0000 2009", + new Date(1237363207000l)), new TestData("2009-03-20T10:00:07.000Z", "2009-03-20T10:00:07Z", - "Fri, 20 Mar 2009 10:00:07 GMT", "Thu Mar 20 10:00:07 +0000 2009",new DateTime(1237543207000l)) }; + "Fri, 20 Mar 2009 10:00:07 GMT", "Thu Mar 20 10:00:07 +0000 2009", + new Date(1237543207000l)) }; } @Test public void testIso8601DateParse() throws ExecutionException, InterruptedException { - DateTime dsDate = dateService.iso8601DateParse(testData[0].iso8601DateString); + Date dsDate = dateService.iso8601DateParse(testData[0].iso8601DateString); assertEquals(dsDate, testData[0].date); } @Test public void testIso8601SecondsDateParse() throws ExecutionException, InterruptedException { - DateTime dsDate = dateService.iso8601SecondsDateParse(testData[0].iso8601SecondsDateString); + Date dsDate = dateService.iso8601SecondsDateParse(testData[0].iso8601SecondsDateString); assertEquals(dsDate, testData[0].date); } @Test public void testCDateParse() throws ExecutionException, InterruptedException { - DateTime dsDate = dateService.cDateParse(testData[0].cDateString); + Date dsDate = dateService.cDateParse(testData[0].cDateString); assertEquals(dsDate, testData[0].date); } @Test public void testRfc822DateParse() throws ExecutionException, InterruptedException { - DateTime dsDate = dateService.rfc822DateParse(testData[0].rfc822DateString); + Date dsDate = dateService.rfc822DateParse(testData[0].rfc822DateString); assertEquals(dsDate, testData[0].date); } @@ -128,7 +139,7 @@ public class DateServiceTest extends PerformanceTest { String dsString = dateService.cDateFormat(testData[0].date); assertEquals(dsString, testData[0].cDateString); } - + @Test public void testRfc822DateFormat() throws ExecutionException, InterruptedException { String dsString = dateService.rfc822DateFormat(testData[0].date); @@ -144,7 +155,7 @@ public class DateServiceTest extends PerformanceTest { @Test void testFromSeconds() throws ExecutionException, InterruptedException { long seconds = 1254008225; - DateTime date = dateService.fromSeconds(seconds); + Date date = dateService.fromSeconds(seconds); assertEquals(dateService.rfc822DateFormat(date), "Sat, 26 Sep 2009 23:37:05 GMT"); } @@ -154,13 +165,12 @@ public class DateServiceTest extends PerformanceTest { dateService.rfc822DateFormat(); } - @Test void testCDateFormatResponseTime() throws ExecutionException, InterruptedException { for (int i = 0; i < LOOP_COUNT; i++) dateService.cDateFormat(); } - + @Test void testFormatIso8601DateCorrectnessInParallel() throws Throwable { List tasks = new ArrayList(testData.length); @@ -188,40 +198,19 @@ public class DateServiceTest extends PerformanceTest { executeMultiThreadedPerformanceTest("testFormatIso8601DatePerformanceInParallel", tasks); } - @Test - void testFormatIso8601DatePerformanceInParallel_SdfAlternative() throws Throwable { - List tasks = new ArrayList(testData.length); - for (final TestData myData : testData) { - tasks.add(new Runnable() { - public void run() { - dateService.sdfIso8601DateFormat(myData.date); - } - }); - } - executeMultiThreadedPerformanceTest( - "testFormatIso8601DatePerformanceInParallel_SdfAlternative", tasks); - } - @Test void testParseIso8601DateSerialResponseTime() throws ExecutionException, InterruptedException { for (int i = 0; i < LOOP_COUNT; i++) dateService.iso8601DateParse(testData[0].iso8601DateString); } - @Test - void testParseIso8601DateSerialResponseTime_JodaAlternative() throws ExecutionException, - InterruptedException { - for (int i = 0; i < LOOP_COUNT; i++) - dateService.jodaIso8601DateParse(testData[0].iso8601DateString); - } - @Test void testParseIso8601DateCorrectnessInParallel() throws Throwable { List tasks = new ArrayList(testData.length); for (final TestData myData : testData) { tasks.add(new Runnable() { public void run() { - DateTime dsDate = dateService.iso8601DateParse(myData.iso8601DateString); + Date dsDate = dateService.iso8601DateParse(myData.iso8601DateString); assertEquals(dsDate, myData.date); } }); @@ -242,18 +231,4 @@ public class DateServiceTest extends PerformanceTest { executeMultiThreadedPerformanceTest("testParseIso8601DatePerformanceInParallel", tasks); } - @Test - void testParseIso8601DatePerformanceInParallel_JodaAlternative() throws Throwable { - List tasks = new ArrayList(testData.length); - for (final TestData myData : testData) { - tasks.add(new Runnable() { - public void run() { - dateService.jodaIso8601DateParse(myData.iso8601DateString); - } - }); - } - executeMultiThreadedPerformanceTest( - "testParseIso8601DatePerformanceInParallel_JodaAlternative", tasks); - } - } \ No newline at end of file diff --git a/demos/gae-tweetstore/pom.xml b/demos/gae-tweetstore/pom.xml index 58eaaaf6fb..d0656add58 100755 --- a/demos/gae-tweetstore/pom.xml +++ b/demos/gae-tweetstore/pom.xml @@ -49,9 +49,16 @@ ${project.groupId} - jclouds-core + jclouds-blobstore ${project.version} + + ${project.groupId} + jclouds-blobstore + ${project.version} + test-jar + test + ${project.groupId} jclouds-core diff --git a/extensions/joda/pom.xml b/extensions/joda/pom.xml new file mode 100644 index 0000000000..a5ac528bde --- /dev/null +++ b/extensions/joda/pom.xml @@ -0,0 +1,46 @@ + + + + 4.0.0 + + org.jclouds + jclouds-extensions-project + 1.0-SNAPSHOT + + jclouds-joda + jclouds joda DateService Module + jclouds joda DateService Module + + + + joda-time + joda-time + 1.6 + + + diff --git a/extensions/joda/src/main/java/org/jclouds/util/internal/JodaDateService.java b/extensions/joda/src/main/java/org/jclouds/util/internal/JodaDateService.java new file mode 100755 index 0000000000..50a6b56d89 --- /dev/null +++ b/extensions/joda/src/main/java/org/jclouds/util/internal/JodaDateService.java @@ -0,0 +1,111 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.util.internal; + +import java.util.Date; +import java.util.Locale; + +import net.jcip.annotations.ThreadSafe; + +import org.jclouds.util.DateService; +import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; +import org.joda.time.format.DateTimeFormat; +import org.joda.time.format.DateTimeFormatter; + +/** + * + * @author Adrian Cole + * @author James Murty + */ +@ThreadSafe +public class JodaDateService implements DateService { + + private static final DateTimeFormatter rfc822DateFormatter = DateTimeFormat.forPattern( + "EEE, dd MMM yyyy HH:mm:ss 'GMT'").withLocale(Locale.US).withZone( + DateTimeZone.forID("GMT")); + + private static final DateTimeFormatter cDateFormatter = DateTimeFormat.forPattern( + "EEE MMM dd HH:mm:ss '+0000' yyyy").withLocale(Locale.US).withZone( + DateTimeZone.forID("GMT")); + + private static final DateTimeFormatter iso8601SecondsDateFormatter = DateTimeFormat.forPattern( + "yyyy-MM-dd'T'HH:mm:ss'Z'").withLocale(Locale.US).withZone(DateTimeZone.forID("GMT")); + + private static final DateTimeFormatter iso8601DateFormatter = DateTimeFormat.forPattern( + "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").withLocale(Locale.US).withZone( + DateTimeZone.forID("GMT")); + + public final Date fromSeconds(long seconds) { + return new Date(seconds * 1000); + } + + public final String cDateFormat(Date dateTime) { + return cDateFormatter.print(new DateTime(dateTime)); + } + + public final String cDateFormat() { + return cDateFormat(new Date()); + } + + public final Date cDateParse(String toParse) { + return cDateFormatter.parseDateTime(toParse).toDate(); + } + + public final String rfc822DateFormat(Date dateTime) { + return rfc822DateFormatter.print(new DateTime(dateTime)); + } + + public final String rfc822DateFormat() { + return rfc822DateFormat(new Date()); + } + + public final Date rfc822DateParse(String toParse) { + return rfc822DateFormatter.parseDateTime(toParse).toDate(); + } + + public final String iso8601SecondsDateFormat(Date dateTime) { + return iso8601SecondsDateFormatter.print(new DateTime(dateTime)); + } + + public final String iso8601SecondsDateFormat() { + return iso8601SecondsDateFormat(new Date()); + } + + public final String iso8601DateFormat(Date date) { + return iso8601DateFormatter.print(new DateTime(date)); + } + + public final String iso8601DateFormat() { + return iso8601DateFormat(new Date()); + } + + public final Date iso8601DateParse(String toParse) { + return iso8601DateFormatter.parseDateTime(toParse).toDate(); + } + + public final Date iso8601SecondsDateParse(String toParse) { + return iso8601SecondsDateFormatter.parseDateTime(toParse).toDate(); + } +} \ No newline at end of file diff --git a/extensions/joda/src/test/java/org/jclouds/util/JodaDateServiceTest.java b/extensions/joda/src/test/java/org/jclouds/util/JodaDateServiceTest.java new file mode 100755 index 0000000000..c69a4dd2b2 --- /dev/null +++ b/extensions/joda/src/test/java/org/jclouds/util/JodaDateServiceTest.java @@ -0,0 +1,49 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.util; + +import org.jclouds.util.internal.JodaDateService; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; + +/* + * TODO: Scrap any non-DateService references (eg Joda & Amazon) if/when + * we confirm that the DateService is fast enough. + */ + +/** + * Compares performance of date operations + * + * @author Adrian Cole + * @author James Murty + */ +@Test(sequential = true, timeOut = 2 * 60 * 1000, testName = "core.JodaDateServiceTest") +public class JodaDateServiceTest extends DateServiceTest { + @Override + @BeforeTest + protected void createDateService() { + dateService = new JodaDateService(); + } + +} \ No newline at end of file diff --git a/extensions/pom.xml b/extensions/pom.xml index c3f5953210..00d4e07df9 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -39,6 +39,7 @@ gae httpnio + joda log4j ssh diff --git a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/domain/MutableResourceInfo.java b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/domain/MutableResourceInfo.java index c124edbd11..7b8efddb38 100644 --- a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/domain/MutableResourceInfo.java +++ b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/domain/MutableResourceInfo.java @@ -24,10 +24,10 @@ package org.jclouds.mezeo.pcs2.domain; import java.net.URI; +import java.util.Date; import org.jclouds.blobstore.domain.ResourceType; import org.jclouds.mezeo.pcs2.domain.internal.MutableResourceInfoImpl; -import org.joda.time.DateTime; import com.google.inject.ImplementedBy; @@ -44,11 +44,11 @@ public interface MutableResourceInfo extends ResourceInfo { void setName(String value); - void setCreated(DateTime value); + void setCreated(Date value); void setInProject(Boolean value); - void setModified(DateTime value); + void setModified(Date value); void setOwner(String value); @@ -56,7 +56,7 @@ public interface MutableResourceInfo extends ResourceInfo { void setShared(Boolean value); - void setAccessed(DateTime value); + void setAccessed(Date value); void setBytes(Long value); diff --git a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/domain/ResourceInfo.java b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/domain/ResourceInfo.java index 17e69cf7ea..27f4838c1a 100644 --- a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/domain/ResourceInfo.java +++ b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/domain/ResourceInfo.java @@ -24,10 +24,10 @@ package org.jclouds.mezeo.pcs2.domain; import java.net.URI; +import java.util.Date; import org.jclouds.blobstore.domain.ResourceType; import org.jclouds.mezeo.pcs2.domain.internal.ResourceInfoImpl; -import org.joda.time.DateTime; import com.google.inject.ImplementedBy; @@ -44,11 +44,11 @@ public interface ResourceInfo extends Comparable { String getName(); - DateTime getCreated(); + Date getCreated(); Boolean isInProject(); - DateTime getModified(); + Date getModified(); String getOwner(); @@ -56,7 +56,7 @@ public interface ResourceInfo extends Comparable { Boolean isShared(); - DateTime getAccessed(); + Date getAccessed(); Long getBytes(); diff --git a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/domain/internal/ContainerInfoImpl.java b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/domain/internal/ContainerInfoImpl.java index f66ceddaf5..58fd11c9aa 100644 --- a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/domain/internal/ContainerInfoImpl.java +++ b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/domain/internal/ContainerInfoImpl.java @@ -24,10 +24,10 @@ package org.jclouds.mezeo.pcs2.domain.internal; import java.net.URI; +import java.util.Date; import org.jclouds.blobstore.domain.ResourceType; import org.jclouds.mezeo.pcs2.domain.ContainerInfo; -import org.joda.time.DateTime; /** * @@ -37,9 +37,9 @@ import org.joda.time.DateTime; public class ContainerInfoImpl extends ResourceInfoImpl implements ContainerInfo { private final URI contents; - public ContainerInfoImpl(URI url, String name, DateTime created, boolean inProject, - DateTime modified, String owner, int version, boolean shared, DateTime accessed, - long bytes, URI contents, URI tags, URI metadata, URI parent) { + public ContainerInfoImpl(URI url, String name, Date created, boolean inProject, Date modified, + String owner, int version, boolean shared, Date accessed, long bytes, URI contents, + URI tags, URI metadata, URI parent) { super(ResourceType.FOLDER, url, name, created, inProject, modified, owner, version, shared, accessed, bytes, tags, metadata, parent); this.contents = contents; diff --git a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/domain/internal/ContainerListImpl.java b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/domain/internal/ContainerListImpl.java index ab992dc76f..b5503026ab 100644 --- a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/domain/internal/ContainerListImpl.java +++ b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/domain/internal/ContainerListImpl.java @@ -24,6 +24,7 @@ package org.jclouds.mezeo.pcs2.domain.internal; import java.net.URI; +import java.util.Date; import java.util.Map; import java.util.SortedSet; import java.util.TreeSet; @@ -31,7 +32,6 @@ import java.util.TreeSet; import org.jclouds.blobstore.domain.ResourceType; import org.jclouds.mezeo.pcs2.domain.ContainerList; import org.jclouds.mezeo.pcs2.domain.ResourceInfo; -import org.joda.time.DateTime; /** * @@ -45,9 +45,9 @@ public class ContainerListImpl extends TreeSet implements Containe private final ResourceInfo info; private final Map metadataItems; - public ContainerListImpl(URI url, String name, DateTime created, boolean inProject, - DateTime modified, String owner, int version, boolean shared, DateTime accessed, - long bytes, SortedSet contents, URI tags, URI metadata, + public ContainerListImpl(URI url, String name, Date created, boolean inProject, Date modified, + String owner, int version, boolean shared, Date accessed, long bytes, + SortedSet contents, URI tags, URI metadata, Map metadataItems, URI parent) { this.info = new ResourceInfoImpl(ResourceType.FOLDER, url, name, created, inProject, modified, owner, version, shared, accessed, bytes, tags, metadata, parent); @@ -59,7 +59,7 @@ public class ContainerListImpl extends TreeSet implements Containe return metadataItems; } - public DateTime getAccessed() { + public Date getAccessed() { return info.getAccessed(); } @@ -67,7 +67,7 @@ public class ContainerListImpl extends TreeSet implements Containe return info.getBytes(); } - public DateTime getCreated() { + public Date getCreated() { return info.getCreated(); } @@ -75,7 +75,7 @@ public class ContainerListImpl extends TreeSet implements Containe return info.getMetadata(); } - public DateTime getModified() { + public Date getModified() { return info.getModified(); } diff --git a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/domain/internal/FileInfoImpl.java b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/domain/internal/FileInfoImpl.java index 1e9a0ffd48..19d8f3062c 100644 --- a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/domain/internal/FileInfoImpl.java +++ b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/domain/internal/FileInfoImpl.java @@ -24,10 +24,10 @@ package org.jclouds.mezeo.pcs2.domain.internal; import java.net.URI; +import java.util.Date; import org.jclouds.blobstore.domain.ResourceType; import org.jclouds.mezeo.pcs2.domain.FileInfo; -import org.joda.time.DateTime; /** * @@ -42,8 +42,9 @@ public class FileInfoImpl extends ResourceInfoImpl implements FileInfo { private final URI permissions; private final URI thumbnail; - public FileInfoImpl(URI url, String name, DateTime created, boolean inProject, - DateTime modified, String owner, int version, boolean shared, DateTime accessed, + public FileInfoImpl(URI url, String name, Date created, boolean inProject, + Date modified, + String owner, int version, boolean shared, Date accessed, boolean isPublic, String mimeType, long bytes, URI content, URI parent, URI permissions, URI tags, URI metadata, URI thumbnail) { super(ResourceType.BLOB, url, name, created, inProject, modified, owner, version, shared, diff --git a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/domain/internal/FileInfoWithMetadataImpl.java b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/domain/internal/FileInfoWithMetadataImpl.java index 8e66c04140..3b9ae7e21c 100644 --- a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/domain/internal/FileInfoWithMetadataImpl.java +++ b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/domain/internal/FileInfoWithMetadataImpl.java @@ -24,10 +24,10 @@ package org.jclouds.mezeo.pcs2.domain.internal; import java.net.URI; +import java.util.Date; import java.util.Map; import org.jclouds.mezeo.pcs2.domain.FileInfoWithMetadata; -import org.joda.time.DateTime; /** * @@ -37,8 +37,8 @@ import org.joda.time.DateTime; public class FileInfoWithMetadataImpl extends FileInfoImpl implements FileInfoWithMetadata { private final Map metadataItems; - public FileInfoWithMetadataImpl(URI url, String name, DateTime created, boolean inProject, - DateTime modified, String owner, int version, boolean shared, DateTime accessed, + public FileInfoWithMetadataImpl(URI url, String name, Date created, boolean inProject, + Date modified, String owner, int version, boolean shared, Date accessed, boolean isPublic, String mimeType, long bytes, URI content, URI parent, URI permissions, URI tags, URI metadata, Map metadataItems, URI thumbnail) { super(url, name, created, inProject, modified, owner, version, shared, accessed, isPublic, diff --git a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/domain/internal/MutableResourceInfoImpl.java b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/domain/internal/MutableResourceInfoImpl.java index fab034eb21..e565bb1950 100644 --- a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/domain/internal/MutableResourceInfoImpl.java +++ b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/domain/internal/MutableResourceInfoImpl.java @@ -24,11 +24,11 @@ package org.jclouds.mezeo.pcs2.domain.internal; import java.net.URI; +import java.util.Date; import org.jclouds.blobstore.domain.ResourceType; import org.jclouds.mezeo.pcs2.domain.MutableResourceInfo; import org.jclouds.mezeo.pcs2.domain.ResourceInfo; -import org.joda.time.DateTime; /** * @@ -40,13 +40,13 @@ public class MutableResourceInfoImpl implements MutableResourceInfo { private ResourceType type; private URI url; private String name; - private DateTime created; + private Date created; private Boolean inProject; - private DateTime modified; + private Date modified; private String owner; private Integer version; private Boolean shared; - private DateTime accessed; + private Date accessed; private Long bytes; private URI tags; private URI metadata; @@ -82,11 +82,11 @@ public class MutableResourceInfoImpl implements MutableResourceInfo { this.name = name; } - public DateTime getCreated() { + public Date getCreated() { return created; } - public void setCreated(DateTime created) { + public void setCreated(Date created) { this.created = created; } @@ -98,11 +98,11 @@ public class MutableResourceInfoImpl implements MutableResourceInfo { this.inProject = inProject; } - public DateTime getModified() { + public Date getModified() { return modified; } - public void setModified(DateTime modified) { + public void setModified(Date modified) { this.modified = modified; } @@ -130,11 +130,11 @@ public class MutableResourceInfoImpl implements MutableResourceInfo { this.shared = shared; } - public DateTime getAccessed() { + public Date getAccessed() { return accessed; } - public void setAccessed(DateTime accessed) { + public void setAccessed(Date accessed) { this.accessed = accessed; } diff --git a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/domain/internal/ResourceInfoImpl.java b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/domain/internal/ResourceInfoImpl.java index 52ece72056..2a12761cba 100644 --- a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/domain/internal/ResourceInfoImpl.java +++ b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/domain/internal/ResourceInfoImpl.java @@ -24,10 +24,10 @@ package org.jclouds.mezeo.pcs2.domain.internal; import java.net.URI; +import java.util.Date; import org.jclouds.blobstore.domain.ResourceType; import org.jclouds.mezeo.pcs2.domain.ResourceInfo; -import org.joda.time.DateTime; /** * @@ -39,21 +39,21 @@ public class ResourceInfoImpl implements ResourceInfo { private final ResourceType type; private final URI url; private final String name; - private final DateTime created; + private final Date created; private final boolean inProject; - private final DateTime modified; + private final Date modified; private final String owner; private final int version; private final boolean shared; - private final DateTime accessed; + private final Date accessed; private final long bytes; private final URI tags; private final URI metadata; private final URI parent; - protected ResourceInfoImpl(ResourceType type, URI url, String name, DateTime created, - boolean inProject, DateTime modified, String owner, int version, boolean shared, - DateTime accessed, long bytes, URI tags, URI metadata, URI parent) { + protected ResourceInfoImpl(ResourceType type, URI url, String name, Date created, + boolean inProject, Date modified, String owner, int version, boolean shared, + Date accessed, long bytes, URI tags, URI metadata, URI parent) { super(); this.type = type; this.url = url; @@ -91,7 +91,7 @@ public class ResourceInfoImpl implements ResourceInfo { return name; } - public DateTime getCreated() { + public Date getCreated() { return created; } @@ -99,7 +99,7 @@ public class ResourceInfoImpl implements ResourceInfo { return inProject; } - public DateTime getModified() { + public Date getModified() { return modified; } @@ -115,7 +115,7 @@ public class ResourceInfoImpl implements ResourceInfo { return shared; } - public DateTime getAccessed() { + public Date getAccessed() { return accessed; } diff --git a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/xml/ContainerHandler.java b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/xml/ContainerHandler.java index 4af19a97e4..41b3246664 100755 --- a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/xml/ContainerHandler.java +++ b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/xml/ContainerHandler.java @@ -24,6 +24,7 @@ package org.jclouds.mezeo.pcs2.xml; import java.net.URI; +import java.util.Date; import java.util.Map; import java.util.SortedSet; @@ -38,7 +39,6 @@ import org.jclouds.mezeo.pcs2.domain.internal.ContainerInfoImpl; import org.jclouds.mezeo.pcs2.domain.internal.ContainerListImpl; import org.jclouds.mezeo.pcs2.domain.internal.FileInfoImpl; import org.jclouds.util.DateService; -import org.joda.time.DateTime; import org.xml.sax.Attributes; import org.xml.sax.SAXException; @@ -58,13 +58,13 @@ public class ContainerHandler extends ParseSax.HandlerWithResult private URI rootUrl; private String rootName; - private DateTime rootCreated; + private Date rootCreated; private boolean rootInproject; - private DateTime rootModified; + private Date rootModified; private String rootOwner; private int rootVersion; private boolean rootShared; - private DateTime rootAccessed; + private Date rootAccessed; private long rootBytes; private URI rootParent; private URI rootTags; @@ -72,13 +72,13 @@ public class ContainerHandler extends ParseSax.HandlerWithResult private URI currentUrl; private String currentName; - private DateTime currentCreated; + private Date currentCreated; private boolean currentInproject; - private DateTime currentModified; + private Date currentModified; private String currentOwner; private int currentVersion; private boolean currentShared; - private DateTime currentAccessed; + private Date currentAccessed; private long currentBytes; private URI currentParent; private URI currentTags; @@ -116,7 +116,7 @@ public class ContainerHandler extends ParseSax.HandlerWithResult if (qName.equals("contents") && attributes.getIndex("count") != -1) { int index = attributes.getIndex("xlink:href"); if (index != -1) { - rootUrl = URI.create(attributes.getValue(index).replace("/contents","")); + rootUrl = URI.create(attributes.getValue(index).replace("/contents", "")); } inContents = true; return; diff --git a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/xml/FileHandler.java b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/xml/FileHandler.java index ad138ce7b4..cac38f769d 100644 --- a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/xml/FileHandler.java +++ b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/xml/FileHandler.java @@ -24,6 +24,7 @@ package org.jclouds.mezeo.pcs2.xml; import java.net.URI; +import java.util.Date; import java.util.Map; import javax.inject.Inject; @@ -32,7 +33,6 @@ import org.jclouds.http.functions.ParseSax; import org.jclouds.mezeo.pcs2.domain.FileInfoWithMetadata; import org.jclouds.mezeo.pcs2.domain.internal.FileInfoWithMetadataImpl; import org.jclouds.util.DateService; -import org.joda.time.DateTime; import org.xml.sax.Attributes; import org.xml.sax.SAXException; @@ -46,13 +46,13 @@ public class FileHandler extends ParseSax.HandlerWithResult response = parser.apply(is); - assertEquals(response, ImmutableMap.of("MD5","IGPBYI1uC6+AJJxC4r5YBA==","test","1")); + assertEquals(response, ImmutableMap.of("MD5", "IGPBYI1uC6+AJJxC4r5YBA==", "test", "1")); } } diff --git a/nirvanix/sdn/core/src/test/java/org/jclouds/nirvanix/sdn/functions/ParseSessionTokenFromJsonResponseTest.java b/nirvanix/sdn/core/src/test/java/org/jclouds/nirvanix/sdn/functions/ParseSessionTokenFromJsonResponseTest.java index c421301cb7..a54cfbdc7b 100644 --- a/nirvanix/sdn/core/src/test/java/org/jclouds/nirvanix/sdn/functions/ParseSessionTokenFromJsonResponseTest.java +++ b/nirvanix/sdn/core/src/test/java/org/jclouds/nirvanix/sdn/functions/ParseSessionTokenFromJsonResponseTest.java @@ -29,7 +29,6 @@ import java.io.InputStream; import java.net.UnknownHostException; import org.jclouds.http.functions.config.ParserModule; -import org.jclouds.util.DateService; import org.testng.annotations.Test; import com.google.gson.Gson; @@ -45,7 +44,6 @@ import com.google.inject.Injector; public class ParseSessionTokenFromJsonResponseTest { Injector i = Guice.createInjector(new ParserModule()); - DateService dateService = new DateService(); public void testApplyInputStreamDetails() throws UnknownHostException { InputStream is = getClass().getResourceAsStream("/login.json"); diff --git a/nirvanix/sdn/core/src/test/java/org/jclouds/nirvanix/sdn/functions/ParseUploadInfoFromJsonResponseTest.java b/nirvanix/sdn/core/src/test/java/org/jclouds/nirvanix/sdn/functions/ParseUploadInfoFromJsonResponseTest.java index 46cf64fdb4..8fcd0fea16 100644 --- a/nirvanix/sdn/core/src/test/java/org/jclouds/nirvanix/sdn/functions/ParseUploadInfoFromJsonResponseTest.java +++ b/nirvanix/sdn/core/src/test/java/org/jclouds/nirvanix/sdn/functions/ParseUploadInfoFromJsonResponseTest.java @@ -31,7 +31,6 @@ import java.net.UnknownHostException; import org.jclouds.http.functions.config.ParserModule; import org.jclouds.nirvanix.sdn.domain.UploadInfo; -import org.jclouds.util.DateService; import org.testng.annotations.Test; import com.google.gson.Gson; @@ -47,7 +46,6 @@ import com.google.inject.Injector; public class ParseUploadInfoFromJsonResponseTest { Injector i = Guice.createInjector(new ParserModule()); - DateService dateService = new DateService(); public void testApplyInputStreamDetails() throws UnknownHostException { InputStream is = getClass().getResourceAsStream("/authtoken.json"); @@ -56,7 +54,8 @@ public class ParseUploadInfoFromJsonResponseTest { .getInstance(Gson.class)); UploadInfo response = parser.apply(is); assertEquals(response.getHost(), URI.create("https://node1.nirvanix.com")); - assertEquals(response.getToken(), "siR-ALYd~BEcJ8GR2tE~oX3SEHO8~2WXKT5xjFk~YLS5OvJyHI21TN34rQ"); + assertEquals(response.getToken(), + "siR-ALYd~BEcJ8GR2tE~oX3SEHO8~2WXKT5xjFk~YLS5OvJyHI21TN34rQ"); } } diff --git a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/domain/MutableObjectInfoWithMetadata.java b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/domain/MutableObjectInfoWithMetadata.java index ec257cbb1d..a1d4d788f9 100644 --- a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/domain/MutableObjectInfoWithMetadata.java +++ b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/domain/MutableObjectInfoWithMetadata.java @@ -23,10 +23,10 @@ */ package org.jclouds.rackspace.cloudfiles.domain; +import java.util.Date; import java.util.Map; import org.jclouds.rackspace.cloudfiles.domain.internal.MutableObjectInfoWithMetadataImpl; -import org.joda.time.DateTime; import com.google.inject.ImplementedBy; @@ -44,7 +44,7 @@ public interface MutableObjectInfoWithMetadata extends ObjectInfo { void setBytes(long bytes); - void setLastModified(DateTime lastModified); + void setLastModified(Date lastModified); void setContentType(String contentType); diff --git a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/domain/ObjectInfo.java b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/domain/ObjectInfo.java index a46f2d31de..b8d3944b8f 100644 --- a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/domain/ObjectInfo.java +++ b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/domain/ObjectInfo.java @@ -23,7 +23,7 @@ */ package org.jclouds.rackspace.cloudfiles.domain; -import org.joda.time.DateTime; +import java.util.Date; /** * @@ -33,9 +33,13 @@ import org.joda.time.DateTime; public interface ObjectInfo extends Comparable { String getName(); - byte [] getHash(); + + byte[] getHash(); + Long getBytes(); + String getContentType(); - DateTime getLastModified(); + + Date getLastModified(); } \ No newline at end of file diff --git a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/domain/internal/MutableObjectInfoWithMetadataImpl.java b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/domain/internal/MutableObjectInfoWithMetadataImpl.java index bf8f6a1e8a..667f838c6d 100644 --- a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/domain/internal/MutableObjectInfoWithMetadataImpl.java +++ b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/domain/internal/MutableObjectInfoWithMetadataImpl.java @@ -25,13 +25,13 @@ package org.jclouds.rackspace.cloudfiles.domain.internal; import java.util.Arrays; +import java.util.Date; import java.util.Map; import javax.ws.rs.core.MediaType; import org.jclouds.rackspace.cloudfiles.domain.MutableObjectInfoWithMetadata; import org.jclouds.rackspace.cloudfiles.domain.ObjectInfo; -import org.joda.time.DateTime; import com.google.common.collect.Maps; @@ -45,7 +45,7 @@ public class MutableObjectInfoWithMetadataImpl implements MutableObjectInfoWithM private Long bytes; private byte[] hash; private String contentType = MediaType.APPLICATION_OCTET_STREAM; - private DateTime lastModified; + private Date lastModified; private final Map metadata = Maps.newHashMap(); public Map getMetadata() { @@ -80,7 +80,7 @@ public class MutableObjectInfoWithMetadataImpl implements MutableObjectInfoWithM return hash; } - public DateTime getLastModified() { + public Date getLastModified() { return lastModified; } @@ -144,7 +144,7 @@ public class MutableObjectInfoWithMetadataImpl implements MutableObjectInfoWithM return (this == o) ? 0 : getName().compareTo(o.getName()); } - public void setLastModified(DateTime lastModified) { + public void setLastModified(Date lastModified) { this.lastModified = lastModified; } diff --git a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/functions/ParseObjectInfoListFromJsonResponse.java b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/functions/ParseObjectInfoListFromJsonResponse.java index 1328a0f5a2..98d7ba7e7d 100644 --- a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/functions/ParseObjectInfoListFromJsonResponse.java +++ b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/functions/ParseObjectInfoListFromJsonResponse.java @@ -30,6 +30,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.lang.reflect.Type; +import java.util.Date; import java.util.SortedSet; import javax.inject.Inject; @@ -42,7 +43,6 @@ import org.jclouds.rackspace.cloudfiles.domain.ObjectInfo; import org.jclouds.rackspace.cloudfiles.options.ListContainerOptions; import org.jclouds.rest.InvocationContext; import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.joda.time.DateTime; import com.google.common.base.Function; import com.google.common.collect.Iterables; @@ -55,8 +55,8 @@ import com.google.gson.reflect.TypeToken; * * @author Adrian Cole */ -public class ParseObjectInfoListFromJsonResponse extends ParseJson> - implements InvocationContext { +public class ParseObjectInfoListFromJsonResponse extends + ParseJson> implements InvocationContext { private GeneratedHttpRequest request; @@ -70,7 +70,7 @@ public class ParseObjectInfoListFromJsonResponse extends ParseJson apply(InputStream stream) { @@ -170,8 +176,8 @@ public class ParseObjectInfoListFromJsonResponse extends ParseJson(returnVal, options.getPath(), marker, options - .getMaxResults(), truncated); + return new ListContainerResponseImpl(returnVal, options.getPath(), marker, + options.getMaxResults(), truncated); } catch (UnsupportedEncodingException e) { throw new RuntimeException("jclouds requires UTF-8 encoding", e); diff --git a/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/domain/Image.java b/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/domain/Image.java index fc41fd65ab..ebf920a3d4 100644 --- a/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/domain/Image.java +++ b/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/domain/Image.java @@ -23,13 +23,13 @@ */ package org.jclouds.rackspace.cloudservers.domain; -import org.joda.time.DateTime; +import java.util.Date; /** * An image is a collection of files used to create or rebuild a server. Rackspace provides a number * of pre-built OS images by default. You may also create custom images from cloud servers you have - * launched. These custom images are useful for backup purposes or for producing gold server - * images if you plan to deploy a particular server configuration frequently. + * launched. These custom images are useful for backup purposes or for producing gold server images + * if you plan to deploy a particular server configuration frequently. * * @author Adrian Cole */ @@ -37,13 +37,13 @@ public class Image { public static final Image NOT_FOUND = new Image(-1, "NOT_FOUND"); - private DateTime created; + private Date created; private int id; private String name; private Integer progress; private Integer serverId; private ImageStatus status; - private DateTime updated; + private Date updated; public Image() { } @@ -53,11 +53,11 @@ public class Image { this.name = name; } - public void setCreated(DateTime created) { + public void setCreated(Date created) { this.created = created; } - public DateTime getCreated() { + public Date getCreated() { return created; } @@ -101,11 +101,11 @@ public class Image { return status; } - public void setUpdated(DateTime updated) { + public void setUpdated(Date updated) { this.updated = updated; } - public DateTime getUpdated() { + public Date getUpdated() { return updated; } diff --git a/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/options/ListOptions.java b/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/options/ListOptions.java index 93b1a45e64..33302fef8f 100644 --- a/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/options/ListOptions.java +++ b/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/options/ListOptions.java @@ -23,8 +23,9 @@ */ package org.jclouds.rackspace.cloudservers.options; +import java.util.Date; + import org.jclouds.rackspace.options.BaseListOptions; -import org.joda.time.DateTime; /** * Options used to control the amount of detail in the request. @@ -51,7 +52,7 @@ public class ListOptions extends BaseListOptions { * {@inheritDoc} */ @Override - public ListOptions changesSince(DateTime ifModifiedSince) { + public ListOptions changesSince(Date ifModifiedSince) { super.changesSince(ifModifiedSince); return this; } @@ -102,9 +103,9 @@ public class ListOptions extends BaseListOptions { } /** - * @see BaseListOptions#changesSince(DateTime) + * @see BaseListOptions#changesSince(Date) */ - public static ListOptions changesSince(DateTime since) { + public static ListOptions changesSince(Date since) { ListOptions options = new ListOptions(); return options.changesSince(since); } diff --git a/rackspace/src/main/java/org/jclouds/rackspace/options/BaseListOptions.java b/rackspace/src/main/java/org/jclouds/rackspace/options/BaseListOptions.java index a44ad71db5..7ff16ed670 100644 --- a/rackspace/src/main/java/org/jclouds/rackspace/options/BaseListOptions.java +++ b/rackspace/src/main/java/org/jclouds/rackspace/options/BaseListOptions.java @@ -26,8 +26,9 @@ package org.jclouds.rackspace.options; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; +import java.util.Date; + import org.jclouds.http.options.BaseHttpRequestOptions; -import org.joda.time.DateTime; /** * Options used to control paginated results (aka list commands). @@ -41,9 +42,9 @@ public class BaseListOptions extends BaseHttpRequestOptions { /** * Only return objects changed since this time. */ - public BaseListOptions changesSince(DateTime ifModifiedSince) { + public BaseListOptions changesSince(Date ifModifiedSince) { this.queryParameters.put("changes-since", checkNotNull(ifModifiedSince, "ifModifiedSince") - .getMillis() + .getTime() / 1000 + ""); return this; } @@ -93,9 +94,9 @@ public class BaseListOptions extends BaseHttpRequestOptions { } /** - * @see BaseListOptions#changesSince(DateTime) + * @see BaseListOptions#changesSince(Date) */ - public static BaseListOptions changesSince(DateTime since) { + public static BaseListOptions changesSince(Date since) { BaseListOptions options = new BaseListOptions(); return options.changesSince(since); } diff --git a/rackspace/src/test/java/org/jclouds/rackspace/cloudfiles/functions/ParseObjectInfoListFromJsonResponseTest.java b/rackspace/src/test/java/org/jclouds/rackspace/cloudfiles/functions/ParseObjectInfoListFromJsonResponseTest.java index 10d9173f05..446c5299ab 100644 --- a/rackspace/src/test/java/org/jclouds/rackspace/cloudfiles/functions/ParseObjectInfoListFromJsonResponseTest.java +++ b/rackspace/src/test/java/org/jclouds/rackspace/cloudfiles/functions/ParseObjectInfoListFromJsonResponseTest.java @@ -36,7 +36,7 @@ import org.jclouds.rackspace.cloudfiles.domain.ObjectInfo; import org.jclouds.rackspace.cloudfiles.functions.ParseObjectInfoListFromJsonResponse.ObjectInfoImpl; import org.jclouds.rackspace.cloudfiles.options.ListContainerOptions; import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.joda.time.DateTime; +import org.jclouds.util.internal.SimpleDateFormatDateService; import org.testng.annotations.Test; import org.testng.collections.Lists; @@ -59,16 +59,18 @@ public class ParseObjectInfoListFromJsonResponseTest { ObjectInfoImpl one = i.getInstance(ObjectInfoImpl.class); one.name = "test_obj_1"; one.hash = "4281c348eaf83e70ddce0e07221c3d28"; - one.bytes = 14l; + one.bytes = 14l; one.content_type = "application/octet-stream"; - one.last_modified = new DateTime("2009-02-03T05:26:32.612278"); + one.last_modified = new SimpleDateFormatDateService() + .iso8601DateParse("2009-02-03T05:26:32.612Z"); expects.add(one); ObjectInfoImpl two = i.getInstance(ObjectInfoImpl.class); two.name = ("test_obj_2"); two.hash = ("b039efe731ad111bc1b0ef221c3849d0"); two.bytes = (64l); two.content_type = ("application/octet-stream"); - two.last_modified =(new DateTime("2009-02-03T05:26:32.612278")); + two.last_modified = (new SimpleDateFormatDateService() + .iso8601DateParse("2009-02-03T05:26:32.612Z")); expects.add(two); GeneratedHttpRequest request = createMock(GeneratedHttpRequest.class); ListContainerOptions options = new ListContainerOptions(); diff --git a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/CloudServersClientTest.java b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/CloudServersClientTest.java index 18b8b3f23f..6f17e8e9ce 100755 --- a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/CloudServersClientTest.java +++ b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/CloudServersClientTest.java @@ -38,6 +38,7 @@ import java.net.InetAddress; import java.net.URI; import java.net.UnknownHostException; import java.util.Collections; +import java.util.Date; import javax.ws.rs.HttpMethod; import javax.ws.rs.core.HttpHeaders; @@ -78,7 +79,6 @@ import org.jclouds.rackspace.cloudservers.options.RebuildServerOptions; import org.jclouds.rest.config.RestModule; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.rest.internal.RestAnnotationProcessor; -import org.joda.time.DateTime; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -103,8 +103,8 @@ public class CloudServersClientTest { .getClass(); public void testCreateServer() throws SecurityException, NoSuchMethodException { - Method method = CloudServersAsyncClient.class.getMethod("createServer", String.class, int.class, - int.class, createServerOptionsVarargsClass); + Method method = CloudServersAsyncClient.class.getMethod("createServer", String.class, + int.class, int.class, createServerOptionsVarargsClass); GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] { "ralphie", 2, 1 }); @@ -114,8 +114,8 @@ public class CloudServersClientTest { } public void testCreateServerWithIpGroup() throws SecurityException, NoSuchMethodException { - Method method = CloudServersAsyncClient.class.getMethod("createServer", String.class, int.class, - int.class, createServerOptionsVarargsClass); + Method method = CloudServersAsyncClient.class.getMethod("createServer", String.class, + int.class, int.class, createServerOptionsVarargsClass); GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] { "ralphie", 2, 1, withSharedIpGroup(2) }); @@ -126,8 +126,8 @@ public class CloudServersClientTest { } public void testCreateServerWithFile() throws SecurityException, NoSuchMethodException { - Method method = CloudServersAsyncClient.class.getMethod("createServer", String.class, int.class, - int.class, createServerOptionsVarargsClass); + Method method = CloudServersAsyncClient.class.getMethod("createServer", String.class, + int.class, int.class, createServerOptionsVarargsClass); GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] { "ralphie", 2, 1, @@ -139,8 +139,8 @@ public class CloudServersClientTest { } public void testCreateServerWithMetadata() throws SecurityException, NoSuchMethodException { - Method method = CloudServersAsyncClient.class.getMethod("createServer", String.class, int.class, - int.class, createServerOptionsVarargsClass); + Method method = CloudServersAsyncClient.class.getMethod("createServer", String.class, + int.class, int.class, createServerOptionsVarargsClass); GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] { "ralphie", 2, 1, withMetadata(ImmutableMap.of("foo", "bar")) }); @@ -152,8 +152,8 @@ public class CloudServersClientTest { public void testCreateServerWithIpGroupAndSharedIp() throws SecurityException, NoSuchMethodException, UnknownHostException { - Method method = CloudServersAsyncClient.class.getMethod("createServer", String.class, int.class, - int.class, createServerOptionsVarargsClass); + Method method = CloudServersAsyncClient.class.getMethod("createServer", String.class, + int.class, int.class, createServerOptionsVarargsClass); GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] { @@ -187,7 +187,8 @@ public class CloudServersClientTest { } public void testListServers() throws SecurityException, NoSuchMethodException { - Method method = CloudServersAsyncClient.class.getMethod("listServers", listOptionsVarargsClass); + Method method = CloudServersAsyncClient.class.getMethod("listServers", + listOptionsVarargsClass); GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] {}); @@ -201,17 +202,18 @@ public class CloudServersClientTest { assertEquals(processor.createExceptionParserOrNullIfNotFound(method), null); } - DateTime now = new DateTime(); + Date now = new Date(); public void testListServersOptions() throws SecurityException, NoSuchMethodException { - Method method = CloudServersAsyncClient.class.getMethod("listServers", listOptionsVarargsClass); + Method method = CloudServersAsyncClient.class.getMethod("listServers", + listOptionsVarargsClass); GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] { changesSince(now).maxResults(1).startAt(2) }); assertEquals(httpMethod.getEndpoint().getHost(), "localhost"); assertEquals(httpMethod.getEndpoint().getPath(), "/servers"); assertEquals(httpMethod.getEndpoint().getQuery(), "format=json&changes-since=" - + now.getMillis() / 1000 + "&limit=1&offset=2"); + + now.getTime() / 1000 + "&limit=1&offset=2"); assertEquals(httpMethod.getMethod(), HttpMethod.GET); assertEquals(httpMethod.getHeaders().size(), 0); assertEquals(processor.createResponseParser(method, httpMethod).getClass(), @@ -220,7 +222,8 @@ public class CloudServersClientTest { } public void testListServersDetail() throws SecurityException, NoSuchMethodException { - Method method = CloudServersAsyncClient.class.getMethod("listServers", listOptionsVarargsClass); + Method method = CloudServersAsyncClient.class.getMethod("listServers", + listOptionsVarargsClass); GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] { withDetails() }); @@ -251,7 +254,8 @@ public class CloudServersClientTest { } public void testListFlavors() throws SecurityException, NoSuchMethodException { - Method method = CloudServersAsyncClient.class.getMethod("listFlavors", listOptionsVarargsClass); + Method method = CloudServersAsyncClient.class.getMethod("listFlavors", + listOptionsVarargsClass); GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] {}); @@ -266,14 +270,15 @@ public class CloudServersClientTest { } public void testListFlavorsOptions() throws SecurityException, NoSuchMethodException { - Method method = CloudServersAsyncClient.class.getMethod("listFlavors", listOptionsVarargsClass); + Method method = CloudServersAsyncClient.class.getMethod("listFlavors", + listOptionsVarargsClass); GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] { changesSince(now).maxResults(1).startAt(2) }); assertEquals(httpMethod.getEndpoint().getHost(), "localhost"); assertEquals(httpMethod.getEndpoint().getPath(), "/flavors"); assertEquals(httpMethod.getEndpoint().getQuery(), "format=json&changes-since=" - + now.getMillis() / 1000 + "&limit=1&offset=2"); + + now.getTime() / 1000 + "&limit=1&offset=2"); assertEquals(httpMethod.getMethod(), HttpMethod.GET); assertEquals(httpMethod.getHeaders().size(), 0); assertEquals(processor.createResponseParser(method, httpMethod).getClass(), @@ -282,7 +287,8 @@ public class CloudServersClientTest { } public void testListFlavorsDetail() throws SecurityException, NoSuchMethodException { - Method method = CloudServersAsyncClient.class.getMethod("listFlavors", listOptionsVarargsClass); + Method method = CloudServersAsyncClient.class.getMethod("listFlavors", + listOptionsVarargsClass); GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] { withDetails() }); @@ -297,14 +303,15 @@ public class CloudServersClientTest { } public void testListFlavorsDetailOptions() throws SecurityException, NoSuchMethodException { - Method method = CloudServersAsyncClient.class.getMethod("listFlavors", listOptionsVarargsClass); + Method method = CloudServersAsyncClient.class.getMethod("listFlavors", + listOptionsVarargsClass); GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] { withDetails().changesSince(now).maxResults(1).startAt(2) }); assertEquals(httpMethod.getEndpoint().getHost(), "localhost"); assertEquals(httpMethod.getEndpoint().getPath(), "/flavors/detail"); assertEquals(httpMethod.getEndpoint().getQuery(), "format=json&changes-since=" - + now.getMillis() / 1000 + "&limit=1&offset=2"); + + now.getTime() / 1000 + "&limit=1&offset=2"); assertEquals(httpMethod.getMethod(), HttpMethod.GET); assertEquals(httpMethod.getHeaders().size(), 0); assertEquals(processor.createResponseParser(method, httpMethod).getClass(), @@ -329,7 +336,8 @@ public class CloudServersClientTest { } public void testListImages() throws SecurityException, NoSuchMethodException { - Method method = CloudServersAsyncClient.class.getMethod("listImages", listOptionsVarargsClass); + Method method = CloudServersAsyncClient.class + .getMethod("listImages", listOptionsVarargsClass); GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] {}); @@ -344,7 +352,8 @@ public class CloudServersClientTest { } public void testListImagesDetail() throws SecurityException, NoSuchMethodException { - Method method = CloudServersAsyncClient.class.getMethod("listImages", listOptionsVarargsClass); + Method method = CloudServersAsyncClient.class + .getMethod("listImages", listOptionsVarargsClass); GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] { withDetails() }); @@ -359,14 +368,15 @@ public class CloudServersClientTest { } public void testListImagesOptions() throws SecurityException, NoSuchMethodException { - Method method = CloudServersAsyncClient.class.getMethod("listImages", listOptionsVarargsClass); + Method method = CloudServersAsyncClient.class + .getMethod("listImages", listOptionsVarargsClass); GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] { changesSince(now).maxResults(1).startAt(2) }); assertEquals(httpMethod.getEndpoint().getHost(), "localhost"); assertEquals(httpMethod.getEndpoint().getPath(), "/images"); assertEquals(httpMethod.getEndpoint().getQuery(), "format=json&changes-since=" - + now.getMillis() / 1000 + "&limit=1&offset=2"); + + now.getTime() / 1000 + "&limit=1&offset=2"); assertEquals(httpMethod.getMethod(), HttpMethod.GET); assertEquals(httpMethod.getHeaders().size(), 0); assertEquals(processor.createResponseParser(method, httpMethod).getClass(), @@ -375,14 +385,15 @@ public class CloudServersClientTest { } public void testListImagesDetailOptions() throws SecurityException, NoSuchMethodException { - Method method = CloudServersAsyncClient.class.getMethod("listImages", listOptionsVarargsClass); + Method method = CloudServersAsyncClient.class + .getMethod("listImages", listOptionsVarargsClass); GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] { withDetails().changesSince(now).maxResults(1).startAt(2) }); assertEquals(httpMethod.getEndpoint().getHost(), "localhost"); assertEquals(httpMethod.getEndpoint().getPath(), "/images/detail"); assertEquals(httpMethod.getEndpoint().getQuery(), "format=json&changes-since=" - + now.getMillis() / 1000 + "&limit=1&offset=2"); + + now.getTime() / 1000 + "&limit=1&offset=2"); assertEquals(httpMethod.getMethod(), HttpMethod.GET); assertEquals(httpMethod.getHeaders().size(), 0); assertEquals(processor.createResponseParser(method, httpMethod).getClass(), @@ -423,8 +434,8 @@ public class CloudServersClientTest { public void testShareIpNoConfig() throws SecurityException, NoSuchMethodException, UnknownHostException { - Method method = CloudServersAsyncClient.class.getMethod("shareIp", InetAddress.class, int.class, - int.class, boolean.class); + Method method = CloudServersAsyncClient.class.getMethod("shareIp", InetAddress.class, + int.class, int.class, boolean.class); GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] { InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 }), 2, 3, false }); @@ -445,8 +456,8 @@ public class CloudServersClientTest { public void testShareIpConfig() throws SecurityException, NoSuchMethodException, UnknownHostException { - Method method = CloudServersAsyncClient.class.getMethod("shareIp", InetAddress.class, int.class, - int.class, boolean.class); + Method method = CloudServersAsyncClient.class.getMethod("shareIp", InetAddress.class, + int.class, int.class, boolean.class); GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] { InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 }), 2, 3, true }); @@ -468,7 +479,8 @@ public class CloudServersClientTest { public void testUnshareIpNoConfig() throws SecurityException, NoSuchMethodException, UnknownHostException { - Method method = CloudServersAsyncClient.class.getMethod("unshareIp", InetAddress.class, int.class); + Method method = CloudServersAsyncClient.class.getMethod("unshareIp", InetAddress.class, + int.class); GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] { InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 }), 2, 3, false }); @@ -521,8 +533,8 @@ public class CloudServersClientTest { } public void testChangeAdminPass() throws SecurityException, NoSuchMethodException { - Method method = CloudServersAsyncClient.class - .getMethod("changeAdminPass", int.class, String.class); + Method method = CloudServersAsyncClient.class.getMethod("changeAdminPass", int.class, + String.class); GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] { 2, "foo" }); @@ -542,7 +554,8 @@ public class CloudServersClientTest { } public void testChangeServerName() throws SecurityException, NoSuchMethodException { - Method method = CloudServersAsyncClient.class.getMethod("renameServer", int.class, String.class); + Method method = CloudServersAsyncClient.class.getMethod("renameServer", int.class, + String.class); GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] { 2, "foo" }); @@ -586,7 +599,7 @@ public class CloudServersClientTest { assertEquals(httpMethod.getEndpoint().getHost(), "localhost"); assertEquals(httpMethod.getEndpoint().getPath(), "/shared_ip_groups"); assertEquals(httpMethod.getEndpoint().getQuery(), "format=json&changes-since=" - + now.getMillis() / 1000 + "&limit=1&offset=2"); + + now.getTime() / 1000 + "&limit=1&offset=2"); assertEquals(httpMethod.getMethod(), HttpMethod.GET); assertEquals(httpMethod.getHeaders().size(), 0); assertEquals(processor.createResponseParser(method, httpMethod).getClass(), @@ -620,7 +633,7 @@ public class CloudServersClientTest { assertEquals(httpMethod.getEndpoint().getHost(), "localhost"); assertEquals(httpMethod.getEndpoint().getPath(), "/shared_ip_groups/detail"); assertEquals(httpMethod.getEndpoint().getQuery(), "format=json&changes-since=" - + now.getMillis() / 1000 + "&limit=1&offset=2"); + + now.getTime() / 1000 + "&limit=1&offset=2"); assertEquals(httpMethod.getMethod(), HttpMethod.GET); assertEquals(httpMethod.getHeaders().size(), 0); assertEquals(processor.createResponseParser(method, httpMethod).getClass(), @@ -758,8 +771,8 @@ public class CloudServersClientTest { } public void testCreateImageWithIpGroup() throws SecurityException, NoSuchMethodException { - Method method = CloudServersAsyncClient.class.getMethod("createImageFromServer", String.class, - int.class); + Method method = CloudServersAsyncClient.class.getMethod("createImageFromServer", + String.class, int.class); GeneratedHttpRequest httpMethod = processor.createRequest(method, new Object[] { "ralphie", 2 }); diff --git a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/functions/ParseAddressesFromJsonResponseTest.java b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/functions/ParseAddressesFromJsonResponseTest.java index 9a03f28344..3b823a6899 100644 --- a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/functions/ParseAddressesFromJsonResponseTest.java +++ b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/functions/ParseAddressesFromJsonResponseTest.java @@ -32,7 +32,6 @@ import java.util.List; import org.jclouds.http.functions.config.ParserModule; import org.jclouds.rackspace.cloudservers.domain.Addresses; -import org.jclouds.util.DateService; import org.testng.annotations.Test; import com.google.gson.Gson; @@ -49,7 +48,6 @@ import com.google.inject.internal.ImmutableList; public class ParseAddressesFromJsonResponseTest { Injector i = Guice.createInjector(new ParserModule()); - DateService dateService = new DateService(); public void testApplyInputStreamDetails() throws UnknownHostException { InputStream is = getClass().getResourceAsStream("/cloudservers/test_list_addresses.json"); diff --git a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/functions/ParseFlavorFromJsonResponseTest.java b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/functions/ParseFlavorFromJsonResponseTest.java index 363fd8123e..0c2101af6c 100644 --- a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/functions/ParseFlavorFromJsonResponseTest.java +++ b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/functions/ParseFlavorFromJsonResponseTest.java @@ -30,7 +30,6 @@ import java.net.UnknownHostException; import org.jclouds.http.functions.config.ParserModule; import org.jclouds.rackspace.cloudservers.domain.Flavor; -import org.jclouds.util.DateService; import org.testng.annotations.Test; import com.google.gson.Gson; @@ -46,7 +45,6 @@ import com.google.inject.Injector; public class ParseFlavorFromJsonResponseTest { Injector i = Guice.createInjector(new ParserModule()); - DateService dateService = new DateService(); public void testApplyInputStreamDetails() throws UnknownHostException { InputStream is = getClass().getResourceAsStream("/cloudservers/test_get_flavor_details.json"); diff --git a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/functions/ParseImageFromJsonResponseTest.java b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/functions/ParseImageFromJsonResponseTest.java index 3e72ed32ab..772d96d038 100644 --- a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/functions/ParseImageFromJsonResponseTest.java +++ b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/functions/ParseImageFromJsonResponseTest.java @@ -32,7 +32,6 @@ import org.jclouds.http.functions.config.ParserModule; import org.jclouds.rackspace.cloudservers.domain.Image; import org.jclouds.rackspace.cloudservers.domain.ImageStatus; import org.jclouds.util.DateService; -import org.joda.time.DateTime; import org.testng.annotations.Test; import com.google.gson.Gson; @@ -48,7 +47,7 @@ import com.google.inject.Injector; public class ParseImageFromJsonResponseTest { Injector i = Guice.createInjector(new ParserModule()); - DateService dateService = new DateService(); + DateService dateService = i.getInstance(DateService.class); public void testApplyInputStreamDetails() throws UnknownHostException { InputStream is = getClass().getResourceAsStream("/cloudservers/test_get_image_details.json"); @@ -57,11 +56,12 @@ public class ParseImageFromJsonResponseTest { Image response = parser.apply(is); assertEquals(response.getId(), 2); assertEquals(response.getName(), "CentOS 5.2"); - assertEquals(response.getCreated(), new DateTime("2010-08-10T12:00:00Z")); + assertEquals(response.getCreated(), dateService + .iso8601SecondsDateParse("2010-08-10T12:00:00Z")); assertEquals(response.getProgress(), new Integer(80)); assertEquals(response.getServerId(), new Integer(12)); assertEquals(response.getStatus(), ImageStatus.SAVING); - assertEquals(response.getUpdated(), new DateTime("2010-10-10T12:00:00Z")); + assertEquals(response.getUpdated(), dateService + .iso8601SecondsDateParse(("2010-10-10T12:00:00Z"))); } - } diff --git a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/functions/ParseImageListFromJsonResponseTest.java b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/functions/ParseImageListFromJsonResponseTest.java index 0618e5f35a..59bbe8e852 100644 --- a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/functions/ParseImageListFromJsonResponseTest.java +++ b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/functions/ParseImageListFromJsonResponseTest.java @@ -33,7 +33,6 @@ import org.jclouds.http.functions.config.ParserModule; import org.jclouds.rackspace.cloudservers.domain.Image; import org.jclouds.rackspace.cloudservers.domain.ImageStatus; import org.jclouds.util.DateService; -import org.joda.time.DateTime; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; @@ -50,7 +49,7 @@ import com.google.inject.Injector; public class ParseImageListFromJsonResponseTest { Injector i = Guice.createInjector(new ParserModule()); - DateService dateService = new DateService(); + DateService dateService = i.getInstance(DateService.class); public void testApplyInputStream() { InputStream is = getClass().getResourceAsStream("/cloudservers/test_list_images.json"); @@ -70,20 +69,24 @@ public class ParseImageListFromJsonResponseTest { List response = parser.apply(is); assertEquals(response.get(0).getId(), 2); assertEquals(response.get(0).getName(), "CentOS 5.2"); - assertEquals(response.get(0).getCreated(), new DateTime("2010-08-10T12:00:00Z")); + assertEquals(response.get(0).getCreated(), dateService + .iso8601SecondsDateParse("2010-08-10T12:00:00Z")); assertEquals(response.get(0).getProgress(), null); assertEquals(response.get(0).getServerId(), null); assertEquals(response.get(0).getStatus(), ImageStatus.ACTIVE); - assertEquals(response.get(0).getUpdated(), new DateTime("2010-10-10T12:00:00Z")); + assertEquals(response.get(0).getUpdated(), dateService + .iso8601SecondsDateParse("2010-10-10T12:00:00Z")); assertEquals(response.get(1).getId(), 743); assertEquals(response.get(1).getName(), "My Server Backup"); - assertEquals(response.get(1).getCreated(), new DateTime("2009-07-07T09:56:16-05:00")); + assertEquals(response.get(1).getCreated(), dateService + .iso8601SecondsDateParse("2009-07-07T09:56:16-05:00")); ; assertEquals(response.get(1).getProgress(), new Integer(80)); assertEquals(response.get(1).getServerId(), new Integer(12)); assertEquals(response.get(1).getStatus(), ImageStatus.SAVING); - assertEquals(response.get(1).getUpdated(), new DateTime("2010-10-10T12:00:00Z")); + assertEquals(response.get(1).getUpdated(), dateService + .iso8601SecondsDateParse("2010-10-10T12:00:00Z")); } } diff --git a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/functions/ParseInetAddressListFromJsonResponseTest.java b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/functions/ParseInetAddressListFromJsonResponseTest.java index ea799f8c61..298e504ecb 100644 --- a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/functions/ParseInetAddressListFromJsonResponseTest.java +++ b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/functions/ParseInetAddressListFromJsonResponseTest.java @@ -31,7 +31,6 @@ import java.net.UnknownHostException; import java.util.List; import org.jclouds.http.functions.config.ParserModule; -import org.jclouds.util.DateService; import org.testng.annotations.Test; import com.google.gson.Gson; @@ -48,10 +47,10 @@ import com.google.inject.internal.ImmutableList; public class ParseInetAddressListFromJsonResponseTest { Injector i = Guice.createInjector(new ParserModule()); - DateService dateService = new DateService(); public void testPublic() throws UnknownHostException { - InputStream is = getClass().getResourceAsStream("/cloudservers/test_list_addresses_public.json"); + InputStream is = getClass().getResourceAsStream( + "/cloudservers/test_list_addresses_public.json"); ParseInetAddressListFromJsonResponse parser = new ParseInetAddressListFromJsonResponse(i .getInstance(Gson.class)); @@ -61,7 +60,8 @@ public class ParseInetAddressListFromJsonResponseTest { } public void testPrivate() throws UnknownHostException { - InputStream is = getClass().getResourceAsStream("/cloudservers/test_list_addresses_private.json"); + InputStream is = getClass().getResourceAsStream( + "/cloudservers/test_list_addresses_private.json"); ParseInetAddressListFromJsonResponse parser = new ParseInetAddressListFromJsonResponse(i .getInstance(Gson.class)); diff --git a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/functions/ParseSharedIpGroupFromJsonResponseTest.java b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/functions/ParseSharedIpGroupFromJsonResponseTest.java index 498b40a719..31083cabd3 100644 --- a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/functions/ParseSharedIpGroupFromJsonResponseTest.java +++ b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/functions/ParseSharedIpGroupFromJsonResponseTest.java @@ -30,7 +30,6 @@ import java.net.UnknownHostException; import org.jclouds.http.functions.config.ParserModule; import org.jclouds.rackspace.cloudservers.domain.SharedIpGroup; -import org.jclouds.util.DateService; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; @@ -47,7 +46,6 @@ import com.google.inject.Injector; public class ParseSharedIpGroupFromJsonResponseTest { Injector i = Guice.createInjector(new ParserModule()); - DateService dateService = new DateService(); public void testApplyInputStreamDetails() throws UnknownHostException { InputStream is = getClass().getResourceAsStream("/cloudservers/test_get_sharedipgroup_details.json"); diff --git a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/options/ListOptionsTest.java b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/options/ListOptionsTest.java index f82f9f1f65..cd86320a53 100644 --- a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/options/ListOptionsTest.java +++ b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/options/ListOptionsTest.java @@ -23,10 +23,14 @@ */ package org.jclouds.rackspace.cloudservers.options; -import static org.jclouds.rackspace.cloudservers.options.ListOptions.Builder.*; +import static org.jclouds.rackspace.cloudservers.options.ListOptions.Builder.changesSince; +import static org.jclouds.rackspace.cloudservers.options.ListOptions.Builder.maxResults; +import static org.jclouds.rackspace.cloudservers.options.ListOptions.Builder.startAt; +import static org.jclouds.rackspace.cloudservers.options.ListOptions.Builder.withDetails; import static org.testng.Assert.assertEquals; -import org.joda.time.DateTime; +import java.util.Date; + import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; @@ -50,9 +54,9 @@ public class ListOptionsTest { } public void testChangesSince() { - DateTime ifModifiedSince = new DateTime(); + Date ifModifiedSince = new Date(); ListOptions options = new ListOptions().changesSince(ifModifiedSince); - assertEquals(ImmutableList.of(ifModifiedSince.getMillis() / 1000 + ""), options + assertEquals(ImmutableList.of(ifModifiedSince.getTime() / 1000 + ""), options .buildQueryParameters().get("changes-since")); } @@ -69,9 +73,9 @@ public class ListOptionsTest { } public void testChangesSinceStatic() { - DateTime ifModifiedSince = new DateTime(); + Date ifModifiedSince = new Date(); ListOptions options = changesSince(ifModifiedSince); - assertEquals(ImmutableList.of(ifModifiedSince.getMillis() / 1000 + ""), options + assertEquals(ImmutableList.of(ifModifiedSince.getTime() / 1000 + ""), options .buildQueryParameters().get("changes-since")); } diff --git a/rackspace/src/test/java/org/jclouds/rackspace/options/BaseListOptionsTest.java b/rackspace/src/test/java/org/jclouds/rackspace/options/BaseListOptionsTest.java index 1d332c3fc7..0854b368ee 100644 --- a/rackspace/src/test/java/org/jclouds/rackspace/options/BaseListOptionsTest.java +++ b/rackspace/src/test/java/org/jclouds/rackspace/options/BaseListOptionsTest.java @@ -28,7 +28,8 @@ import static org.jclouds.rackspace.options.BaseListOptions.Builder.maxResults; import static org.jclouds.rackspace.options.BaseListOptions.Builder.startAt; import static org.testng.Assert.assertEquals; -import org.joda.time.DateTime; +import java.util.Date; + import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; @@ -42,9 +43,9 @@ import com.google.common.collect.ImmutableList; public class BaseListOptionsTest { public void testChangesSince() { - DateTime ifModifiedSince = new DateTime(); + Date ifModifiedSince = new Date(); BaseListOptions options = new BaseListOptions().changesSince(ifModifiedSince); - assertEquals(ImmutableList.of(ifModifiedSince.getMillis() / 1000 + ""), options + assertEquals(ImmutableList.of(ifModifiedSince.getTime() / 1000 + ""), options .buildQueryParameters().get("changes-since")); } @@ -61,9 +62,9 @@ public class BaseListOptionsTest { } public void testChangesSinceStatic() { - DateTime ifModifiedSince = new DateTime(); + Date ifModifiedSince = new Date(); BaseListOptions options = changesSince(ifModifiedSince); - assertEquals(ImmutableList.of(ifModifiedSince.getMillis() / 1000 + ""), options + assertEquals(ImmutableList.of(ifModifiedSince.getTime() / 1000 + ""), options .buildQueryParameters().get("changes-since")); } diff --git a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/binder/RimuHostingCreateInstanceBinder.java b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/binder/RimuHostingCreateInstanceBinder.java index a36a4ad59d..33bf3f334a 100644 --- a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/binder/RimuHostingCreateInstanceBinder.java +++ b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/binder/RimuHostingCreateInstanceBinder.java @@ -23,14 +23,14 @@ */ package org.jclouds.rimuhosting.miro.binder; -import org.jclouds.http.HttpRequest; -import org.jclouds.rimuhosting.miro.data.NewServerData; -import org.jclouds.rimuhosting.miro.data.CreateOptions; -import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; + import java.util.Map; +import org.jclouds.http.HttpRequest; +import org.jclouds.rimuhosting.miro.data.CreateOptions; +import org.jclouds.rimuhosting.miro.data.NewServerData; + /** * @author Ivan Meredith */ diff --git a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/config/RimuHostingContextModule.java b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/config/RimuHostingContextModule.java index 619e03dced..8581998f5c 100644 --- a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/config/RimuHostingContextModule.java +++ b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/config/RimuHostingContextModule.java @@ -23,24 +23,25 @@ */ package org.jclouds.rimuhosting.miro.config; -import com.google.inject.AbstractModule; -import com.google.inject.Provides; -import com.google.inject.Scopes; -import org.jclouds.http.functions.config.ParserModule.CDateTimeAdapter; -import org.jclouds.http.functions.config.ParserModule.DateTimeAdapter; +import java.net.URI; + +import javax.inject.Named; +import javax.inject.Singleton; + +import org.jclouds.compute.ComputeService; +import org.jclouds.http.functions.config.ParserModule.CDateAdapter; +import org.jclouds.http.functions.config.ParserModule.DateAdapter; import org.jclouds.lifecycle.Closer; import org.jclouds.rest.RestContext; import org.jclouds.rest.internal.RestContextImpl; import org.jclouds.rimuhosting.miro.RimuHosting; import org.jclouds.rimuhosting.miro.RimuHostingAsyncClient; import org.jclouds.rimuhosting.miro.RimuHostingClient; -import org.jclouds.rimuhosting.miro.servers.RimuHostingComputeService; import org.jclouds.rimuhosting.miro.reference.RimuHostingConstants; -import org.jclouds.compute.ComputeService; +import org.jclouds.rimuhosting.miro.servers.RimuHostingComputeService; -import javax.inject.Named; -import javax.inject.Singleton; -import java.net.URI; +import com.google.inject.AbstractModule; +import com.google.inject.Provides; /** * Configures the RimuHosting connection, including logging and http transport. @@ -50,7 +51,7 @@ import java.net.URI; public class RimuHostingContextModule extends AbstractModule { @Override protected void configure() { - bind(DateTimeAdapter.class).to(CDateTimeAdapter.class); + bind(DateAdapter.class).to(CDateAdapter.class); bind(ComputeService.class).to(RimuHostingComputeService.class); } diff --git a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/config/RimuHostingContextModuleTest.java b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/config/RimuHostingContextModuleTest.java index 3966c08e0a..080a528da9 100644 --- a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/config/RimuHostingContextModuleTest.java +++ b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/config/RimuHostingContextModuleTest.java @@ -23,15 +23,15 @@ */ package org.jclouds.rimuhosting.miro.config; -import com.google.inject.Guice; -import com.google.inject.Injector; +import static org.testng.Assert.assertEquals; + import org.jclouds.concurrent.WithinThreadExecutorService; import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.http.HttpRetryHandler; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.http.functions.config.ParserModule; -import org.jclouds.http.functions.config.ParserModule.CDateTimeAdapter; -import org.jclouds.http.functions.config.ParserModule.DateTimeAdapter; +import org.jclouds.http.functions.config.ParserModule.CDateAdapter; +import org.jclouds.http.functions.config.ParserModule.DateAdapter; import org.jclouds.http.handlers.CloseContentAndSetExceptionErrorHandler; import org.jclouds.http.handlers.DelegatingErrorHandler; import org.jclouds.http.handlers.DelegatingRetryHandler; @@ -40,9 +40,11 @@ import org.jclouds.logging.Logger; import org.jclouds.logging.Logger.LoggerFactory; import org.jclouds.rimuhosting.miro.reference.RimuHostingConstants; import org.jclouds.util.Jsr330; -import static org.testng.Assert.assertEquals; import org.testng.annotations.Test; +import com.google.inject.Guice; +import com.google.inject.Injector; + /** * @author Adrian Cole */ @@ -50,44 +52,48 @@ import org.testng.annotations.Test; public class RimuHostingContextModuleTest { Injector createInjector() { - return Guice.createInjector(new RimuHostingRestClientModule(), new RimuHostingContextModule() { - @Override - protected void configure() { - bindConstant().annotatedWith(Jsr330.named(RimuHostingConstants.PROPERTY_RIMUHOSTING_USER)).to( - "user"); - bindConstant().annotatedWith(Jsr330.named(RimuHostingConstants.PROPERTY_RIMUHOSTING_PASSWORD)) - .to("password"); - bindConstant().annotatedWith(Jsr330.named(RimuHostingConstants.PROPERTY_RIMUHOSTING_ENDPOINT)) - .to("http://localhost"); - bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() { - public Logger getLogger(String category) { - return Logger.NULL; - } - }); - super.configure(); - } - }, new ParserModule(), new JavaUrlHttpCommandExecutorServiceModule(), - new ExecutorServiceModule(new WithinThreadExecutorService())); + return Guice.createInjector(new RimuHostingRestClientModule(), + new RimuHostingContextModule() { + @Override + protected void configure() { + bindConstant().annotatedWith( + Jsr330.named(RimuHostingConstants.PROPERTY_RIMUHOSTING_USER)).to( + "user"); + bindConstant().annotatedWith( + Jsr330.named(RimuHostingConstants.PROPERTY_RIMUHOSTING_PASSWORD)).to( + "password"); + bindConstant().annotatedWith( + Jsr330.named(RimuHostingConstants.PROPERTY_RIMUHOSTING_ENDPOINT)).to( + "http://localhost"); + bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() { + public Logger getLogger(String category) { + return Logger.NULL; + } + }); + super.configure(); + } + }, new ParserModule(), new JavaUrlHttpCommandExecutorServiceModule(), + new ExecutorServiceModule(new WithinThreadExecutorService())); } @Test void testServerErrorHandler() { DelegatingErrorHandler handler = createInjector().getInstance(DelegatingErrorHandler.class); assertEquals(handler.getServerErrorHandler().getClass(), - CloseContentAndSetExceptionErrorHandler.class); + CloseContentAndSetExceptionErrorHandler.class); } @Test - void testDateTimeAdapter() { - assertEquals(this.createInjector().getInstance(DateTimeAdapter.class).getClass(), - CDateTimeAdapter.class); + void testDateAdapter() { + assertEquals(this.createInjector().getInstance(DateAdapter.class).getClass(), + CDateAdapter.class); } @Test void testClientErrorHandler() { DelegatingErrorHandler handler = createInjector().getInstance(DelegatingErrorHandler.class); assertEquals(handler.getClientErrorHandler().getClass(), - CloseContentAndSetExceptionErrorHandler.class); + CloseContentAndSetExceptionErrorHandler.class); } @Test diff --git a/tools/getpath/pom.xml b/tools/getpath/pom.xml index 7e6bd38a95..40f62f612b 100644 --- a/tools/getpath/pom.xml +++ b/tools/getpath/pom.xml @@ -43,6 +43,11 @@ + + ${project.groupId} + jclouds-blobstore + ${project.version} + ${project.groupId} jclouds-aws diff --git a/tools/vfs/pom.xml b/tools/vfs/pom.xml index 7701a2ae7a..7197887fda 100644 --- a/tools/vfs/pom.xml +++ b/tools/vfs/pom.xml @@ -41,6 +41,11 @@ test + + ${project.groupId} + jclouds-blobstore + ${project.version} + ${project.groupId} jclouds-aws diff --git a/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileObject.java b/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileObject.java index 3a0705cf9d..f065100e83 100644 --- a/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileObject.java +++ b/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileObject.java @@ -342,7 +342,7 @@ public class BlobStoreFileObject extends AbstractFileObject { if (metadata == null || metadata.getLastModified() == null) { getMetadataAtPath(getNameTrimLeadingSlashes()); } - return metadata.getLastModified() != null ? metadata.getLastModified().getMillis() : super + return metadata.getLastModified() != null ? metadata.getLastModified().getTime() : super .doGetLastModifiedTime(); } diff --git a/twitter/src/main/java/org/jclouds/twitter/config/TwitterContextModule.java b/twitter/src/main/java/org/jclouds/twitter/config/TwitterContextModule.java index 7d67b0f42f..4c125880a9 100644 --- a/twitter/src/main/java/org/jclouds/twitter/config/TwitterContextModule.java +++ b/twitter/src/main/java/org/jclouds/twitter/config/TwitterContextModule.java @@ -28,8 +28,8 @@ import java.net.URI; import javax.inject.Named; import javax.inject.Singleton; -import org.jclouds.http.functions.config.ParserModule.CDateTimeAdapter; -import org.jclouds.http.functions.config.ParserModule.DateTimeAdapter; +import org.jclouds.http.functions.config.ParserModule.CDateAdapter; +import org.jclouds.http.functions.config.ParserModule.DateAdapter; import org.jclouds.lifecycle.Closer; import org.jclouds.rest.RestContext; import org.jclouds.rest.internal.RestContextImpl; @@ -49,7 +49,7 @@ import com.google.inject.Provides; public class TwitterContextModule extends AbstractModule { @Override protected void configure() { - bind(DateTimeAdapter.class).to(CDateTimeAdapter.class); + bind(DateAdapter.class).to(CDateAdapter.class); } @Provides diff --git a/twitter/src/main/java/org/jclouds/twitter/domain/Status.java b/twitter/src/main/java/org/jclouds/twitter/domain/Status.java index 7e242526ba..252b8524c4 100644 --- a/twitter/src/main/java/org/jclouds/twitter/domain/Status.java +++ b/twitter/src/main/java/org/jclouds/twitter/domain/Status.java @@ -23,7 +23,7 @@ */ package org.jclouds.twitter.domain; -import org.joda.time.DateTime; +import java.util.Date; import com.google.gson.annotations.SerializedName; @@ -34,7 +34,7 @@ import com.google.gson.annotations.SerializedName; */ public class Status implements Comparable { @SerializedName("created_at") - private DateTime createdAt; + private Date createdAt; private boolean favorited; private String geo; private long id; @@ -52,7 +52,7 @@ public class Status implements Comparable { public Status() { } - public Status(DateTime createdAt, boolean favorited, String geo, long id, + public Status(Date createdAt, boolean favorited, String geo, long id, String inReplyToScreenName, Integer inReplyToStatusId, Integer inReplyToUserId, String source, String text, boolean truncated, User user) { this.createdAt = createdAt; @@ -108,11 +108,11 @@ public class Status implements Comparable { return true; } - public DateTime getCreatedAt() { + public Date getCreatedAt() { return createdAt; } - public void setCreatedAt(DateTime createdAt) { + public void setCreatedAt(Date createdAt) { this.createdAt = createdAt; } diff --git a/twitter/src/main/java/org/jclouds/twitter/domain/User.java b/twitter/src/main/java/org/jclouds/twitter/domain/User.java index 67aadef244..54f54641cd 100644 --- a/twitter/src/main/java/org/jclouds/twitter/domain/User.java +++ b/twitter/src/main/java/org/jclouds/twitter/domain/User.java @@ -24,8 +24,7 @@ package org.jclouds.twitter.domain; import java.net.URI; - -import org.joda.time.DateTime; +import java.util.Date; import com.google.gson.annotations.SerializedName; @@ -35,7 +34,7 @@ import com.google.gson.annotations.SerializedName; */ public class User implements Comparable { @SerializedName("created_at") - private DateTime createdAt; + private Date createdAt; private String description; @SerializedName("favourites_count") private int favouritesCount; @@ -83,7 +82,7 @@ public class User implements Comparable { } - public User(DateTime createdAt, String description, int favouritesCount, int followersCount, + public User(Date createdAt, String description, int favouritesCount, int followersCount, boolean following, int friendsCount, boolean geoEnabled, long id, String location, String name, boolean notifications, String profileBackgroundColor, URI profileBackgroundImageUrl, boolean profileBackgroundTile, URI profileImageUrl, @@ -273,11 +272,11 @@ public class User implements Comparable { this.friendsCount = friendsCount; } - public DateTime getCreatedAt() { + public Date getCreatedAt() { return createdAt; } - public void setCreatedAt(DateTime createdAt) { + public void setCreatedAt(Date createdAt) { this.createdAt = createdAt; } diff --git a/twitter/src/test/java/org/jclouds/twitter/config/TwitterContextModuleTest.java b/twitter/src/test/java/org/jclouds/twitter/config/TwitterContextModuleTest.java index 6c97cfaadc..40e5369d28 100644 --- a/twitter/src/test/java/org/jclouds/twitter/config/TwitterContextModuleTest.java +++ b/twitter/src/test/java/org/jclouds/twitter/config/TwitterContextModuleTest.java @@ -30,8 +30,8 @@ import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.http.HttpRetryHandler; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.http.functions.config.ParserModule; -import org.jclouds.http.functions.config.ParserModule.CDateTimeAdapter; -import org.jclouds.http.functions.config.ParserModule.DateTimeAdapter; +import org.jclouds.http.functions.config.ParserModule.CDateAdapter; +import org.jclouds.http.functions.config.ParserModule.DateAdapter; import org.jclouds.http.handlers.CloseContentAndSetExceptionErrorHandler; import org.jclouds.http.handlers.DelegatingErrorHandler; import org.jclouds.http.handlers.DelegatingRetryHandler; @@ -80,9 +80,9 @@ public class TwitterContextModuleTest { } @Test - void testDateTimeAdapter() { - assertEquals(this.createInjector().getInstance(DateTimeAdapter.class).getClass(), - CDateTimeAdapter.class); + void testDateAdapter() { + assertEquals(this.createInjector().getInstance(DateAdapter.class).getClass(), + CDateAdapter.class); } @Test diff --git a/twitter/src/test/java/org/jclouds/twitter/functions/ParseStatusesFromJsonResponseTest.java b/twitter/src/test/java/org/jclouds/twitter/functions/ParseStatusesFromJsonResponseTest.java index 7986b0bf40..89201b36f0 100644 --- a/twitter/src/test/java/org/jclouds/twitter/functions/ParseStatusesFromJsonResponseTest.java +++ b/twitter/src/test/java/org/jclouds/twitter/functions/ParseStatusesFromJsonResponseTest.java @@ -34,6 +34,7 @@ import org.jclouds.http.functions.config.ParserModule; import org.jclouds.twitter.domain.Status; import org.jclouds.twitter.domain.User; import org.jclouds.util.DateService; +import org.jclouds.util.internal.SimpleDateFormatDateService; import org.testng.annotations.Test; import com.google.common.collect.ImmutableSortedSet; @@ -52,11 +53,11 @@ public class ParseStatusesFromJsonResponseTest { Injector i = Guice.createInjector(new ParserModule() { @Override protected void configure() { - bind(DateTimeAdapter.class).to(CDateTimeAdapter.class); + bind(DateAdapter.class).to(CDateAdapter.class); super.configure(); } }); - DateService dateService = new DateService(); + DateService dateService = new SimpleDateFormatDateService(); public void testApplyInputStreamDetails() throws UnknownHostException { InputStream is = getClass().getResourceAsStream("/test_mentions.json"); diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/Task.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/Task.java index c89c0c1452..d11837f6ba 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/Task.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/Task.java @@ -23,10 +23,11 @@ */ package org.jclouds.vcloud.domain; +import java.util.Date; + import org.jclouds.rest.domain.Link; import org.jclouds.rest.domain.NamedLink; import org.jclouds.vcloud.domain.internal.TaskImpl; -import org.joda.time.DateTime; import com.google.inject.ImplementedBy; @@ -38,9 +39,9 @@ public interface Task extends Link, Comparable { TaskStatus getStatus(); - DateTime getStartTime(); + Date getStartTime(); - DateTime getEndTime(); + Date getEndTime(); NamedLink getOwner(); diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/TerremarkVirtualSystem.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/TerremarkVirtualSystem.java index 9c9ced7947..c17b666c5e 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/TerremarkVirtualSystem.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/TerremarkVirtualSystem.java @@ -23,7 +23,7 @@ */ package org.jclouds.vcloud.domain; -import org.joda.time.DateTime; +import java.util.Date; /** * @author Adrian Cole @@ -39,7 +39,7 @@ public class TerremarkVirtualSystem extends VirtualSystem { private final String configurationDataRoot; private final String configurationFile; private final String configurationID; - private final DateTime creationTime; + private final Date creationTime; private final String description; private final String logDataRoot; private final String recoveryFile; @@ -51,7 +51,7 @@ public class TerremarkVirtualSystem extends VirtualSystem { String automaticStartupAction, String automaticStartupActionDelay, String automaticStartupActionSequenceNumber, String caption, String configurationDataRoot, String configurationFile, String configurationID, - DateTime creationTime, String description, String elementName, int instanceID, + Date creationTime, String description, String elementName, int instanceID, String logDataRoot, String recoveryFile, String snapshotDataRoot, String suspendDataRoot, String swapFileDataRoot, String virtualSystemIdentifier, String virtualSystemType) { @@ -110,7 +110,7 @@ public class TerremarkVirtualSystem extends VirtualSystem { return configurationID; } - public DateTime getCreationTime() { + public Date getCreationTime() { return creationTime; } diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/TaskImpl.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/TaskImpl.java index f3195ac89b..c2414c4790 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/TaskImpl.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/TaskImpl.java @@ -26,12 +26,12 @@ package org.jclouds.vcloud.domain.internal; import static com.google.common.base.Preconditions.checkNotNull; import java.net.URI; +import java.util.Date; import org.jclouds.rest.domain.NamedLink; import org.jclouds.rest.domain.internal.LinkImpl; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.TaskStatus; -import org.joda.time.DateTime; import com.google.inject.internal.Nullable; @@ -43,15 +43,15 @@ import com.google.inject.internal.Nullable; */ public class TaskImpl extends LinkImpl implements Task { private final TaskStatus status; - private final DateTime startTime; + private final Date startTime; @Nullable - private final DateTime endTime; + private final Date endTime; private final NamedLink owner; @Nullable private final NamedLink result; - public TaskImpl(String type, URI location, TaskStatus status, DateTime startTime, - @Nullable DateTime endTime, NamedLink owner, @Nullable NamedLink result) { + public TaskImpl(String type, URI location, TaskStatus status, Date startTime, + @Nullable Date endTime, NamedLink owner, @Nullable NamedLink result) { super(type, location); this.status = checkNotNull(status, "status"); this.startTime = startTime; @@ -64,7 +64,7 @@ public class TaskImpl extends LinkImpl implements Task { return status; } - public DateTime getStartTime() { + public Date getStartTime() { return startTime; } @@ -76,7 +76,7 @@ public class TaskImpl extends LinkImpl implements Task { return result; } - public DateTime getEndTime() { + public Date getEndTime() { return endTime; } diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java index d1def3fafa..e6c76d4028 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java @@ -24,6 +24,7 @@ package org.jclouds.vcloud.xml; import java.text.ParseException; +import java.util.Date; import javax.annotation.Resource; import javax.inject.Inject; @@ -37,7 +38,6 @@ import org.jclouds.util.DateService; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.TaskStatus; import org.jclouds.vcloud.domain.internal.TaskImpl; -import org.joda.time.DateTime; import org.xml.sax.Attributes; import org.xml.sax.SAXException; @@ -51,8 +51,8 @@ public class TaskHandler extends ParseSax.HandlerWithResult { private NamedLink owner; private NamedLink result; private TaskStatus status; - private DateTime startTime; - private DateTime endTime; + private Date startTime; + private Date endTime; private Task task; @Resource @@ -88,7 +88,7 @@ public class TaskHandler extends ParseSax.HandlerWithResult { } } - private DateTime parseDate(Attributes attributes, String attribute) { + private Date parseDate(Attributes attributes, String attribute) { try { return dateService.iso8601DateParse(attributes.getValue(attributes.getIndex(attribute))); diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/domain/VirtualSystem.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/domain/VirtualSystem.java index b1d6b5e8f9..c4b5a12807 100644 --- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/domain/VirtualSystem.java +++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/domain/VirtualSystem.java @@ -23,7 +23,7 @@ */ package org.jclouds.vcloud.terremark.domain; -import org.joda.time.DateTime; +import java.util.Date; /** * @author Adrian Cole @@ -39,7 +39,7 @@ public class VirtualSystem { private final String configurationDataRoot; private final String configurationFile; private final String configurationID; - private final DateTime creationTime; + private final Date creationTime; private final String description; private final String elementName; private final int instanceID; @@ -50,12 +50,12 @@ public class VirtualSystem { private final String swapFileDataRoot; private final String virtualSystemIdentifier; private final String virtualSystemType; - + public VirtualSystem(String automaticRecoveryAction, String automaticShutdownAction, String automaticStartupAction, String automaticStartupActionDelay, String automaticStartupActionSequenceNumber, String caption, String configurationDataRoot, String configurationFile, String configurationID, - DateTime creationTime, String description, String elementName, int instanceID, + Date creationTime, String description, String elementName, int instanceID, String logDataRoot, String recoveryFile, String snapshotDataRoot, String suspendDataRoot, String swapFileDataRoot, String virtualSystemIdentifier, String virtualSystemType) { @@ -117,7 +117,7 @@ public class VirtualSystem { return configurationID; } - public DateTime getCreationTime() { + public Date getCreationTime() { return creationTime; } @@ -326,5 +326,4 @@ public class VirtualSystem { + virtualSystemIdentifier + ", virtualSystemType=" + virtualSystemType + "]"; } - } \ No newline at end of file diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/xml/VirtualSystemHandler.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/xml/VirtualSystemHandler.java index 56f66d5c3f..f6c8697abf 100644 --- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/xml/VirtualSystemHandler.java +++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/xml/VirtualSystemHandler.java @@ -23,11 +23,12 @@ */ package org.jclouds.vcloud.terremark.xml; +import java.util.Date; + import javax.inject.Inject; import org.jclouds.http.functions.ParseSax; import org.jclouds.util.DateService; -import org.joda.time.DateTime; import org.xml.sax.Attributes; import org.xml.sax.SAXException; @@ -49,7 +50,7 @@ public class VirtualSystemHandler extends private String configurationDataRoot; private String configurationFile; private String configurationID; - private DateTime creationTime; + private Date creationTime; private String description; private String elementName; private int instanceID; @@ -77,7 +78,8 @@ public class VirtualSystemHandler extends public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { if (attributes.getIndex("xsi:nil") != -1 - || attributes.getIndex("xmlns") == -1 || !"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" + || attributes.getIndex("xmlns") == -1 + || !"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" .equals(attributes.getValue("xmlns"))) { skip = true; return; @@ -132,12 +134,13 @@ public class VirtualSystemHandler extends } else if (qName.equals("VirtualSystemType")) { this.virtualSystemType = currentText.toString().trim(); } else if (qName.equals("q2:System")) { - this.system = new org.jclouds.vcloud.domain.TerremarkVirtualSystem(automaticRecoveryAction, - automaticShutdownAction, automaticStartupAction, automaticStartupActionDelay, - automaticStartupActionSequenceNumber, caption, configurationDataRoot, - configurationFile, configurationID, creationTime, description, elementName, - instanceID, logDataRoot, recoveryFile, snapshotDataRoot, suspendDataRoot, - swapFileDataRoot, virtualSystemIdentifier, virtualSystemType); + this.system = new org.jclouds.vcloud.domain.TerremarkVirtualSystem( + automaticRecoveryAction, automaticShutdownAction, automaticStartupAction, + automaticStartupActionDelay, automaticStartupActionSequenceNumber, caption, + configurationDataRoot, configurationFile, configurationID, creationTime, + description, elementName, instanceID, logDataRoot, recoveryFile, + snapshotDataRoot, suspendDataRoot, swapFileDataRoot, virtualSystemIdentifier, + virtualSystemType); this.automaticRecoveryAction = null; this.automaticShutdownAction = null; this.automaticStartupAction = null;