Skip to content

Commit 8bbcb0f

Browse files
author
arnett, stu
committed
v2.2.0
1 parent 505e931 commit 8bbcb0f

20 files changed

+850
-17
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ description = 'EMC Object Client for Java - provides REST access to object data
2929
ext.githubProjectName = 'ecs-object-client-java'
3030

3131
buildscript {
32-
ext.commonBuildVersion = '1.4'
33-
ext.commonBuildDir = "https://raw.githubusercontent.com/emcvipr/ecs-common-build/v$commonBuildVersion"
32+
ext.commonBuildVersion = '1.4.1'
33+
ext.commonBuildDir = "https://raw.githubusercontent.com/EMCECS/ecs-common-build/v$commonBuildVersion"
3434
apply from: "$commonBuildDir/ecs-publish.buildscript.gradle", to: buildscript
3535
}
3636

src/main/java/com/emc/object/AbstractJerseyClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ protected ClientResponse executeRequest(Client client, ObjectRequest request) {
8585
// (i.e. if content-encoding is set)
8686
request.property(ApacheHttpClient4Config.PROPERTY_ENABLE_BUFFERING, Boolean.TRUE);
8787

88-
String headerContentType = RestUtil.getFirstAsString(request.getHeaders(), RestUtil.DEFAULT_CONTENT_TYPE);
88+
String headerContentType = RestUtil.getFirstAsString(request.getHeaders(), RestUtil.HEADER_CONTENT_TYPE);
8989
if (headerContentType != null) contentType = headerContentType;
9090
}
9191

