Skip to content

Commit

Permalink
Merge pull request #5 from EMCECS/feature-release-3.0.1
Browse files Browse the repository at this point in the history
Release 3.0.1
  • Loading branch information
twincitiesguy authored Mar 2, 2017
2 parents a9e2b27 + ebb7fac commit 3d4ca66
Show file tree
Hide file tree
Showing 11 changed files with 235 additions and 65 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ description = 'EMC Object Client for Java - provides REST access to object data
ext.githubProjectName = 'ecs-object-client-java'

buildscript {
ext.commonBuildVersion = '1.5'
ext.commonBuildVersion = '1.6'
ext.commonBuildDir = "https://raw.githubusercontent.com/EMCECS/ecs-common-build/v$commonBuildVersion"
apply from: "$commonBuildDir/ecs-publish.buildscript.gradle", to: buildscript
}
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Jan 05 14:25:15 PST 2016
#Thu Mar 02 09:09:22 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-bin.zip
46 changes: 25 additions & 21 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,30 @@
##
##############################################################################

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null

APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

Expand All @@ -30,6 +48,7 @@ die ( ) {
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
Expand All @@ -40,26 +59,11 @@ case "`uname`" in
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac

# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar

# Determine the Java command to use to start the JVM.
Expand All @@ -85,7 +89,7 @@ location of your Java installation."
fi

# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
Expand Down
8 changes: 4 additions & 4 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

Expand Down Expand Up @@ -46,7 +46,7 @@ echo location of your Java installation.
goto fail

:init
@rem Get command-line arguments, handling Windowz variants
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
Expand Down
17 changes: 16 additions & 1 deletion src/main/java/com/emc/object/s3/jersey/CodecFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
Expand All @@ -60,6 +61,7 @@ public CodecFilter(CodecChain encodeChain) {
@Override
public ClientResponse handle(ClientRequest request) throws ClientHandlerException {
Map<String, String> userMeta = (Map<String, String>) request.getProperties().get(RestUtil.PROPERTY_USER_METADATA);
Map<String, String> metaBackup = null;

Boolean encode = (Boolean) request.getProperties().get(RestUtil.PROPERTY_ENCODE_ENTITY);
if (encode != null && encode) {
Expand All @@ -75,6 +77,9 @@ public ClientResponse handle(ClientRequest request) throws ClientHandlerExceptio
SizeOverrideWriter.setEntitySize(-1L);
}

// backup original metadata in case of an error
metaBackup = new HashMap<String, String>(userMeta);

// we need pre-stream metadata from the encoder, but we don't have the entity output stream, so we'll use
// a "dangling" output stream and connect it in the adapter
// NOTE: we can't alter the headers in the adapt() method because they've already been a) signed and b) sent
Expand All @@ -89,7 +94,17 @@ public ClientResponse handle(ClientRequest request) throws ClientHandlerExceptio
}

// execute request
ClientResponse response = getNext().handle(request);
ClientResponse response;
try {
response = getNext().handle(request);
} catch (RuntimeException e) {
if (encode != null && encode) {
// restore metadata from backup
userMeta.clear();
userMeta.putAll(metaBackup);
}
throw e;
}

// get user metadata from response headers
MultivaluedMap<String, String> headers = response.getHeaders();
Expand Down
82 changes: 52 additions & 30 deletions src/main/java/com/emc/object/s3/request/CopyObjectRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,13 @@ public class CopyObjectRequest extends S3ObjectRequest {
private String sourceKey;
private String sourceVersionId;

private Date ifModifiedSince;
private Date ifUnmodifiedSince;
private String ifMatch;
private String ifNoneMatch;
private Date ifSourceModifiedSince;
private Date ifSourceUnmodifiedSince;
private String ifSourceMatch;
private String ifSourceNoneMatch;

private String ifTargetMatch;
private String ifTargetNoneMatch;

private S3ObjectMetadata objectMetadata;
private AccessControlList acl;
Expand All @@ -65,12 +68,15 @@ public Map<String, List<Object>> getHeaders() {
if (sourceVersionId != null) source += "?versionId=" + sourceVersionId;
RestUtil.putSingle(headers, S3Constants.AMZ_COPY_SOURCE, source);

if (ifModifiedSince != null)
RestUtil.putSingle(headers, S3Constants.AMZ_SOURCE_MODIFIED_SINCE, ifModifiedSince);
if (ifUnmodifiedSince != null)
RestUtil.putSingle(headers, S3Constants.AMZ_SOURCE_UNMODIFIED_SINCE, ifUnmodifiedSince);
if (ifMatch != null) RestUtil.putSingle(headers, S3Constants.AMZ_SOURCE_MATCH, ifMatch);
if (ifNoneMatch != null) RestUtil.putSingle(headers, S3Constants.AMZ_SOURCE_NONE_MATCH, ifNoneMatch);
if (ifSourceModifiedSince != null)
RestUtil.putSingle(headers, S3Constants.AMZ_SOURCE_MODIFIED_SINCE, ifSourceModifiedSince);
if (ifSourceUnmodifiedSince != null)
RestUtil.putSingle(headers, S3Constants.AMZ_SOURCE_UNMODIFIED_SINCE, ifSourceUnmodifiedSince);
if (ifSourceMatch != null) RestUtil.putSingle(headers, S3Constants.AMZ_SOURCE_MATCH, ifSourceMatch);
if (ifSourceNoneMatch != null)
RestUtil.putSingle(headers, S3Constants.AMZ_SOURCE_NONE_MATCH, ifSourceNoneMatch);
if (ifTargetMatch != null) RestUtil.putSingle(headers, RestUtil.HEADER_IF_MATCH, ifTargetMatch);
if (ifTargetNoneMatch != null) RestUtil.putSingle(headers, RestUtil.HEADER_IF_NONE_MATCH, ifTargetNoneMatch);
if (objectMetadata != null) {
RestUtil.putSingle(headers, S3Constants.AMZ_METADATA_DIRECTIVE, "REPLACE");
headers.putAll(objectMetadata.toHeaders());
Expand All @@ -96,36 +102,52 @@ public void setSourceVersionId(String sourceVersionId) {
this.sourceVersionId = sourceVersionId;
}

public Date getIfModifiedSince() {
return ifModifiedSince;
public Date getIfSourceModifiedSince() {
return ifSourceModifiedSince;
}

public void setIfSourceModifiedSince(Date ifSourceModifiedSince) {
this.ifSourceModifiedSince = ifSourceModifiedSince;
}

public Date getIfSourceUnmodifiedSince() {
return ifSourceUnmodifiedSince;
}

public void setIfSourceUnmodifiedSince(Date ifSourceUnmodifiedSince) {
this.ifSourceUnmodifiedSince = ifSourceUnmodifiedSince;
}

public String getIfSourceMatch() {
return ifSourceMatch;
}

public void setIfModifiedSince(Date ifModifiedSince) {
this.ifModifiedSince = ifModifiedSince;
public void setIfSourceMatch(String ifSourceMatch) {
this.ifSourceMatch = ifSourceMatch;
}

public Date getIfUnmodifiedSince() {
return ifUnmodifiedSince;
public String getIfSourceNoneMatch() {
return ifSourceNoneMatch;
}

public void setIfUnmodifiedSince(Date ifUnmodifiedSince) {
this.ifUnmodifiedSince = ifUnmodifiedSince;
public void setIfSourceNoneMatch(String ifSourceNoneMatch) {
this.ifSourceNoneMatch = ifSourceNoneMatch;
}

public String getIfMatch() {
return ifMatch;
public String getIfTargetMatch() {
return ifTargetMatch;
}

public void setIfMatch(String ifMatch) {
this.ifMatch = ifMatch;
public void setIfTargetMatch(String ifTargetMatch) {
this.ifTargetMatch = ifTargetMatch;
}

public String getIfNoneMatch() {
return ifNoneMatch;
public String getIfTargetNoneMatch() {
return ifTargetNoneMatch;
}

public void setIfNoneMatch(String ifNoneMatch) {
this.ifNoneMatch = ifNoneMatch;
public void setIfTargetNoneMatch(String ifTargetNoneMatch) {
this.ifTargetNoneMatch = ifTargetNoneMatch;
}

public S3ObjectMetadata getObjectMetadata() {
Expand Down Expand Up @@ -158,22 +180,22 @@ public CopyObjectRequest withSourceVersionId(String sourceVersionId) {
}

public CopyObjectRequest withIfModifiedSince(Date ifModifiedSince) {
setIfModifiedSince(ifModifiedSince);
setIfSourceModifiedSince(ifModifiedSince);
return this;
}

public CopyObjectRequest withIfUnmodifiedSince(Date ifUnmodifiedSince) {
setIfUnmodifiedSince(ifUnmodifiedSince);
setIfSourceUnmodifiedSince(ifUnmodifiedSince);
return this;
}

public CopyObjectRequest withIfMatch(String ifMatch) {
setIfMatch(ifMatch);
setIfSourceMatch(ifMatch);
return this;
}

public CopyObjectRequest withIfNoneMatch(String ifNoneMatch) {
setIfNoneMatch(ifNoneMatch);
setIfSourceNoneMatch(ifNoneMatch);
return this;
}

Expand Down
28 changes: 25 additions & 3 deletions src/main/java/com/emc/object/util/ConfigUri.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,32 @@ public ConfigUri(Class<C> targetClass) {
}

public C parseUri(String configUri) {
return parseUri(configUri, false);
return parseUri(configUri, null);
}

public C parseUri(String configUri, boolean strict) {
public C parseUri(String configUri, C defaults) {
return parseUri(configUri, defaults, false);
}

public C parseUri(String configUri, C defaultObject, boolean strict) {
try {
URI uriObj = new URI(configUri);
C object = targetClass.newInstance();

// set defaults
if (defaultObject != null) {
// standard properties
for (PropertyDescriptor descriptor : paramPropertyMap.values()) {
Object defaultValue = descriptor.getReadMethod().invoke(defaultObject);
descriptor.getWriteMethod().invoke(object, defaultValue);
}
// map properties
for (PropertyDescriptor descriptor : mapPropertyMap.values()) {
Object defaultValue = descriptor.getReadMethod().invoke(defaultObject);
descriptor.getWriteMethod().invoke(object, defaultValue);
}
}

if (protocolProperty != null && uriObj.getScheme() != null)
setPropertyValues(object, protocolProperty, Collections.singletonList(uriObj.getScheme()));

Expand Down Expand Up @@ -186,8 +204,12 @@ public C parseUri(String configUri, boolean strict) {
}

public String generateUri(C object) {
return generateUri(object, null);
}

public String generateUri(C object, C defaultObject) {
try {
C defaultObject = targetClass.newInstance();
if (defaultObject == null) defaultObject = targetClass.newInstance();

// collect parameters
MultivaluedMap<String, String> params = new MultivaluedMapImpl();
Expand Down
Loading

0 comments on commit 3d4ca66

Please sign in to comment.