Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix checkstyle in twilio and sendgrid samples. #91

Merged
merged 1 commit into from
Feb 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions managed_vms/sendgrid/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@
<target>1.8</target>
</configuration>
</plugin>
<!--
The sendgrid sample currently (2016-01-22) fails the Google Style
checks. We can uncomment this block when it is fixed.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
Expand All @@ -65,7 +62,6 @@
<execution><goals><goal>check</goal></goals></execution>
</executions>
</plugin>
-->
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ public class SendEmailServlet extends HttpServlet {
@Override
public void service(HttpServletRequest req, HttpServletResponse resp) throws IOException,
ServletException {
final String SENDGRID_API_KEY = System.getenv("SENDGRID_API_KEY");
final String SENDGRID_SENDER = System.getenv("SENDGRID_SENDER");
final String TO_EMAIL = req.getParameter("to");
if (TO_EMAIL == null) {
resp.getWriter().print("Please provide an email address in the \"to\" query string"
+ " parameter.");
final String sendgridApiKey = System.getenv("SENDGRID_API_KEY");
final String sendgridSender = System.getenv("SENDGRID_SENDER");
final String toEmail = req.getParameter("to");
if (toEmail == null) {
resp.getWriter()
.print("Please provide an email address in the \"to\" query string parameter.");
return;
}

SendGrid sendgrid = new SendGrid(SENDGRID_API_KEY);
SendGrid sendgrid = new SendGrid(sendgridApiKey);
SendGrid.Email email = new SendGrid.Email();
email.addTo(TO_EMAIL);
email.setFrom(SENDGRID_SENDER);
email.addTo(toEmail);
email.setFrom(sendgridSender);
email.setSubject("This is a test email");
email.setText("Example text body.");

Expand All @@ -58,8 +58,7 @@ public void service(HttpServletRequest req, HttpServletResponse resp) throws IOE
return;
}
resp.getWriter().print("Email sent.");
}
catch (SendGridException e) {
} catch (SendGridException e) {
throw new ServletException("SendGrid error", e);
}
}
Expand Down
4 changes: 0 additions & 4 deletions managed_vms/twilio/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@
<target>1.8</target>
</configuration>
</plugin>
<!--
The twilio sample currently (2016-01-22) fails the Google Style
checks. We can uncomment this block when it is fixed.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
Expand All @@ -65,7 +62,6 @@
<execution><goals><goal>check</goal></goals></execution>
</executions>
</plugin>
-->
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,21 @@ public class SendSmsServlet extends HttpServlet {
@Override
public void service(HttpServletRequest req, HttpServletResponse resp) throws IOException,
ServletException {
final String TWILIO_ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
final String TWILIO_AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");
final String TWILIO_NUMBER = System.getenv("TWILIO_NUMBER");
final String TO_NUMBER = (String) req.getParameter("to");
if (TO_NUMBER == null) {
resp.getWriter().print("Please provide the number to message in the \"to\" query string"
+ " parameter.");
final String twilioAccountSid = System.getenv("TWILIO_ACCOUNT_SID");
final String twilioAuthToken = System.getenv("TWILIO_AUTH_TOKEN");
final String twilioNumber = System.getenv("TWILIO_NUMBER");
final String toNumber = (String) req.getParameter("to");
if (toNumber == null) {
resp.getWriter()
.print("Please provide the number to message in the \"to\" query string parameter.");
return;
}
TwilioRestClient client = new TwilioRestClient(TWILIO_ACCOUNT_SID,
TWILIO_AUTH_TOKEN);
TwilioRestClient client = new TwilioRestClient(twilioAccountSid, twilioAuthToken);
Account account = client.getAccount();
MessageFactory messageFactory = account.getMessageFactory();
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("To", TO_NUMBER));
params.add(new BasicNameValuePair("From", TWILIO_NUMBER));
params.add(new BasicNameValuePair("To", toNumber));
params.add(new BasicNameValuePair("From", twilioNumber));
params.add(new BasicNameValuePair("Body", "Hello from Twilio!"));
try {
Message sms = messageFactory.create(params);
Expand Down