Skip to content

Commit

Permalink
AWS SDK for Android 2.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
AWS committed Apr 7, 2017
1 parent 66de079 commit 0958a37
Show file tree
Hide file tree
Showing 718 changed files with 39,993 additions and 6,413 deletions.
16 changes: 14 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
# Change Log - AWS SDK for Android
## [Release 2.4.1](https://github.com/aws/aws-sdk-android/releases/tag/release_v2.4.1)

### New Features:
- **Support for Amazon Cloudwatch Logs**: Amazon CloudWatch is a monitoring service for AWS cloud resources and the applications you run on AWS. You can use Amazon CloudWatch to collect and track metrics, collect and monitor log files, and set alarms.

### Bug Fixes:
- **Amazon IoT**: fix an issue which triggers `NetworkOnMainThreadException` when calling `reconnectToSession()`. See [issue #261](https://github.com/aws/aws-sdk-android/issues/261)
- **Amazon S3**: fixed maven dependencies. See [issue #276](https://github.com/aws/aws-sdk-android/issues/276) & [issue #268](https://github.com/aws/aws-sdk-android/issues/268)
- **Amazon S3**: fixed an issue which caused resource path to be incorrectly encoded.See [AWS Forum Post](https://forums.aws.amazon.com/thread.jspa?threadID=252898)
- **General**: checkstyle fixes across the sdk.
- **General**: move all sdk's to use commons logging instead of LogCat.

## [Release 2.4.0](https://github.com/aws/aws-sdk-android/releases/tag/release_v2.4.0) (03/21/2017)

### Improvements:
Expand Down Expand Up @@ -36,7 +48,7 @@
- **Amazon Pinpoint**: Fixed a bug that caused a crash when opening a deep link. See [issue #246](https://github.com/aws/aws-sdk-android/pull/246).
- **Amazon Lex**: Fix incorrect comparison for dialog states. See [issue #245](https://github.com/aws/aws-sdk-android/pull/245).

## [Release 2.3.8](https://github.com/aws/aws-sdk-android/release/tag/release_v2.3.8) (12/20/2016)
## [Release 2.3.8] (https://github.com/aws/aws-sdk-android/release/tag/release_v2.3.8) (12/20/2016)

### Bug Fixes:

Expand Down Expand Up @@ -361,4 +373,4 @@ Two new exceptions added for getSession API. These exceptions have been added to

### Bug Fixes
- **Amazon S3**: Fixed an issue that occurs when required headers are not properly signed. This issue affects S3 in two regions: Frankfurt (eu-central-1) and China (cn-north-1). [#42](https://github.com/aws/aws-sdk-android/issues/42)
- **AWS Core Runtime Library**: Fixed an issue in Maven distribution where an incorrect version string is set in "User-Agent".
- **AWS Core Runtime Library**: Fixed an issue in Maven distribution where an incorrect version string is set in "User-Agent".
4 changes: 2 additions & 2 deletions aws-android-sdk-apigateway-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
<parent>
<groupId>com.amazonaws</groupId>
<artifactId>aws-android-sdk-pom</artifactId>
<version>2.4.0</version>
<version>2.4.1</version>
</parent>

<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-android-sdk-core</artifactId>
<optional>false</optional>
<version>2.4.0</version>
<version>2.4.1</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,21 @@ public class ApiClientException extends AmazonServiceException {

private static final long serialVersionUID = 1L;

/**
* Constructor.
*
* @param errorMessage the error message.
*/
public ApiClientException(String errorMessage) {
super(errorMessage);
}

/**
* Constructor.
*
* @param errorMessage the error message.
* @param cause the root cause.
*/
public ApiClientException(String errorMessage, Exception cause) {
super(errorMessage, cause);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public class ApiClientFactory {
private static final String AMAZON_API_GATEWAY_SERVICE_NAME = "execute-api";
// endpoint pattern for extracting region out of an endpoint
// e.g. https://my-api-id.execute-api.region-id.amazonaws.com/stage
private static Pattern ENDPOINT_PATTERN = Pattern.compile("^https?://\\w+.execute-api.([a-z0-9-]+).amazonaws.com/.*");
private static final Pattern ENDPOINT_PATTERN = Pattern
.compile("^https?://\\w+.execute-api.([a-z0-9-]+).amazonaws.com/.*");

private String endpoint;
private String apiKey;
Expand All @@ -47,6 +48,7 @@ public class ApiClientFactory {
* @param endpoint endpoint url
* @return the factory itself for chaining
*/
@SuppressWarnings("checkstyle:hiddenfield")
public ApiClientFactory endpoint(String endpoint) {
this.endpoint = endpoint;
return this;
Expand All @@ -58,6 +60,7 @@ public ApiClientFactory endpoint(String endpoint) {
* @param apiKey to send in header
* @return the factory itself for chaining
*/
@SuppressWarnings("checkstyle:hiddenfield")
public ApiClientFactory apiKey(String apiKey) {
this.apiKey = apiKey;
return this;
Expand All @@ -70,6 +73,7 @@ public ApiClientFactory apiKey(String apiKey) {
* @param region a region string
* @return the factory itself for chaining
*/
@SuppressWarnings("checkstyle:hiddenfield")
public ApiClientFactory region(String region) {
this.regionOverride = region;
return this;
Expand All @@ -81,6 +85,7 @@ public ApiClientFactory region(String region) {
* @param clientConfiguration Configuration to use
* @return the factory itself for chaining
*/
@SuppressWarnings("checkstyle:hiddenfield")
public ApiClientFactory clientConfiguration(ClientConfiguration clientConfiguration) {
this.clientConfiguration = clientConfiguration;
return this;
Expand All @@ -92,6 +97,7 @@ public ApiClientFactory clientConfiguration(ClientConfiguration clientConfigurat
* @param provider an AWS credentials provider
* @return the factory itself for chaining
*/
@SuppressWarnings("checkstyle:hiddenfield")
public ApiClientFactory credentialsProvider(AWSCredentialsProvider provider) {
this.provider = provider;
return this;
Expand All @@ -100,20 +106,22 @@ public ApiClientFactory credentialsProvider(AWSCredentialsProvider provider) {
/**
* Instantiates a client for the given API.
*
* @param <T> the api client interface.
* @param apiClass API class defined in API Gateway.
* @return a client for the given API
* @return a client for the given API.
*/
@SuppressWarnings("checkstyle:hiddenfield")
public <T> T build(Class<T> apiClass) {
if (apiClass == null) {
throw new IllegalArgumentException("Missing API class");
}
String endpoint = getEndpoint(apiClass);
final String endpoint = getEndpoint(apiClass);
if (endpoint == null) {
throw new IllegalArgumentException("Missing endpoint information");
}
String apiName = getApiName(apiClass);
ApiClientHandler handler = getHandler(endpoint, apiName);
Object proxy = Proxy.newProxyInstance(apiClass.getClassLoader(),
final String apiName = getApiName(apiClass);
final ApiClientHandler handler = getHandler(endpoint, apiName);
final Object proxy = Proxy.newProxyInstance(apiClass.getClassLoader(),
new Class<?>[] {
apiClass
}, handler);
Expand All @@ -127,11 +135,12 @@ public <T> T build(Class<T> apiClass) {
* @param apiName API class name
* @return an invocation handler
*/
@SuppressWarnings("checkstyle:hiddenfield")
ApiClientHandler getHandler(String endpoint, String apiName) {
Signer signer = provider == null ? null : getSigner(getRegion(endpoint));
final Signer signer = provider == null ? null : getSigner(getRegion(endpoint));

// Ensure we always pass a configuration to the handler
ClientConfiguration configuration = (clientConfiguration == null) ? new ClientConfiguration() : clientConfiguration;
final ClientConfiguration configuration = (clientConfiguration == null) ? new ClientConfiguration() : clientConfiguration;

return new ApiClientHandler(endpoint, apiName, signer, provider, apiKey, configuration);
}
Expand All @@ -143,7 +152,7 @@ ApiClientHandler getHandler(String endpoint, String apiName) {
* @return endpoint
*/
String getEndpoint(Class<?> apiClass) {
Service service = apiClass.getAnnotation(Service.class);
final Service service = apiClass.getAnnotation(Service.class);
if (service == null) {
throw new IllegalArgumentException("Can't find annotation Service");
}
Expand All @@ -168,7 +177,7 @@ String getApiName(Class<?> apiClass) {
* @return signer
*/
Signer getSigner(String region) {
AWS4Signer signer = new AWS4Signer();
final AWS4Signer signer = new AWS4Signer();
signer.setServiceName(AMAZON_API_GATEWAY_SERVICE_NAME);
signer.setRegionName(region);
return signer;
Expand All @@ -180,11 +189,12 @@ Signer getSigner(String region) {
* @param endpoint endpoint string
* @return region string
*/
@SuppressWarnings("checkstyle:hiddenfield")
String getRegion(String endpoint) {
if (regionOverride != null) {
return regionOverride;
}
Matcher m = ENDPOINT_PATTERN.matcher(endpoint);
final Matcher m = ENDPOINT_PATTERN.matcher(endpoint);
if (m.matches()) {
return m.group(1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,15 @@
class ApiClientHandler implements InvocationHandler {


private static final Gson gson = new GsonBuilder()
private static final Gson GSON_WITH_DATE_FORMATTER = new GsonBuilder()
.registerTypeAdapter(Date.class, new DateDeserializer(new String[] {
DateUtils.ISO8601_DATE_PATTERN, DateUtils.ALTERNATE_ISO8601_DATE_PATTERN,
DateUtils.COMPRESSED_DATE_PATTERN, DateUtils.RFC822_DATE_PATTERN
DateUtils.ISO8601_DATE_PATTERN, DateUtils.ALTERNATE_ISO8601_DATE_PATTERN,
DateUtils.COMPRESSED_DATE_PATTERN, DateUtils.RFC822_DATE_PATTERN
})).create();

private static final int HTTP_RESPONSE_OK = 200;
private static final int HTTP_RESPONSE_LAST_SUCCESS_STATUSCODE = 300;

private final String endpoint;
private final String apiName;
private final Signer signer;
Expand Down Expand Up @@ -162,7 +165,7 @@ Request<?> buildRequest(Method method, Object[] args) {
if (content != null) {
throw new IllegalStateException("Can't have more than one Body");
}
content = args[i] == null ? null : gson.toJson(args[i]);
content = args[i] == null ? null : GSON_WITH_DATE_FORMATTER.toJson(args[i]);
continue;
}

Expand Down Expand Up @@ -271,12 +274,12 @@ Object handleResponse(HttpResponse response, Method method) throws Throwable {
final int code = response.getStatusCode();
final InputStream content = response.getContent();
// successful request if code is 2xx
if (code >= 200 && code < 300) {
if (code >= HTTP_RESPONSE_OK && code < HTTP_RESPONSE_LAST_SUCCESS_STATUSCODE) {
final Type t = method.getReturnType();
if (t != void.class && content != null) {
final Reader reader = new InputStreamReader(response.getContent(),
StringUtils.UTF8);
final Object obj = gson.fromJson(reader, t);
final Object obj = GSON_WITH_DATE_FORMATTER.fromJson(reader, t);
reader.close();
return obj;
} else {
Expand All @@ -301,7 +304,7 @@ Object handleResponse(HttpResponse response, Method method) throws Throwable {

boolean isExecuteMethod(Method method) {
final Operation op = method.getAnnotation(Operation.class);
return op == null && method.getName().equalsIgnoreCase("execute")
return op == null && "execute".equalsIgnoreCase(method.getName())
&& method.getReturnType().isAssignableFrom(ApiResponse.class)
&& method.getParameterTypes().length == 1
&& method.getParameterTypes()[0].isAssignableFrom(ApiRequest.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public ApiRequest() {
/**
* Sets all headers, clearing any existing ones.
*
* @param headers A map of all http headers
* @return the updated request object.
*/
public ApiRequest withHeaders(Map<String, String> headers) {
Expand All @@ -63,8 +64,8 @@ public ApiRequest withHeaders(Map<String, String> headers) {
/**
* Sets the header in the request.
*
* @param header
* @param value
* @param header the http header name.
* @param value the http header value.
* @return the updated request object.
*/
public ApiRequest addHeader(String header, String value) {
Expand Down Expand Up @@ -104,6 +105,7 @@ public String getPath() {
/**
* Sets all parameters, clearing any existing values.
*
* @param parameters the http request parameters.
* @return the updated request object.
*/
public ApiRequest withParameters(Map<String, String> parameters) {
Expand All @@ -123,8 +125,8 @@ public Map<String, String> getParameters() {
/**
* Set parameters with name and value.
*
* @param name
* @param value
* @param name the parameter name.
* @param value the parameter value.
* @return the updated request object.
*/
public ApiRequest withParameter(String name, String value) {
Expand All @@ -144,7 +146,7 @@ public ApiRequest withHttpMethod(HttpMethodName httpMethod) {
}

/**
* @return
* @return the {@link HttpMethodName}
*/
public HttpMethodName getHttpMethod() {
return request.getHttpMethod();
Expand All @@ -167,7 +169,7 @@ public ApiRequest withBody(InputStream body) {
* Sets the optional stream containing the payload data from the byte array
* to include for this request. Not all requests will contain payload data.
*
* @param body
* @param body The request body represented as a array of bytes.
* @return the updated request object.
*/
public ApiRequest withBody(byte[] body) {
Expand All @@ -180,7 +182,7 @@ public ApiRequest withBody(byte[] body) {
* content to include for this request. Not all requests will contain
* payload data.
*
* @param body
* @param body the request body represented as a string.
* @return the updated request object.
*/
public ApiRequest withBody(String body) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* The Http Operation.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Operation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,24 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* The request parameter.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.PARAMETER)
public @interface Parameter {
/**
* Name of the parameter.
*
* @return name of the parameter
*
* @return
*/
String name() default "";

/**
* Location of this parameter. Possible values are <tt>header</tt>,
* <tt>path</tt> , and <tt>query</tt>.
*
* @return location of the parameter
*
* @return
*/
String location();
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* The APIGateway service.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Service {
/**
* Service endpoint.
*
* @return service endpoint
*/
String endpoint();
}
4 changes: 2 additions & 2 deletions aws-android-sdk-autoscaling/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
<parent>
<groupId>com.amazonaws</groupId>
<artifactId>aws-android-sdk-pom</artifactId>
<version>2.4.0</version>
<version>2.4.1</version>
</parent>

<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-android-sdk-core</artifactId>
<optional>false</optional>
<version>2.4.0</version>
<version>2.4.1</version>
</dependency>
</dependencies>

Expand Down
Loading

0 comments on commit 0958a37

Please sign in to comment.