Skip to content

Commit e9d66ea

Browse files
committed
Create a Inbound Parse data parser sendgrid#144 (wip)
1 parent 8703eb6 commit e9d66ea

File tree

9 files changed

+384
-0
lines changed

9 files changed

+384
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# ParseExample
2+
3+
How to start the ParseExample application
4+
---
5+
6+
1. Run `mvn clean install` to build your application
7+
1. Start application with `java -jar target/dropwizard-parse-example-1.0-SNAPSHOT.jar server config.yml`
8+
1. To check that your application is running enter url `http://localhost:8080`
9+
10+
Health Check
11+
---
12+
13+
To see your applications health enter url `http://localhost:8081/healthcheck`
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
logging:
2+
level: INFO
3+
loggers:
4+
com.sendgrid: DEBUG
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.sendgrid</groupId>
5+
<artifactId>dropwizard-parse-example</artifactId>
6+
<name>ParseExample</name>
7+
<version>1.0-SNAPSHOT</version>
8+
<prerequisites>
9+
<maven>3.0.0</maven>
10+
</prerequisites>
11+
<build>
12+
<plugins>
13+
<plugin>
14+
<artifactId>maven-shade-plugin</artifactId>
15+
<version>2.4.1</version>
16+
<executions>
17+
<execution>
18+
<phase>package</phase>
19+
<goals>
20+
<goal>shade</goal>
21+
</goals>
22+
</execution>
23+
</executions>
24+
<configuration>
25+
<createDependencyReducedPom>true</createDependencyReducedPom>
26+
<transformers>
27+
<transformer />
28+
<transformer>
29+
<mainClass>${mainClass}</mainClass>
30+
</transformer>
31+
</transformers>
32+
<filters>
33+
<filter>
34+
<artifact>*:*</artifact>
35+
<excludes>
36+
<exclude>META-INF/*.SF</exclude>
37+
<exclude>META-INF/*.DSA</exclude>
38+
<exclude>META-INF/*.RSA</exclude>
39+
</excludes>
40+
</filter>
41+
</filters>
42+
</configuration>
43+
</plugin>
44+
<plugin>
45+
<artifactId>maven-jar-plugin</artifactId>
46+
<version>2.6</version>
47+
<configuration>
48+
<archive>
49+
<manifest>
50+
<addClasspath>true</addClasspath>
51+
<mainClass>${mainClass}</mainClass>
52+
</manifest>
53+
</archive>
54+
</configuration>
55+
</plugin>
56+
<plugin>
57+
<artifactId>maven-compiler-plugin</artifactId>
58+
<version>3.3</version>
59+
<configuration>
60+
<source>1.8</source>
61+
<target>1.8</target>
62+
</configuration>
63+
</plugin>
64+
<plugin>
65+
<artifactId>maven-source-plugin</artifactId>
66+
<version>2.4</version>
67+
<executions>
68+
<execution>
69+
<id>attach-sources</id>
70+
<goals>
71+
<goal>jar</goal>
72+
</goals>
73+
</execution>
74+
</executions>
75+
</plugin>
76+
<plugin>
77+
<artifactId>maven-javadoc-plugin</artifactId>
78+
<version>2.10.3</version>
79+
<executions>
80+
<execution>
81+
<id>attach-javadocs</id>
82+
<goals>
83+
<goal>jar</goal>
84+
</goals>
85+
</execution>
86+
</executions>
87+
</plugin>
88+
</plugins>
89+
</build>
90+
<reporting>
91+
<plugins>
92+
<plugin>
93+
<artifactId>maven-project-info-reports-plugin</artifactId>
94+
<version>2.8.1</version>
95+
<configuration>
96+
<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
97+
<dependencyDetailsEnabled>false</dependencyDetailsEnabled>
98+
</configuration>
99+
</plugin>
100+
<plugin>
101+
<artifactId>maven-javadoc-plugin</artifactId>
102+
<version>2.10.3</version>
103+
</plugin>
104+
</plugins>
105+
</reporting>
106+
<dependencyManagement>
107+
<dependencies>
108+
<dependency>
109+
<groupId>io.dropwizard</groupId>
110+
<artifactId>dropwizard-bom</artifactId>
111+
<version>${dropwizard.version}</version>
112+
<type>pom</type>
113+
<scope>import</scope>
114+
</dependency>
115+
</dependencies>
116+
</dependencyManagement>
117+
<properties>
118+
<dropwizard.version>1.0.3</dropwizard.version>
119+
<mainClass>com.sendgrid.ParseExampleApplication</mainClass>
120+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
121+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
122+
</properties>
123+
</project>
124+
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project
3+
xmlns="http://maven.apache.org/POM/4.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
6+
7+
<modelVersion>4.0.0</modelVersion>
8+
<prerequisites>
9+
<maven>3.0.0</maven>
10+
</prerequisites>
11+
12+
<groupId>com.sendgrid</groupId>
13+
<artifactId>dropwizard-parse-example</artifactId>
14+
<version>1.0-SNAPSHOT</version>
15+
<packaging>jar</packaging>
16+
17+
<name>ParseExample</name>
18+
19+
<properties>
20+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
21+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
22+
<dropwizard.version>1.0.3</dropwizard.version>
23+
<mainClass>com.sendgrid.ParseExampleApplication</mainClass>
24+
</properties>
25+
26+
<dependencyManagement>
27+
<dependencies>
28+
<dependency>
29+
<groupId>io.dropwizard</groupId>
30+
<artifactId>dropwizard-bom</artifactId>
31+
<version>${dropwizard.version}</version>
32+
<type>pom</type>
33+
<scope>import</scope>
34+
</dependency>
35+
</dependencies>
36+
</dependencyManagement>
37+
38+
<dependencies>
39+
<dependency>
40+
<groupId>io.dropwizard</groupId>
41+
<artifactId>dropwizard-core</artifactId>
42+
</dependency>
43+
<dependency>
44+
<groupId>io.dropwizard</groupId>
45+
<artifactId>dropwizard-forms</artifactId>
46+
</dependency>
47+
</dependencies>
48+
49+
<build>
50+
<plugins>
51+
<plugin>
52+
<artifactId>maven-shade-plugin</artifactId>
53+
<version>2.4.1</version>
54+
<configuration>
55+
<createDependencyReducedPom>true</createDependencyReducedPom>
56+
<transformers>
57+
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
58+
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
59+
<mainClass>${mainClass}</mainClass>
60+
</transformer>
61+
</transformers>
62+
<!-- exclude signed Manifests -->
63+
<filters>
64+
<filter>
65+
<artifact>*:*</artifact>
66+
<excludes>
67+
<exclude>META-INF/*.SF</exclude>
68+
<exclude>META-INF/*.DSA</exclude>
69+
<exclude>META-INF/*.RSA</exclude>
70+
</excludes>
71+
</filter>
72+
</filters>
73+
</configuration>
74+
<executions>
75+
<execution>
76+
<phase>package</phase>
77+
<goals>
78+
<goal>shade</goal>
79+
</goals>
80+
</execution>
81+
</executions>
82+
</plugin>
83+
<plugin>
84+
<artifactId>maven-jar-plugin</artifactId>
85+
<version>2.6</version>
86+
<configuration>
87+
<archive>
88+
<manifest>
89+
<addClasspath>true</addClasspath>
90+
<mainClass>${mainClass}</mainClass>
91+
</manifest>
92+
</archive>
93+
</configuration>
94+
</plugin>
95+
<plugin>
96+
<artifactId>maven-compiler-plugin</artifactId>
97+
<version>3.3</version>
98+
<configuration>
99+
<source>1.8</source>
100+
<target>1.8</target>
101+
</configuration>
102+
</plugin>
103+
<plugin>
104+
<artifactId>maven-source-plugin</artifactId>
105+
<version>2.4</version>
106+
<executions>
107+
<execution>
108+
<id>attach-sources</id>
109+
<goals>
110+
<goal>jar</goal>
111+
</goals>
112+
</execution>
113+
</executions>
114+
</plugin>
115+
<plugin>
116+
<artifactId>maven-javadoc-plugin</artifactId>
117+
<version>2.10.3</version>
118+
<executions>
119+
<execution>
120+
<id>attach-javadocs</id>
121+
<goals>
122+
<goal>jar</goal>
123+
</goals>
124+
</execution>
125+
</executions>
126+
</plugin>
127+
</plugins>
128+
</build>
129+
130+
<reporting>
131+
<plugins>
132+
<plugin>
133+
<artifactId>maven-project-info-reports-plugin</artifactId>
134+
<version>2.8.1</version>
135+
<configuration>
136+
<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
137+
<dependencyDetailsEnabled>false</dependencyDetailsEnabled>
138+
</configuration>
139+
</plugin>
140+
<plugin>
141+
<artifactId>maven-javadoc-plugin</artifactId>
142+
<version>2.10.3</version>
143+
</plugin>
144+
</plugins>
145+
</reporting>
146+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.sendgrid;
2+
3+
import com.sendgrid.resources.ParseResource;
4+
import io.dropwizard.Application;
5+
import io.dropwizard.forms.MultiPartBundle;
6+
import io.dropwizard.setup.Bootstrap;
7+
import io.dropwizard.setup.Environment;
8+
9+
public class ParseExampleApplication extends Application<ParseExampleConfiguration> {
10+
11+
public static void main(final String[] args) throws Exception {
12+
new ParseExampleApplication().run(args);
13+
}
14+
15+
@Override
16+
public String getName() {
17+
return "ParseExample";
18+
}
19+
20+
@Override
21+
public void initialize(final Bootstrap<ParseExampleConfiguration> bootstrap) {
22+
bootstrap.addBundle(new MultiPartBundle());
23+
}
24+
25+
@Override
26+
public void run(final ParseExampleConfiguration configuration,
27+
final Environment environment) {
28+
final ParseResource resource = new ParseResource();
29+
environment.jersey().register(resource);
30+
}
31+
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.sendgrid;
2+
3+
import io.dropwizard.Configuration;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
import org.hibernate.validator.constraints.*;
6+
import javax.validation.constraints.*;
7+
8+
public class ParseExampleConfiguration extends Configuration {
9+
// TODO: implement service configuration
10+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.sendgrid.api;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
5+
public class Parse {
6+
7+
@JsonProperty
8+
private String envelope;
9+
10+
public String getEnvelope() {
11+
return envelope;
12+
}
13+
14+
public void setEnvelope(String envelope) {
15+
this.envelope = envelope;
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.sendgrid.resources;
2+
3+
import com.sendgrid.api.Parse;
4+
import org.glassfish.jersey.media.multipart.FormDataParam;
5+
import org.hibernate.validator.constraints.NotBlank;
6+
7+
import javax.validation.Valid;
8+
import javax.validation.constraints.NotNull;
9+
import javax.ws.rs.Consumes;
10+
import javax.ws.rs.GET;
11+
import javax.ws.rs.POST;
12+
import javax.ws.rs.Path;
13+
import javax.ws.rs.core.MediaType;
14+
15+
@Path("/")
16+
public class ParseResource {
17+
18+
@GET
19+
public String hello() {
20+
return "hello";
21+
}
22+
23+
@POST
24+
@Path("/inbound")
25+
@Consumes(MediaType.MULTIPART_FORM_DATA)
26+
public String inbound(@FormDataParam("data") Parse parse) {
27+
System.out.println(parse.getEnvelope());
28+
return "OK";
29+
}
30+
}
31+
32+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
================================================================================
2+
3+
ParseExample
4+
5+
================================================================================
6+

0 commit comments

Comments
 (0)