Issue 131: move joda to extension

git-svn-id: http://jclouds.googlecode.com/svn/trunk@2407 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
adrian.f.cole 2009-12-13 02:24:30 +00:00
parent 428709f1a8
commit 507794042e
111 changed files with 880 additions and 776 deletions

View File

@ -23,7 +23,7 @@
*/ */
package org.jclouds.atmosonline.saas.domain; package org.jclouds.atmosonline.saas.domain;
import org.joda.time.DateTime; import java.util.Date;
/** /**
* Metadata of a Atmos Online object * Metadata of a Atmos Online object
@ -32,19 +32,18 @@ import org.joda.time.DateTime;
*/ */
public class SystemMetadata extends DirectoryEntry { public class SystemMetadata extends DirectoryEntry {
private final DateTime atime; private final Date atime;
private final DateTime ctime; private final Date ctime;
private final String gid; private final String gid;
private final DateTime itime; private final Date itime;
private final DateTime mtime; private final Date mtime;
private final int nlink; private final int nlink;
private final String policyname; private final String policyname;
private final long size; private final long size;
private final String uid; private final String uid;
public SystemMetadata(DateTime atime, DateTime ctime, String gid, DateTime itime, public SystemMetadata(Date atime, Date ctime, String gid, Date itime, Date mtime, int nlink,
DateTime mtime, int nlink, String objectid, String objname, String policyname, String objectid, String objname, String policyname, long size, FileType type, String uid) {
long size, FileType type, String uid) {
super(objectid, type, objname); super(objectid, type, objname);
this.atime = atime; this.atime = atime;
this.ctime = ctime; this.ctime = ctime;
@ -65,19 +64,19 @@ public class SystemMetadata extends DirectoryEntry {
return nlink; return nlink;
} }
public DateTime getInceptionTime() { public Date getInceptionTime() {
return itime; return itime;
} }
public DateTime getLastAccessTime() { public Date getLastAccessTime() {
return atime; return atime;
} }
public DateTime getLastMetadataModification() { public Date getLastMetadataModification() {
return mtime; return mtime;
} }
public DateTime getLastUserDataModification() { public Date getLastUserDataModification() {
return ctime; return ctime;
} }

View File

@ -36,8 +36,8 @@ import org.jclouds.http.functions.config.ParserModule;
import org.jclouds.http.handlers.DelegatingErrorHandler; import org.jclouds.http.handlers.DelegatingErrorHandler;
import org.jclouds.http.handlers.DelegatingRetryHandler; import org.jclouds.http.handlers.DelegatingRetryHandler;
import org.jclouds.http.handlers.RedirectionRetryHandler; import org.jclouds.http.handlers.RedirectionRetryHandler;
import org.jclouds.util.DateService;
import org.jclouds.util.Jsr330; import org.jclouds.util.Jsr330;
import org.jclouds.util.internal.SimpleDateFormatDateService;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
@ -73,7 +73,7 @@ public class AtmosStorageRestClientModuleTest {
void testUpdatesOnlyOncePerSecond() throws NoSuchMethodException, InterruptedException { void testUpdatesOnlyOncePerSecond() throws NoSuchMethodException, InterruptedException {
AtmosStorageRestClientModule module = new AtmosStorageRestClientModule(); AtmosStorageRestClientModule module = new AtmosStorageRestClientModule();
Supplier<String> map = module.provideTimeStampCache(1, new DateService()); Supplier<String> map = module.provideTimeStampCache(1, new SimpleDateFormatDateService());
String timeStamp = map.get(); String timeStamp = map.get();
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
map.get(); map.get();

View File

@ -32,8 +32,8 @@ import org.jclouds.aws.ec2.EC2;
import org.jclouds.aws.ec2.EC2AsyncClient; import org.jclouds.aws.ec2.EC2AsyncClient;
import org.jclouds.aws.ec2.EC2Client; import org.jclouds.aws.ec2.EC2Client;
import org.jclouds.aws.reference.AWSConstants; import org.jclouds.aws.reference.AWSConstants;
import org.jclouds.http.functions.config.ParserModule.CDateTimeAdapter; import org.jclouds.http.functions.config.ParserModule.CDateAdapter;
import org.jclouds.http.functions.config.ParserModule.DateTimeAdapter; import org.jclouds.http.functions.config.ParserModule.DateAdapter;
import org.jclouds.lifecycle.Closer; import org.jclouds.lifecycle.Closer;
import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.RestContextImpl; import org.jclouds.rest.internal.RestContextImpl;
@ -49,7 +49,7 @@ import com.google.inject.Provides;
public class EC2ContextModule extends AbstractModule { public class EC2ContextModule extends AbstractModule {
@Override @Override
protected void configure() { protected void configure() {
bind(DateTimeAdapter.class).to(CDateTimeAdapter.class); bind(DateAdapter.class).to(CDateAdapter.class);
} }
@Provides @Provides

View File

@ -24,6 +24,7 @@
package org.jclouds.aws.ec2.config; package org.jclouds.aws.ec2.config;
import java.net.URI; import java.net.URI;
import java.util.Date;
import javax.inject.Named; import javax.inject.Named;
import javax.inject.Singleton; import javax.inject.Singleton;
@ -48,7 +49,6 @@ import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.RestClientFactory; import org.jclouds.rest.RestClientFactory;
import org.jclouds.util.DateService; import org.jclouds.util.DateService;
import org.jclouds.util.TimeStamp; import org.jclouds.util.TimeStamp;
import org.joda.time.DateTime;
import com.google.inject.AbstractModule; import com.google.inject.AbstractModule;
import com.google.inject.Provides; import com.google.inject.Provides;
@ -72,7 +72,8 @@ public class EC2RestClientModule extends AbstractModule {
@TimeStamp @TimeStamp
protected String provideTimeStamp(final DateService dateService, protected String provideTimeStamp(final DateService dateService,
@Named(EC2Constants.PROPERTY_EC2_EXPIREINTERVAL) final int expiration) { @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 @Provides

View File

@ -26,10 +26,9 @@ package org.jclouds.aws.ec2.domain;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.Date;
import java.util.Set; import java.util.Set;
import org.joda.time.DateTime;
import com.google.inject.internal.Nullable; import com.google.inject.internal.Nullable;
/** /**
@ -52,7 +51,7 @@ public class RunningInstance implements Comparable<RunningInstance> {
private final String kernelId; private final String kernelId;
@Nullable @Nullable
private final String keyName; private final String keyName;
private final DateTime launchTime; private final Date launchTime;
private final boolean monitoring; private final boolean monitoring;
@Nullable @Nullable
private final String availabilityZone; private final String availabilityZone;
@ -79,7 +78,7 @@ public class RunningInstance implements Comparable<RunningInstance> {
public RunningInstance(String amiLaunchIndex, @Nullable String dnsName, String imageId, public RunningInstance(String amiLaunchIndex, @Nullable String dnsName, String imageId,
String instanceId, InstanceState instanceState, InstanceType instanceType, String instanceId, InstanceState instanceState, InstanceType instanceType,
@Nullable InetAddress ipAddress, @Nullable String kernelId, @Nullable String keyName, @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 String platform, @Nullable String privateDnsName,
@Nullable InetAddress privateIpAddress, Set<String> productCodes, @Nullable InetAddress privateIpAddress, Set<String> productCodes,
@Nullable String ramdiskId, @Nullable String reason, @Nullable String subnetId, @Nullable String ramdiskId, @Nullable String reason, @Nullable String subnetId,
@ -177,7 +176,7 @@ public class RunningInstance implements Comparable<RunningInstance> {
/** /**
* The time the instance launched. * The time the instance launched.
*/ */
public DateTime getLaunchTime() { public Date getLaunchTime() {
return launchTime; return launchTime;
} }

View File

@ -25,6 +25,7 @@ package org.jclouds.aws.ec2.xml;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.Date;
import java.util.Set; import java.util.Set;
import java.util.SortedSet; 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.http.functions.ParseSax.HandlerWithResult;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
import org.jclouds.util.DateService; import org.jclouds.util.DateService;
import org.joda.time.DateTime;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
@ -67,7 +67,7 @@ public abstract class BaseReservationHandler<T> extends HandlerWithResult<T> {
private InetAddress ipAddress; private InetAddress ipAddress;
private String kernelId; private String kernelId;
private String keyName; private String keyName;
private DateTime launchTime; private Date launchTime;
private boolean monitoring; private boolean monitoring;
private String availabilityZone; private String availabilityZone;
private String platform; private String platform;

View File

@ -23,7 +23,7 @@
*/ */
package org.jclouds.aws.s3.domain; package org.jclouds.aws.s3.domain;
import org.joda.time.DateTime; import java.util.Date;
/** /**
* System metadata of the S3Bucket * System metadata of the S3Bucket
@ -33,7 +33,7 @@ import org.joda.time.DateTime;
public class BucketMetadata implements Comparable<BucketMetadata> { public class BucketMetadata implements Comparable<BucketMetadata> {
/** The serialVersionUID */ /** The serialVersionUID */
private static final long serialVersionUID = -6965068835316857535L; private static final long serialVersionUID = -6965068835316857535L;
private final DateTime creationDate; private final Date creationDate;
private final CanonicalUser owner; private final CanonicalUser owner;
private final String name; private final String name;
@ -48,7 +48,7 @@ public class BucketMetadata implements Comparable<BucketMetadata> {
EU EU
} }
public BucketMetadata(String name, DateTime creationDate, CanonicalUser owner) { public BucketMetadata(String name, Date creationDate, CanonicalUser owner) {
this.name = name; this.name = name;
this.creationDate = creationDate; this.creationDate = creationDate;
this.owner = owner; this.owner = owner;
@ -63,7 +63,7 @@ public class BucketMetadata implements Comparable<BucketMetadata> {
return owner; return owner;
} }
public DateTime getCreationDate() { public Date getCreationDate() {
return creationDate; return creationDate;
} }

View File

@ -23,10 +23,10 @@
*/ */
package org.jclouds.aws.s3.domain; package org.jclouds.aws.s3.domain;
import java.util.Date;
import java.util.Map; import java.util.Map;
import org.jclouds.aws.s3.domain.internal.MutableObjectMetadataImpl; import org.jclouds.aws.s3.domain.internal.MutableObjectMetadataImpl;
import org.joda.time.DateTime;
import com.google.inject.ImplementedBy; import com.google.inject.ImplementedBy;
@ -107,7 +107,7 @@ public interface MutableObjectMetadata extends ObjectMetadata {
*/ */
void setContentMD5(byte[] md5); void setContentMD5(byte[] md5);
void setLastModified(DateTime lastModified); void setLastModified(Date lastModified);
void setETag(String eTag); void setETag(String eTag);

View File

@ -23,10 +23,9 @@
*/ */
package org.jclouds.aws.s3.domain; package org.jclouds.aws.s3.domain;
import java.util.Date;
import java.util.Map; import java.util.Map;
import org.joda.time.DateTime;
/** /**
* /** Amazon S3 is designed to store objects. Objects are stored in {@link S3BucketListing buckets} * /** 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 * and consist of a {@link org.jclouds.aws.s3.domain.S3Object#getData() value}, a
@ -107,7 +106,7 @@ public interface ObjectMetadata extends Comparable<ObjectMetadata> {
*/ */
byte[] getContentMD5(); byte[] getContentMD5();
DateTime getLastModified(); Date getLastModified();
String getETag(); String getETag();

View File

@ -25,11 +25,11 @@ package org.jclouds.aws.s3.domain.internal;
import java.io.Serializable; import java.io.Serializable;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date;
import java.util.Map; import java.util.Map;
import org.jclouds.aws.s3.domain.CanonicalUser; import org.jclouds.aws.s3.domain.CanonicalUser;
import org.jclouds.aws.s3.domain.ObjectMetadata; import org.jclouds.aws.s3.domain.ObjectMetadata;
import org.joda.time.DateTime;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
@ -44,7 +44,7 @@ public class BucketListObjectMetadata implements Serializable, ObjectMetadata {
private static final long serialVersionUID = -4415449798024051115L; private static final long serialVersionUID = -4415449798024051115L;
private final String key; private final String key;
private final DateTime lastModified; private final Date lastModified;
private final String eTag; private final String eTag;
private final long size; private final long size;
private final CanonicalUser owner; private final CanonicalUser owner;
@ -56,7 +56,7 @@ public class BucketListObjectMetadata implements Serializable, ObjectMetadata {
private final String contentEncoding; private final String contentEncoding;
private final Map<String, String> userMetadata; private final Map<String, String> 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) { long size, CanonicalUser owner, StorageClass storageClass) {
this.key = key; this.key = key;
this.lastModified = lastModified; this.lastModified = lastModified;
@ -124,7 +124,7 @@ public class BucketListObjectMetadata implements Serializable, ObjectMetadata {
/** /**
*{@inheritDoc} *{@inheritDoc}
*/ */
public DateTime getLastModified() { public Date getLastModified() {
return lastModified; return lastModified;
} }

View File

@ -25,11 +25,11 @@ package org.jclouds.aws.s3.domain.internal;
import java.io.Serializable; import java.io.Serializable;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date;
import java.util.Map; import java.util.Map;
import org.jclouds.aws.s3.domain.CanonicalUser; import org.jclouds.aws.s3.domain.CanonicalUser;
import org.jclouds.aws.s3.domain.ObjectMetadata; import org.jclouds.aws.s3.domain.ObjectMetadata;
import org.joda.time.DateTime;
/** /**
* Returns the metadata parsable from a bucket listing * 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 static final long serialVersionUID = -4415449798024051115L;
private final String key; private final String key;
private final DateTime lastModified; private final Date lastModified;
private final String eTag; private final String eTag;
private final Long size; private final Long size;
private final CanonicalUser owner; private final CanonicalUser owner;
@ -54,7 +54,7 @@ public class CopyObjectResult implements Serializable, ObjectMetadata {
private final String contentEncoding; private final String contentEncoding;
private final Map<String, String> userMetadata; private final Map<String, String> userMetadata;
public CopyObjectResult(DateTime lastModified, String eTag) { public CopyObjectResult(Date lastModified, String eTag) {
this.key = null; this.key = null;
this.lastModified = lastModified; this.lastModified = lastModified;
this.eTag = eTag; this.eTag = eTag;
@ -121,7 +121,7 @@ public class CopyObjectResult implements Serializable, ObjectMetadata {
/** /**
*{@inheritDoc} *{@inheritDoc}
*/ */
public DateTime getLastModified() { public Date getLastModified() {
return lastModified; return lastModified;
} }
@ -248,5 +248,4 @@ public class CopyObjectResult implements Serializable, ObjectMetadata {
return true; return true;
} }
} }

View File

@ -25,12 +25,12 @@ package org.jclouds.aws.s3.domain.internal;
import java.io.Serializable; import java.io.Serializable;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date;
import java.util.Map; import java.util.Map;
import org.jclouds.aws.s3.domain.CanonicalUser; import org.jclouds.aws.s3.domain.CanonicalUser;
import org.jclouds.aws.s3.domain.MutableObjectMetadata; import org.jclouds.aws.s3.domain.MutableObjectMetadata;
import org.jclouds.aws.s3.domain.ObjectMetadata; import org.jclouds.aws.s3.domain.ObjectMetadata;
import org.joda.time.DateTime;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
@ -45,7 +45,7 @@ public class MutableObjectMetadataImpl implements Serializable, MutableObjectMet
private static final long serialVersionUID = -4648755473986695062L; private static final long serialVersionUID = -4648755473986695062L;
private String key; private String key;
private DateTime lastModified; private Date lastModified;
private String eTag; private String eTag;
private long size; private long size;
private CanonicalUser owner; private CanonicalUser owner;
@ -113,7 +113,7 @@ public class MutableObjectMetadataImpl implements Serializable, MutableObjectMet
/** /**
*{@inheritDoc} *{@inheritDoc}
*/ */
public DateTime getLastModified() { public Date getLastModified() {
return lastModified; return lastModified;
} }
@ -214,7 +214,7 @@ public class MutableObjectMetadataImpl implements Serializable, MutableObjectMet
/** /**
*{@inheritDoc} *{@inheritDoc}
*/ */
public void setLastModified(DateTime lastModified) { public void setLastModified(Date lastModified) {
this.lastModified = lastModified; this.lastModified = lastModified;
} }

View File

@ -28,6 +28,7 @@ import static com.google.common.base.Preconditions.checkState;
import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX; import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.Map; import java.util.Map;
import javax.inject.Inject; 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.aws.s3.reference.S3Headers;
import org.jclouds.http.options.BaseHttpRequestOptions; import org.jclouds.http.options.BaseHttpRequestOptions;
import org.jclouds.util.DateService; 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.base.Preconditions;
import com.google.common.collect.LinkedHashMultimap; import com.google.common.collect.LinkedHashMultimap;
@ -63,7 +64,7 @@ import com.google.common.collect.Multimap;
* Future<S3Object.Metadata> object = connection.copyObject("sourceBucket", "objectName", * Future<S3Object.Metadata> object = connection.copyObject("sourceBucket", "objectName",
* "destinationBucket", "destinationName", * "destinationBucket", "destinationName",
* overrideMetadataWith(meta). * overrideMetadataWith(meta).
* ifSourceModifiedSince(new DateTime().minusDays(1)) * ifSourceModifiedSince(new Date().minusDays(1))
* ); * );
* <code> * <code>
* *
@ -73,7 +74,7 @@ import com.google.common.collect.Multimap;
* /> * />
*/ */
public class CopyObjectOptions extends BaseHttpRequestOptions { 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(); public static final CopyObjectOptions NONE = new CopyObjectOptions();
@ -118,7 +119,7 @@ public class CopyObjectOptions extends BaseHttpRequestOptions {
* *
* @return valid HTTP date * @return valid HTTP date
* @see <a href="http://rfc.net/rfc2616.html?s3.3"/> * @see <a href="http://rfc.net/rfc2616.html?s3.3"/>
* @see CopyObjectOptions#ifSourceModifiedSince(DateTime) * @see CopyObjectOptions#ifSourceModifiedSince(Date)
*/ */
public String getIfModifiedSince() { public String getIfModifiedSince() {
return getFirstHeaderOrNull("x-amz-copy-source-if-modified-since"); return getFirstHeaderOrNull("x-amz-copy-source-if-modified-since");
@ -135,7 +136,7 @@ public class CopyObjectOptions extends BaseHttpRequestOptions {
* *
* @return valid HTTP date * @return valid HTTP date
* @see <a href="http://rfc.net/rfc2616.html?s3.3"/> * @see <a href="http://rfc.net/rfc2616.html?s3.3"/>
* @see CopyObjectOptions#ifSourceUnmodifiedSince(DateTime) * @see CopyObjectOptions#ifSourceUnmodifiedSince(Date)
*/ */
public String getIfUnmodifiedSince() { public String getIfUnmodifiedSince() {
return getFirstHeaderOrNull("x-amz-copy-source-if-unmodified-since"); 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. * Only return the object if it has changed since this time.
* <p/> * <p/>
* Not compatible with {@link #ifSourceETagMatches(String)} or * 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(getIfMatch() == null, "ifETagMatches() is not compatible with ifModifiedSince()");
checkState(getIfUnmodifiedSince() == null, checkState(getIfUnmodifiedSince() == null,
"ifUnmodifiedSince() is not compatible with ifModifiedSince()"); "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. * Only return the object if it hasn't changed since this time.
* <p/> * <p/>
* Not compatible with {@link #ifSourceETagDoesntMatch(String)} or * 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, checkState(getIfNoneMatch() == null,
"ifETagDoesntMatch() is not compatible with ifUnmodifiedSince()"); "ifETagDoesntMatch() is not compatible with ifUnmodifiedSince()");
checkState(getIfModifiedSince() == null, checkState(getIfModifiedSince() == null,
@ -217,7 +218,7 @@ public class CopyObjectOptions extends BaseHttpRequestOptions {
* <p/> * <p/>
* <p/> * <p/>
* Not compatible with {@link #ifSourceETagDoesntMatch(String)} or * Not compatible with {@link #ifSourceETagDoesntMatch(String)} or
* {@link #ifSourceModifiedSince(DateTime)} * {@link #ifSourceModifiedSince(Date)}
* *
* @param eTag * @param eTag
* hash representing the entity * 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 <code>eTag</code>. * The object should not have a eTag hash corresponding with the parameter <code>eTag</code>.
* <p/> * <p/>
* Not compatible with {@link #ifSourceETagMatches(String)} or * Not compatible with {@link #ifSourceETagMatches(String)} or
* {@link #ifSourceUnmodifiedSince(DateTime)} * {@link #ifSourceUnmodifiedSince(Date)}
* *
* @param eTag * @param eTag
* hash representing the entity * hash representing the entity
@ -289,15 +290,15 @@ public class CopyObjectOptions extends BaseHttpRequestOptions {
/** /**
* @see CopyObjectOptions#getIfModifiedSince() * @see CopyObjectOptions#getIfModifiedSince()
*/ */
public static CopyObjectOptions ifSourceModifiedSince(DateTime ifModifiedSince) { public static CopyObjectOptions ifSourceModifiedSince(Date ifModifiedSince) {
CopyObjectOptions options = new CopyObjectOptions(); CopyObjectOptions options = new CopyObjectOptions();
return options.ifSourceModifiedSince(ifModifiedSince); 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(); CopyObjectOptions options = new CopyObjectOptions();
return options.ifSourceUnmodifiedSince(ifUnmodifiedSince); return options.ifSourceUnmodifiedSince(ifUnmodifiedSince);
} }

View File

@ -23,13 +23,14 @@
*/ */
package org.jclouds.aws.s3.xml; package org.jclouds.aws.s3.xml;
import java.util.Date;
import javax.inject.Inject; import javax.inject.Inject;
import org.jclouds.aws.s3.domain.ObjectMetadata; import org.jclouds.aws.s3.domain.ObjectMetadata;
import org.jclouds.aws.s3.domain.internal.CopyObjectResult; import org.jclouds.aws.s3.domain.internal.CopyObjectResult;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.util.DateService; import org.jclouds.util.DateService;
import org.joda.time.DateTime;
/** /**
* Parses the response from Amazon S3 COPY Object command. * Parses the response from Amazon S3 COPY Object command.
@ -45,7 +46,7 @@ public class CopyObjectHandler extends ParseSax.HandlerWithResult<ObjectMetadata
private StringBuilder currentText = new StringBuilder(); private StringBuilder currentText = new StringBuilder();
@Inject @Inject
private DateService dateParser; private DateService dateParser;
private DateTime currentLastModified; private Date currentLastModified;
private String currentETag; private String currentETag;
public ObjectMetadata getResult() { public ObjectMetadata getResult() {

View File

@ -23,6 +23,7 @@
*/ */
package org.jclouds.aws.s3.xml; package org.jclouds.aws.s3.xml;
import java.util.Date;
import java.util.SortedSet; import java.util.SortedSet;
import javax.inject.Inject; import javax.inject.Inject;
@ -31,7 +32,6 @@ import org.jclouds.aws.s3.domain.BucketMetadata;
import org.jclouds.aws.s3.domain.CanonicalUser; import org.jclouds.aws.s3.domain.CanonicalUser;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.util.DateService; import org.jclouds.util.DateService;
import org.joda.time.DateTime;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
@ -53,7 +53,7 @@ public class ListAllMyBucketsHandler extends ParseSax.HandlerWithResult<SortedSe
private final DateService dateParser; private final DateService dateParser;
private String currentName; private String currentName;
private DateTime currentCreationDate; private Date currentCreationDate;
@Inject @Inject
public ListAllMyBucketsHandler(DateService dateParser) { public ListAllMyBucketsHandler(DateService dateParser) {

View File

@ -23,6 +23,7 @@
*/ */
package org.jclouds.aws.s3.xml; package org.jclouds.aws.s3.xml;
import java.util.Date;
import java.util.SortedSet; import java.util.SortedSet;
import javax.inject.Inject; import javax.inject.Inject;
@ -36,7 +37,6 @@ import org.jclouds.aws.s3.domain.internal.TreeSetListBucketResponse;
import org.jclouds.http.HttpUtils; import org.jclouds.http.HttpUtils;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.util.DateService; import org.jclouds.util.DateService;
import org.joda.time.DateTime;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
@ -79,7 +79,7 @@ public class ListBucketHandler extends ParseSax.HandlerWithResult<ListBucketResp
private boolean inCommonPrefixes; private boolean inCommonPrefixes;
private String currentKey; private String currentKey;
private DateTime currentLastModified; private Date currentLastModified;
private String currentETag; private String currentETag;
private byte[] currentMD5; private byte[] currentMD5;
private long currentSize; private long currentSize;

View File

@ -46,6 +46,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URL; import java.net.URL;
import java.util.Date;
import java.util.Map; import java.util.Map;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
@ -66,7 +67,6 @@ import org.jclouds.aws.s3.options.PutObjectOptions;
import org.jclouds.blobstore.integration.internal.BaseBlobStoreIntegrationTest; import org.jclouds.blobstore.integration.internal.BaseBlobStoreIntegrationTest;
import org.jclouds.http.HttpResponseException; import org.jclouds.http.HttpResponseException;
import org.jclouds.util.Utils; import org.jclouds.util.Utils;
import org.joda.time.DateTime;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
@ -369,9 +369,9 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest<S3AsyncClient
String containerName = getContainerName(); String containerName = getContainerName();
String destinationContainer = getContainerName(); String destinationContainer = getContainerName();
try { try {
DateTime before = new DateTime(); Date before = new Date();
addToContainerAndValidate(containerName, sourceKey + "mod"); addToContainerAndValidate(containerName, sourceKey + "mod");
DateTime after = new DateTime().plusSeconds(1); Date after = new Date(System.currentTimeMillis() + 1000);
context.getApi().copyObject(containerName, sourceKey + "mod", destinationContainer, context.getApi().copyObject(containerName, sourceKey + "mod", destinationContainer,
destinationKey, ifSourceModifiedSince(before)); destinationKey, ifSourceModifiedSince(before));
@ -396,9 +396,9 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest<S3AsyncClient
String containerName = getContainerName(); String containerName = getContainerName();
String destinationContainer = getContainerName(); String destinationContainer = getContainerName();
try { try {
DateTime before = new DateTime(); Date before = new Date();
addToContainerAndValidate(containerName, sourceKey + "un"); addToContainerAndValidate(containerName, sourceKey + "un");
DateTime after = new DateTime().plusSeconds(1); Date after = new Date(System.currentTimeMillis() + 1000);
context.getApi().copyObject(containerName, sourceKey + "un", destinationContainer, context.getApi().copyObject(containerName, sourceKey + "un", destinationContainer,
destinationKey, ifSourceUnmodifiedSince(after)); destinationKey, ifSourceUnmodifiedSince(after));
@ -607,7 +607,7 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest<S3AsyncClient
try { try {
SortedSet<BucketMetadata> list = context.getApi().listOwnedBuckets(); SortedSet<BucketMetadata> list = context.getApi().listOwnedBuckets();
BucketMetadata firstContainer = list.first(); BucketMetadata firstContainer = list.first();
BucketMetadata toMatch = new BucketMetadata(containerName, new DateTime(), firstContainer BucketMetadata toMatch = new BucketMetadata(containerName, new Date(), firstContainer
.getOwner()); .getOwner());
assert list.contains(toMatch); assert list.contains(toMatch);
} finally { } finally {

View File

@ -35,8 +35,8 @@ import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.http.functions.config.ParserModule; import org.jclouds.http.functions.config.ParserModule;
import org.jclouds.http.handlers.DelegatingErrorHandler; import org.jclouds.http.handlers.DelegatingErrorHandler;
import org.jclouds.http.handlers.DelegatingRetryHandler; import org.jclouds.http.handlers.DelegatingRetryHandler;
import org.jclouds.util.DateService;
import org.jclouds.util.Jsr330; import org.jclouds.util.Jsr330;
import org.jclouds.util.internal.SimpleDateFormatDateService;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
@ -71,7 +71,7 @@ public class S3RestClientModuleTest {
void testUpdatesOnlyOncePerSecond() throws NoSuchMethodException, InterruptedException { void testUpdatesOnlyOncePerSecond() throws NoSuchMethodException, InterruptedException {
S3RestClientModule module = new S3RestClientModule(); S3RestClientModule module = new S3RestClientModule();
Supplier<String> map = module.provideTimeStampCache(1, new DateService()); Supplier<String> map = module.provideTimeStampCache(1, new SimpleDateFormatDateService());
String timeStamp = map.get(); String timeStamp = map.get();
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
map.get(); map.get();

View File

@ -28,6 +28,7 @@ import static org.easymock.classextension.EasyMock.createMock;
import static org.easymock.classextension.EasyMock.replay; import static org.easymock.classextension.EasyMock.replay;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import java.util.Date;
import java.util.Map; import java.util.Map;
import javax.ws.rs.core.HttpHeaders; 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.blobstore.functions.ParseSystemAndUserMetadataFromHeaders;
import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpResponse;
import org.jclouds.http.HttpUtils; import org.jclouds.http.HttpUtils;
import org.joda.time.DateTime;
import org.testng.annotations.BeforeTest; import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -81,7 +81,7 @@ public class ParseObjectMetadataFromHeadersTest {
assertEquals(response, expects); assertEquals(response, expects);
} }
DateTime now = new DateTime(); Date now = new Date();
Map<String, String> userMetadata = ImmutableMap.of("foo", "bar"); Map<String, String> userMetadata = ImmutableMap.of("foo", "bar");
private MutableObjectMetadataImpl expects; private MutableObjectMetadataImpl expects;
BlobToObjectMetadata blobToObjectMetadata; BlobToObjectMetadata blobToObjectMetadata;

View File

@ -25,6 +25,7 @@ package org.jclouds.aws.s3.internal;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Date;
import java.util.Map; import java.util.Map;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -68,7 +69,6 @@ import org.jclouds.concurrent.FutureFunctionWrapper;
import org.jclouds.http.options.GetOptions; import org.jclouds.http.options.GetOptions;
import org.jclouds.logging.Logger.LoggerFactory; import org.jclouds.logging.Logger.LoggerFactory;
import org.jclouds.util.DateService; import org.jclouds.util.DateService;
import org.joda.time.DateTime;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
@ -168,16 +168,15 @@ public class StubS3AsyncClient implements S3AsyncClient {
blobStore.throwResponseException(412); blobStore.throwResponseException(412);
} }
if (options.getIfModifiedSince() != null) { if (options.getIfModifiedSince() != null) {
DateTime modifiedSince = dateService Date modifiedSince = dateService.rfc822DateParse(options.getIfModifiedSince());
.rfc822DateParse(options.getIfModifiedSince()); if (modifiedSince.after(object.getMetadata().getLastModified()))
if (modifiedSince.isAfter(object.getMetadata().getLastModified()))
blobStore.throwResponseException(412); blobStore.throwResponseException(412);
} }
if (options.getIfUnmodifiedSince() != null) { if (options.getIfUnmodifiedSince() != null) {
DateTime unmodifiedSince = dateService.rfc822DateParse(options Date unmodifiedSince = dateService
.getIfUnmodifiedSince()); .rfc822DateParse(options.getIfUnmodifiedSince());
if (unmodifiedSince.isBefore(object.getMetadata().getLastModified())) if (unmodifiedSince.before(object.getMetadata().getLastModified()))
blobStore.throwResponseException(412); blobStore.throwResponseException(412);
} }
Blob sourceS3 = source.get(sourceObject); Blob sourceS3 = source.get(sourceObject);
@ -186,7 +185,7 @@ public class StubS3AsyncClient implements S3AsyncClient {
if (options.getAcl() != null) if (options.getAcl() != null)
keyToAcl.put(destinationBucket + "/" + destinationObject, options.getAcl()); keyToAcl.put(destinationBucket + "/" + destinationObject, options.getAcl());
newMd.setLastModified(new DateTime()); newMd.setLastModified(new Date());
Blob newBlob = blobProvider.create(newMd); Blob newBlob = blobProvider.create(newMd);
newBlob.setData(sourceS3.getData()); newBlob.setData(sourceS3.getData());
dest.put(destinationObject, newBlob); dest.put(destinationObject, newBlob);

View File

@ -34,12 +34,12 @@ import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.Map; import java.util.Map;
import org.jclouds.aws.s3.domain.CannedAccessPolicy; import org.jclouds.aws.s3.domain.CannedAccessPolicy;
import org.jclouds.aws.s3.reference.S3Headers; import org.jclouds.aws.s3.reference.S3Headers;
import org.jclouds.util.DateService; import org.jclouds.util.internal.SimpleDateFormatDateService;
import org.joda.time.DateTime;
import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -55,7 +55,7 @@ import com.google.common.collect.Multimap;
public class CopyObjectOptionsTest { public class CopyObjectOptionsTest {
private String etag; private String etag;
private DateTime now; private Date now;
private String nowExpected; private String nowExpected;
private Map<String, String> goodMeta; private Map<String, String> goodMeta;
private Map<String, String> badMeta; private Map<String, String> badMeta;
@ -66,9 +66,8 @@ public class CopyObjectOptionsTest {
goodMeta.put("x-amz-meta-adrian", "foo"); goodMeta.put("x-amz-meta-adrian", "foo");
badMeta = Maps.newHashMap(); badMeta = Maps.newHashMap();
badMeta.put("x-google-meta-adrian", "foo"); badMeta.put("x-google-meta-adrian", "foo");
now = new Date();
now = new DateTime(); nowExpected = new SimpleDateFormatDateService().rfc822DateFormat(now);
nowExpected = new DateService().rfc822DateFormat(now);
etag = "mama"; etag = "mama";
} }
@ -288,7 +287,7 @@ public class CopyObjectOptionsTest {
Multimap<String, String> headers = options.buildRequestHeaders(); Multimap<String, String> headers = options.buildRequestHeaders();
assertEquals(headers.get("x-amz-copy-source-if-modified-since").iterator().next(), 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 assertEquals(headers.get("x-amz-copy-source-if-none-match").iterator().next(), "\"" + etag
+ "\""); + "\"");
for (String value : goodMeta.values()) for (String value : goodMeta.values())

View File

@ -31,6 +31,7 @@ import org.jclouds.aws.s3.domain.ObjectMetadata;
import org.jclouds.aws.s3.domain.internal.CopyObjectResult; import org.jclouds.aws.s3.domain.internal.CopyObjectResult;
import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.util.DateService; import org.jclouds.util.DateService;
import org.jclouds.util.internal.SimpleDateFormatDateService;
import org.testng.annotations.BeforeTest; import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -54,8 +55,9 @@ public class CopyObjectHandlerTest extends BaseHandlerTest {
public void testApplyInputStream() { public void testApplyInputStream() {
InputStream is = getClass().getResourceAsStream("/s3/copy_object.xml"); InputStream is = getClass().getResourceAsStream("/s3/copy_object.xml");
ObjectMetadata expected = new CopyObjectResult(new DateService() ObjectMetadata expected = new CopyObjectResult(new SimpleDateFormatDateService()
.iso8601DateParse("2009-03-19T13:23:27.000Z"), "\"92836a3ea45a6984d1b4d23a747d46bb\""); .iso8601DateParse("2009-03-19T13:23:27.000Z"),
"\"92836a3ea45a6984d1b4d23a747d46bb\"");
ObjectMetadata result = (ObjectMetadata) factory.create( ObjectMetadata result = (ObjectMetadata) factory.create(
injector.getInstance(CopyObjectHandler.class)).parse(is); injector.getInstance(CopyObjectHandler.class)).parse(is);

View File

@ -27,6 +27,7 @@ import static org.testng.Assert.assertEquals;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.CompletionService; 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.HttpException;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.config.ParserModule; 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.AfterTest;
import org.testng.annotations.BeforeTest; import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -109,13 +110,13 @@ public class S3ParserTest extends PerformanceTest {
SortedSet<BucketMetadata> s3Buckets = runParseListAllMyBuckets(); SortedSet<BucketMetadata> s3Buckets = runParseListAllMyBuckets();
BucketMetadata container1 = s3Buckets.first(); BucketMetadata container1 = s3Buckets.first();
assert container1.getName().equals("adrianjbosstest"); assert container1.getName().equals("adrianjbosstest");
DateTime expectedDate1 = new DateTime("2009-03-12T02:00:07.000Z"); Date expectedDate1 = new SimpleDateFormatDateService().iso8601DateParse("2009-03-12T02:00:07.000Z");
DateTime date1 = container1.getCreationDate(); Date date1 = container1.getCreationDate();
assert date1.equals(expectedDate1); assert date1.equals(expectedDate1);
BucketMetadata container2 = (BucketMetadata) s3Buckets.toArray()[1]; BucketMetadata container2 = (BucketMetadata) s3Buckets.toArray()[1];
assert container2.getName().equals("adrianjbosstest2"); assert container2.getName().equals("adrianjbosstest2");
DateTime expectedDate2 = new DateTime("2009-03-12T02:00:09.000Z"); Date expectedDate2 = new SimpleDateFormatDateService().iso8601DateParse("2009-03-12T02:00:09.000Z");
DateTime date2 = container2.getCreationDate(); Date date2 = container2.getCreationDate();
assert date2.equals(expectedDate2); assert date2.equals(expectedDate2);
assert s3Buckets.size() == 2; assert s3Buckets.size() == 2;
CanonicalUser owner = new CanonicalUser( CanonicalUser owner = new CanonicalUser(
@ -133,7 +134,7 @@ public class S3ParserTest extends PerformanceTest {
assert container.size() == 1; assert container.size() == 1;
ObjectMetadata object = container.iterator().next(); ObjectMetadata object = container.iterator().next();
assert object.getKey().equals("3366"); 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( assert object.getLastModified().equals(expected) : String.format(
"expected %1$s, but got %1$s", expected, object.getLastModified()); "expected %1$s, but got %1$s", expected, object.getLastModified());
assertEquals(object.getETag(), "\"9d7bb64e8e18ee34eec06dd2cf37b766\""); assertEquals(object.getETag(), "\"9d7bb64e8e18ee34eec06dd2cf37b766\"");
@ -159,7 +160,8 @@ public class S3ParserTest extends PerformanceTest {
public void testCanParseCopyObjectResult() throws HttpException, UnsupportedEncodingException { public void testCanParseCopyObjectResult() throws HttpException, UnsupportedEncodingException {
ObjectMetadata metadata = runParseCopyObjectResult(); 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.getLastModified(), expected);
assertEquals(metadata.getETag(), "\"92836a3ea45a6984d1b4d23a747d46bb\""); assertEquals(metadata.getETag(), "\"92836a3ea45a6984d1b4d23a747d46bb\"");
} }

View File

@ -47,6 +47,11 @@
</properties> </properties>
<dependencies> <dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jclouds-blobstore</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>jclouds-azure</artifactId> <artifactId>jclouds-azure</artifactId>

View File

@ -108,7 +108,7 @@ public class JCloudsS3Service extends S3Service {
Map map = new HashMap(); Map map = new HashMap();
// Result fields returned when copy is successful. // 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()); map.put("ETag", jcObjectMetadata.getETag());
return map; return map;
} catch (Exception e) { } catch (Exception e) {

View File

@ -46,6 +46,7 @@ import org.jclouds.aws.s3.options.ListBucketOptions;
import org.jclouds.aws.s3.options.PutObjectOptions; import org.jclouds.aws.s3.options.PutObjectOptions;
import org.jclouds.http.options.GetOptions; import org.jclouds.http.options.GetOptions;
import org.jclouds.util.DateService; import org.jclouds.util.DateService;
import org.jclouds.util.internal.SimpleDateFormatDateService;
import org.jets3t.service.S3ServiceException; import org.jets3t.service.S3ServiceException;
import org.jets3t.service.acl.AccessControlList; import org.jets3t.service.acl.AccessControlList;
import org.jets3t.service.acl.CanonicalGrantee; 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.S3Object;
import org.jets3t.service.model.S3Owner; import org.jets3t.service.model.S3Owner;
import org.jets3t.service.utils.RestUtils; import org.jets3t.service.utils.RestUtils;
import org.joda.time.DateTime;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
@ -104,11 +104,11 @@ public class Util {
jsObject.setContentLength(jcObjectMD.getSize()); jsObject.setContentLength(jcObjectMD.getSize());
jsObject.setContentDisposition(jcObjectMD.getContentDisposition()); jsObject.setContentDisposition(jcObjectMD.getContentDisposition());
jsObject.setContentEncoding(jcObjectMD.getContentEncoding()); jsObject.setContentEncoding(jcObjectMD.getContentEncoding());
jsObject.setLastModifiedDate(jcObjectMD.getLastModified().toDate()); jsObject.setLastModifiedDate(jcObjectMD.getLastModified());
jsObject.setETag(jcObjectMD.getETag()); jsObject.setETag(jcObjectMD.getETag());
jsObject.setMd5Hash(jcObjectMD.getContentMD5()); jsObject.setMd5Hash(jcObjectMD.getContentMD5());
jsObject.addAllMetadata(jcObjectMD.getUserMetadata()); jsObject.addAllMetadata(jcObjectMD.getUserMetadata());
jsObject.addMetadata(S3Object.METADATA_HEADER_DATE, jcObjectMD.getLastModified().toDate()); jsObject.addMetadata(S3Object.METADATA_HEADER_DATE, jcObjectMD.getLastModified());
return jsObject; return jsObject;
} }
@ -135,7 +135,7 @@ public class Util {
jcObject.getMetadata().setCacheControl((String) jsObject.getMetadata("Cache-Control")); jcObject.getMetadata().setCacheControl((String) jsObject.getMetadata("Cache-Control"));
jcObject.getMetadata().setContentDisposition(jsObject.getContentDisposition()); jcObject.getMetadata().setContentDisposition(jsObject.getContentDisposition());
jcObject.getMetadata().setContentEncoding(jsObject.getContentEncoding()); jcObject.getMetadata().setContentEncoding(jsObject.getContentEncoding());
jcObject.getMetadata().setLastModified(new DateTime(jsObject.getLastModifiedDate())); jcObject.getMetadata().setLastModified(jsObject.getLastModifiedDate());
jcObject.setContentLength(jsObject.getContentLength()); jcObject.setContentLength(jsObject.getContentLength());
if (jsObject.getStorageClass() != null) if (jsObject.getStorageClass() != null)
jcObject.getMetadata().setStorageClass(StorageClass.valueOf(jsObject.getStorageClass())); jcObject.getMetadata().setStorageClass(StorageClass.valueOf(jsObject.getStorageClass()));
@ -163,7 +163,7 @@ public class Util {
} }
// User metadata // User metadata
DateService dateService = new DateService(); DateService dateService = new SimpleDateFormatDateService();
for (Object maybeUserMetadataObj : jsObject.getMetadataMap().entrySet()) { for (Object maybeUserMetadataObj : jsObject.getMetadataMap().entrySet()) {
String name = ((Entry<String, Object>) maybeUserMetadataObj).getKey(); String name = ((Entry<String, Object>) maybeUserMetadataObj).getKey();
Object value = ((Entry<String, Object>) maybeUserMetadataObj).getValue(); Object value = ((Entry<String, Object>) maybeUserMetadataObj).getValue();
@ -183,10 +183,10 @@ public class Util {
throws UnsupportedEncodingException { throws UnsupportedEncodingException {
GetOptions options = new GetOptions(); GetOptions options = new GetOptions();
if (ifModifiedSince != null) { if (ifModifiedSince != null) {
options.ifModifiedSince(new DateTime(ifModifiedSince)); options.ifModifiedSince(ifModifiedSince.getTime());
} }
if (ifUnmodifiedSince != null) { if (ifUnmodifiedSince != null) {
options.ifUnmodifiedSince(new DateTime(ifUnmodifiedSince)); options.ifUnmodifiedSince(ifUnmodifiedSince.getTime());
} }
// TODO: options.ifETagMatches should accept multiple match tags // TODO: options.ifETagMatches should accept multiple match tags
if (ifMatchTags != null && ifMatchTags.length > 0) { if (ifMatchTags != null && ifMatchTags.length > 0) {
@ -331,10 +331,10 @@ public class Util {
options.overrideAcl(convertACLToCannedAccessPolicy(acl)); options.overrideAcl(convertACLToCannedAccessPolicy(acl));
} }
if (ifModifiedSince != null) { if (ifModifiedSince != null) {
options.ifSourceModifiedSince(new DateTime(ifModifiedSince)); options.ifSourceModifiedSince(ifModifiedSince.getTime());
} }
if (ifUnmodifiedSince != null) { if (ifUnmodifiedSince != null) {
options.ifSourceUnmodifiedSince(new DateTime(ifUnmodifiedSince)); options.ifSourceUnmodifiedSince(ifUnmodifiedSince.getTime());
} }
// TODO: options.ifETagMatches should accept multiple match tags // TODO: options.ifETagMatches should accept multiple match tags
if (ifMatchTags != null && ifMatchTags.length > 0) { if (ifMatchTags != null && ifMatchTags.length > 0) {

View File

@ -34,7 +34,7 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorCompletionService; import java.util.concurrent.ExecutorCompletionService;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.joda.time.DateTime; import org.jclouds.util.internal.SimpleDateFormatDateService;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
@ -103,12 +103,14 @@ public class S3ParserTest extends org.jclouds.aws.s3.xml.S3ParserTest {
List<Bucket> buckets = response.entries; List<Bucket> buckets = response.entries;
Bucket bucket1 = (Bucket) buckets.get(0); Bucket bucket1 = (Bucket) buckets.get(0);
assert bucket1.name.equals("adrianjbosstest"); 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; Date date1 = bucket1.creationDate;
assert date1.toString().equals(expectedDate1.toString()); assert date1.toString().equals(expectedDate1.toString());
Bucket bucket2 = (Bucket) buckets.get(1); Bucket bucket2 = (Bucket) buckets.get(1);
assert bucket2.name.equals("adrianjbosstest2"); 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; Date date2 = bucket2.creationDate;
assert date2.toString().equals(expectedDate2.toString()); assert date2.toString().equals(expectedDate2.toString());
assert buckets.size() == 2; assert buckets.size() == 2;
@ -125,7 +127,8 @@ public class S3ParserTest extends org.jclouds.aws.s3.xml.S3ParserTest {
ListBucketResponse response = runAmazonParseListBucketResult(); ListBucketResponse response = runAmazonParseListBucketResult();
ListEntry content = (ListEntry) response.entries.get(0); ListEntry content = (ListEntry) response.entries.get(0);
assert content.key.equals("3366"); 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.eTag.equals("\"9d7bb64e8e18ee34eec06dd2cf37b766\"");
assert content.size == 136; assert content.size == 136;
assert content.owner.id assert content.owner.id

View File

@ -24,8 +24,7 @@
package org.jclouds.azure.storage.blob.domain; package org.jclouds.azure.storage.blob.domain;
import java.net.URI; import java.net.URI;
import java.util.Date;
import org.joda.time.DateTime;
/** /**
* *
@ -37,7 +36,7 @@ public interface ListableBlobProperties extends Comparable<ListableBlobPropertie
String getName(); String getName();
DateTime getLastModified(); Date getLastModified();
String getETag(); String getETag();

View File

@ -24,8 +24,7 @@
package org.jclouds.azure.storage.blob.domain; package org.jclouds.azure.storage.blob.domain;
import java.net.URI; import java.net.URI;
import java.util.Date;
import org.joda.time.DateTime;
/** /**
* *
@ -37,7 +36,7 @@ public interface ListableContainerProperties extends Comparable<ListableContaine
String getName(); String getName();
DateTime getLastModified(); Date getLastModified();
String getETag(); String getETag();
} }

View File

@ -24,10 +24,10 @@
package org.jclouds.azure.storage.blob.domain; package org.jclouds.azure.storage.blob.domain;
import java.net.URI; import java.net.URI;
import java.util.Date;
import java.util.Map; import java.util.Map;
import org.jclouds.azure.storage.blob.domain.internal.MutableBlobPropertiesImpl; import org.jclouds.azure.storage.blob.domain.internal.MutableBlobPropertiesImpl;
import org.joda.time.DateTime;
import com.google.inject.ImplementedBy; import com.google.inject.ImplementedBy;
@ -51,7 +51,7 @@ public interface MutableBlobProperties extends BlobProperties {
/** /**
* @see ListableContainerProperties#setLastModified * @see ListableContainerProperties#setLastModified
*/ */
void setLastModified(DateTime lastModified); void setLastModified(Date lastModified);
/** /**
* @see ListableContainerProperties#setETag * @see ListableContainerProperties#setETag

View File

@ -24,10 +24,10 @@
package org.jclouds.azure.storage.blob.domain; package org.jclouds.azure.storage.blob.domain;
import java.net.URI; import java.net.URI;
import java.util.Date;
import java.util.Map; import java.util.Map;
import org.jclouds.azure.storage.blob.domain.internal.MutableContainerPropertiesWithMetadataImpl; import org.jclouds.azure.storage.blob.domain.internal.MutableContainerPropertiesWithMetadataImpl;
import org.joda.time.DateTime;
import com.google.inject.ImplementedBy; import com.google.inject.ImplementedBy;
@ -51,7 +51,7 @@ public interface MutableContainerPropertiesWithMetadata extends ContainerPropert
/** /**
* @see ListableContainerProperties#setLastModified * @see ListableContainerProperties#setLastModified
*/ */
void setLastModified(DateTime lastModified); void setLastModified(Date lastModified);
/** /**
* @see ListableContainerProperties#setETag * @see ListableContainerProperties#setETag

View File

@ -27,9 +27,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.io.Serializable; import java.io.Serializable;
import java.net.URI; import java.net.URI;
import java.util.Date;
import org.jclouds.azure.storage.blob.domain.ListableBlobProperties; import org.jclouds.azure.storage.blob.domain.ListableBlobProperties;
import org.joda.time.DateTime;
import com.google.inject.internal.Nullable; import com.google.inject.internal.Nullable;
@ -45,14 +45,14 @@ public class ListableBlobPropertiesImpl implements Serializable, ListableBlobPro
private final String name; private final String name;
private final URI url; private final URI url;
private final DateTime lastModified; private final Date lastModified;
private final String eTag; private final String eTag;
private final long size; private final long size;
private final String contentType; private final String contentType;
private final String contentEncoding; private final String contentEncoding;
private final String contentLanguage; 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, long size, String contentType, @Nullable String contentEncoding,
@Nullable String contentLanguage) { @Nullable String contentLanguage) {
this.name = checkNotNull(name, "name"); this.name = checkNotNull(name, "name");
@ -89,7 +89,7 @@ public class ListableBlobPropertiesImpl implements Serializable, ListableBlobPro
/** /**
*{@inheritDoc} *{@inheritDoc}
*/ */
public DateTime getLastModified() { public Date getLastModified() {
return lastModified; return lastModified;
} }

View File

@ -27,9 +27,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.io.Serializable; import java.io.Serializable;
import java.net.URI; import java.net.URI;
import java.util.Date;
import org.jclouds.azure.storage.blob.domain.ListableContainerProperties; import org.jclouds.azure.storage.blob.domain.ListableContainerProperties;
import org.joda.time.DateTime;
/** /**
* Allows you to manipulate metadata. * Allows you to manipulate metadata.
@ -43,10 +43,10 @@ public class ListableContainerPropertiesImpl implements Serializable, ListableCo
private final String name; private final String name;
private final URI url; private final URI url;
private final DateTime lastModified; private final Date lastModified;
private final String eTag; 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.url = checkNotNull(url, "url");
this.name = checkNotNull(url.getPath(), "url.getPath()").replaceFirst("/", ""); this.name = checkNotNull(url.getPath(), "url.getPath()").replaceFirst("/", "");
this.lastModified = checkNotNull(lastModified, "lastModified"); this.lastModified = checkNotNull(lastModified, "lastModified");
@ -63,7 +63,7 @@ public class ListableContainerPropertiesImpl implements Serializable, ListableCo
/** /**
*{@inheritDoc} *{@inheritDoc}
*/ */
public DateTime getLastModified() { public Date getLastModified() {
return lastModified; return lastModified;
} }

View File

@ -26,11 +26,11 @@ package org.jclouds.azure.storage.blob.domain.internal;
import java.io.Serializable; import java.io.Serializable;
import java.net.URI; import java.net.URI;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date;
import java.util.Map; import java.util.Map;
import org.jclouds.azure.storage.blob.domain.ListableBlobProperties; import org.jclouds.azure.storage.blob.domain.ListableBlobProperties;
import org.jclouds.azure.storage.blob.domain.MutableBlobProperties; import org.jclouds.azure.storage.blob.domain.MutableBlobProperties;
import org.joda.time.DateTime;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
@ -46,7 +46,7 @@ public class MutableBlobPropertiesImpl implements Serializable, MutableBlobPrope
private String name; private String name;
private URI url; private URI url;
private DateTime lastModified; private Date lastModified;
private String eTag; private String eTag;
private long size; private long size;
private String contentType; private String contentType;
@ -82,7 +82,7 @@ public class MutableBlobPropertiesImpl implements Serializable, MutableBlobPrope
/** /**
*{@inheritDoc} *{@inheritDoc}
*/ */
public DateTime getLastModified() { public Date getLastModified() {
return lastModified; return lastModified;
} }
@ -169,7 +169,7 @@ public class MutableBlobPropertiesImpl implements Serializable, MutableBlobPrope
/** /**
*{@inheritDoc} *{@inheritDoc}
*/ */
public void setLastModified(DateTime lastModified) { public void setLastModified(Date lastModified) {
this.lastModified = lastModified; this.lastModified = lastModified;
} }

View File

@ -25,11 +25,11 @@ package org.jclouds.azure.storage.blob.domain.internal;
import java.io.Serializable; import java.io.Serializable;
import java.net.URI; import java.net.URI;
import java.util.Date;
import java.util.Map; import java.util.Map;
import org.jclouds.azure.storage.blob.domain.ListableContainerProperties; import org.jclouds.azure.storage.blob.domain.ListableContainerProperties;
import org.jclouds.azure.storage.blob.domain.MutableContainerPropertiesWithMetadata; import org.jclouds.azure.storage.blob.domain.MutableContainerPropertiesWithMetadata;
import org.joda.time.DateTime;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
@ -38,14 +38,15 @@ import com.google.common.collect.Maps;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class MutableContainerPropertiesWithMetadataImpl implements Serializable, MutableContainerPropertiesWithMetadata { public class MutableContainerPropertiesWithMetadataImpl implements Serializable,
MutableContainerPropertiesWithMetadata {
/** The serialVersionUID */ /** The serialVersionUID */
private static final long serialVersionUID = -4648755473986695062L; private static final long serialVersionUID = -4648755473986695062L;
private String name; private String name;
private URI url; private URI url;
private DateTime lastModified; private Date lastModified;
private String eTag; private String eTag;
private Map<String, String> metadata = Maps.newHashMap(); private Map<String, String> metadata = Maps.newHashMap();
@ -59,10 +60,11 @@ public class MutableContainerPropertiesWithMetadataImpl implements Serializable,
public String getName() { public String getName() {
return name; return name;
} }
/** /**
*{@inheritDoc} *{@inheritDoc}
*/ */
public DateTime getLastModified() { public Date getLastModified() {
return lastModified; return lastModified;
} }
@ -73,7 +75,6 @@ public class MutableContainerPropertiesWithMetadataImpl implements Serializable,
return eTag; return eTag;
} }
/** /**
*{@inheritDoc} *{@inheritDoc}
*/ */
@ -105,7 +106,7 @@ public class MutableContainerPropertiesWithMetadataImpl implements Serializable,
/** /**
*{@inheritDoc} *{@inheritDoc}
*/ */
public void setLastModified(DateTime lastModified) { public void setLastModified(Date lastModified) {
this.lastModified = lastModified; this.lastModified = lastModified;
} }

View File

@ -24,6 +24,7 @@
package org.jclouds.azure.storage.blob.xml; package org.jclouds.azure.storage.blob.xml;
import java.net.URI; import java.net.URI;
import java.util.Date;
import java.util.SortedSet; import java.util.SortedSet;
import javax.inject.Inject; 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.azure.storage.domain.internal.BoundedTreeSet;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.util.DateService; import org.jclouds.util.DateService;
import org.joda.time.DateTime;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
@ -55,7 +55,7 @@ public class AccountNameEnumerationResultsHandler extends
private int maxResults; private int maxResults;
private String nextMarker; private String nextMarker;
private URI currentUrl; private URI currentUrl;
private DateTime currentLastModified; private Date currentLastModified;
private String currentETag; private String currentETag;
private StringBuilder currentText = new StringBuilder(); private StringBuilder currentText = new StringBuilder();
@ -68,8 +68,8 @@ public class AccountNameEnumerationResultsHandler extends
} }
public BoundedSortedSet<ListableContainerProperties> getResult() { public BoundedSortedSet<ListableContainerProperties> getResult() {
return new BoundedTreeSet<ListableContainerProperties>(containerMetadata, currentUrl, prefix, marker, return new BoundedTreeSet<ListableContainerProperties>(containerMetadata, currentUrl, prefix,
maxResults, nextMarker); marker, maxResults, nextMarker);
} }
public void endElement(String uri, String name, String qName) { public void endElement(String uri, String name, String qName) {

View File

@ -24,6 +24,7 @@
package org.jclouds.azure.storage.blob.xml; package org.jclouds.azure.storage.blob.xml;
import java.net.URI; import java.net.URI;
import java.util.Date;
import java.util.SortedSet; import java.util.SortedSet;
import javax.inject.Inject; 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.HttpUtils;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.util.DateService; import org.jclouds.util.DateService;
import org.joda.time.DateTime;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
@ -59,7 +59,7 @@ public class ContainerNameEnumerationResultsHandler extends
private String nextMarker; private String nextMarker;
private URI currentUrl; private URI currentUrl;
private URI containerUrl; private URI containerUrl;
private DateTime currentLastModified; private Date currentLastModified;
private String currentETag; private String currentETag;
private StringBuilder currentText = new StringBuilder(); private StringBuilder currentText = new StringBuilder();

View File

@ -26,6 +26,7 @@ package org.jclouds.azure.storage.blob.internal;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Date;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutionException; 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.concurrent.FutureFunctionWrapper;
import org.jclouds.http.options.GetOptions; import org.jclouds.http.options.GetOptions;
import org.jclouds.logging.Logger.LoggerFactory; import org.jclouds.logging.Logger.LoggerFactory;
import org.joda.time.DateTime;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
@ -176,7 +176,7 @@ public class StubAzureBlobAsyncClient implements AzureBlobAsyncClient {
new Function<String, ListableContainerProperties>() { new Function<String, ListableContainerProperties>() {
public ListableContainerProperties apply(String name) { public ListableContainerProperties apply(String name) {
return new ListableContainerPropertiesImpl(URI.create("http://stub/" return new ListableContainerPropertiesImpl(URI.create("http://stub/"
+ name), new DateTime(), ""); + name), new Date(), "");
} }
}), null, null, null, null, null); }), null, null, null, null, null);

View File

@ -37,8 +37,8 @@ import org.jclouds.http.functions.config.ParserModule;
import org.jclouds.http.handlers.DelegatingErrorHandler; import org.jclouds.http.handlers.DelegatingErrorHandler;
import org.jclouds.http.handlers.DelegatingRetryHandler; import org.jclouds.http.handlers.DelegatingRetryHandler;
import org.jclouds.http.handlers.RedirectionRetryHandler; import org.jclouds.http.handlers.RedirectionRetryHandler;
import org.jclouds.util.DateService;
import org.jclouds.util.Jsr330; import org.jclouds.util.Jsr330;
import org.jclouds.util.internal.SimpleDateFormatDateService;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
@ -69,7 +69,7 @@ public class AzureStorageRestClientModuleTest {
void testUpdatesOnlyOncePerSecond() throws NoSuchMethodException, InterruptedException { void testUpdatesOnlyOncePerSecond() throws NoSuchMethodException, InterruptedException {
AzureStorageRestClientModule module = new AzureStorageRestClientModule(); AzureStorageRestClientModule module = new AzureStorageRestClientModule();
Supplier<String> map = module.provideTimeStampCache(1, new DateService()); Supplier<String> map = module.provideTimeStampCache(1, new SimpleDateFormatDateService());
String timeStamp = map.get(); String timeStamp = map.get();
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
map.get(); map.get();

View File

@ -24,10 +24,10 @@
package org.jclouds.blobstore.domain; package org.jclouds.blobstore.domain;
import java.net.URI; import java.net.URI;
import java.util.Date;
import java.util.Map; import java.util.Map;
import org.jclouds.blobstore.domain.internal.MutableResourceMetadataImpl; import org.jclouds.blobstore.domain.internal.MutableResourceMetadataImpl;
import org.joda.time.DateTime;
import com.google.inject.ImplementedBy; 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#BLOB_LAST_MODIFIED
* @see org.jclouds.blobstore.attr.ContainerCapability#MILLISECOND_PRECISION * @see org.jclouds.blobstore.attr.ContainerCapability#MILLISECOND_PRECISION
*/ */
void setLastModified(DateTime lastModified); void setLastModified(Date lastModified);
/** /**
* Any key-value pairs associated with the resource. * Any key-value pairs associated with the resource.

View File

@ -24,10 +24,10 @@
package org.jclouds.blobstore.domain; package org.jclouds.blobstore.domain;
import java.net.URI; import java.net.URI;
import java.util.Date;
import java.util.Map; import java.util.Map;
import org.jclouds.blobstore.domain.internal.ResourceMetadataImpl; import org.jclouds.blobstore.domain.internal.ResourceMetadataImpl;
import org.joda.time.DateTime;
import com.google.inject.ImplementedBy; import com.google.inject.ImplementedBy;
@ -79,7 +79,7 @@ public interface ResourceMetadata extends Comparable<ResourceMetadata> {
* @see org.jclouds.blobstore.attr.ContainerCapability#CONTAINER_SIZE * @see org.jclouds.blobstore.attr.ContainerCapability#CONTAINER_SIZE
* @see org.jclouds.blobstore.attr.ContainerCapability#BLOB_SIZE * @see org.jclouds.blobstore.attr.ContainerCapability#BLOB_SIZE
*/ */
public Long getSize(); Long getSize();
/** /**
* Last modification time of the resource * Last modification time of the resource
@ -88,7 +88,7 @@ public interface ResourceMetadata extends Comparable<ResourceMetadata> {
* @see org.jclouds.blobstore.attr.ContainerCapability#BLOB_LAST_MODIFIED * @see org.jclouds.blobstore.attr.ContainerCapability#BLOB_LAST_MODIFIED
* @see org.jclouds.blobstore.attr.ContainerCapability#MILLISECOND_PRECISION * @see org.jclouds.blobstore.attr.ContainerCapability#MILLISECOND_PRECISION
*/ */
public DateTime getLastModified(); Date getLastModified();
/** /**
* Any key-value pairs associated with the resource. * Any key-value pairs associated with the resource.
@ -98,6 +98,4 @@ public interface ResourceMetadata extends Comparable<ResourceMetadata> {
*/ */
Map<String, String> getUserMetadata(); Map<String, String> getUserMetadata();
} }

View File

@ -25,12 +25,12 @@ package org.jclouds.blobstore.domain.internal;
import java.io.Serializable; import java.io.Serializable;
import java.net.URI; import java.net.URI;
import java.util.Date;
import java.util.Map; import java.util.Map;
import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.Blob;
import org.jclouds.blobstore.domain.BlobMetadata; import org.jclouds.blobstore.domain.BlobMetadata;
import org.jclouds.blobstore.domain.ResourceType; import org.jclouds.blobstore.domain.ResourceType;
import org.joda.time.DateTime;
/** /**
* System and user Metadata for the {@link Blob}. * 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 String contentType;
private final byte[] contentMD5; private final byte[] contentMD5;
public BlobMetadataImpl(String id, String name, URI location, String eTag, public BlobMetadataImpl(String id, String name, URI location, String eTag, Long size,
Long size, DateTime lastModified, Map<String, String> userMetadata, String contentType, Date lastModified, Map<String, String> userMetadata, String contentType,
byte[] contentMD5) { byte[] contentMD5) {
super(ResourceType.BLOB, id, name, location, eTag, size, lastModified, userMetadata); super(ResourceType.BLOB, id, name, location, eTag, size, lastModified, userMetadata);
this.contentType = contentType; this.contentType = contentType;

View File

@ -25,12 +25,12 @@ package org.jclouds.blobstore.domain.internal;
import java.io.Serializable; import java.io.Serializable;
import java.net.URI; import java.net.URI;
import java.util.Date;
import java.util.Map; import java.util.Map;
import org.jclouds.blobstore.domain.MutableResourceMetadata; import org.jclouds.blobstore.domain.MutableResourceMetadata;
import org.jclouds.blobstore.domain.ResourceMetadata; import org.jclouds.blobstore.domain.ResourceMetadata;
import org.jclouds.blobstore.domain.ResourceType; import org.jclouds.blobstore.domain.ResourceType;
import org.joda.time.DateTime;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
@ -50,7 +50,7 @@ public class MutableResourceMetadataImpl implements MutableResourceMetadata, Ser
private URI location; private URI location;
private String eTag; private String eTag;
private Long size; private Long size;
private DateTime lastModified; private Date lastModified;
private Map<String, String> userMetadata; private Map<String, String> userMetadata;
public MutableResourceMetadataImpl() { public MutableResourceMetadataImpl() {
@ -98,7 +98,7 @@ public class MutableResourceMetadataImpl implements MutableResourceMetadata, Ser
return size; return size;
} }
public DateTime getLastModified() { public Date getLastModified() {
return lastModified; return lastModified;
} }
@ -173,7 +173,7 @@ public class MutableResourceMetadataImpl implements MutableResourceMetadata, Ser
return true; return true;
} }
public void setLastModified(DateTime lastModified) { public void setLastModified(Date lastModified) {
this.lastModified = lastModified; this.lastModified = lastModified;
} }

View File

@ -27,11 +27,11 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.io.Serializable; import java.io.Serializable;
import java.net.URI; import java.net.URI;
import java.util.Date;
import java.util.Map; import java.util.Map;
import org.jclouds.blobstore.domain.ResourceMetadata; import org.jclouds.blobstore.domain.ResourceMetadata;
import org.jclouds.blobstore.domain.ResourceType; import org.jclouds.blobstore.domain.ResourceType;
import org.joda.time.DateTime;
import com.google.inject.internal.Nullable; import com.google.inject.internal.Nullable;
@ -57,12 +57,12 @@ public class ResourceMetadataImpl implements ResourceMetadata, Serializable {
private final @Nullable private final @Nullable
Long size; Long size;
private final @Nullable private final @Nullable
DateTime lastModified; Date lastModified;
private final Map<String, String> userMetadata; private final Map<String, String> userMetadata;
public ResourceMetadataImpl(ResourceType type, @Nullable String id, @Nullable String name, public ResourceMetadataImpl(ResourceType type, @Nullable String id, @Nullable String name,
@Nullable URI location, @Nullable String eTag, @Nullable Long size, @Nullable URI location, @Nullable String eTag, @Nullable Long size,
@Nullable DateTime lastModified, Map<String, String> userMetadata) { @Nullable Date lastModified, Map<String, String> userMetadata) {
this.type = checkNotNull(type, "type"); this.type = checkNotNull(type, "type");
this.id = id; this.id = id;
this.name = name; this.name = name;
@ -103,7 +103,7 @@ public class ResourceMetadataImpl implements ResourceMetadata, Serializable {
return size; return size;
} }
public DateTime getLastModified() { public Date getLastModified() {
return lastModified; return lastModified;
} }

View File

@ -23,11 +23,12 @@
*/ */
package org.jclouds.blobstore.functions; package org.jclouds.blobstore.functions;
import java.util.Date;
import javax.inject.Inject; import javax.inject.Inject;
import org.jclouds.blobstore.options.GetOptions; import org.jclouds.blobstore.options.GetOptions;
import org.jclouds.util.DateService; import org.jclouds.util.DateService;
import org.joda.time.DateTime;
import com.google.common.base.Function; import com.google.common.base.Function;
@ -47,14 +48,14 @@ public class HttpGetOptionsListToGetOptions implements
to.ifETagMatches(from[0].getIfMatch().replaceAll("\"", "")); to.ifETagMatches(from[0].getIfMatch().replaceAll("\"", ""));
} }
if (from[0].getIfModifiedSince() != null) { if (from[0].getIfModifiedSince() != null) {
DateTime time = dateService.rfc822DateParse(from[0].getIfModifiedSince()); Date time = dateService.rfc822DateParse(from[0].getIfModifiedSince());
to.ifModifiedSince(time); to.ifModifiedSince(time);
} }
if (from[0].getIfNoneMatch() != null) { if (from[0].getIfNoneMatch() != null) {
to.ifETagDoesntMatch(from[0].getIfNoneMatch().replaceAll("\"", "")); to.ifETagDoesntMatch(from[0].getIfNoneMatch().replaceAll("\"", ""));
} }
if (from[0].getIfUnmodifiedSince() != null) { if (from[0].getIfUnmodifiedSince() != null) {
DateTime time = dateService.rfc822DateParse(from[0].getIfUnmodifiedSince()); Date time = dateService.rfc822DateParse(from[0].getIfUnmodifiedSince());
to.ifUnmodifiedSince(time); to.ifUnmodifiedSince(time);
} }
for (String range : from[0].getRanges()) { for (String range : from[0].getRanges()) {

View File

@ -23,14 +23,14 @@
*/ */
package org.jclouds.blobstore.options; 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.io.UnsupportedEncodingException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import org.joda.time.DateTime;
/** /**
* Contains options supported for HTTP GET operations. <h2> * Contains options supported for HTTP GET operations. <h2>
* Usage</h2> The recommended way to instantiate a GetObjectOptions object is to statically import * Usage</h2> 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 * // this will get the first megabyte of an object, provided it wasn't modified since yesterday
* Future<S3Object> object = client.get("objectName",range(0,1024).ifUnmodifiedSince(new DateTime().minusDays(1))); * Future<S3Object> object = client.get("objectName",range(0,1024).ifUnmodifiedSince(new Date().minusDays(1)));
* <code> * <code>
* *
* @author Adrian Cole * @author Adrian Cole
@ -50,8 +50,8 @@ import org.joda.time.DateTime;
*/ */
public class GetOptions { public class GetOptions {
private final List<String> ranges = new ArrayList<String>(); private final List<String> ranges = new ArrayList<String>();
private DateTime ifModifiedSince; private Date ifModifiedSince;
private DateTime ifUnmodifiedSince; private Date ifUnmodifiedSince;
private String ifMatch; private String ifMatch;
private String ifNoneMatch; private String ifNoneMatch;
@ -77,9 +77,9 @@ public class GetOptions {
/** /**
* Only return the object if it has changed since this time. * Only return the object if it has changed since this time.
* <p /> * <p />
* 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, checkArgument(getIfMatch() == null,
"ifETagMatches() is not compatible with ifModifiedSince()"); "ifETagMatches() is not compatible with ifModifiedSince()");
checkArgument(getIfUnmodifiedSince() == null, 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 * Return the object only if it has been modified since the specified time, otherwise return a
* 304 (not modified). * 304 (not modified).
* *
* @see GetOptions#ifModifiedSince(DateTime) * @see GetOptions#ifModifiedSince(Date)
*/ */
public DateTime getIfModifiedSince() { public Date getIfModifiedSince() {
return this.ifModifiedSince; return this.ifModifiedSince;
} }
/** /**
* Only return the object if it hasn't changed since this time. * Only return the object if it hasn't changed since this time.
* <p /> * <p />
* 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, checkArgument(getIfNoneMatch() == null,
"ifETagDoesntMatch() is not compatible with ifUnmodifiedSince()"); "ifETagDoesntMatch() is not compatible with ifUnmodifiedSince()");
checkArgument(getIfModifiedSince() == null, 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 * Return the object only if it has not been modified since the specified time, otherwise return
* a 412 (precondition failed). * a 412 (precondition failed).
* *
* @see GetOptions#ifUnmodifiedSince(DateTime) * @see GetOptions#ifUnmodifiedSince(Date)
*/ */
public DateTime getIfUnmodifiedSince() { public Date getIfUnmodifiedSince() {
return this.ifUnmodifiedSince; return this.ifUnmodifiedSince;
} }
@ -130,7 +130,7 @@ public class GetOptions {
* The object's eTag hash should match the parameter <code>eTag</code>. * The object's eTag hash should match the parameter <code>eTag</code>.
* *
* <p /> * <p />
* Not compatible with {@link #ifETagDoesntMatch(String)} or {@link #ifModifiedSince(DateTime)} * Not compatible with {@link #ifETagDoesntMatch(String)} or {@link #ifModifiedSince(Date)}
* *
* @param eTag * @param eTag
* hash representing the entity * hash representing the entity
@ -159,7 +159,7 @@ public class GetOptions {
/** /**
* The object should not have a eTag hash corresponding with the parameter <code>eTag</code>. * The object should not have a eTag hash corresponding with the parameter <code>eTag</code>.
* <p /> * <p />
* Not compatible with {@link #ifETagMatches(String)} or {@link #ifUnmodifiedSince(DateTime)} * Not compatible with {@link #ifETagMatches(String)} or {@link #ifUnmodifiedSince(Date)}
* *
* @param eTag * @param eTag
* hash representing the entity * hash representing the entity
@ -202,15 +202,15 @@ public class GetOptions {
/** /**
* @see GetOptions#getIfModifiedSince() * @see GetOptions#getIfModifiedSince()
*/ */
public static GetOptions ifModifiedSince(DateTime ifModifiedSince) { public static GetOptions ifModifiedSince(Date ifModifiedSince) {
GetOptions options = new GetOptions(); GetOptions options = new GetOptions();
return options.ifModifiedSince(ifModifiedSince); 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(); GetOptions options = new GetOptions();
return options.ifUnmodifiedSince(ifUnmodifiedSince); return options.ifUnmodifiedSince(ifUnmodifiedSince);
} }

View File

@ -40,7 +40,7 @@ import org.jclouds.blobstore.domain.internal.MutableBlobMetadataImpl;
import org.jclouds.http.HttpException; import org.jclouds.http.HttpException;
import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpResponse;
import org.jclouds.rest.internal.GeneratedHttpRequest; 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.BeforeTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -61,8 +61,8 @@ public class ParseBlobMetadataFromHeadersTest {
@BeforeTest @BeforeTest
void setUp() { void setUp() {
parser = new ParseSystemAndUserMetadataFromHeaders(blobMetadataProvider, new DateService(), parser = new ParseSystemAndUserMetadataFromHeaders(blobMetadataProvider,
"prefix"); new SimpleDateFormatDateService(), "prefix");
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class); GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes(); 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"); from.getHeaders().put(HttpHeaders.LAST_MODIFIED, "Wed, 09 Sep 2009 19:50:23 GMT");
MutableBlobMetadata metadata = blobMetadataProvider.get(); MutableBlobMetadata metadata = blobMetadataProvider.get();
parser.parseLastModifiedOrThrowException(from, metadata); parser.parseLastModifiedOrThrowException(from, metadata);
assertEquals(metadata.getLastModified(), new DateService() assertEquals(metadata.getLastModified(), new SimpleDateFormatDateService()
.rfc822DateParse("Wed, 09 Sep 2009 19:50:23 GMT")); .rfc822DateParse("Wed, 09 Sep 2009 19:50:23 GMT"));
} }

View File

@ -36,6 +36,7 @@ import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.SortedSet; import java.util.SortedSet;
import org.apache.commons.io.IOUtils; 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.blobstore.util.BlobStoreUtils;
import org.jclouds.http.HttpResponseException; import org.jclouds.http.HttpResponseException;
import org.jclouds.http.HttpUtils; import org.jclouds.http.HttpUtils;
import org.joda.time.DateTime;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -61,12 +61,12 @@ public class BaseBlobIntegrationTest<A, S> extends BaseBlobStoreIntegrationTest<
try { try {
String key = "apples"; String key = "apples";
DateTime before = new DateTime().minusSeconds(1); Date before = new Date(System.currentTimeMillis() - 1000);
// first create the object // first create the object
addObjectAndValidateContent(containerName, key); addObjectAndValidateContent(containerName, key);
// now, modify it // now, modify it
addObjectAndValidateContent(containerName, key); addObjectAndValidateContent(containerName, key);
DateTime after = new DateTime().plusSeconds(1); Date after = new Date(System.currentTimeMillis() + 1000);
context.getBlobStore().getBlob(containerName, key, ifModifiedSince(before)); context.getBlobStore().getBlob(containerName, key, ifModifiedSince(before));
validateContent(containerName, key); validateContent(containerName, key);
@ -90,9 +90,9 @@ public class BaseBlobIntegrationTest<A, S> extends BaseBlobStoreIntegrationTest<
String key = "apples"; String key = "apples";
DateTime before = new DateTime().minusSeconds(1); Date before = new Date(System.currentTimeMillis() - 1000);
addObjectAndValidateContent(containerName, key); addObjectAndValidateContent(containerName, key);
DateTime after = new DateTime().plusSeconds(1); Date after = new Date(System.currentTimeMillis() + 1000);
context.getBlobStore().getBlob(containerName, key, ifUnmodifiedSince(after)); context.getBlobStore().getBlob(containerName, key, ifUnmodifiedSince(after));
validateContent(containerName, key); validateContent(containerName, key);

View File

@ -36,6 +36,7 @@ import java.io.ObjectOutput;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import java.net.URI; import java.net.URI;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.SortedSet; import java.util.SortedSet;
@ -85,7 +86,6 @@ import org.jclouds.http.HttpUtils;
import org.jclouds.http.options.HttpRequestOptions; import org.jclouds.http.options.HttpRequestOptions;
import org.jclouds.util.DateService; import org.jclouds.util.DateService;
import org.jclouds.util.Utils; import org.jclouds.util.Utils;
import org.joda.time.DateTime;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
@ -513,7 +513,7 @@ public class StubAsyncBlobStore implements AsyncBlobStore {
byte[] data = toByteArray(object.getData()); byte[] data = toByteArray(object.getData());
object.getMetadata().setSize(data.length); object.getMetadata().setSize(data.length);
MutableBlobMetadata newMd = copy(object.getMetadata()); MutableBlobMetadata newMd = copy(object.getMetadata());
newMd.setLastModified(new DateTime()); newMd.setLastModified(new Date());
final byte[] md5 = HttpUtils.md5(data); final byte[] md5 = HttpUtils.md5(data);
final String eTag = HttpUtils.toHexString(md5); final String eTag = HttpUtils.toHexString(md5);
newMd.setETag(eTag); newMd.setETag(eTag);
@ -567,8 +567,8 @@ public class StubAsyncBlobStore implements AsyncBlobStore {
throwResponseException(304); throwResponseException(304);
} }
if (options.getIfModifiedSince() != null) { if (options.getIfModifiedSince() != null) {
DateTime modifiedSince = options.getIfModifiedSince(); Date modifiedSince = options.getIfModifiedSince();
if (object.getMetadata().getLastModified().isBefore(modifiedSince)) { if (object.getMetadata().getLastModified().before(modifiedSince)) {
HttpResponse response = new HttpResponse(); HttpResponse response = new HttpResponse();
response.setStatusCode(304); response.setStatusCode(304);
throw new ExecutionException(new HttpResponseException(String.format( throw new ExecutionException(new HttpResponseException(String.format(
@ -578,8 +578,8 @@ public class StubAsyncBlobStore implements AsyncBlobStore {
} }
if (options.getIfUnmodifiedSince() != null) { if (options.getIfUnmodifiedSince() != null) {
DateTime unmodifiedSince = options.getIfUnmodifiedSince(); Date unmodifiedSince = options.getIfUnmodifiedSince();
if (object.getMetadata().getLastModified().isAfter(unmodifiedSince)) { if (object.getMetadata().getLastModified().after(unmodifiedSince)) {
HttpResponse response = new HttpResponse(); HttpResponse response = new HttpResponse();
response.setStatusCode(412); response.setStatusCode(412);
throw new ExecutionException(new HttpResponseException(String.format( throw new ExecutionException(new HttpResponseException(String.format(

View File

@ -32,8 +32,8 @@ import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull; import static org.testng.Assert.assertNull;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.Date;
import org.joda.time.DateTime;
import org.testng.annotations.BeforeTest; import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -48,11 +48,11 @@ import com.google.common.collect.ImmutableList;
public class GetOptionsTest { public class GetOptionsTest {
private String etag; private String etag;
private DateTime now; private Date now;
@BeforeTest @BeforeTest
void setUp() { void setUp() {
now = new DateTime(); now = new Date();
etag = "yrdy"; etag = "yrdy";
} }

View File

@ -94,11 +94,6 @@
<version>7.0.0pre3</version> <version>7.0.0pre3</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>1.6</version>
</dependency>
<dependency> <dependency>
<groupId>org.bouncycastle</groupId> <groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15</artifactId> <artifactId>bcprov-jdk15</artifactId>

View File

@ -27,6 +27,7 @@ import java.lang.reflect.Type;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date;
import java.util.SortedSet; import java.util.SortedSet;
import javax.inject.Inject; 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;
import org.jclouds.http.functions.ParseSax.HandlerWithResult; import org.jclouds.http.functions.ParseSax.HandlerWithResult;
import org.jclouds.util.DateService; import org.jclouds.util.DateService;
import org.joda.time.DateTime;
import org.xml.sax.XMLReader; import org.xml.sax.XMLReader;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
@ -132,60 +132,62 @@ public class ParserModule extends AbstractModule {
@Provides @Provides
@Singleton @Singleton
Gson provideGson(DateTimeAdapter adapter, SortedSetOfInetAddressCreator addressSetCreator) { Gson provideGson(DateAdapter adapter, SortedSetOfInetAddressCreator addressSetCreator) {
GsonBuilder gson = new GsonBuilder(); GsonBuilder gson = new GsonBuilder();
gson.registerTypeAdapter(InetAddress.class, new InetAddressAdapter()); gson.registerTypeAdapter(InetAddress.class, new InetAddressAdapter());
gson.registerTypeAdapter(DateTime.class, adapter); gson.registerTypeAdapter(Date.class, adapter);
gson.registerTypeAdapter(new TypeToken<SortedSet<InetAddress>>() { gson.registerTypeAdapter(new TypeToken<SortedSet<InetAddress>>() {
}.getType(), addressSetCreator); }.getType(), addressSetCreator);
return gson.create(); return gson.create();
} }
@ImplementedBy(Iso8601DateTimeAdapter.class) @ImplementedBy(Iso8601DateAdapter.class)
public static interface DateTimeAdapter extends JsonSerializer<DateTime>, public static interface DateAdapter extends JsonSerializer<Date>, JsonDeserializer<Date> {
JsonDeserializer<DateTime> {
} }
@Singleton @Singleton
public static class Iso8601DateTimeAdapter implements DateTimeAdapter { public static class Iso8601DateAdapter implements DateAdapter {
private final DateService dateService; private final DateService dateService;
@Inject @Inject
private Iso8601DateTimeAdapter(DateService dateService) { private Iso8601DateAdapter(DateService dateService) {
this.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)); 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 { throws JsonParseException {
String toParse = json.getAsJsonPrimitive().getAsString(); String toParse = json.getAsJsonPrimitive().getAsString();
DateTime toReturn = dateService.jodaIso8601DateParse(toParse); try {
return toReturn; return dateService.iso8601DateParse(toParse);
} catch (RuntimeException e) {
return dateService.iso8601SecondsDateParse(toParse);
}
} }
} }
@Singleton @Singleton
public static class CDateTimeAdapter implements DateTimeAdapter { public static class CDateAdapter implements DateAdapter {
private final DateService dateService; private final DateService dateService;
@Inject @Inject
private CDateTimeAdapter(DateService dateService) { private CDateAdapter(DateService dateService) {
this.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)); 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 { throws JsonParseException {
String toParse = json.getAsJsonPrimitive().getAsString(); String toParse = json.getAsJsonPrimitive().getAsString();
DateTime toReturn = dateService.cDateParse(toParse); Date toReturn = dateService.cDateParse(toParse);
return toReturn; return toReturn;
} }

View File

@ -28,12 +28,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.HttpHeaders;
import org.jclouds.util.DateService; 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.base.Joiner;
import com.google.common.collect.Multimap; 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 * // this will get the first megabyte of an object, provided it wasn't modified since yesterday
* Future<S3Object> object = client.get("objectName",range(0,1024).ifUnmodifiedSince(new DateTime().minusDays(1))); * Future<S3Object> object = client.get("objectName",range(0,1024).ifUnmodifiedSince(new Date().minusDays(1)));
* <code> * <code>
* *
* @author Adrian Cole * @author Adrian Cole
* *
*/ */
public class GetOptions extends BaseHttpRequestOptions { 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(); public static final GetOptions NONE = new GetOptions();
private final List<String> ranges = new ArrayList<String>(); private final List<String> ranges = new ArrayList<String>();
@ -110,9 +111,9 @@ public class GetOptions extends BaseHttpRequestOptions {
/** /**
* Only return the object if it has changed since this time. * Only return the object if it has changed since this time.
* <p /> * <p />
* 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, checkArgument(getIfMatch() == null,
"ifETagMatches() is not compatible with ifModifiedSince()"); "ifETagMatches() is not compatible with ifModifiedSince()");
checkArgument(getIfUnmodifiedSince() == null, 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 * Return the object only if it has been modified since the specified time, otherwise return a
* 304 (not modified). * 304 (not modified).
* *
* @see GetOptions#ifModifiedSince(DateTime) * @see GetOptions#ifModifiedSince(Date)
*/ */
public String getIfModifiedSince() { public String getIfModifiedSince() {
return this.getFirstHeaderOrNull(HttpHeaders.IF_MODIFIED_SINCE); 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. * Only return the object if it hasn't changed since this time.
* <p /> * <p />
* 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, checkArgument(getIfNoneMatch() == null,
"ifETagDoesntMatch() is not compatible with ifUnmodifiedSince()"); "ifETagDoesntMatch() is not compatible with ifUnmodifiedSince()");
checkArgument(getIfModifiedSince() == null, 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 * Return the object only if it has not been modified since the specified time, otherwise return
* a 412 (precondition failed). * a 412 (precondition failed).
* *
* @see GetOptions#ifUnmodifiedSince(DateTime) * @see GetOptions#ifUnmodifiedSince(Date)
*/ */
public String getIfUnmodifiedSince() { public String getIfUnmodifiedSince() {
return this.getFirstHeaderOrNull(HttpHeaders.IF_UNMODIFIED_SINCE); 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 <code>eTag</code>. * The object's eTag hash should match the parameter <code>eTag</code>.
* *
* <p /> * <p />
* Not compatible with {@link #ifETagDoesntMatch(byte[])} or {@link #ifModifiedSince(DateTime)} * Not compatible with {@link #ifETagDoesntMatch(byte[])} or {@link #ifModifiedSince(Date)}
* *
* @param eTag * @param eTag
* hash representing the entity * 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 <code>eTag</code>. * The object should not have a eTag hash corresponding with the parameter <code>eTag</code>.
* <p /> * <p />
* Not compatible with {@link #ifETagMatches(String)} or {@link #ifUnmodifiedSince(DateTime)} * Not compatible with {@link #ifETagMatches(String)} or {@link #ifUnmodifiedSince(Date)}
* *
* @param eTag * @param eTag
* hash representing the entity * hash representing the entity
@ -258,15 +259,15 @@ public class GetOptions extends BaseHttpRequestOptions {
/** /**
* @see GetOptions#getIfModifiedSince() * @see GetOptions#getIfModifiedSince()
*/ */
public static GetOptions ifModifiedSince(DateTime ifModifiedSince) { public static GetOptions ifModifiedSince(Date ifModifiedSince) {
GetOptions options = new GetOptions(); GetOptions options = new GetOptions();
return options.ifModifiedSince(ifModifiedSince); 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(); GetOptions options = new GetOptions();
return options.ifUnmodifiedSince(ifUnmodifiedSince); return options.ifUnmodifiedSince(ifUnmodifiedSince);
} }

View File

@ -23,12 +23,12 @@
*/ */
package org.jclouds.predicates; package org.jclouds.predicates;
import java.util.Date;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
import org.joda.time.DateTime;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
@ -55,7 +55,7 @@ public class RetryablePredicate<T> implements Predicate<T> {
@Override @Override
public boolean apply(T input) { public boolean apply(T input) {
try { try {
for (DateTime end = new DateTime().plusMillis(maxWait); before(end); Thread for (Date end = new Date(System.currentTimeMillis() + maxWait); before(end); Thread
.sleep(checkInterval)) { .sleep(checkInterval)) {
if (predicate.apply(input)) { if (predicate.apply(input)) {
return true; return true;
@ -69,11 +69,11 @@ public class RetryablePredicate<T> implements Predicate<T> {
return false; return false;
} }
boolean before(DateTime end) { boolean before(Date end) {
return new DateTime().compareTo(end) <= 1; return new Date().compareTo(end) <= 1;
} }
boolean atOrAfter(DateTime end) { boolean atOrAfter(Date end) {
return new DateTime().compareTo(end) >= 0; return new Date().compareTo(end) >= 0;
} }
} }

View File

@ -23,186 +23,46 @@
*/ */
package org.jclouds.util; package org.jclouds.util;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.Locale;
import java.util.SimpleTimeZone;
import net.jcip.annotations.GuardedBy; import org.jclouds.util.internal.SimpleDateFormatDateService;
import net.jcip.annotations.ThreadSafe;
import org.joda.time.DateTime; import com.google.inject.ImplementedBy;
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import com.google.common.annotations.VisibleForTesting;
/** /**
* Parses and formats the ISO8601 and RFC822 date formats found in XML responses and HTTP response * Parses and formats the ISO8601, C, and RFC822 date formats found in XML responses and HTTP
* headers. * response headers.
* <p>
* Either {@link SimpleDateFormat} or {@link DateTimeFormatter} classes are used internally,
* depending on which version gives the best performance.
* *
* @author Adrian Cole * @author Adrian Cole
* @author James Murty * @author James Murty
*/ */
@ThreadSafe @ImplementedBy(SimpleDateFormatDateService.class)
public class DateService { public interface 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);
@GuardedBy("this") Date fromSeconds(long seconds);
private static final SimpleDateFormat iso8601SimpleDateFormat = new SimpleDateFormat(
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);
@GuardedBy("this") String cDateFormat(Date date);
private static final SimpleDateFormat rfc822SimpleDateFormat = new SimpleDateFormat(
"EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
private static final DateTimeFormatter rfc822DateTimeFormatter = DateTimeFormat.forPattern( String cDateFormat();
"EEE, dd MMM yyyy HH:mm:ss 'GMT'").withLocale(Locale.US).withZone(
DateTimeZone.forID("GMT"));
@GuardedBy("this") Date cDateParse(String toParse);
private static final SimpleDateFormat cSimpleDateFormat = new SimpleDateFormat(
"EEE MMM dd HH:mm:ss '+0000' yyyy", Locale.US);
private static final DateTimeFormatter cDateTimeFormatter = DateTimeFormat.forPattern( String rfc822DateFormat(Date date);
"EEE MMM dd HH:mm:ss '+0000' yyyy").withLocale(Locale.US).withZone(
DateTimeZone.forID("GMT"));
private static final DateTimeFormatter iso8601SecondsDateTimeFormatter = DateTimeFormat String rfc822DateFormat();
.forPattern("yyyy-MM-dd'T'HH:mm:ss'Z'").withLocale(Locale.US).withZone(
DateTimeZone.forID("GMT"));
private static final DateTimeFormatter iso8601DateTimeFormatter = DateTimeFormat.forPattern( Date rfc822DateParse(String toParse);
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").withLocale(Locale.US).withZone(
DateTimeZone.forID("GMT"));
static { String iso8601SecondsDateFormat(Date dateTime);
iso8601SimpleDateFormat.setTimeZone(new SimpleTimeZone(0, "GMT"));
iso8601SecondsSimpleDateFormat.setTimeZone(new SimpleTimeZone(0, "GMT"));
rfc822SimpleDateFormat.setTimeZone(new SimpleTimeZone(0, "GMT"));
cSimpleDateFormat.setTimeZone(new SimpleTimeZone(0, "GMT"));
}
public final DateTime fromSeconds(long seconds) { String iso8601SecondsDateFormat();
return new DateTime(seconds * 1000);
}
public final String cDateFormat(DateTime dateTime) { String iso8601DateFormat(Date date);
return cDateTimeFormatter.print(dateTime);
}
public final String cDateFormat(Date date) { String iso8601DateFormat();
return cDateFormat(new DateTime(date));
}
public final String cDateFormat() { Date iso8601DateParse(String toParse);
return cDateFormat(new DateTime());
}
public final DateTime cDateParse(String toParse) { Date iso8601SecondsDateParse(String toParse);
synchronized (cSimpleDateFormat) {
try {
return new DateTime(cSimpleDateFormat.parse(toParse));
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
}
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());
}
}
} }

View File

@ -34,9 +34,9 @@ import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull; import static org.testng.Assert.assertNull;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.Date;
import org.jclouds.util.DateService; import org.jclouds.util.internal.SimpleDateFormatDateService;
import org.joda.time.DateTime;
import org.testng.annotations.BeforeTest; import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -49,13 +49,13 @@ import org.testng.annotations.Test;
public class GetOptionsTest { public class GetOptionsTest {
private String etag; private String etag;
private DateTime now; private Date now;
private String nowExpected; private String nowExpected;
@BeforeTest @BeforeTest
void setUp() { void setUp() {
now = new DateTime(); now = new Date();
nowExpected = new DateService().rfc822DateFormat(now); nowExpected = new SimpleDateFormatDateService().rfc822DateFormat(now);
etag = "yrdy"; etag = "yrdy";
} }

View File

@ -23,9 +23,9 @@
*/ */
package org.jclouds.predicates; package org.jclouds.predicates;
import java.util.Date;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.joda.time.DateTime;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
@ -43,23 +43,25 @@ public class RetryablePredicateTest {
void testAlwaysTrue() { void testAlwaysTrue() {
RetryablePredicate<String> predicate = new RetryablePredicate<String>(Predicates RetryablePredicate<String> predicate = new RetryablePredicate<String>(Predicates
.<String> alwaysTrue(), 3, 1, TimeUnit.SECONDS); .<String> alwaysTrue(), 3, 1, TimeUnit.SECONDS);
DateTime start = new DateTime(); Date startPlusSecond = new Date(System.currentTimeMillis() + 1000);
predicate.apply(""); predicate.apply("");
DateTime now = new DateTime(); Date now = new Date();
assert now.compareTo(start.plusSeconds(1)) < 0 : String.format("%s should be less than %s", assert now.compareTo(startPlusSecond) < 0 : String.format("%s should be less than %s", now,
now, start.plusSeconds(1)); } startPlusSecond);
}
@Test @Test
void testAlwaysFalseMillis() { void testAlwaysFalseMillis() {
RetryablePredicate<String> predicate = new RetryablePredicate<String>(Predicates RetryablePredicate<String> predicate = new RetryablePredicate<String>(Predicates
.<String> alwaysFalse(), 3, 1, TimeUnit.SECONDS); .<String> 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(""); predicate.apply("");
DateTime now = new DateTime(); Date now = new Date();
assert now.compareTo(start.plusSeconds(3)) >= 0 : String.format("%s should be less than %s", assert now.compareTo(startPlus3Seconds) >= 0 : String.format("%s should be less than %s",
start.plusSeconds(3), now); startPlus3Seconds, now);
assert now.compareTo(start.plusSeconds(4)) <= 0 : String.format( assert now.compareTo(startPlus4Seconds) <= 0 : String.format("%s should be greater than %s",
"%s should be greater than %s", start.plusSeconds(6), now); startPlus4Seconds, now);
} }
@ -79,13 +81,15 @@ public class RetryablePredicateTest {
RetryablePredicate<String> predicate = new RetryablePredicate<String>(new SecondTimeTrue(), RetryablePredicate<String> predicate = new RetryablePredicate<String>(new SecondTimeTrue(),
3, 1, TimeUnit.SECONDS); 3, 1, TimeUnit.SECONDS);
DateTime start = new DateTime(); Date startPlusSecond = new Date(System.currentTimeMillis() + 1000);
Date startPlus2Seconds = new Date(System.currentTimeMillis() + 2000);
predicate.apply(""); predicate.apply("");
DateTime now = new DateTime(); Date now = new Date();
assert now.compareTo(start.plusSeconds(1)) >= 0 : String.format("%s should be greater than %s", assert now.compareTo(startPlusSecond) >= 0 : String.format("%s should be greater than %s",
now,start.plusSeconds(1)); now, startPlusSecond);
assert now.compareTo(start.plusSeconds(2)) <= 0 : String.format( assert now.compareTo(startPlus2Seconds) <= 0 : String.format("%s should be greater than %s",
"%s should be greater than %s", start.plusSeconds(2), now); startPlus2Seconds, now);
} }
} }

View File

@ -40,6 +40,7 @@ import java.net.URI;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Date;
import java.util.Map; import java.util.Map;
import java.util.concurrent.Future; import java.util.concurrent.Future;
@ -100,7 +101,7 @@ import org.jclouds.rest.binders.BindToStringEntity;
import org.jclouds.rest.config.RestModule; import org.jclouds.rest.config.RestModule;
import org.jclouds.util.DateService; import org.jclouds.util.DateService;
import org.jclouds.util.Jsr330; import org.jclouds.util.Jsr330;
import org.joda.time.DateTime; import org.jclouds.util.internal.SimpleDateFormatDateService;
import org.mortbay.jetty.HttpHeaders; import org.mortbay.jetty.HttpHeaders;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
@ -1171,7 +1172,7 @@ public class RestAnnotationProcessorTest {
public void testCreateGetVarArgOptionsThatProducesHeaders() throws SecurityException, public void testCreateGetVarArgOptionsThatProducesHeaders() throws SecurityException,
NoSuchMethodException { NoSuchMethodException {
DateTime date = new DateTime(); Date date = new Date();
GetOptions options = GetOptions.Builder.ifModifiedSince(date); GetOptions options = GetOptions.Builder.ifModifiedSince(date);
HttpRequestOptions[] optionsHolder = new HttpRequestOptions[] {}; HttpRequestOptions[] optionsHolder = new HttpRequestOptions[] {};
Method method = TestRequest.class.getMethod("get", String.class, optionsHolder.getClass()); Method method = TestRequest.class.getMethod("get", String.class, optionsHolder.getClass());
@ -1189,7 +1190,7 @@ public class RestAnnotationProcessorTest {
public void testCreateGetOptionsThatProducesHeaders() throws SecurityException, public void testCreateGetOptionsThatProducesHeaders() throws SecurityException,
NoSuchMethodException { NoSuchMethodException {
DateTime date = new DateTime(); Date date = new Date();
GetOptions options = GetOptions.Builder.ifModifiedSince(date); GetOptions options = GetOptions.Builder.ifModifiedSince(date);
Method method = TestRequest.class.getMethod("get", String.class, HttpRequestOptions.class); Method method = TestRequest.class.getMethod("get", String.class, HttpRequestOptions.class);
GeneratedHttpRequest<?> httpMethod = factory(TestRequest.class).createRequest(method, GeneratedHttpRequest<?> httpMethod = factory(TestRequest.class).createRequest(method,
@ -1622,7 +1623,7 @@ public class RestAnnotationProcessorTest {
} }
Injector injector; Injector injector;
DateService dateService = new DateService(); DateService dateService = new SimpleDateFormatDateService();
@BeforeClass @BeforeClass
void setupFactory() { void setupFactory() {

View File

@ -26,11 +26,12 @@ package org.jclouds.util;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import org.jclouds.PerformanceTest; import org.jclouds.PerformanceTest;
import org.joda.time.DateTime; import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.inject.Guice; import com.google.inject.Guice;
@ -47,11 +48,15 @@ import com.google.inject.Injector;
* @author Adrian Cole * @author Adrian Cole
* @author James Murty * @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 { 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; protected TestData[] testData;
@ -61,9 +66,10 @@ public class DateServiceTest extends PerformanceTest {
public final String rfc822DateString; public final String rfc822DateString;
public final String cDateString; public final String cDateString;
public final DateTime date; public final Date date;
TestData(String iso8601, String iso8601Seconds, String rfc822, String cDateString, DateTime dateTime) { TestData(String iso8601, String iso8601Seconds, String rfc822, String cDateString,
Date dateTime) {
this.iso8601DateString = iso8601; this.iso8601DateString = iso8601;
this.iso8601SecondsDateString = iso8601Seconds; this.iso8601SecondsDateString = iso8601Seconds;
this.rfc822DateString = rfc822; this.rfc822DateString = rfc822;
@ -76,38 +82,43 @@ public class DateServiceTest extends PerformanceTest {
// Constant time test values, each TestData item must contain matching times! // Constant time test values, each TestData item must contain matching times!
testData = new TestData[] { testData = new TestData[] {
new TestData("2009-03-12T02:00:07.000Z", "2009-03-12T02:00:07Z", 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", 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", 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", 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", 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 @Test
public void testIso8601DateParse() throws ExecutionException, InterruptedException { 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); assertEquals(dsDate, testData[0].date);
} }
@Test @Test
public void testIso8601SecondsDateParse() throws ExecutionException, InterruptedException { 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); assertEquals(dsDate, testData[0].date);
} }
@Test @Test
public void testCDateParse() throws ExecutionException, InterruptedException { 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); assertEquals(dsDate, testData[0].date);
} }
@Test @Test
public void testRfc822DateParse() throws ExecutionException, InterruptedException { 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); assertEquals(dsDate, testData[0].date);
} }
@ -144,7 +155,7 @@ public class DateServiceTest extends PerformanceTest {
@Test @Test
void testFromSeconds() throws ExecutionException, InterruptedException { void testFromSeconds() throws ExecutionException, InterruptedException {
long seconds = 1254008225; 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"); assertEquals(dateService.rfc822DateFormat(date), "Sat, 26 Sep 2009 23:37:05 GMT");
} }
@ -154,7 +165,6 @@ public class DateServiceTest extends PerformanceTest {
dateService.rfc822DateFormat(); dateService.rfc822DateFormat();
} }
@Test @Test
void testCDateFormatResponseTime() throws ExecutionException, InterruptedException { void testCDateFormatResponseTime() throws ExecutionException, InterruptedException {
for (int i = 0; i < LOOP_COUNT; i++) for (int i = 0; i < LOOP_COUNT; i++)
@ -188,40 +198,19 @@ public class DateServiceTest extends PerformanceTest {
executeMultiThreadedPerformanceTest("testFormatIso8601DatePerformanceInParallel", tasks); executeMultiThreadedPerformanceTest("testFormatIso8601DatePerformanceInParallel", tasks);
} }
@Test
void testFormatIso8601DatePerformanceInParallel_SdfAlternative() throws Throwable {
List<Runnable> tasks = new ArrayList<Runnable>(testData.length);
for (final TestData myData : testData) {
tasks.add(new Runnable() {
public void run() {
dateService.sdfIso8601DateFormat(myData.date);
}
});
}
executeMultiThreadedPerformanceTest(
"testFormatIso8601DatePerformanceInParallel_SdfAlternative", tasks);
}
@Test @Test
void testParseIso8601DateSerialResponseTime() throws ExecutionException, InterruptedException { void testParseIso8601DateSerialResponseTime() throws ExecutionException, InterruptedException {
for (int i = 0; i < LOOP_COUNT; i++) for (int i = 0; i < LOOP_COUNT; i++)
dateService.iso8601DateParse(testData[0].iso8601DateString); 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 @Test
void testParseIso8601DateCorrectnessInParallel() throws Throwable { void testParseIso8601DateCorrectnessInParallel() throws Throwable {
List<Runnable> tasks = new ArrayList<Runnable>(testData.length); List<Runnable> tasks = new ArrayList<Runnable>(testData.length);
for (final TestData myData : testData) { for (final TestData myData : testData) {
tasks.add(new Runnable() { tasks.add(new Runnable() {
public void run() { public void run() {
DateTime dsDate = dateService.iso8601DateParse(myData.iso8601DateString); Date dsDate = dateService.iso8601DateParse(myData.iso8601DateString);
assertEquals(dsDate, myData.date); assertEquals(dsDate, myData.date);
} }
}); });
@ -242,18 +231,4 @@ public class DateServiceTest extends PerformanceTest {
executeMultiThreadedPerformanceTest("testParseIso8601DatePerformanceInParallel", tasks); executeMultiThreadedPerformanceTest("testParseIso8601DatePerformanceInParallel", tasks);
} }
@Test
void testParseIso8601DatePerformanceInParallel_JodaAlternative() throws Throwable {
List<Runnable> tasks = new ArrayList<Runnable>(testData.length);
for (final TestData myData : testData) {
tasks.add(new Runnable() {
public void run() {
dateService.jodaIso8601DateParse(myData.iso8601DateString);
}
});
}
executeMultiThreadedPerformanceTest(
"testParseIso8601DatePerformanceInParallel_JodaAlternative", tasks);
}
} }

View File

@ -49,9 +49,16 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>jclouds-core</artifactId> <artifactId>jclouds-blobstore</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jclouds-blobstore</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>jclouds-core</artifactId> <artifactId>jclouds-core</artifactId>

46
extensions/joda/pom.xml Normal file
View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
$HeadURL$
$Revision$
$Date$
Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
====================================================================
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.html
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.
====================================================================
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jclouds</groupId>
<artifactId>jclouds-extensions-project</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>jclouds-joda</artifactId>
<name>jclouds joda DateService Module</name>
<description>jclouds joda DateService Module</description>
<dependencies>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>1.6</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,111 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* 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();
}
}

View File

@ -0,0 +1,49 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* 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();
}
}

View File

@ -39,6 +39,7 @@
<modules> <modules>
<module>gae</module> <module>gae</module>
<module>httpnio</module> <module>httpnio</module>
<module>joda</module>
<module>log4j</module> <module>log4j</module>
<module>ssh</module> <module>ssh</module>
</modules> </modules>

View File

@ -24,10 +24,10 @@
package org.jclouds.mezeo.pcs2.domain; package org.jclouds.mezeo.pcs2.domain;
import java.net.URI; import java.net.URI;
import java.util.Date;
import org.jclouds.blobstore.domain.ResourceType; import org.jclouds.blobstore.domain.ResourceType;
import org.jclouds.mezeo.pcs2.domain.internal.MutableResourceInfoImpl; import org.jclouds.mezeo.pcs2.domain.internal.MutableResourceInfoImpl;
import org.joda.time.DateTime;
import com.google.inject.ImplementedBy; import com.google.inject.ImplementedBy;
@ -44,11 +44,11 @@ public interface MutableResourceInfo extends ResourceInfo {
void setName(String value); void setName(String value);
void setCreated(DateTime value); void setCreated(Date value);
void setInProject(Boolean value); void setInProject(Boolean value);
void setModified(DateTime value); void setModified(Date value);
void setOwner(String value); void setOwner(String value);
@ -56,7 +56,7 @@ public interface MutableResourceInfo extends ResourceInfo {
void setShared(Boolean value); void setShared(Boolean value);
void setAccessed(DateTime value); void setAccessed(Date value);
void setBytes(Long value); void setBytes(Long value);

View File

@ -24,10 +24,10 @@
package org.jclouds.mezeo.pcs2.domain; package org.jclouds.mezeo.pcs2.domain;
import java.net.URI; import java.net.URI;
import java.util.Date;
import org.jclouds.blobstore.domain.ResourceType; import org.jclouds.blobstore.domain.ResourceType;
import org.jclouds.mezeo.pcs2.domain.internal.ResourceInfoImpl; import org.jclouds.mezeo.pcs2.domain.internal.ResourceInfoImpl;
import org.joda.time.DateTime;
import com.google.inject.ImplementedBy; import com.google.inject.ImplementedBy;
@ -44,11 +44,11 @@ public interface ResourceInfo extends Comparable<ResourceInfo> {
String getName(); String getName();
DateTime getCreated(); Date getCreated();
Boolean isInProject(); Boolean isInProject();
DateTime getModified(); Date getModified();
String getOwner(); String getOwner();
@ -56,7 +56,7 @@ public interface ResourceInfo extends Comparable<ResourceInfo> {
Boolean isShared(); Boolean isShared();
DateTime getAccessed(); Date getAccessed();
Long getBytes(); Long getBytes();

View File

@ -24,10 +24,10 @@
package org.jclouds.mezeo.pcs2.domain.internal; package org.jclouds.mezeo.pcs2.domain.internal;
import java.net.URI; import java.net.URI;
import java.util.Date;
import org.jclouds.blobstore.domain.ResourceType; import org.jclouds.blobstore.domain.ResourceType;
import org.jclouds.mezeo.pcs2.domain.ContainerInfo; 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 { public class ContainerInfoImpl extends ResourceInfoImpl implements ContainerInfo {
private final URI contents; private final URI contents;
public ContainerInfoImpl(URI url, String name, DateTime created, boolean inProject, public ContainerInfoImpl(URI url, String name, Date created, boolean inProject, Date modified,
DateTime modified, String owner, int version, boolean shared, DateTime accessed, String owner, int version, boolean shared, Date accessed, long bytes, URI contents,
long bytes, URI contents, URI tags, URI metadata, URI parent) { URI tags, URI metadata, URI parent) {
super(ResourceType.FOLDER, url, name, created, inProject, modified, owner, version, shared, super(ResourceType.FOLDER, url, name, created, inProject, modified, owner, version, shared,
accessed, bytes, tags, metadata, parent); accessed, bytes, tags, metadata, parent);
this.contents = contents; this.contents = contents;

View File

@ -24,6 +24,7 @@
package org.jclouds.mezeo.pcs2.domain.internal; package org.jclouds.mezeo.pcs2.domain.internal;
import java.net.URI; import java.net.URI;
import java.util.Date;
import java.util.Map; import java.util.Map;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.TreeSet; import java.util.TreeSet;
@ -31,7 +32,6 @@ import java.util.TreeSet;
import org.jclouds.blobstore.domain.ResourceType; import org.jclouds.blobstore.domain.ResourceType;
import org.jclouds.mezeo.pcs2.domain.ContainerList; import org.jclouds.mezeo.pcs2.domain.ContainerList;
import org.jclouds.mezeo.pcs2.domain.ResourceInfo; import org.jclouds.mezeo.pcs2.domain.ResourceInfo;
import org.joda.time.DateTime;
/** /**
* *
@ -45,9 +45,9 @@ public class ContainerListImpl extends TreeSet<ResourceInfo> implements Containe
private final ResourceInfo info; private final ResourceInfo info;
private final Map<String, URI> metadataItems; private final Map<String, URI> metadataItems;
public ContainerListImpl(URI url, String name, DateTime created, boolean inProject, public ContainerListImpl(URI url, String name, Date created, boolean inProject, Date modified,
DateTime modified, String owner, int version, boolean shared, DateTime accessed, String owner, int version, boolean shared, Date accessed, long bytes,
long bytes, SortedSet<? extends ResourceInfo> contents, URI tags, URI metadata, SortedSet<? extends ResourceInfo> contents, URI tags, URI metadata,
Map<String, URI> metadataItems, URI parent) { Map<String, URI> metadataItems, URI parent) {
this.info = new ResourceInfoImpl(ResourceType.FOLDER, url, name, created, inProject, this.info = new ResourceInfoImpl(ResourceType.FOLDER, url, name, created, inProject,
modified, owner, version, shared, accessed, bytes, tags, metadata, parent); modified, owner, version, shared, accessed, bytes, tags, metadata, parent);
@ -59,7 +59,7 @@ public class ContainerListImpl extends TreeSet<ResourceInfo> implements Containe
return metadataItems; return metadataItems;
} }
public DateTime getAccessed() { public Date getAccessed() {
return info.getAccessed(); return info.getAccessed();
} }
@ -67,7 +67,7 @@ public class ContainerListImpl extends TreeSet<ResourceInfo> implements Containe
return info.getBytes(); return info.getBytes();
} }
public DateTime getCreated() { public Date getCreated() {
return info.getCreated(); return info.getCreated();
} }
@ -75,7 +75,7 @@ public class ContainerListImpl extends TreeSet<ResourceInfo> implements Containe
return info.getMetadata(); return info.getMetadata();
} }
public DateTime getModified() { public Date getModified() {
return info.getModified(); return info.getModified();
} }

View File

@ -24,10 +24,10 @@
package org.jclouds.mezeo.pcs2.domain.internal; package org.jclouds.mezeo.pcs2.domain.internal;
import java.net.URI; import java.net.URI;
import java.util.Date;
import org.jclouds.blobstore.domain.ResourceType; import org.jclouds.blobstore.domain.ResourceType;
import org.jclouds.mezeo.pcs2.domain.FileInfo; 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 permissions;
private final URI thumbnail; private final URI thumbnail;
public FileInfoImpl(URI url, String name, DateTime created, boolean inProject, public FileInfoImpl(URI url, String name, Date created, boolean inProject,
DateTime modified, String owner, int version, boolean shared, DateTime accessed, Date modified,
String owner, int version, boolean shared, Date accessed,
boolean isPublic, String mimeType, long bytes, URI content, URI parent, boolean isPublic, String mimeType, long bytes, URI content, URI parent,
URI permissions, URI tags, URI metadata, URI thumbnail) { URI permissions, URI tags, URI metadata, URI thumbnail) {
super(ResourceType.BLOB, url, name, created, inProject, modified, owner, version, shared, super(ResourceType.BLOB, url, name, created, inProject, modified, owner, version, shared,

View File

@ -24,10 +24,10 @@
package org.jclouds.mezeo.pcs2.domain.internal; package org.jclouds.mezeo.pcs2.domain.internal;
import java.net.URI; import java.net.URI;
import java.util.Date;
import java.util.Map; import java.util.Map;
import org.jclouds.mezeo.pcs2.domain.FileInfoWithMetadata; 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 { public class FileInfoWithMetadataImpl extends FileInfoImpl implements FileInfoWithMetadata {
private final Map<String, URI> metadataItems; private final Map<String, URI> metadataItems;
public FileInfoWithMetadataImpl(URI url, String name, DateTime created, boolean inProject, public FileInfoWithMetadataImpl(URI url, String name, Date created, boolean inProject,
DateTime modified, String owner, int version, boolean shared, DateTime accessed, Date modified, String owner, int version, boolean shared, Date accessed,
boolean isPublic, String mimeType, long bytes, URI content, URI parent, boolean isPublic, String mimeType, long bytes, URI content, URI parent,
URI permissions, URI tags, URI metadata, Map<String, URI> metadataItems, URI thumbnail) { URI permissions, URI tags, URI metadata, Map<String, URI> metadataItems, URI thumbnail) {
super(url, name, created, inProject, modified, owner, version, shared, accessed, isPublic, super(url, name, created, inProject, modified, owner, version, shared, accessed, isPublic,

View File

@ -24,11 +24,11 @@
package org.jclouds.mezeo.pcs2.domain.internal; package org.jclouds.mezeo.pcs2.domain.internal;
import java.net.URI; import java.net.URI;
import java.util.Date;
import org.jclouds.blobstore.domain.ResourceType; import org.jclouds.blobstore.domain.ResourceType;
import org.jclouds.mezeo.pcs2.domain.MutableResourceInfo; import org.jclouds.mezeo.pcs2.domain.MutableResourceInfo;
import org.jclouds.mezeo.pcs2.domain.ResourceInfo; 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 ResourceType type;
private URI url; private URI url;
private String name; private String name;
private DateTime created; private Date created;
private Boolean inProject; private Boolean inProject;
private DateTime modified; private Date modified;
private String owner; private String owner;
private Integer version; private Integer version;
private Boolean shared; private Boolean shared;
private DateTime accessed; private Date accessed;
private Long bytes; private Long bytes;
private URI tags; private URI tags;
private URI metadata; private URI metadata;
@ -82,11 +82,11 @@ public class MutableResourceInfoImpl implements MutableResourceInfo {
this.name = name; this.name = name;
} }
public DateTime getCreated() { public Date getCreated() {
return created; return created;
} }
public void setCreated(DateTime created) { public void setCreated(Date created) {
this.created = created; this.created = created;
} }
@ -98,11 +98,11 @@ public class MutableResourceInfoImpl implements MutableResourceInfo {
this.inProject = inProject; this.inProject = inProject;
} }
public DateTime getModified() { public Date getModified() {
return modified; return modified;
} }
public void setModified(DateTime modified) { public void setModified(Date modified) {
this.modified = modified; this.modified = modified;
} }
@ -130,11 +130,11 @@ public class MutableResourceInfoImpl implements MutableResourceInfo {
this.shared = shared; this.shared = shared;
} }
public DateTime getAccessed() { public Date getAccessed() {
return accessed; return accessed;
} }
public void setAccessed(DateTime accessed) { public void setAccessed(Date accessed) {
this.accessed = accessed; this.accessed = accessed;
} }

View File

@ -24,10 +24,10 @@
package org.jclouds.mezeo.pcs2.domain.internal; package org.jclouds.mezeo.pcs2.domain.internal;
import java.net.URI; import java.net.URI;
import java.util.Date;
import org.jclouds.blobstore.domain.ResourceType; import org.jclouds.blobstore.domain.ResourceType;
import org.jclouds.mezeo.pcs2.domain.ResourceInfo; 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 ResourceType type;
private final URI url; private final URI url;
private final String name; private final String name;
private final DateTime created; private final Date created;
private final boolean inProject; private final boolean inProject;
private final DateTime modified; private final Date modified;
private final String owner; private final String owner;
private final int version; private final int version;
private final boolean shared; private final boolean shared;
private final DateTime accessed; private final Date accessed;
private final long bytes; private final long bytes;
private final URI tags; private final URI tags;
private final URI metadata; private final URI metadata;
private final URI parent; private final URI parent;
protected ResourceInfoImpl(ResourceType type, URI url, String name, DateTime created, protected ResourceInfoImpl(ResourceType type, URI url, String name, Date created,
boolean inProject, DateTime modified, String owner, int version, boolean shared, boolean inProject, Date modified, String owner, int version, boolean shared,
DateTime accessed, long bytes, URI tags, URI metadata, URI parent) { Date accessed, long bytes, URI tags, URI metadata, URI parent) {
super(); super();
this.type = type; this.type = type;
this.url = url; this.url = url;
@ -91,7 +91,7 @@ public class ResourceInfoImpl implements ResourceInfo {
return name; return name;
} }
public DateTime getCreated() { public Date getCreated() {
return created; return created;
} }
@ -99,7 +99,7 @@ public class ResourceInfoImpl implements ResourceInfo {
return inProject; return inProject;
} }
public DateTime getModified() { public Date getModified() {
return modified; return modified;
} }
@ -115,7 +115,7 @@ public class ResourceInfoImpl implements ResourceInfo {
return shared; return shared;
} }
public DateTime getAccessed() { public Date getAccessed() {
return accessed; return accessed;
} }

View File

@ -24,6 +24,7 @@
package org.jclouds.mezeo.pcs2.xml; package org.jclouds.mezeo.pcs2.xml;
import java.net.URI; import java.net.URI;
import java.util.Date;
import java.util.Map; import java.util.Map;
import java.util.SortedSet; 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.ContainerListImpl;
import org.jclouds.mezeo.pcs2.domain.internal.FileInfoImpl; import org.jclouds.mezeo.pcs2.domain.internal.FileInfoImpl;
import org.jclouds.util.DateService; import org.jclouds.util.DateService;
import org.joda.time.DateTime;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
@ -58,13 +58,13 @@ public class ContainerHandler extends ParseSax.HandlerWithResult<ContainerList>
private URI rootUrl; private URI rootUrl;
private String rootName; private String rootName;
private DateTime rootCreated; private Date rootCreated;
private boolean rootInproject; private boolean rootInproject;
private DateTime rootModified; private Date rootModified;
private String rootOwner; private String rootOwner;
private int rootVersion; private int rootVersion;
private boolean rootShared; private boolean rootShared;
private DateTime rootAccessed; private Date rootAccessed;
private long rootBytes; private long rootBytes;
private URI rootParent; private URI rootParent;
private URI rootTags; private URI rootTags;
@ -72,13 +72,13 @@ public class ContainerHandler extends ParseSax.HandlerWithResult<ContainerList>
private URI currentUrl; private URI currentUrl;
private String currentName; private String currentName;
private DateTime currentCreated; private Date currentCreated;
private boolean currentInproject; private boolean currentInproject;
private DateTime currentModified; private Date currentModified;
private String currentOwner; private String currentOwner;
private int currentVersion; private int currentVersion;
private boolean currentShared; private boolean currentShared;
private DateTime currentAccessed; private Date currentAccessed;
private long currentBytes; private long currentBytes;
private URI currentParent; private URI currentParent;
private URI currentTags; private URI currentTags;

View File

@ -24,6 +24,7 @@
package org.jclouds.mezeo.pcs2.xml; package org.jclouds.mezeo.pcs2.xml;
import java.net.URI; import java.net.URI;
import java.util.Date;
import java.util.Map; import java.util.Map;
import javax.inject.Inject; 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.FileInfoWithMetadata;
import org.jclouds.mezeo.pcs2.domain.internal.FileInfoWithMetadataImpl; import org.jclouds.mezeo.pcs2.domain.internal.FileInfoWithMetadataImpl;
import org.jclouds.util.DateService; import org.jclouds.util.DateService;
import org.joda.time.DateTime;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
@ -46,13 +46,13 @@ public class FileHandler extends ParseSax.HandlerWithResult<FileInfoWithMetadata
protected URI currentUrl; protected URI currentUrl;
private String currentName; private String currentName;
private DateTime currentCreated; private Date currentCreated;
private boolean currentInproject; private boolean currentInproject;
private DateTime currentModified; private Date currentModified;
private String currentOwner; private String currentOwner;
private int currentVersion; private int currentVersion;
private boolean currentShared; private boolean currentShared;
private DateTime currentAccessed; private Date currentAccessed;
private long currentBytes; private long currentBytes;
private String currentMimeType; private String currentMimeType;
private boolean currentPublic; private boolean currentPublic;

View File

@ -30,7 +30,6 @@ import java.net.UnknownHostException;
import java.util.Map; import java.util.Map;
import org.jclouds.http.functions.config.ParserModule; import org.jclouds.http.functions.config.ParserModule;
import org.jclouds.util.DateService;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
@ -47,7 +46,6 @@ import com.google.inject.Injector;
public class ParseMetadataFromJsonResponseTest { public class ParseMetadataFromJsonResponseTest {
Injector i = Guice.createInjector(new ParserModule()); Injector i = Guice.createInjector(new ParserModule());
DateService dateService = new DateService();
public void testApplyInputStreamDetails() throws UnknownHostException { public void testApplyInputStreamDetails() throws UnknownHostException {
InputStream is = getClass().getResourceAsStream("/metadata.json"); InputStream is = getClass().getResourceAsStream("/metadata.json");

View File

@ -29,7 +29,6 @@ import java.io.InputStream;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import org.jclouds.http.functions.config.ParserModule; import org.jclouds.http.functions.config.ParserModule;
import org.jclouds.util.DateService;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.gson.Gson; import com.google.gson.Gson;
@ -45,7 +44,6 @@ import com.google.inject.Injector;
public class ParseSessionTokenFromJsonResponseTest { public class ParseSessionTokenFromJsonResponseTest {
Injector i = Guice.createInjector(new ParserModule()); Injector i = Guice.createInjector(new ParserModule());
DateService dateService = new DateService();
public void testApplyInputStreamDetails() throws UnknownHostException { public void testApplyInputStreamDetails() throws UnknownHostException {
InputStream is = getClass().getResourceAsStream("/login.json"); InputStream is = getClass().getResourceAsStream("/login.json");

View File

@ -31,7 +31,6 @@ import java.net.UnknownHostException;
import org.jclouds.http.functions.config.ParserModule; import org.jclouds.http.functions.config.ParserModule;
import org.jclouds.nirvanix.sdn.domain.UploadInfo; import org.jclouds.nirvanix.sdn.domain.UploadInfo;
import org.jclouds.util.DateService;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.gson.Gson; import com.google.gson.Gson;
@ -47,7 +46,6 @@ import com.google.inject.Injector;
public class ParseUploadInfoFromJsonResponseTest { public class ParseUploadInfoFromJsonResponseTest {
Injector i = Guice.createInjector(new ParserModule()); Injector i = Guice.createInjector(new ParserModule());
DateService dateService = new DateService();
public void testApplyInputStreamDetails() throws UnknownHostException { public void testApplyInputStreamDetails() throws UnknownHostException {
InputStream is = getClass().getResourceAsStream("/authtoken.json"); InputStream is = getClass().getResourceAsStream("/authtoken.json");
@ -56,7 +54,8 @@ public class ParseUploadInfoFromJsonResponseTest {
.getInstance(Gson.class)); .getInstance(Gson.class));
UploadInfo response = parser.apply(is); UploadInfo response = parser.apply(is);
assertEquals(response.getHost(), URI.create("https://node1.nirvanix.com")); 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");
} }
} }

View File

@ -23,10 +23,10 @@
*/ */
package org.jclouds.rackspace.cloudfiles.domain; package org.jclouds.rackspace.cloudfiles.domain;
import java.util.Date;
import java.util.Map; import java.util.Map;
import org.jclouds.rackspace.cloudfiles.domain.internal.MutableObjectInfoWithMetadataImpl; import org.jclouds.rackspace.cloudfiles.domain.internal.MutableObjectInfoWithMetadataImpl;
import org.joda.time.DateTime;
import com.google.inject.ImplementedBy; import com.google.inject.ImplementedBy;
@ -44,7 +44,7 @@ public interface MutableObjectInfoWithMetadata extends ObjectInfo {
void setBytes(long bytes); void setBytes(long bytes);
void setLastModified(DateTime lastModified); void setLastModified(Date lastModified);
void setContentType(String contentType); void setContentType(String contentType);

View File

@ -23,7 +23,7 @@
*/ */
package org.jclouds.rackspace.cloudfiles.domain; 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<ObjectInfo> { public interface ObjectInfo extends Comparable<ObjectInfo> {
String getName(); String getName();
byte[] getHash(); byte[] getHash();
Long getBytes(); Long getBytes();
String getContentType(); String getContentType();
DateTime getLastModified();
Date getLastModified();
} }

View File

@ -25,13 +25,13 @@
package org.jclouds.rackspace.cloudfiles.domain.internal; package org.jclouds.rackspace.cloudfiles.domain.internal;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date;
import java.util.Map; import java.util.Map;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import org.jclouds.rackspace.cloudfiles.domain.MutableObjectInfoWithMetadata; import org.jclouds.rackspace.cloudfiles.domain.MutableObjectInfoWithMetadata;
import org.jclouds.rackspace.cloudfiles.domain.ObjectInfo; import org.jclouds.rackspace.cloudfiles.domain.ObjectInfo;
import org.joda.time.DateTime;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
@ -45,7 +45,7 @@ public class MutableObjectInfoWithMetadataImpl implements MutableObjectInfoWithM
private Long bytes; private Long bytes;
private byte[] hash; private byte[] hash;
private String contentType = MediaType.APPLICATION_OCTET_STREAM; private String contentType = MediaType.APPLICATION_OCTET_STREAM;
private DateTime lastModified; private Date lastModified;
private final Map<String, String> metadata = Maps.newHashMap(); private final Map<String, String> metadata = Maps.newHashMap();
public Map<String, String> getMetadata() { public Map<String, String> getMetadata() {
@ -80,7 +80,7 @@ public class MutableObjectInfoWithMetadataImpl implements MutableObjectInfoWithM
return hash; return hash;
} }
public DateTime getLastModified() { public Date getLastModified() {
return lastModified; return lastModified;
} }
@ -144,7 +144,7 @@ public class MutableObjectInfoWithMetadataImpl implements MutableObjectInfoWithM
return (this == o) ? 0 : getName().compareTo(o.getName()); return (this == o) ? 0 : getName().compareTo(o.getName());
} }
public void setLastModified(DateTime lastModified) { public void setLastModified(Date lastModified) {
this.lastModified = lastModified; this.lastModified = lastModified;
} }

View File

@ -30,6 +30,7 @@ import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.Date;
import java.util.SortedSet; import java.util.SortedSet;
import javax.inject.Inject; 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.rackspace.cloudfiles.options.ListContainerOptions;
import org.jclouds.rest.InvocationContext; import org.jclouds.rest.InvocationContext;
import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.joda.time.DateTime;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
@ -55,8 +55,8 @@ import com.google.gson.reflect.TypeToken;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class ParseObjectInfoListFromJsonResponse extends ParseJson<ListContainerResponse<ObjectInfo>> public class ParseObjectInfoListFromJsonResponse extends
implements InvocationContext { ParseJson<ListContainerResponse<ObjectInfo>> implements InvocationContext {
private GeneratedHttpRequest<?> request; private GeneratedHttpRequest<?> request;
@ -70,7 +70,7 @@ public class ParseObjectInfoListFromJsonResponse extends ParseJson<ListContainer
String hash; String hash;
long bytes; long bytes;
String content_type; String content_type;
DateTime last_modified; Date last_modified;
public int compareTo(ObjectInfoImpl o) { public int compareTo(ObjectInfoImpl o) {
return (this == o) ? 0 : name.compareTo(o.name); return (this == o) ? 0 : name.compareTo(o.name);
@ -88,7 +88,7 @@ public class ParseObjectInfoListFromJsonResponse extends ParseJson<ListContainer
return HttpUtils.fromHexString(hash); return HttpUtils.fromHexString(hash);
} }
public DateTime getLastModified() { public Date getLastModified() {
return last_modified; return last_modified;
} }
@ -145,6 +145,12 @@ public class ParseObjectInfoListFromJsonResponse extends ParseJson<ListContainer
public int compareTo(ObjectInfo o) { public int compareTo(ObjectInfo o) {
return (this == o) ? 0 : getName().compareTo(o.getName()); return (this == o) ? 0 : getName().compareTo(o.getName());
} }
@Override
public String toString() {
return "ObjectInfoImpl [bytes=" + bytes + ", content_type=" + content_type + ", hash="
+ hash + ", last_modified=" + last_modified.getTime() + ", name=" + name + "]";
}
} }
public ListContainerResponse<ObjectInfo> apply(InputStream stream) { public ListContainerResponse<ObjectInfo> apply(InputStream stream) {
@ -170,8 +176,8 @@ public class ParseObjectInfoListFromJsonResponse extends ParseJson<ListContainer
})); }));
boolean truncated = options.getMaxResults() == returnVal.size(); boolean truncated = options.getMaxResults() == returnVal.size();
String marker = truncated ? returnVal.last().getName() : null; String marker = truncated ? returnVal.last().getName() : null;
return new ListContainerResponseImpl<ObjectInfo>(returnVal, options.getPath(), marker, options return new ListContainerResponseImpl<ObjectInfo>(returnVal, options.getPath(), marker,
.getMaxResults(), truncated); options.getMaxResults(), truncated);
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
throw new RuntimeException("jclouds requires UTF-8 encoding", e); throw new RuntimeException("jclouds requires UTF-8 encoding", e);

View File

@ -23,13 +23,13 @@
*/ */
package org.jclouds.rackspace.cloudservers.domain; 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 * 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 * 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 * launched. These custom images are useful for backup purposes or for producing gold server images
* images if you plan to deploy a particular server configuration frequently. * if you plan to deploy a particular server configuration frequently.
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@ -37,13 +37,13 @@ public class Image {
public static final Image NOT_FOUND = new Image(-1, "NOT_FOUND"); public static final Image NOT_FOUND = new Image(-1, "NOT_FOUND");
private DateTime created; private Date created;
private int id; private int id;
private String name; private String name;
private Integer progress; private Integer progress;
private Integer serverId; private Integer serverId;
private ImageStatus status; private ImageStatus status;
private DateTime updated; private Date updated;
public Image() { public Image() {
} }
@ -53,11 +53,11 @@ public class Image {
this.name = name; this.name = name;
} }
public void setCreated(DateTime created) { public void setCreated(Date created) {
this.created = created; this.created = created;
} }
public DateTime getCreated() { public Date getCreated() {
return created; return created;
} }
@ -101,11 +101,11 @@ public class Image {
return status; return status;
} }
public void setUpdated(DateTime updated) { public void setUpdated(Date updated) {
this.updated = updated; this.updated = updated;
} }
public DateTime getUpdated() { public Date getUpdated() {
return updated; return updated;
} }

View File

@ -23,8 +23,9 @@
*/ */
package org.jclouds.rackspace.cloudservers.options; package org.jclouds.rackspace.cloudservers.options;
import java.util.Date;
import org.jclouds.rackspace.options.BaseListOptions; import org.jclouds.rackspace.options.BaseListOptions;
import org.joda.time.DateTime;
/** /**
* Options used to control the amount of detail in the request. * Options used to control the amount of detail in the request.
@ -51,7 +52,7 @@ public class ListOptions extends BaseListOptions {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public ListOptions changesSince(DateTime ifModifiedSince) { public ListOptions changesSince(Date ifModifiedSince) {
super.changesSince(ifModifiedSince); super.changesSince(ifModifiedSince);
return this; 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(); ListOptions options = new ListOptions();
return options.changesSince(since); return options.changesSince(since);
} }

View File

@ -26,8 +26,9 @@ package org.jclouds.rackspace.options;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
import java.util.Date;
import org.jclouds.http.options.BaseHttpRequestOptions; import org.jclouds.http.options.BaseHttpRequestOptions;
import org.joda.time.DateTime;
/** /**
* Options used to control paginated results (aka list commands). * 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. * 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") this.queryParameters.put("changes-since", checkNotNull(ifModifiedSince, "ifModifiedSince")
.getMillis() .getTime()
/ 1000 + ""); / 1000 + "");
return this; 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(); BaseListOptions options = new BaseListOptions();
return options.changesSince(since); return options.changesSince(since);
} }

View File

@ -36,7 +36,7 @@ import org.jclouds.rackspace.cloudfiles.domain.ObjectInfo;
import org.jclouds.rackspace.cloudfiles.functions.ParseObjectInfoListFromJsonResponse.ObjectInfoImpl; import org.jclouds.rackspace.cloudfiles.functions.ParseObjectInfoListFromJsonResponse.ObjectInfoImpl;
import org.jclouds.rackspace.cloudfiles.options.ListContainerOptions; import org.jclouds.rackspace.cloudfiles.options.ListContainerOptions;
import org.jclouds.rest.internal.GeneratedHttpRequest; 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.annotations.Test;
import org.testng.collections.Lists; import org.testng.collections.Lists;
@ -61,14 +61,16 @@ public class ParseObjectInfoListFromJsonResponseTest {
one.hash = "4281c348eaf83e70ddce0e07221c3d28"; one.hash = "4281c348eaf83e70ddce0e07221c3d28";
one.bytes = 14l; one.bytes = 14l;
one.content_type = "application/octet-stream"; 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); expects.add(one);
ObjectInfoImpl two = i.getInstance(ObjectInfoImpl.class); ObjectInfoImpl two = i.getInstance(ObjectInfoImpl.class);
two.name = ("test_obj_2"); two.name = ("test_obj_2");
two.hash = ("b039efe731ad111bc1b0ef221c3849d0"); two.hash = ("b039efe731ad111bc1b0ef221c3849d0");
two.bytes = (64l); two.bytes = (64l);
two.content_type = ("application/octet-stream"); 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); expects.add(two);
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class); GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
ListContainerOptions options = new ListContainerOptions(); ListContainerOptions options = new ListContainerOptions();

View File

@ -38,6 +38,7 @@ import java.net.InetAddress;
import java.net.URI; import java.net.URI;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.Collections; import java.util.Collections;
import java.util.Date;
import javax.ws.rs.HttpMethod; import javax.ws.rs.HttpMethod;
import javax.ws.rs.core.HttpHeaders; 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.config.RestModule;
import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.joda.time.DateTime;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -103,8 +103,8 @@ public class CloudServersClientTest {
.getClass(); .getClass();
public void testCreateServer() throws SecurityException, NoSuchMethodException { public void testCreateServer() throws SecurityException, NoSuchMethodException {
Method method = CloudServersAsyncClient.class.getMethod("createServer", String.class, int.class, Method method = CloudServersAsyncClient.class.getMethod("createServer", String.class,
int.class, createServerOptionsVarargsClass); int.class, int.class, createServerOptionsVarargsClass);
GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method, GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method,
new Object[] { "ralphie", 2, 1 }); new Object[] { "ralphie", 2, 1 });
@ -114,8 +114,8 @@ public class CloudServersClientTest {
} }
public void testCreateServerWithIpGroup() throws SecurityException, NoSuchMethodException { public void testCreateServerWithIpGroup() throws SecurityException, NoSuchMethodException {
Method method = CloudServersAsyncClient.class.getMethod("createServer", String.class, int.class, Method method = CloudServersAsyncClient.class.getMethod("createServer", String.class,
int.class, createServerOptionsVarargsClass); int.class, int.class, createServerOptionsVarargsClass);
GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method, GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method,
new Object[] { "ralphie", 2, 1, withSharedIpGroup(2) }); new Object[] { "ralphie", 2, 1, withSharedIpGroup(2) });
@ -126,8 +126,8 @@ public class CloudServersClientTest {
} }
public void testCreateServerWithFile() throws SecurityException, NoSuchMethodException { public void testCreateServerWithFile() throws SecurityException, NoSuchMethodException {
Method method = CloudServersAsyncClient.class.getMethod("createServer", String.class, int.class, Method method = CloudServersAsyncClient.class.getMethod("createServer", String.class,
int.class, createServerOptionsVarargsClass); int.class, int.class, createServerOptionsVarargsClass);
GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method, GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method,
new Object[] { "ralphie", 2, 1, new Object[] { "ralphie", 2, 1,
@ -139,8 +139,8 @@ public class CloudServersClientTest {
} }
public void testCreateServerWithMetadata() throws SecurityException, NoSuchMethodException { public void testCreateServerWithMetadata() throws SecurityException, NoSuchMethodException {
Method method = CloudServersAsyncClient.class.getMethod("createServer", String.class, int.class, Method method = CloudServersAsyncClient.class.getMethod("createServer", String.class,
int.class, createServerOptionsVarargsClass); int.class, int.class, createServerOptionsVarargsClass);
GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method, GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method,
new Object[] { "ralphie", 2, 1, withMetadata(ImmutableMap.of("foo", "bar")) }); new Object[] { "ralphie", 2, 1, withMetadata(ImmutableMap.of("foo", "bar")) });
@ -152,8 +152,8 @@ public class CloudServersClientTest {
public void testCreateServerWithIpGroupAndSharedIp() throws SecurityException, public void testCreateServerWithIpGroupAndSharedIp() throws SecurityException,
NoSuchMethodException, UnknownHostException { NoSuchMethodException, UnknownHostException {
Method method = CloudServersAsyncClient.class.getMethod("createServer", String.class, int.class, Method method = CloudServersAsyncClient.class.getMethod("createServer", String.class,
int.class, createServerOptionsVarargsClass); int.class, int.class, createServerOptionsVarargsClass);
GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method, GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method,
new Object[] { new Object[] {
@ -187,7 +187,8 @@ public class CloudServersClientTest {
} }
public void testListServers() throws SecurityException, NoSuchMethodException { public void testListServers() throws SecurityException, NoSuchMethodException {
Method method = CloudServersAsyncClient.class.getMethod("listServers", listOptionsVarargsClass); Method method = CloudServersAsyncClient.class.getMethod("listServers",
listOptionsVarargsClass);
GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method, GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method,
new Object[] {}); new Object[] {});
@ -201,17 +202,18 @@ public class CloudServersClientTest {
assertEquals(processor.createExceptionParserOrNullIfNotFound(method), null); assertEquals(processor.createExceptionParserOrNullIfNotFound(method), null);
} }
DateTime now = new DateTime(); Date now = new Date();
public void testListServersOptions() throws SecurityException, NoSuchMethodException { public void testListServersOptions() throws SecurityException, NoSuchMethodException {
Method method = CloudServersAsyncClient.class.getMethod("listServers", listOptionsVarargsClass); Method method = CloudServersAsyncClient.class.getMethod("listServers",
listOptionsVarargsClass);
GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method, GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method,
new Object[] { changesSince(now).maxResults(1).startAt(2) }); new Object[] { changesSince(now).maxResults(1).startAt(2) });
assertEquals(httpMethod.getEndpoint().getHost(), "localhost"); assertEquals(httpMethod.getEndpoint().getHost(), "localhost");
assertEquals(httpMethod.getEndpoint().getPath(), "/servers"); assertEquals(httpMethod.getEndpoint().getPath(), "/servers");
assertEquals(httpMethod.getEndpoint().getQuery(), "format=json&changes-since=" 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.getMethod(), HttpMethod.GET);
assertEquals(httpMethod.getHeaders().size(), 0); assertEquals(httpMethod.getHeaders().size(), 0);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(), assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
@ -220,7 +222,8 @@ public class CloudServersClientTest {
} }
public void testListServersDetail() throws SecurityException, NoSuchMethodException { public void testListServersDetail() throws SecurityException, NoSuchMethodException {
Method method = CloudServersAsyncClient.class.getMethod("listServers", listOptionsVarargsClass); Method method = CloudServersAsyncClient.class.getMethod("listServers",
listOptionsVarargsClass);
GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method, GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method,
new Object[] { withDetails() }); new Object[] { withDetails() });
@ -251,7 +254,8 @@ public class CloudServersClientTest {
} }
public void testListFlavors() throws SecurityException, NoSuchMethodException { public void testListFlavors() throws SecurityException, NoSuchMethodException {
Method method = CloudServersAsyncClient.class.getMethod("listFlavors", listOptionsVarargsClass); Method method = CloudServersAsyncClient.class.getMethod("listFlavors",
listOptionsVarargsClass);
GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method, GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method,
new Object[] {}); new Object[] {});
@ -266,14 +270,15 @@ public class CloudServersClientTest {
} }
public void testListFlavorsOptions() throws SecurityException, NoSuchMethodException { public void testListFlavorsOptions() throws SecurityException, NoSuchMethodException {
Method method = CloudServersAsyncClient.class.getMethod("listFlavors", listOptionsVarargsClass); Method method = CloudServersAsyncClient.class.getMethod("listFlavors",
listOptionsVarargsClass);
GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method, GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method,
new Object[] { changesSince(now).maxResults(1).startAt(2) }); new Object[] { changesSince(now).maxResults(1).startAt(2) });
assertEquals(httpMethod.getEndpoint().getHost(), "localhost"); assertEquals(httpMethod.getEndpoint().getHost(), "localhost");
assertEquals(httpMethod.getEndpoint().getPath(), "/flavors"); assertEquals(httpMethod.getEndpoint().getPath(), "/flavors");
assertEquals(httpMethod.getEndpoint().getQuery(), "format=json&changes-since=" 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.getMethod(), HttpMethod.GET);
assertEquals(httpMethod.getHeaders().size(), 0); assertEquals(httpMethod.getHeaders().size(), 0);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(), assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
@ -282,7 +287,8 @@ public class CloudServersClientTest {
} }
public void testListFlavorsDetail() throws SecurityException, NoSuchMethodException { public void testListFlavorsDetail() throws SecurityException, NoSuchMethodException {
Method method = CloudServersAsyncClient.class.getMethod("listFlavors", listOptionsVarargsClass); Method method = CloudServersAsyncClient.class.getMethod("listFlavors",
listOptionsVarargsClass);
GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method, GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method,
new Object[] { withDetails() }); new Object[] { withDetails() });
@ -297,14 +303,15 @@ public class CloudServersClientTest {
} }
public void testListFlavorsDetailOptions() throws SecurityException, NoSuchMethodException { public void testListFlavorsDetailOptions() throws SecurityException, NoSuchMethodException {
Method method = CloudServersAsyncClient.class.getMethod("listFlavors", listOptionsVarargsClass); Method method = CloudServersAsyncClient.class.getMethod("listFlavors",
listOptionsVarargsClass);
GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method, GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method,
new Object[] { withDetails().changesSince(now).maxResults(1).startAt(2) }); new Object[] { withDetails().changesSince(now).maxResults(1).startAt(2) });
assertEquals(httpMethod.getEndpoint().getHost(), "localhost"); assertEquals(httpMethod.getEndpoint().getHost(), "localhost");
assertEquals(httpMethod.getEndpoint().getPath(), "/flavors/detail"); assertEquals(httpMethod.getEndpoint().getPath(), "/flavors/detail");
assertEquals(httpMethod.getEndpoint().getQuery(), "format=json&changes-since=" 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.getMethod(), HttpMethod.GET);
assertEquals(httpMethod.getHeaders().size(), 0); assertEquals(httpMethod.getHeaders().size(), 0);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(), assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
@ -329,7 +336,8 @@ public class CloudServersClientTest {
} }
public void testListImages() throws SecurityException, NoSuchMethodException { public void testListImages() throws SecurityException, NoSuchMethodException {
Method method = CloudServersAsyncClient.class.getMethod("listImages", listOptionsVarargsClass); Method method = CloudServersAsyncClient.class
.getMethod("listImages", listOptionsVarargsClass);
GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method, GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method,
new Object[] {}); new Object[] {});
@ -344,7 +352,8 @@ public class CloudServersClientTest {
} }
public void testListImagesDetail() throws SecurityException, NoSuchMethodException { public void testListImagesDetail() throws SecurityException, NoSuchMethodException {
Method method = CloudServersAsyncClient.class.getMethod("listImages", listOptionsVarargsClass); Method method = CloudServersAsyncClient.class
.getMethod("listImages", listOptionsVarargsClass);
GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method, GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method,
new Object[] { withDetails() }); new Object[] { withDetails() });
@ -359,14 +368,15 @@ public class CloudServersClientTest {
} }
public void testListImagesOptions() throws SecurityException, NoSuchMethodException { public void testListImagesOptions() throws SecurityException, NoSuchMethodException {
Method method = CloudServersAsyncClient.class.getMethod("listImages", listOptionsVarargsClass); Method method = CloudServersAsyncClient.class
.getMethod("listImages", listOptionsVarargsClass);
GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method, GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method,
new Object[] { changesSince(now).maxResults(1).startAt(2) }); new Object[] { changesSince(now).maxResults(1).startAt(2) });
assertEquals(httpMethod.getEndpoint().getHost(), "localhost"); assertEquals(httpMethod.getEndpoint().getHost(), "localhost");
assertEquals(httpMethod.getEndpoint().getPath(), "/images"); assertEquals(httpMethod.getEndpoint().getPath(), "/images");
assertEquals(httpMethod.getEndpoint().getQuery(), "format=json&changes-since=" 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.getMethod(), HttpMethod.GET);
assertEquals(httpMethod.getHeaders().size(), 0); assertEquals(httpMethod.getHeaders().size(), 0);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(), assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
@ -375,14 +385,15 @@ public class CloudServersClientTest {
} }
public void testListImagesDetailOptions() throws SecurityException, NoSuchMethodException { public void testListImagesDetailOptions() throws SecurityException, NoSuchMethodException {
Method method = CloudServersAsyncClient.class.getMethod("listImages", listOptionsVarargsClass); Method method = CloudServersAsyncClient.class
.getMethod("listImages", listOptionsVarargsClass);
GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method, GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method,
new Object[] { withDetails().changesSince(now).maxResults(1).startAt(2) }); new Object[] { withDetails().changesSince(now).maxResults(1).startAt(2) });
assertEquals(httpMethod.getEndpoint().getHost(), "localhost"); assertEquals(httpMethod.getEndpoint().getHost(), "localhost");
assertEquals(httpMethod.getEndpoint().getPath(), "/images/detail"); assertEquals(httpMethod.getEndpoint().getPath(), "/images/detail");
assertEquals(httpMethod.getEndpoint().getQuery(), "format=json&changes-since=" 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.getMethod(), HttpMethod.GET);
assertEquals(httpMethod.getHeaders().size(), 0); assertEquals(httpMethod.getHeaders().size(), 0);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(), assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
@ -423,8 +434,8 @@ public class CloudServersClientTest {
public void testShareIpNoConfig() throws SecurityException, NoSuchMethodException, public void testShareIpNoConfig() throws SecurityException, NoSuchMethodException,
UnknownHostException { UnknownHostException {
Method method = CloudServersAsyncClient.class.getMethod("shareIp", InetAddress.class, int.class, Method method = CloudServersAsyncClient.class.getMethod("shareIp", InetAddress.class,
int.class, boolean.class); int.class, int.class, boolean.class);
GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method, GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method,
new Object[] { InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 }), 2, 3, false }); 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, public void testShareIpConfig() throws SecurityException, NoSuchMethodException,
UnknownHostException { UnknownHostException {
Method method = CloudServersAsyncClient.class.getMethod("shareIp", InetAddress.class, int.class, Method method = CloudServersAsyncClient.class.getMethod("shareIp", InetAddress.class,
int.class, boolean.class); int.class, int.class, boolean.class);
GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method, GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method,
new Object[] { InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 }), 2, 3, true }); 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, public void testUnshareIpNoConfig() throws SecurityException, NoSuchMethodException,
UnknownHostException { UnknownHostException {
Method method = CloudServersAsyncClient.class.getMethod("unshareIp", InetAddress.class, int.class); Method method = CloudServersAsyncClient.class.getMethod("unshareIp", InetAddress.class,
int.class);
GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method, GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method,
new Object[] { InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 }), 2, 3, false }); 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 { public void testChangeAdminPass() throws SecurityException, NoSuchMethodException {
Method method = CloudServersAsyncClient.class Method method = CloudServersAsyncClient.class.getMethod("changeAdminPass", int.class,
.getMethod("changeAdminPass", int.class, String.class); String.class);
GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method, GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method,
new Object[] { 2, "foo" }); new Object[] { 2, "foo" });
@ -542,7 +554,8 @@ public class CloudServersClientTest {
} }
public void testChangeServerName() throws SecurityException, NoSuchMethodException { 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<CloudServersAsyncClient> httpMethod = processor.createRequest(method, GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method,
new Object[] { 2, "foo" }); new Object[] { 2, "foo" });
@ -586,7 +599,7 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getEndpoint().getHost(), "localhost"); assertEquals(httpMethod.getEndpoint().getHost(), "localhost");
assertEquals(httpMethod.getEndpoint().getPath(), "/shared_ip_groups"); assertEquals(httpMethod.getEndpoint().getPath(), "/shared_ip_groups");
assertEquals(httpMethod.getEndpoint().getQuery(), "format=json&changes-since=" 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.getMethod(), HttpMethod.GET);
assertEquals(httpMethod.getHeaders().size(), 0); assertEquals(httpMethod.getHeaders().size(), 0);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(), assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
@ -620,7 +633,7 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getEndpoint().getHost(), "localhost"); assertEquals(httpMethod.getEndpoint().getHost(), "localhost");
assertEquals(httpMethod.getEndpoint().getPath(), "/shared_ip_groups/detail"); assertEquals(httpMethod.getEndpoint().getPath(), "/shared_ip_groups/detail");
assertEquals(httpMethod.getEndpoint().getQuery(), "format=json&changes-since=" 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.getMethod(), HttpMethod.GET);
assertEquals(httpMethod.getHeaders().size(), 0); assertEquals(httpMethod.getHeaders().size(), 0);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(), assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
@ -758,8 +771,8 @@ public class CloudServersClientTest {
} }
public void testCreateImageWithIpGroup() throws SecurityException, NoSuchMethodException { public void testCreateImageWithIpGroup() throws SecurityException, NoSuchMethodException {
Method method = CloudServersAsyncClient.class.getMethod("createImageFromServer", String.class, Method method = CloudServersAsyncClient.class.getMethod("createImageFromServer",
int.class); String.class, int.class);
GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method, GeneratedHttpRequest<CloudServersAsyncClient> httpMethod = processor.createRequest(method,
new Object[] { "ralphie", 2 }); new Object[] { "ralphie", 2 });

View File

@ -32,7 +32,6 @@ import java.util.List;
import org.jclouds.http.functions.config.ParserModule; import org.jclouds.http.functions.config.ParserModule;
import org.jclouds.rackspace.cloudservers.domain.Addresses; import org.jclouds.rackspace.cloudservers.domain.Addresses;
import org.jclouds.util.DateService;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.gson.Gson; import com.google.gson.Gson;
@ -49,7 +48,6 @@ import com.google.inject.internal.ImmutableList;
public class ParseAddressesFromJsonResponseTest { public class ParseAddressesFromJsonResponseTest {
Injector i = Guice.createInjector(new ParserModule()); Injector i = Guice.createInjector(new ParserModule());
DateService dateService = new DateService();
public void testApplyInputStreamDetails() throws UnknownHostException { public void testApplyInputStreamDetails() throws UnknownHostException {
InputStream is = getClass().getResourceAsStream("/cloudservers/test_list_addresses.json"); InputStream is = getClass().getResourceAsStream("/cloudservers/test_list_addresses.json");

View File

@ -30,7 +30,6 @@ import java.net.UnknownHostException;
import org.jclouds.http.functions.config.ParserModule; import org.jclouds.http.functions.config.ParserModule;
import org.jclouds.rackspace.cloudservers.domain.Flavor; import org.jclouds.rackspace.cloudservers.domain.Flavor;
import org.jclouds.util.DateService;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.gson.Gson; import com.google.gson.Gson;
@ -46,7 +45,6 @@ import com.google.inject.Injector;
public class ParseFlavorFromJsonResponseTest { public class ParseFlavorFromJsonResponseTest {
Injector i = Guice.createInjector(new ParserModule()); Injector i = Guice.createInjector(new ParserModule());
DateService dateService = new DateService();
public void testApplyInputStreamDetails() throws UnknownHostException { public void testApplyInputStreamDetails() throws UnknownHostException {
InputStream is = getClass().getResourceAsStream("/cloudservers/test_get_flavor_details.json"); InputStream is = getClass().getResourceAsStream("/cloudservers/test_get_flavor_details.json");

View File

@ -32,7 +32,6 @@ import org.jclouds.http.functions.config.ParserModule;
import org.jclouds.rackspace.cloudservers.domain.Image; import org.jclouds.rackspace.cloudservers.domain.Image;
import org.jclouds.rackspace.cloudservers.domain.ImageStatus; import org.jclouds.rackspace.cloudservers.domain.ImageStatus;
import org.jclouds.util.DateService; import org.jclouds.util.DateService;
import org.joda.time.DateTime;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.gson.Gson; import com.google.gson.Gson;
@ -48,7 +47,7 @@ import com.google.inject.Injector;
public class ParseImageFromJsonResponseTest { public class ParseImageFromJsonResponseTest {
Injector i = Guice.createInjector(new ParserModule()); Injector i = Guice.createInjector(new ParserModule());
DateService dateService = new DateService(); DateService dateService = i.getInstance(DateService.class);
public void testApplyInputStreamDetails() throws UnknownHostException { public void testApplyInputStreamDetails() throws UnknownHostException {
InputStream is = getClass().getResourceAsStream("/cloudservers/test_get_image_details.json"); InputStream is = getClass().getResourceAsStream("/cloudservers/test_get_image_details.json");
@ -57,11 +56,12 @@ public class ParseImageFromJsonResponseTest {
Image response = parser.apply(is); Image response = parser.apply(is);
assertEquals(response.getId(), 2); assertEquals(response.getId(), 2);
assertEquals(response.getName(), "CentOS 5.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.getProgress(), new Integer(80));
assertEquals(response.getServerId(), new Integer(12)); assertEquals(response.getServerId(), new Integer(12));
assertEquals(response.getStatus(), ImageStatus.SAVING); 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")));
} }
} }

View File

@ -33,7 +33,6 @@ import org.jclouds.http.functions.config.ParserModule;
import org.jclouds.rackspace.cloudservers.domain.Image; import org.jclouds.rackspace.cloudservers.domain.Image;
import org.jclouds.rackspace.cloudservers.domain.ImageStatus; import org.jclouds.rackspace.cloudservers.domain.ImageStatus;
import org.jclouds.util.DateService; import org.jclouds.util.DateService;
import org.joda.time.DateTime;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -50,7 +49,7 @@ import com.google.inject.Injector;
public class ParseImageListFromJsonResponseTest { public class ParseImageListFromJsonResponseTest {
Injector i = Guice.createInjector(new ParserModule()); Injector i = Guice.createInjector(new ParserModule());
DateService dateService = new DateService(); DateService dateService = i.getInstance(DateService.class);
public void testApplyInputStream() { public void testApplyInputStream() {
InputStream is = getClass().getResourceAsStream("/cloudservers/test_list_images.json"); InputStream is = getClass().getResourceAsStream("/cloudservers/test_list_images.json");
@ -70,20 +69,24 @@ public class ParseImageListFromJsonResponseTest {
List<Image> response = parser.apply(is); List<Image> response = parser.apply(is);
assertEquals(response.get(0).getId(), 2); assertEquals(response.get(0).getId(), 2);
assertEquals(response.get(0).getName(), "CentOS 5.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).getProgress(), null);
assertEquals(response.get(0).getServerId(), null); assertEquals(response.get(0).getServerId(), null);
assertEquals(response.get(0).getStatus(), ImageStatus.ACTIVE); 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).getId(), 743);
assertEquals(response.get(1).getName(), "My Server Backup"); 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).getProgress(), new Integer(80));
assertEquals(response.get(1).getServerId(), new Integer(12)); assertEquals(response.get(1).getServerId(), new Integer(12));
assertEquals(response.get(1).getStatus(), ImageStatus.SAVING); 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"));
} }
} }

View File

@ -31,7 +31,6 @@ import java.net.UnknownHostException;
import java.util.List; import java.util.List;
import org.jclouds.http.functions.config.ParserModule; import org.jclouds.http.functions.config.ParserModule;
import org.jclouds.util.DateService;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.gson.Gson; import com.google.gson.Gson;
@ -48,10 +47,10 @@ import com.google.inject.internal.ImmutableList;
public class ParseInetAddressListFromJsonResponseTest { public class ParseInetAddressListFromJsonResponseTest {
Injector i = Guice.createInjector(new ParserModule()); Injector i = Guice.createInjector(new ParserModule());
DateService dateService = new DateService();
public void testPublic() throws UnknownHostException { 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 ParseInetAddressListFromJsonResponse parser = new ParseInetAddressListFromJsonResponse(i
.getInstance(Gson.class)); .getInstance(Gson.class));
@ -61,7 +60,8 @@ public class ParseInetAddressListFromJsonResponseTest {
} }
public void testPrivate() throws UnknownHostException { 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 ParseInetAddressListFromJsonResponse parser = new ParseInetAddressListFromJsonResponse(i
.getInstance(Gson.class)); .getInstance(Gson.class));

View File

@ -30,7 +30,6 @@ import java.net.UnknownHostException;
import org.jclouds.http.functions.config.ParserModule; import org.jclouds.http.functions.config.ParserModule;
import org.jclouds.rackspace.cloudservers.domain.SharedIpGroup; import org.jclouds.rackspace.cloudservers.domain.SharedIpGroup;
import org.jclouds.util.DateService;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -47,7 +46,6 @@ import com.google.inject.Injector;
public class ParseSharedIpGroupFromJsonResponseTest { public class ParseSharedIpGroupFromJsonResponseTest {
Injector i = Guice.createInjector(new ParserModule()); Injector i = Guice.createInjector(new ParserModule());
DateService dateService = new DateService();
public void testApplyInputStreamDetails() throws UnknownHostException { public void testApplyInputStreamDetails() throws UnknownHostException {
InputStream is = getClass().getResourceAsStream("/cloudservers/test_get_sharedipgroup_details.json"); InputStream is = getClass().getResourceAsStream("/cloudservers/test_get_sharedipgroup_details.json");

View File

@ -23,10 +23,14 @@
*/ */
package org.jclouds.rackspace.cloudservers.options; 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 static org.testng.Assert.assertEquals;
import org.joda.time.DateTime; import java.util.Date;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -50,9 +54,9 @@ public class ListOptionsTest {
} }
public void testChangesSince() { public void testChangesSince() {
DateTime ifModifiedSince = new DateTime(); Date ifModifiedSince = new Date();
ListOptions options = new ListOptions().changesSince(ifModifiedSince); ListOptions options = new ListOptions().changesSince(ifModifiedSince);
assertEquals(ImmutableList.of(ifModifiedSince.getMillis() / 1000 + ""), options assertEquals(ImmutableList.of(ifModifiedSince.getTime() / 1000 + ""), options
.buildQueryParameters().get("changes-since")); .buildQueryParameters().get("changes-since"));
} }
@ -69,9 +73,9 @@ public class ListOptionsTest {
} }
public void testChangesSinceStatic() { public void testChangesSinceStatic() {
DateTime ifModifiedSince = new DateTime(); Date ifModifiedSince = new Date();
ListOptions options = changesSince(ifModifiedSince); ListOptions options = changesSince(ifModifiedSince);
assertEquals(ImmutableList.of(ifModifiedSince.getMillis() / 1000 + ""), options assertEquals(ImmutableList.of(ifModifiedSince.getTime() / 1000 + ""), options
.buildQueryParameters().get("changes-since")); .buildQueryParameters().get("changes-since"));
} }

View File

@ -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.jclouds.rackspace.options.BaseListOptions.Builder.startAt;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import org.joda.time.DateTime; import java.util.Date;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -42,9 +43,9 @@ import com.google.common.collect.ImmutableList;
public class BaseListOptionsTest { public class BaseListOptionsTest {
public void testChangesSince() { public void testChangesSince() {
DateTime ifModifiedSince = new DateTime(); Date ifModifiedSince = new Date();
BaseListOptions options = new BaseListOptions().changesSince(ifModifiedSince); BaseListOptions options = new BaseListOptions().changesSince(ifModifiedSince);
assertEquals(ImmutableList.of(ifModifiedSince.getMillis() / 1000 + ""), options assertEquals(ImmutableList.of(ifModifiedSince.getTime() / 1000 + ""), options
.buildQueryParameters().get("changes-since")); .buildQueryParameters().get("changes-since"));
} }
@ -61,9 +62,9 @@ public class BaseListOptionsTest {
} }
public void testChangesSinceStatic() { public void testChangesSinceStatic() {
DateTime ifModifiedSince = new DateTime(); Date ifModifiedSince = new Date();
BaseListOptions options = changesSince(ifModifiedSince); BaseListOptions options = changesSince(ifModifiedSince);
assertEquals(ImmutableList.of(ifModifiedSince.getMillis() / 1000 + ""), options assertEquals(ImmutableList.of(ifModifiedSince.getTime() / 1000 + ""), options
.buildQueryParameters().get("changes-since")); .buildQueryParameters().get("changes-since"));
} }

View File

@ -23,14 +23,14 @@
*/ */
package org.jclouds.rimuhosting.miro.binder; 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.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import java.util.Map; 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 * @author Ivan Meredith
*/ */

View File

@ -23,24 +23,25 @@
*/ */
package org.jclouds.rimuhosting.miro.config; package org.jclouds.rimuhosting.miro.config;
import com.google.inject.AbstractModule; import java.net.URI;
import com.google.inject.Provides;
import com.google.inject.Scopes; import javax.inject.Named;
import org.jclouds.http.functions.config.ParserModule.CDateTimeAdapter; import javax.inject.Singleton;
import org.jclouds.http.functions.config.ParserModule.DateTimeAdapter;
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.lifecycle.Closer;
import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.RestContextImpl; import org.jclouds.rest.internal.RestContextImpl;
import org.jclouds.rimuhosting.miro.RimuHosting; import org.jclouds.rimuhosting.miro.RimuHosting;
import org.jclouds.rimuhosting.miro.RimuHostingAsyncClient; import org.jclouds.rimuhosting.miro.RimuHostingAsyncClient;
import org.jclouds.rimuhosting.miro.RimuHostingClient; import org.jclouds.rimuhosting.miro.RimuHostingClient;
import org.jclouds.rimuhosting.miro.servers.RimuHostingComputeService;
import org.jclouds.rimuhosting.miro.reference.RimuHostingConstants; import org.jclouds.rimuhosting.miro.reference.RimuHostingConstants;
import org.jclouds.compute.ComputeService; import org.jclouds.rimuhosting.miro.servers.RimuHostingComputeService;
import javax.inject.Named; import com.google.inject.AbstractModule;
import javax.inject.Singleton; import com.google.inject.Provides;
import java.net.URI;
/** /**
* Configures the RimuHosting connection, including logging and http transport. * Configures the RimuHosting connection, including logging and http transport.
@ -50,7 +51,7 @@ import java.net.URI;
public class RimuHostingContextModule extends AbstractModule { public class RimuHostingContextModule extends AbstractModule {
@Override @Override
protected void configure() { protected void configure() {
bind(DateTimeAdapter.class).to(CDateTimeAdapter.class); bind(DateAdapter.class).to(CDateAdapter.class);
bind(ComputeService.class).to(RimuHostingComputeService.class); bind(ComputeService.class).to(RimuHostingComputeService.class);
} }

View File

@ -23,15 +23,15 @@
*/ */
package org.jclouds.rimuhosting.miro.config; package org.jclouds.rimuhosting.miro.config;
import com.google.inject.Guice; import static org.testng.Assert.assertEquals;
import com.google.inject.Injector;
import org.jclouds.concurrent.WithinThreadExecutorService; import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.http.HttpRetryHandler; import org.jclouds.http.HttpRetryHandler;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
import org.jclouds.http.functions.config.ParserModule; import org.jclouds.http.functions.config.ParserModule;
import org.jclouds.http.functions.config.ParserModule.CDateTimeAdapter; import org.jclouds.http.functions.config.ParserModule.CDateAdapter;
import org.jclouds.http.functions.config.ParserModule.DateTimeAdapter; import org.jclouds.http.functions.config.ParserModule.DateAdapter;
import org.jclouds.http.handlers.CloseContentAndSetExceptionErrorHandler; import org.jclouds.http.handlers.CloseContentAndSetExceptionErrorHandler;
import org.jclouds.http.handlers.DelegatingErrorHandler; import org.jclouds.http.handlers.DelegatingErrorHandler;
import org.jclouds.http.handlers.DelegatingRetryHandler; import org.jclouds.http.handlers.DelegatingRetryHandler;
@ -40,9 +40,11 @@ import org.jclouds.logging.Logger;
import org.jclouds.logging.Logger.LoggerFactory; import org.jclouds.logging.Logger.LoggerFactory;
import org.jclouds.rimuhosting.miro.reference.RimuHostingConstants; import org.jclouds.rimuhosting.miro.reference.RimuHostingConstants;
import org.jclouds.util.Jsr330; import org.jclouds.util.Jsr330;
import static org.testng.Assert.assertEquals;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
/** /**
* @author Adrian Cole * @author Adrian Cole
*/ */
@ -50,15 +52,19 @@ import org.testng.annotations.Test;
public class RimuHostingContextModuleTest { public class RimuHostingContextModuleTest {
Injector createInjector() { Injector createInjector() {
return Guice.createInjector(new RimuHostingRestClientModule(), new RimuHostingContextModule() { return Guice.createInjector(new RimuHostingRestClientModule(),
new RimuHostingContextModule() {
@Override @Override
protected void configure() { protected void configure() {
bindConstant().annotatedWith(Jsr330.named(RimuHostingConstants.PROPERTY_RIMUHOSTING_USER)).to( bindConstant().annotatedWith(
Jsr330.named(RimuHostingConstants.PROPERTY_RIMUHOSTING_USER)).to(
"user"); "user");
bindConstant().annotatedWith(Jsr330.named(RimuHostingConstants.PROPERTY_RIMUHOSTING_PASSWORD)) bindConstant().annotatedWith(
.to("password"); Jsr330.named(RimuHostingConstants.PROPERTY_RIMUHOSTING_PASSWORD)).to(
bindConstant().annotatedWith(Jsr330.named(RimuHostingConstants.PROPERTY_RIMUHOSTING_ENDPOINT)) "password");
.to("http://localhost"); bindConstant().annotatedWith(
Jsr330.named(RimuHostingConstants.PROPERTY_RIMUHOSTING_ENDPOINT)).to(
"http://localhost");
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() { bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
public Logger getLogger(String category) { public Logger getLogger(String category) {
return Logger.NULL; return Logger.NULL;
@ -78,9 +84,9 @@ public class RimuHostingContextModuleTest {
} }
@Test @Test
void testDateTimeAdapter() { void testDateAdapter() {
assertEquals(this.createInjector().getInstance(DateTimeAdapter.class).getClass(), assertEquals(this.createInjector().getInstance(DateAdapter.class).getClass(),
CDateTimeAdapter.class); CDateAdapter.class);
} }
@Test @Test

View File

@ -43,6 +43,11 @@
</properties> </properties>
<dependencies> <dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jclouds-blobstore</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>jclouds-aws</artifactId> <artifactId>jclouds-aws</artifactId>

View File

@ -41,6 +41,11 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jclouds-blobstore</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>jclouds-aws</artifactId> <artifactId>jclouds-aws</artifactId>

View File

@ -342,7 +342,7 @@ public class BlobStoreFileObject extends AbstractFileObject {
if (metadata == null || metadata.getLastModified() == null) { if (metadata == null || metadata.getLastModified() == null) {
getMetadataAtPath(getNameTrimLeadingSlashes()); getMetadataAtPath(getNameTrimLeadingSlashes());
} }
return metadata.getLastModified() != null ? metadata.getLastModified().getMillis() : super return metadata.getLastModified() != null ? metadata.getLastModified().getTime() : super
.doGetLastModifiedTime(); .doGetLastModifiedTime();
} }

Some files were not shown because too many files have changed in this diff Show More