Commit 4f38de54457599e398d5ee9a2b09c91e1121124a

Authored by Alex Mukha
1 parent 003b8ddf45
Exists in master

Implementation of simple labda template.

... ... @@ -34,6 +34,14 @@
34 34 </execution>
35 35 </executions>
36 36 </plugin>
  37 + <plugin>
  38 + <groupId>org.apache.maven.plugins</groupId>
  39 + <artifactId>maven-compiler-plugin</artifactId>
  40 + <configuration>
  41 + <source>1.8</source>
  42 + <target>1.8</target>
  43 + </configuration>
  44 + </plugin>
37 45 </plugins>
38 46 </build>
39 47  
... ...
src/main/java/org/alfresco/heartbeat/HeartbeatRequest.java
... ... @@ -0,0 +1,66 @@
  1 +package org.alfresco.heartbeat;
  2 +
  3 +/**
  4 + * Represents the request object
  5 + *
  6 + * @author amukha
  7 + */
  8 +public class HeartbeatRequest
  9 +{
  10 + private String repositoryId;
  11 + private String repositoryVersion;
  12 +
  13 + public HeartbeatRequest()
  14 + {
  15 +
  16 + }
  17 +
  18 + public String getRepositoryId()
  19 + {
  20 + return repositoryId;
  21 + }
  22 +
  23 + public void setRepositoryId(String repositoryId)
  24 + {
  25 + this.repositoryId = repositoryId;
  26 + }
  27 +
  28 + public String getRepositoryVersion()
  29 + {
  30 + return repositoryVersion;
  31 + }
  32 +
  33 + public void setRepositoryVersion(String repositoryVersion)
  34 + {
  35 + this.repositoryVersion = repositoryVersion;
  36 + }
  37 +
  38 + @Override
  39 + public boolean equals(Object o)
  40 + {
  41 + if (this == o) return true;
  42 + if (o == null || getClass() != o.getClass()) return false;
  43 +
  44 + HeartbeatRequest that = (HeartbeatRequest) o;
  45 +
  46 + if (repositoryId != null ? !repositoryId.equals(that.repositoryId) : that.repositoryId != null) return false;
  47 + return repositoryVersion != null ? repositoryVersion.equals(that.repositoryVersion) : that.repositoryVersion == null;
  48 + }
  49 +
  50 + @Override
  51 + public int hashCode()
  52 + {
  53 + int result = repositoryId != null ? repositoryId.hashCode() : 0;
  54 + result = 31 * result + (repositoryVersion != null ? repositoryVersion.hashCode() : 0);
  55 + return result;
  56 + }
  57 +
  58 + @Override
  59 + public String toString()
  60 + {
  61 + return "HeartbeatRequest{" +
  62 + "repositoryId='" + repositoryId + '\'' +
  63 + ", repositoryVersion='" + repositoryVersion + '\'' +
  64 + '}';
  65 + }
  66 +}
... ...
src/main/java/org/alfresco/heartbeat/HeartbeatResponse.java
... ... @@ -0,0 +1,51 @@
  1 +package org.alfresco.heartbeat;
  2 +
  3 +/**
  4 + * Represents the response object
  5 + *
  6 + * @author amukha
  7 + */
  8 +public class HeartbeatResponse
  9 +{
  10 + private boolean success;
  11 +
  12 + public HeartbeatResponse()
  13 + {
  14 +
  15 + }
  16 +
  17 + public void setSuccess(boolean success)
  18 + {
  19 + this.success = success;
  20 + }
  21 +
  22 + public boolean isSuccess()
  23 + {
  24 + return success;
  25 + }
  26 +
  27 + @Override
  28 + public boolean equals(Object o)
  29 + {
  30 + if (this == o) return true;
  31 + if (o == null || getClass() != o.getClass()) return false;
  32 +
  33 + HeartbeatResponse response = (HeartbeatResponse) o;
  34 +
  35 + return success == response.success;
  36 + }
  37 +
  38 + @Override
  39 + public int hashCode()
  40 + {
  41 + return (success ? 1 : 0);
  42 + }
  43 +
  44 + @Override
  45 + public String toString()
  46 + {
  47 + return "HeartbeatResponse{" +
  48 + "success=" + success +
  49 + '}';
  50 + }
  51 +}
... ...
src/main/java/org/alfresco/heartbeat/handler/HeartbeatRequestHandler.java
... ... @@ -0,0 +1,25 @@
  1 +package org.alfresco.heartbeat.handler;
  2 +
  3 +
  4 +import com.amazonaws.services.lambda.runtime.RequestHandler;
  5 +import org.alfresco.heartbeat.HeartbeatRequest;
  6 +import org.alfresco.heartbeat.HeartbeatResponse;
  7 +
  8 +import com.amazonaws.services.lambda.runtime.Context;
  9 +
  10 +/**
  11 + * Represents the receiver of the heart beat
  12 + *
  13 + * @author amukha
  14 + */
  15 +public class HeartbeatRequestHandler implements RequestHandler<HeartbeatRequest, HeartbeatResponse>
  16 +{
  17 + @Override
  18 + public HeartbeatResponse handleRequest(HeartbeatRequest request, Context context)
  19 + {
  20 + context.getLogger().log("Received object: " + request);
  21 + HeartbeatResponse response = new HeartbeatResponse();
  22 + response.setSuccess(true);
  23 + return response;
  24 + }
  25 +}
... ...