src/main/java/com/emc/object/s3/S3Client.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,26 @@ public interface S3Client {
201201
*/
202202
void setBucketStaleReadAllowed(String bucketName, boolean staleReadsAllowed);
203203

204+
/**
205+
* Lists the system metadata search keys.
206+
*/
207+
MetadataSearchList listSystemMetadataSearchKeys();
208+
209+
/**
210+
* Lists the metadata search keys associated with the givne bucket.
211+
*/
212+
MetadataSearchList listBucketMetadataSearchKeys(String bucketName);
213+
214+
/**
215+
* Queries objects in a bucket using parameters specified in <code>request</code>
216+
*/
217+
QueryObjectsResult queryObjects(QueryObjectsRequest request);
218+
219+
/**
220+
* Gets the next page of objects using the results of a previous query-objects call
221+
*/
222+
QueryObjectsResult queryMoreObjects(QueryObjectsResult lastResult);
223+
204224
/**
205225
* Lists all objects in <code>bucketName</code> with no restrictions
206226
*/

src/main/java/com/emc/object/s3/S3Constants.java

100755100644
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,12 @@ public final class S3Constants {
5151
public static final String AMZ_VERSION_ID = AMZ_PREFIX + "version-id";
5252

5353
public static final String PARAM_ACCESS_KEY = "AWSAccessKeyId";
54+
public static final String PARAM_ATTRIBUTES = "attributes";
5455
public static final String PARAM_DELIMITER = "delimiter";
5556
public static final String PARAM_ENCODING_TYPE = "encoding-type";
5657
public static final String PARAM_ENDPOINT = "endpoint";
5758
public static final String PARAM_EXPIRES = "Expires";
59+
public static final String PARAM_INCLUDE_OLDER_VERSIONS = "include-older-versions";
5860
public static final String PARAM_IS_STALE_ALLOWED = "isstaleallowed";
5961
public static final String PARAM_KEY_MARKER = "key-marker";
6062
public static final String PARAM_LIMIT = "limit";
@@ -65,13 +67,15 @@ public final class S3Constants {
6567
public static final String PARAM_PART_NUMBER = "partNumber";
6668
public static final String PARAM_PART_NUMBER_MARKER = "part-number-marker";
6769
public static final String PARAM_PREFIX = "prefix";
70+
public static final String PARAM_QUERY = "query";
6871
public static final String PARAM_RESPONSE_HEADER_CACHE_CONTROL = "response-cache-control";
6972
public static final String PARAM_RESPONSE_HEADER_CONTENT_DISPOSITION = "response-content-disposition";
7073
public static final String PARAM_RESPONSE_HEADER_CONTENT_ENCODING = "response-content-encoding";
7174
public static final String PARAM_RESPONSE_HEADER_CONTENT_LANGUAGE = "response-content-language";
7275
public static final String PARAM_RESPONSE_HEADER_CONTENT_TYPE = "response-content-type";
7376
public static final String PARAM_RESPONSE_HEADER_EXPIRES = "response-expires";
7477
public static final String PARAM_SIGNATURE = "Signature";
78+
public static final String PARAM_SORTED = "sorted";
7579
public static final String PARAM_UPLOAD_ID = "uploadId";
7680
public static final String PARAM_UPLOAD_ID_MARKER = "upload-id-marker";
7781
public static final String PARAM_VERSION_ID = "versionId";

src/main/java/com/emc/object/s3/S3ObjectMetadata.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ public static <T> S3ObjectMetadata fromHeaders(Map<String, List<T>> headers) {
6161
objectMetadata.contentMd5 = RestUtil.getFirstAsString(headers, RestUtil.HEADER_CONTENT_MD5);
6262
objectMetadata.contentType = RestUtil.getFirstAsString(headers, RestUtil.HEADER_CONTENT_TYPE);
6363
objectMetadata.eTag = RestUtil.getFirstAsString(headers, RestUtil.HEADER_ETAG, true);
64-
objectMetadata.httpExpires = RestUtil.headerParse(RestUtil.getFirstAsString(headers, RestUtil.HEADER_EXPIRES));
64+
objectMetadata.httpExpires = RestUtil.headerParse(
65+
RestUtil.stripQuotes(RestUtil.getFirstAsString(headers, RestUtil.HEADER_EXPIRES)));
6566

6667
// prefer x-emc-mtime (has millisecond granularity)
6768
String mtime = RestUtil.getFirstAsString(headers, RestUtil.EMC_MTIME);
@@ -238,8 +239,12 @@ public Map<String, String> getUserMetadata() {
238239
return userMetadata;
239240
}
240241

242+
/**
243+
* Stores a copy of the map to prevent internal alterations (i.e. codecs) from affecting the original map
244+
*/
241245
public void setUserMetadata(Map<String, String> userMetadata) {
242-
this.userMetadata = userMetadata;
246+
if (userMetadata == null) this.userMetadata = null;
247+
else this.userMetadata = new HashMap<String, String>(userMetadata);
243248
}
244249

245250
public String getUserMetadata(String name) {
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (c) 2015, EMC Corporation.
3+
* Redistribution and use in source and binary forms, with or without modification,
4+
* are permitted provided that the following conditions are met:
5+
*
6+
* + Redistributions of source code must retain the above copyright notice,
7+
* this list of conditions and the following disclaimer.
8+
* + Redistributions in binary form must reproduce the above copyright
9+
* notice, this list of conditions and the following disclaimer in the
10+
* documentation and/or other materials provided with the distribution.
11+
* + The name of EMC Corporation may not be used to endorse or promote
12+
* products derived from this software without specific prior written
13+
* permission.
14+
*
15+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17+
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
19+
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25+
* POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
package com.emc.object.s3.bean;
28+
29+
import javax.xml.bind.annotation.XmlEnum;
30+
31+
@XmlEnum
32+
public enum MetadataSearchDatatype {
33+
string, integer, datetime, decimal
34+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.emc.object.s3.bean;
2+
3+
import javax.xml.bind.annotation.XmlElement;
4+
import javax.xml.bind.annotation.XmlType;
5+
6+
/**
7+
* Describes a metadata search key associated with a bucket.
8+
*/
9+
@XmlType(propOrder = {"name", "datatype"})
10+
public class MetadataSearchKey {
11+
private String name;
12+
private MetadataSearchDatatype datatype;
13+
14+
public MetadataSearchKey() {}
15+
16+
public MetadataSearchKey(String name, MetadataSearchDatatype datatype) {
17+
this.name = name;
18+
this.datatype = datatype;
19+
}
20+
21+
@XmlElement(name = "Name")
22+
public String getName() {
23+
return name;
24+
}
25+
26+
public void setName(String name) {
27+
this.name = name;
28+
}
29+
30+
@XmlElement(name = "Datatype")
31+
public MetadataSearchDatatype getDatatype() {
32+
return datatype;
33+
}
34+
35+
public void setDatatype(MetadataSearchDatatype datatype) { this.datatype = datatype; }
36+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.emc.object.s3.bean;
2+
3+
import javax.xml.bind.annotation.XmlElement;
4+
import javax.xml.bind.annotation.XmlElementWrapper;
5+
import javax.xml.bind.annotation.XmlRootElement;
6+
import java.util.ArrayList;
7+
import java.util.List;
8+
9+
/**
10+
* List of search metadata associated with a bucket.
11+
*/
12+
@XmlRootElement(name = "MetadataSearchList")
13+
public class MetadataSearchList {
14+
15+
private List<MetadataSearchKey> indexableKeys = new ArrayList<MetadataSearchKey>();
16+
private List<MetadataSearchKey> optionalAttributes = new ArrayList<MetadataSearchKey>();
17+
18+
@XmlElementWrapper(name = "IndexableKeys")
19+
@XmlElement(name = "Key")
20+
public List<MetadataSearchKey> getIndexableKeys() {
21+
return indexableKeys;
22+
}
23+
24+
public void setIndexableKeys(List<MetadataSearchKey> indexableKeys) {
25+
this.indexableKeys = indexableKeys;
26+
}
27+
28+
@XmlElementWrapper(name = "OptionalAttributes")
29+
@XmlElement(name = "Attribute")
30+
public List<MetadataSearchKey> getOptionalAttributes() {
31+
return optionalAttributes;
32+
}
33+
34+
public void setOptionalAttributes(List<MetadataSearchKey> optionalAttributes) {
35+
this.optionalAttributes = optionalAttributes;
36+
}
37+
}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/*
2+
* Copyright (c) 2015-2016, EMC Corporation.
3+
* Redistribution and use in source and binary forms, with or without modification,
4+
* are permitted provided that the following conditions are met:
5+
*
6+
* + Redistributions of source code must retain the above copyright notice,
7+
* this list of conditions and the following disclaimer.
8+
* + Redistributions in binary form must reproduce the above copyright
9+
* notice, this list of conditions and the following disclaimer in the
10+
* documentation and/or other materials provided with the distribution.
11+
* + The name of EMC Corporation may not be used to endorse or promote
12+
* products derived from this software without specific prior written
13+
* permission.
14+
*
15+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17+
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
19+
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25+
* POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
package com.emc.object.s3.bean;
28+
29+
import javax.xml.bind.annotation.XmlElement;
30+
import javax.xml.bind.annotation.XmlElementWrapper;
31+
import javax.xml.bind.annotation.XmlTransient;
32+
import javax.xml.bind.annotation.XmlType;
33+
import java.util.ArrayList;
34+
import java.util.HashMap;
35+
import java.util.List;
36+
import java.util.Map;
37+
38+
@XmlType(propOrder = {"type", "queryMetadataEntries"})
39+
public class QueryMetadata {
40+
private QueryMetadataType type;
41+
private Map<String, String> mdMap = new HashMap<String, String>();
42+
43+
@XmlElement(name = "type", namespace = "")
44+
public QueryMetadataType getType() {
45+
return type;
46+
}
47+
48+
public void setType(QueryMetadataType type) {
49+
this.type = type;
50+
}
51+
52+
@XmlTransient
53+
public Map<String, String> getMdMap() {
54+
return mdMap;
55+
}
56+
57+
public void setMdMap(Map<String, String> mdMap) {
58+
this.mdMap = mdMap;
59+
}
60+
61+
/**
62+
* @deprecated Use {@link #getMdMap()} instead.
63+
*/
64+
@XmlElementWrapper(name = "mdMap", namespace = "")
65+
@XmlElement(name = "entry", namespace = "")
66+
public List<QueryMetadataEntry> getQueryMetadataEntries() {
67+
if (mdMap == null) return null;
68+
List<QueryMetadataEntry> queryMetadataEntries = new ArrayList<QueryMetadataEntry>();
69+
for (String key : mdMap.keySet()) {
70+
queryMetadataEntries.add(new QueryMetadataEntry(key, mdMap.get(key)));
71+
}
72+
return queryMetadataEntries;
73+
}
74+
75+
/**
76+
* @deprecated Use {@link #setMdMap(Map)} instead.
77+
*/
78+
public void setQueryMetadataEntries(List<QueryMetadataEntry> queryMetadataEntries) {
79+
mdMap = new HashMap<String, String>();
80+
for (QueryMetadataEntry entry : queryMetadataEntries) {
81+
mdMap.put(entry.getKey(), entry.getValue());
82+
}
83+
}
84+
85+
public static class QueryMetadataEntry {
86+
private String key;
87+
private String value;
88+
89+
public QueryMetadataEntry() {
90+
}
91+
92+
public QueryMetadataEntry(String key, String value) {
93+
this.key = key;
94+
this.value = value;
95+
}
96+
97+
@XmlElement(name = "key", namespace = "")
98+
public String getKey() {
99+
return key;
100+
}
101+
102+
public void setKey(String key) {
103+
this.key = key;
104+
}
105+
106+
@XmlElement(name = "value", namespace = "")
107+
public String getValue() {
108+
return value;
109+
}
110+
111+
public void setValue(String value) {
112+
this.value = value;
113+
}
114+
}
115+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.emc.object.s3.bean;
2+
3+
import javax.xml.bind.annotation.XmlEnum;
4+
5+
@XmlEnum
6+
public enum QueryMetadataType {
7+
SYSMD, USERMD
8+
}

0 commit comments

Comments
 (0)