mirror of https://github.com/apache/jclouds.git
set default mime type
git-svn-id: http://jclouds.googlecode.com/svn/trunk@71 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
d6284ea47e
commit
9dfac47f05
|
@ -24,7 +24,6 @@
|
||||||
package org.jclouds.aws.s3.domain;
|
package org.jclouds.aws.s3.domain;
|
||||||
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.jclouds.aws.s3.domain.S3Owner;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* // TODO: Adrian: Document this!
|
* // TODO: Adrian: Document this!
|
||||||
|
@ -34,13 +33,16 @@ import org.jclouds.aws.s3.domain.S3Owner;
|
||||||
public class S3Object {
|
public class S3Object {
|
||||||
public static final S3Object NOT_FOUND = new S3Object();
|
public static final S3Object NOT_FOUND = new S3Object();
|
||||||
|
|
||||||
|
public static final String UNKNOWN_MIME_TYPE = "application/x-unknown-mime-type";
|
||||||
|
|
||||||
private String key;
|
private String key;
|
||||||
private DateTime lastModified;
|
private DateTime lastModified;
|
||||||
private String eTag;
|
private String eTag;
|
||||||
private long size;
|
private long size = -1;
|
||||||
private S3Owner owner;
|
private S3Owner owner;
|
||||||
private String contentType;
|
private String contentType = UNKNOWN_MIME_TYPE;
|
||||||
private String storageClass = "STANDARD"; //there is currently no other type.
|
private String storageClass = "STANDARD"; // there is currently no other
|
||||||
|
// type.
|
||||||
private String contentMD5;
|
private String contentMD5;
|
||||||
private String server;
|
private String server;
|
||||||
private Object content;
|
private Object content;
|
||||||
|
@ -127,22 +129,36 @@ public class S3Object {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o)
|
||||||
if (!(o instanceof S3Object)) return false;
|
return true;
|
||||||
|
if (!(o instanceof S3Object))
|
||||||
|
return false;
|
||||||
|
|
||||||
S3Object s3Object = (S3Object) o;
|
S3Object s3Object = (S3Object) o;
|
||||||
|
|
||||||
if (size != s3Object.size) return false;
|
if (size != s3Object.size)
|
||||||
if (contentMD5 != null ? !contentMD5.equals(s3Object.contentMD5) : s3Object.contentMD5 != null) return false;
|
|
||||||
if (contentType != null ? !contentType.equals(s3Object.contentType) : s3Object.contentType != null)
|
|
||||||
return false;
|
return false;
|
||||||
if (eTag != null ? !eTag.equals(s3Object.eTag) : s3Object.eTag != null) return false;
|
if (contentMD5 != null ? !contentMD5.equals(s3Object.contentMD5)
|
||||||
if (!key.equals(s3Object.key)) return false;
|
: s3Object.contentMD5 != null)
|
||||||
if (lastModified != null ? !lastModified.equals(s3Object.lastModified) : s3Object.lastModified != null)
|
|
||||||
return false;
|
return false;
|
||||||
if (owner != null ? !owner.equals(s3Object.owner) : s3Object.owner != null) return false;
|
if (contentType != null ? !contentType.equals(s3Object.contentType)
|
||||||
if (server != null ? !server.equals(s3Object.server) : s3Object.server != null) return false;
|
: s3Object.contentType != null)
|
||||||
if (storageClass != null ? !storageClass.equals(s3Object.storageClass) : s3Object.storageClass != null)
|
return false;
|
||||||
|
if (eTag != null ? !eTag.equals(s3Object.eTag) : s3Object.eTag != null)
|
||||||
|
return false;
|
||||||
|
if (!key.equals(s3Object.key))
|
||||||
|
return false;
|
||||||
|
if (lastModified != null ? !lastModified.equals(s3Object.lastModified)
|
||||||
|
: s3Object.lastModified != null)
|
||||||
|
return false;
|
||||||
|
if (owner != null ? !owner.equals(s3Object.owner)
|
||||||
|
: s3Object.owner != null)
|
||||||
|
return false;
|
||||||
|
if (server != null ? !server.equals(s3Object.server)
|
||||||
|
: s3Object.server != null)
|
||||||
|
return false;
|
||||||
|
if (storageClass != null ? !storageClass.equals(s3Object.storageClass)
|
||||||
|
: s3Object.storageClass != null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -151,15 +167,17 @@ public class S3Object {
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result = key.hashCode();
|
int result = key.hashCode();
|
||||||
result = 31 * result + (lastModified != null ? lastModified.hashCode() : 0);
|
result = 31 * result
|
||||||
|
+ (lastModified != null ? lastModified.hashCode() : 0);
|
||||||
result = 31 * result + (eTag != null ? eTag.hashCode() : 0);
|
result = 31 * result + (eTag != null ? eTag.hashCode() : 0);
|
||||||
result = 31 * result + (int) (size ^ (size >>> 32));
|
result = 31 * result + (int) (size ^ (size >>> 32));
|
||||||
result = 31 * result + (owner != null ? owner.hashCode() : 0);
|
result = 31 * result + (owner != null ? owner.hashCode() : 0);
|
||||||
result = 31 * result + (contentType != null ? contentType.hashCode() : 0);
|
result = 31 * result
|
||||||
result = 31 * result + (storageClass != null ? storageClass.hashCode() : 0);
|
+ (contentType != null ? contentType.hashCode() : 0);
|
||||||
|
result = 31 * result
|
||||||
|
+ (storageClass != null ? storageClass.hashCode() : 0);
|
||||||
result = 31 * result + (contentMD5 != null ? contentMD5.hashCode() : 0);
|
result = 31 * result + (contentMD5 != null ? contentMD5.hashCode() : 0);
|
||||||
result = 31 * result + (server != null ? server.hashCode() : 0);
|
result = 31 * result + (server != null ? server.hashCode() : 0);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Adrian Cole <adriancole@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
|
||||||
|
*
|
||||||
|
* 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.aws.s3.domain;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
import org.jclouds.aws.s3.domain.S3Object;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public class S3ObjectTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testSetNoContentType(){
|
||||||
|
S3Object object = new S3Object();
|
||||||
|
File file = new File("hello.txt");
|
||||||
|
object.setContent(file);
|
||||||
|
Assert.assertEquals(object.getContentType(), S3Object.UNKNOWN_MIME_TYPE);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue