Resolves checkstyle issues for semaphore servant serverless service-layer service-locator (#1079)
* Reduces checkstyle errors in semaphore * Reduces checkstyle errors in servant * Reduces checkstyle errors in serverless * Reduces checkstyle errors in service-layer * Reduces checkstyle errors in service-locator
This commit is contained in:
committed by
Ilkka Seppälä
parent
37599eb48f
commit
390795154f
@ -30,13 +30,13 @@ import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper;
|
||||
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* abstract dynamodb handler
|
||||
* abstract dynamodb handler.
|
||||
*
|
||||
* @param <T> - serializable collection
|
||||
*/
|
||||
public abstract class AbstractDynamoDbHandler<T extends Serializable> {
|
||||
@ -78,10 +78,10 @@ public abstract class AbstractDynamoDbHandler<T extends Serializable> {
|
||||
}
|
||||
|
||||
/**
|
||||
* API Gateway response
|
||||
* API Gateway response.
|
||||
*
|
||||
* @param statusCode - status code
|
||||
* @param body - Object body
|
||||
* @param body - Object body
|
||||
* @return - api gateway proxy response
|
||||
*/
|
||||
protected APIGatewayProxyResponseEvent apiGatewayProxyResponseEvent(Integer statusCode, T body) {
|
||||
|
@ -28,14 +28,12 @@ import com.amazonaws.services.lambda.runtime.RequestHandler;
|
||||
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent;
|
||||
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent;
|
||||
import com.iluwatar.serverless.baas.model.Person;
|
||||
import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* find person from persons collection
|
||||
* Created by dheeraj.mummar on 3/5/18.
|
||||
* find person from persons collection Created by dheeraj.mummar on 3/5/18.
|
||||
*/
|
||||
public class FindPersonApiHandler extends AbstractDynamoDbHandler<Person>
|
||||
implements RequestHandler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> {
|
||||
@ -44,10 +42,11 @@ public class FindPersonApiHandler extends AbstractDynamoDbHandler<Person>
|
||||
private static final Integer SUCCESS_STATUS_CODE = 200;
|
||||
|
||||
@Override
|
||||
public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent apiGatewayProxyRequestEvent,
|
||||
Context context) {
|
||||
public APIGatewayProxyResponseEvent handleRequest(
|
||||
APIGatewayProxyRequestEvent apiGatewayProxyRequestEvent, Context context) {
|
||||
Map<String, String> pathParameters = apiGatewayProxyRequestEvent.getPathParameters();
|
||||
pathParameters.keySet().stream().map(key -> key + "=" + pathParameters.get(key)).forEach(LOG::info);
|
||||
pathParameters.keySet().stream().map(key -> key + "=" + pathParameters.get(key))
|
||||
.forEach(LOG::info);
|
||||
|
||||
Person person = this.getDynamoDbMapper().load(Person.class, apiGatewayProxyRequestEvent
|
||||
.getPathParameters().get("id"));
|
||||
|
@ -28,14 +28,12 @@ import com.amazonaws.services.lambda.runtime.RequestHandler;
|
||||
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent;
|
||||
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent;
|
||||
import com.iluwatar.serverless.baas.model.Person;
|
||||
import java.io.IOException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* save person into persons collection
|
||||
* Created by dheeraj.mummar on 3/4/18.
|
||||
* save person into persons collection Created by dheeraj.mummar on 3/4/18.
|
||||
*/
|
||||
public class SavePersonApiHandler extends AbstractDynamoDbHandler<Person>
|
||||
implements RequestHandler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> {
|
||||
@ -45,8 +43,8 @@ public class SavePersonApiHandler extends AbstractDynamoDbHandler<Person>
|
||||
private static final Integer BAD_REQUEST_STATUS_CODE = 400;
|
||||
|
||||
@Override
|
||||
public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent
|
||||
apiGatewayProxyRequestEvent, Context context) {
|
||||
public APIGatewayProxyResponseEvent handleRequest(
|
||||
APIGatewayProxyRequestEvent apiGatewayProxyRequestEvent, Context context) {
|
||||
APIGatewayProxyResponseEvent apiGatewayProxyResponseEvent;
|
||||
Person person;
|
||||
try {
|
||||
|
@ -25,12 +25,10 @@ package com.iluwatar.serverless.baas.model;
|
||||
|
||||
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute;
|
||||
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBDocument;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Address class
|
||||
* Created by dheeraj.mummarareddy on 3/4/18.
|
||||
* Address class Created by dheeraj.mummarareddy on 3/4/18.
|
||||
*/
|
||||
@DynamoDBDocument
|
||||
public class Address implements Serializable {
|
||||
|
@ -28,12 +28,10 @@ import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAutoGeneratedKey;
|
||||
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey;
|
||||
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Person class
|
||||
* Created by dheeraj.mummarareddy on 3/4/18.
|
||||
* Person class Created by dheeraj.mummarareddy on 3/4/18.
|
||||
*/
|
||||
@DynamoDBTable(tableName = "persons")
|
||||
public class Person implements Serializable {
|
||||
|
@ -25,12 +25,11 @@ package com.iluwatar.serverless.faas;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Api gateway response
|
||||
* Api gateway response.
|
||||
*
|
||||
* @param <T> serializable object
|
||||
*/
|
||||
@ -44,11 +43,11 @@ public class ApiGatewayResponse<T extends Serializable> implements Serializable
|
||||
private final Boolean isBase64Encoded;
|
||||
|
||||
/**
|
||||
* api gateway response
|
||||
* api gateway response.
|
||||
*
|
||||
* @param statusCode - http status code
|
||||
* @param body - response body
|
||||
* @param headers - response headers
|
||||
* @param statusCode - http status code
|
||||
* @param body - response body
|
||||
* @param headers - response headers
|
||||
* @param isBase64Encoded - base64Encoded flag
|
||||
*/
|
||||
public ApiGatewayResponse(Integer statusCode, String body, Map<String, String> headers,
|
||||
@ -60,7 +59,7 @@ public class ApiGatewayResponse<T extends Serializable> implements Serializable
|
||||
}
|
||||
|
||||
/**
|
||||
* http status code
|
||||
* http status code.
|
||||
*
|
||||
* @return statusCode - http status code
|
||||
*/
|
||||
@ -69,7 +68,7 @@ public class ApiGatewayResponse<T extends Serializable> implements Serializable
|
||||
}
|
||||
|
||||
/**
|
||||
* response body
|
||||
* response body.
|
||||
*
|
||||
* @return string body
|
||||
*/
|
||||
@ -78,7 +77,7 @@ public class ApiGatewayResponse<T extends Serializable> implements Serializable
|
||||
}
|
||||
|
||||
/**
|
||||
* response headers
|
||||
* response headers.
|
||||
*
|
||||
* @return response headers
|
||||
*/
|
||||
@ -87,7 +86,7 @@ public class ApiGatewayResponse<T extends Serializable> implements Serializable
|
||||
}
|
||||
|
||||
/**
|
||||
* base64Encoded flag, API Gateway expects the property to be called "isBase64Encoded"
|
||||
* base64Encoded flag, API Gateway expects the property to be called "isBase64Encoded".
|
||||
*
|
||||
* @return base64Encoded flag
|
||||
*/
|
||||
@ -96,7 +95,8 @@ public class ApiGatewayResponse<T extends Serializable> implements Serializable
|
||||
}
|
||||
|
||||
/**
|
||||
* ApiGatewayResponse Builder class
|
||||
* ApiGatewayResponse Builder class.
|
||||
*
|
||||
* @param <T> Serializable object
|
||||
*/
|
||||
public static class ApiGatewayResponseBuilder<T extends Serializable> {
|
||||
@ -107,7 +107,8 @@ public class ApiGatewayResponse<T extends Serializable> implements Serializable
|
||||
private Boolean isBase64Encoded;
|
||||
|
||||
/**
|
||||
* http status code
|
||||
* http status code.
|
||||
*
|
||||
* @param statusCode - http status code
|
||||
* @return ApiGatewayResponseBuilder
|
||||
*/
|
||||
@ -117,7 +118,8 @@ public class ApiGatewayResponse<T extends Serializable> implements Serializable
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializable body
|
||||
* Serializable body.
|
||||
*
|
||||
* @param body - Serializable object
|
||||
* @return ApiGatewayResponseBuilder
|
||||
*/
|
||||
@ -127,7 +129,8 @@ public class ApiGatewayResponse<T extends Serializable> implements Serializable
|
||||
}
|
||||
|
||||
/**
|
||||
* response headers
|
||||
* response headers.
|
||||
*
|
||||
* @param headers - response headers
|
||||
* @return ApiGatewayResponseBuilder
|
||||
*/
|
||||
@ -137,7 +140,8 @@ public class ApiGatewayResponse<T extends Serializable> implements Serializable
|
||||
}
|
||||
|
||||
/**
|
||||
* base64Encoded glag
|
||||
* base64Encoded flag.
|
||||
*
|
||||
* @param isBase64Encoded - base64Encoded flag
|
||||
* @return ApiGatewayResponseBuilder
|
||||
*/
|
||||
@ -147,7 +151,7 @@ public class ApiGatewayResponse<T extends Serializable> implements Serializable
|
||||
}
|
||||
|
||||
/**
|
||||
* build ApiGatewayResponse
|
||||
* build ApiGatewayResponse.
|
||||
*
|
||||
* @return ApiGatewayResponse
|
||||
*/
|
||||
|
@ -26,7 +26,7 @@ package com.iluwatar.serverless.faas;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Lambda context information
|
||||
* Lambda context information.
|
||||
*/
|
||||
public class LambdaInfo implements Serializable {
|
||||
|
||||
@ -110,22 +110,28 @@ public class LambdaInfo implements Serializable {
|
||||
|
||||
LambdaInfo that = (LambdaInfo) o;
|
||||
|
||||
if (awsRequestId != null ? !awsRequestId.equals(that.awsRequestId) : that.awsRequestId != null) {
|
||||
if (awsRequestId != null ? !awsRequestId
|
||||
.equals(that.awsRequestId) : that.awsRequestId != null) {
|
||||
return false;
|
||||
}
|
||||
if (logGroupName != null ? !logGroupName.equals(that.logGroupName) : that.logGroupName != null) {
|
||||
if (logGroupName != null ? !logGroupName
|
||||
.equals(that.logGroupName) : that.logGroupName != null) {
|
||||
return false;
|
||||
}
|
||||
if (logStreamName != null ? !logStreamName.equals(that.logStreamName) : that.logStreamName != null) {
|
||||
if (logStreamName != null ? !logStreamName
|
||||
.equals(that.logStreamName) : that.logStreamName != null) {
|
||||
return false;
|
||||
}
|
||||
if (functionName != null ? !functionName.equals(that.functionName) : that.functionName != null) {
|
||||
if (functionName != null ? !functionName
|
||||
.equals(that.functionName) : that.functionName != null) {
|
||||
return false;
|
||||
}
|
||||
if (functionVersion != null ? !functionVersion.equals(that.functionVersion) : that.functionVersion != null) {
|
||||
if (functionVersion != null ? !functionVersion
|
||||
.equals(that.functionVersion) : that.functionVersion != null) {
|
||||
return false;
|
||||
}
|
||||
return memoryLimitInMb != null ? memoryLimitInMb.equals(that.memoryLimitInMb) : that.memoryLimitInMb == null;
|
||||
return memoryLimitInMb != null ? memoryLimitInMb
|
||||
.equals(that.memoryLimitInMb) : that.memoryLimitInMb == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -23,22 +23,20 @@
|
||||
|
||||
package com.iluwatar.serverless.faas.api;
|
||||
|
||||
import com.iluwatar.serverless.faas.ApiGatewayResponse;
|
||||
|
||||
import com.amazonaws.services.lambda.runtime.Context;
|
||||
import com.amazonaws.services.lambda.runtime.RequestHandler;
|
||||
import com.iluwatar.serverless.faas.ApiGatewayResponse;
|
||||
import com.iluwatar.serverless.faas.LambdaInfo;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* LambdaInfoApiHandler - simple api to get lambda context
|
||||
* Created by dheeraj.mummar on 2/5/18.
|
||||
* LambdaInfoApiHandler - simple api to get lambda context Created by dheeraj.mummar on 2/5/18.
|
||||
*/
|
||||
public class LambdaInfoApiHandler implements RequestHandler<Map<String, Object>, ApiGatewayResponse> {
|
||||
public class LambdaInfoApiHandler
|
||||
implements RequestHandler<Map<String, Object>, ApiGatewayResponse> {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(LambdaInfoApiHandler.class);
|
||||
private static final Integer SUCCESS_STATUS_CODE = 200;
|
||||
@ -49,16 +47,17 @@ public class LambdaInfoApiHandler implements RequestHandler<Map<String, Object>,
|
||||
LOG.info("received: " + input);
|
||||
|
||||
return new ApiGatewayResponse
|
||||
.ApiGatewayResponseBuilder<LambdaInfo>()
|
||||
.headers(headers())
|
||||
.statusCode(SUCCESS_STATUS_CODE)
|
||||
.body(lambdaInfo(context))
|
||||
.build();
|
||||
.ApiGatewayResponseBuilder<LambdaInfo>()
|
||||
.headers(headers())
|
||||
.statusCode(SUCCESS_STATUS_CODE)
|
||||
.body(lambdaInfo(context))
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* lambdaInfo
|
||||
* lambdaInfo.
|
||||
*
|
||||
* @param context - Lambda context
|
||||
* @return LambdaInfo
|
||||
*/
|
||||
|
Reference in New Issue
Block a user