forked from sendgrid/sendgrid-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a Inbound Parse data parser sendgrid#144 (wip)
- Loading branch information
Showing
9 changed files
with
384 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
examples/helpers/inbound/dropwizard-parse-example/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# ParseExample | ||
|
||
How to start the ParseExample application | ||
--- | ||
|
||
1. Run `mvn clean install` to build your application | ||
1. Start application with `java -jar target/dropwizard-parse-example-1.0-SNAPSHOT.jar server config.yml` | ||
1. To check that your application is running enter url `http://localhost:8080` | ||
|
||
Health Check | ||
--- | ||
|
||
To see your applications health enter url `http://localhost:8081/healthcheck` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
logging: | ||
level: INFO | ||
loggers: | ||
com.sendgrid: DEBUG |
124 changes: 124 additions & 0 deletions
124
examples/helpers/inbound/dropwizard-parse-example/dependency-reduced-pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.sendgrid</groupId> | ||
<artifactId>dropwizard-parse-example</artifactId> | ||
<name>ParseExample</name> | ||
<version>1.0-SNAPSHOT</version> | ||
<prerequisites> | ||
<maven>3.0.0</maven> | ||
</prerequisites> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>2.4.1</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<createDependencyReducedPom>true</createDependencyReducedPom> | ||
<transformers> | ||
<transformer /> | ||
<transformer> | ||
<mainClass>${mainClass}</mainClass> | ||
</transformer> | ||
</transformers> | ||
<filters> | ||
<filter> | ||
<artifact>*:*</artifact> | ||
<excludes> | ||
<exclude>META-INF/*.SF</exclude> | ||
<exclude>META-INF/*.DSA</exclude> | ||
<exclude>META-INF/*.RSA</exclude> | ||
</excludes> | ||
</filter> | ||
</filters> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>2.6</version> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<addClasspath>true</addClasspath> | ||
<mainClass>${mainClass}</mainClass> | ||
</manifest> | ||
</archive> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.3</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-source-plugin</artifactId> | ||
<version>2.4</version> | ||
<executions> | ||
<execution> | ||
<id>attach-sources</id> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-javadoc-plugin</artifactId> | ||
<version>2.10.3</version> | ||
<executions> | ||
<execution> | ||
<id>attach-javadocs</id> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<reporting> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-project-info-reports-plugin</artifactId> | ||
<version>2.8.1</version> | ||
<configuration> | ||
<dependencyLocationsEnabled>false</dependencyLocationsEnabled> | ||
<dependencyDetailsEnabled>false</dependencyDetailsEnabled> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-javadoc-plugin</artifactId> | ||
<version>2.10.3</version> | ||
</plugin> | ||
</plugins> | ||
</reporting> | ||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>io.dropwizard</groupId> | ||
<artifactId>dropwizard-bom</artifactId> | ||
<version>${dropwizard.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
<properties> | ||
<dropwizard.version>1.0.3</dropwizard.version> | ||
<mainClass>com.sendgrid.ParseExampleApplication</mainClass> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
</project> | ||
|
146 changes: 146 additions & 0 deletions
146
examples/helpers/inbound/dropwizard-parse-example/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<prerequisites> | ||
<maven>3.0.0</maven> | ||
</prerequisites> | ||
|
||
<groupId>com.sendgrid</groupId> | ||
<artifactId>dropwizard-parse-example</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>ParseExample</name> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
<dropwizard.version>1.0.3</dropwizard.version> | ||
<mainClass>com.sendgrid.ParseExampleApplication</mainClass> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>io.dropwizard</groupId> | ||
<artifactId>dropwizard-bom</artifactId> | ||
<version>${dropwizard.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.dropwizard</groupId> | ||
<artifactId>dropwizard-core</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.dropwizard</groupId> | ||
<artifactId>dropwizard-forms</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>2.4.1</version> | ||
<configuration> | ||
<createDependencyReducedPom>true</createDependencyReducedPom> | ||
<transformers> | ||
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/> | ||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> | ||
<mainClass>${mainClass}</mainClass> | ||
</transformer> | ||
</transformers> | ||
<!-- exclude signed Manifests --> | ||
<filters> | ||
<filter> | ||
<artifact>*:*</artifact> | ||
<excludes> | ||
<exclude>META-INF/*.SF</exclude> | ||
<exclude>META-INF/*.DSA</exclude> | ||
<exclude>META-INF/*.RSA</exclude> | ||
</excludes> | ||
</filter> | ||
</filters> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>2.6</version> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<addClasspath>true</addClasspath> | ||
<mainClass>${mainClass}</mainClass> | ||
</manifest> | ||
</archive> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.3</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-source-plugin</artifactId> | ||
<version>2.4</version> | ||
<executions> | ||
<execution> | ||
<id>attach-sources</id> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-javadoc-plugin</artifactId> | ||
<version>2.10.3</version> | ||
<executions> | ||
<execution> | ||
<id>attach-javadocs</id> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<reporting> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-project-info-reports-plugin</artifactId> | ||
<version>2.8.1</version> | ||
<configuration> | ||
<dependencyLocationsEnabled>false</dependencyLocationsEnabled> | ||
<dependencyDetailsEnabled>false</dependencyDetailsEnabled> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-javadoc-plugin</artifactId> | ||
<version>2.10.3</version> | ||
</plugin> | ||
</plugins> | ||
</reporting> | ||
</project> |
32 changes: 32 additions & 0 deletions
32
.../inbound/dropwizard-parse-example/src/main/java/com/sendgrid/ParseExampleApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.sendgrid; | ||
|
||
import com.sendgrid.resources.ParseResource; | ||
import io.dropwizard.Application; | ||
import io.dropwizard.forms.MultiPartBundle; | ||
import io.dropwizard.setup.Bootstrap; | ||
import io.dropwizard.setup.Environment; | ||
|
||
public class ParseExampleApplication extends Application<ParseExampleConfiguration> { | ||
|
||
public static void main(final String[] args) throws Exception { | ||
new ParseExampleApplication().run(args); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "ParseExample"; | ||
} | ||
|
||
@Override | ||
public void initialize(final Bootstrap<ParseExampleConfiguration> bootstrap) { | ||
bootstrap.addBundle(new MultiPartBundle()); | ||
} | ||
|
||
@Override | ||
public void run(final ParseExampleConfiguration configuration, | ||
final Environment environment) { | ||
final ParseResource resource = new ParseResource(); | ||
environment.jersey().register(resource); | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
...nbound/dropwizard-parse-example/src/main/java/com/sendgrid/ParseExampleConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.sendgrid; | ||
|
||
import io.dropwizard.Configuration; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import org.hibernate.validator.constraints.*; | ||
import javax.validation.constraints.*; | ||
|
||
public class ParseExampleConfiguration extends Configuration { | ||
// TODO: implement service configuration | ||
} |
17 changes: 17 additions & 0 deletions
17
examples/helpers/inbound/dropwizard-parse-example/src/main/java/com/sendgrid/api/Parse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.sendgrid.api; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
public class Parse { | ||
|
||
@JsonProperty | ||
private String envelope; | ||
|
||
public String getEnvelope() { | ||
return envelope; | ||
} | ||
|
||
public void setEnvelope(String envelope) { | ||
this.envelope = envelope; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
.../inbound/dropwizard-parse-example/src/main/java/com/sendgrid/resources/ParseResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.sendgrid.resources; | ||
|
||
import com.sendgrid.api.Parse; | ||
import org.glassfish.jersey.media.multipart.FormDataParam; | ||
import org.hibernate.validator.constraints.NotBlank; | ||
|
||
import javax.validation.Valid; | ||
import javax.validation.constraints.NotNull; | ||
import javax.ws.rs.Consumes; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.POST; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
@Path("/") | ||
public class ParseResource { | ||
|
||
@GET | ||
public String hello() { | ||
return "hello"; | ||
} | ||
|
||
@POST | ||
@Path("/inbound") | ||
@Consumes(MediaType.MULTIPART_FORM_DATA) | ||
public String inbound(@FormDataParam("data") Parse parse) { | ||
System.out.println(parse.getEnvelope()); | ||
return "OK"; | ||
} | ||
} | ||
|
||
|
6 changes: 6 additions & 0 deletions
6
examples/helpers/inbound/dropwizard-parse-example/src/main/resources/banner.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
================================================================================ | ||
|
||
ParseExample | ||
|
||
================================================================================ | ||
|