Skip to content

Commit 8148785

Browse files
authored
Update of Flexible folder and the top-level parent pom. (GoogleCloudPlatform#1004)
* Updated flexible/analytics. * Updated flexible/async-rest * Update flexible/cloud-tasks. * Updated flexible/cloudsql * Updated flexible/cloudstorage * Updated flexible/cron * Updated flexible/disk * Updated flexible/endpoints * Updated flexible/errorreporting * Updated flexible/extending-runtime * Updated flexible/gaeinfo * Updated flexible/helloworld. * Updated flexible/mailgun * Updated flexible/mailjet * Updated flexible/memcache. * Updated flexible/postgres * Updated flexible/pubsub. * Updated flexible/sendgrid * Updated flexible/sparkjava * Update flexible/static-files. * Update flexible/twilio. * Updated flexible folder and a few missed violations. * Updated storage/xmp-api/cmdline-sample * Updated storage/xml-api/serviceaccount-appengine/sample * Updated vision/beta/cloud-client * Updated final pom.xml.
1 parent 5bfacb8 commit 8148785

File tree

96 files changed

+633
-445
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+633
-445
lines changed

flexible/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Google App Engine Flexible Environment Java Samples
22

3+
<a href="https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/java-docs-samples&page=editor&open_in_editor=flexible/README.md">
4+
<img alt="Open in Cloud Shell" src ="http://gstatic.com/cloudssh/images/open-btn.png"></a>
5+
36
This is a repository that contains Java code samples for [Google App Engine
47
flexible environment][aeflex-docs].
58

flexible/analytics/pom.xml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,22 @@
2020
<groupId>com.example.flexible</groupId>
2121
<artifactId>flexible-analytics</artifactId>
2222

23+
<!--
24+
The parent pom defines common style checks and testing strategies for our samples.
25+
Removing or replacing it should not affect the execution of the samples in anyway.
26+
-->
2327
<parent>
24-
<artifactId>appengine-flexible</artifactId>
25-
<groupId>com.google.cloud</groupId>
26-
<version>1.0.0</version>
27-
<relativePath>..</relativePath>
28+
<groupId>com.google.cloud.samples</groupId>
29+
<artifactId>shared-configuration</artifactId>
30+
<version>1.0.8</version>
2831
</parent>
2932

3033
<properties>
34+
<maven.compiler.target>1.8</maven.compiler.target>
35+
<maven.compiler.source>1.8</maven.compiler.source>
36+
3137
<appengine.maven.plugin>1.3.2</appengine.maven.plugin>
3238
<jetty>9.4.4.v20170414</jetty>
33-
3439
<failOnMissingWebXml>false</failOnMissingWebXml> <!-- REQUIRED -->
3540
</properties>
3641

flexible/analytics/src/main/java/com/example/analytics/AnalyticsServlet.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
/*
22
* Copyright 2015 Google Inc.
33
*
4-
* <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5-
* except in compliance with the License. You may obtain a copy of the License at
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
67
*
7-
* <p>http://www.apache.org/licenses/LICENSE-2.0
8+
* http://www.apache.org/licenses/LICENSE-2.0
89
*
9-
* <p>Unless required by applicable law or agreed to in writing, software distributed under the
10-
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11-
* express or implied. See the License for the specific language governing permissions and
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
1214
* limitations under the License.
1315
*/
16+
1417
package com.example.analytics;
1518

1619
import java.io.IOException;

flexible/async-rest/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11

22
# Example Web App Using Asynchronous Servlets #
33

4+
<a href="https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/java-docs-samples&page=editor&open_in_editor=flexible/async-rest/README.md">
5+
<img alt="Open in Cloud Shell" src ="http://gstatic.com/cloudssh/images/open-btn.png"></a>
6+
7+
48
This web app demonstrates using asynchronous servlet techniques to reduce server resources.
59

610
The code for this tutorial is [here](https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/flexible/async-rest).

flexible/async-rest/pom.xml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@
2121
<version>1.0.0-SNAPSHOT</version>
2222
<packaging>war</packaging>
2323

24+
<!--
25+
The parent pom defines common style checks and testing strategies for our samples.
26+
Removing or replacing it should not affect the execution of the samples in anyway.
27+
-->
2428
<parent>
25-
<artifactId>appengine-flexible</artifactId>
26-
<groupId>com.google.cloud</groupId>
27-
<version>1.0.0</version>
28-
<relativePath>..</relativePath>
29+
<groupId>com.google.cloud.samples</groupId>
30+
<artifactId>shared-configuration</artifactId>
31+
<version>1.0.8</version>
2932
</parent>
3033

3134
<properties>

flexible/async-rest/src/main/java/com/google/appengine/demos/DumpServlet.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import java.io.IOException;
2020
import java.io.PrintWriter;
2121
import java.util.Collections;
22-
2322
import javax.servlet.ServletException;
2423
import javax.servlet.http.HttpServlet;
2524
import javax.servlet.http.HttpServletRequest;

flexible/async-rest/src/main/java/com/google/appengine/demos/asyncrest/AbstractRestServlet.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import java.util.Iterator;
2424
import java.util.Map;
2525
import java.util.Queue;
26-
2726
import javax.servlet.ServletConfig;
2827
import javax.servlet.ServletException;
2928
import javax.servlet.UnavailableException;

flexible/async-rest/src/main/java/com/google/appengine/demos/asyncrest/AsyncRestServlet.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,26 @@
1616

1717
package com.google.appengine.demos.asyncrest;
1818

19-
import org.eclipse.jetty.client.HttpClient;
20-
import org.eclipse.jetty.client.api.Response;
21-
import org.eclipse.jetty.client.api.Result;
22-
import org.eclipse.jetty.http.HttpMethod;
23-
import org.eclipse.jetty.util.BufferUtil;
24-
import org.eclipse.jetty.util.Utf8StringBuilder;
25-
import org.eclipse.jetty.util.ajax.JSON;
26-
import org.eclipse.jetty.util.ssl.SslContextFactory;
27-
2819
import java.io.IOException;
2920
import java.io.PrintWriter;
3021
import java.nio.ByteBuffer;
3122
import java.util.Map;
3223
import java.util.Queue;
3324
import java.util.concurrent.ConcurrentLinkedQueue;
3425
import java.util.concurrent.atomic.AtomicInteger;
35-
3626
import javax.servlet.AsyncContext;
3727
import javax.servlet.ServletConfig;
3828
import javax.servlet.ServletException;
3929
import javax.servlet.http.HttpServletRequest;
4030
import javax.servlet.http.HttpServletResponse;
31+
import org.eclipse.jetty.client.HttpClient;
32+
import org.eclipse.jetty.client.api.Response;
33+
import org.eclipse.jetty.client.api.Result;
34+
import org.eclipse.jetty.http.HttpMethod;
35+
import org.eclipse.jetty.util.BufferUtil;
36+
import org.eclipse.jetty.util.Utf8StringBuilder;
37+
import org.eclipse.jetty.util.ajax.JSON;
38+
import org.eclipse.jetty.util.ssl.SslContextFactory;
4139

4240
/**
4341
* Servlet which makes REST calls asynchronously.
@@ -134,8 +132,6 @@ void doComplete() {
134132

135133
// We have results!
136134
// Generate the response
137-
String thumbs = generateResults(results);
138-
139135
response.setContentType("text/html");
140136
PrintWriter out = response.getWriter();
141137
out.println("<html><head>");
@@ -176,6 +172,8 @@ void doComplete() {
176172

177173
out.println("<br/>");
178174
out.print("First 5 results of " + results.size() + ":<br/>");
175+
176+
String thumbs = generateResults(results);
179177
if ("".equals(thumbs)) {
180178
out.print("<i>No results. Ensure " + APPKEY + " property is set correctly.</i>");
181179
} else {

flexible/async-rest/src/main/java/com/google/appengine/demos/asyncrest/SerialRestServlet.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
package com.google.appengine.demos.asyncrest;
1818

19-
import org.eclipse.jetty.util.ajax.JSON;
20-
2119
import java.io.BufferedReader;
2220
import java.io.IOException;
2321
import java.io.InputStreamReader;
@@ -27,10 +25,10 @@
2725
import java.util.LinkedList;
2826
import java.util.Map;
2927
import java.util.Queue;
30-
3128
import javax.servlet.ServletException;
3229
import javax.servlet.http.HttpServletRequest;
3330
import javax.servlet.http.HttpServletResponse;
31+
import org.eclipse.jetty.util.ajax.JSON;
3432

3533
/**
3634
* Servlet which makes REST calls serially.
@@ -41,17 +39,21 @@
4139
* <dd>The Google app key to use</dd>
4240
* </dl>
4341
*/
42+
4443
public class SerialRestServlet extends AbstractRestServlet {
4544

45+
//CHECKSTYLE OFF: VariableDeclarationUsageDistance
4646
@Override
4747
protected void doGet(HttpServletRequest request, HttpServletResponse response)
4848
throws ServletException, IOException {
4949
if (key == null) {
5050
response.sendError(500, APPKEY + " not set");
5151
return;
5252
}
53+
5354
long start = System.nanoTime();
5455

56+
5557
String loc = sanitize(request.getParameter(LOC_PARAM));
5658
String lat = sanitize(request.getParameter(LATITUDE_PARAM));
5759
String longitude = sanitize(request.getParameter(LONGITUDE_PARAM));
@@ -118,6 +120,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
118120
out.println("</body></html>");
119121
out.close();
120122
}
123+
//CHECKSTYLE ON: VariableDeclarationUsageDistance
121124

122125
/**
123126
* Handle HTTP POST request.
@@ -130,4 +133,4 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
130133
doGet(request, response);
131134
}
132135

133-
}
136+
}

flexible/cloud-tasks/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Google Cloud Tasks App Engine Flexible Queue Samples
22

3+
<a href="https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/java-docs-samples&page=editor&open_in_editor=flexible/cloud-tasks/README.md">
4+
<img alt="Open in Cloud Shell" src ="http://gstatic.com/cloudssh/images/open-btn.png"></a>
5+
36
This is a sample AppEngine app demonstrating use of the Cloud Tasks API
47
using App Engine Queues.
58

flexible/cloud-tasks/pom.xml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@
2121
<groupId>com.example.cloudtasks</groupId>
2222
<artifactId>cloudtasks</artifactId>
2323

24+
<!--
25+
The parent pom defines common style checks and testing strategies for our samples.
26+
Removing or replacing it should not affect the execution of the samples in anyway.
27+
-->
2428
<parent>
25-
<artifactId>appengine-flexible</artifactId>
26-
<groupId>com.google.cloud</groupId>
27-
<version>1.0.0</version>
28-
<relativePath>..</relativePath>
29+
<groupId>com.google.cloud.samples</groupId>
30+
<artifactId>shared-configuration</artifactId>
31+
<version>1.0.8</version>
2932
</parent>
3033

3134
<properties>

flexible/cloud-tasks/src/main/java/com/example/cloudtasks/CreateTaskServlet.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Copyright 2017 Google Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,25 +16,23 @@
1616

1717
package com.example.cloudtasks;
1818

19+
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
20+
import com.google.api.client.http.HttpTransport;
21+
import com.google.api.client.http.javanet.NetHttpTransport;
22+
import com.google.api.client.json.JsonFactory;
23+
import com.google.api.client.json.jackson2.JacksonFactory;
24+
import com.google.api.services.cloudtasks.v2beta2.CloudTasks;
1925
import com.google.api.services.cloudtasks.v2beta2.CloudTasksScopes;
2026
import com.google.api.services.cloudtasks.v2beta2.model.AppEngineHttpRequest;
2127
import com.google.api.services.cloudtasks.v2beta2.model.CreateTaskRequest;
2228
import com.google.api.services.cloudtasks.v2beta2.model.Task;
23-
import com.google.appengine.api.utils.SystemProperty;
2429
import com.google.common.io.BaseEncoding;
2530
import java.io.IOException;
2631
import java.io.PrintWriter;
2732
import javax.servlet.annotation.WebServlet;
2833
import javax.servlet.http.HttpServlet;
2934
import javax.servlet.http.HttpServletRequest;
3035
import javax.servlet.http.HttpServletResponse;
31-
import com.google.api.services.cloudtasks.v2beta2.CloudTasks;
32-
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
33-
import com.google.api.client.http.HttpTransport;
34-
import com.google.api.client.http.javanet.NetHttpTransport;
35-
import com.google.api.client.json.JsonFactory;
36-
import com.google.api.client.json.jackson2.JacksonFactory;
37-
3836

3937
@WebServlet(value = "/create_task")
4038
@SuppressWarnings("serial")
@@ -44,13 +42,15 @@ public class CreateTaskServlet extends HttpServlet {
4442
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
4543

4644
String message = req.getParameter("message");
47-
if(message == null) message = "Hello World!";
45+
if (message == null) {
46+
message = "Hello World!";
47+
}
4848

4949
String project = req.getParameter("project");
5050
String location = req.getParameter("location");
51-
String queue_id = req.getParameter("queue");
51+
String queueId = req.getParameter("queue");
5252

53-
createTask(project, location, queue_id, message);
53+
createTask(project, location, queueId, message);
5454

5555
PrintWriter out = resp.getWriter();
5656
out.println(String.format("Created a task with the following message: %s", message));

flexible/cloud-tasks/src/main/java/com/example/cloudtasks/HelloServlet.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Copyright 2017 Google Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,7 +18,6 @@
1818

1919
import java.io.IOException;
2020
import java.io.PrintWriter;
21-
2221
import javax.servlet.annotation.WebServlet;
2322
import javax.servlet.http.HttpServlet;
2423
import javax.servlet.http.HttpServletRequest;

flexible/cloud-tasks/src/main/java/com/example/cloudtasks/TaskHandlerServlet.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Copyright 2017 Google Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,7 +19,6 @@
1919
import java.io.BufferedReader;
2020
import java.io.IOException;
2121
import java.io.PrintWriter;
22-
2322
import javax.servlet.annotation.WebServlet;
2423
import javax.servlet.http.HttpServlet;
2524
import javax.servlet.http.HttpServletRequest;
@@ -34,7 +33,9 @@ public class TaskHandlerServlet extends HttpServlet {
3433
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
3534
BufferedReader br = req.getReader();
3635
StringBuffer dataBuffer = new StringBuffer();
37-
while(br.ready()) dataBuffer.append(br.readLine());
36+
while (br.ready()) {
37+
dataBuffer.append(br.readLine());
38+
}
3839
String data = dataBuffer.toString();
3940

4041
System.out.println(String.format("Received task with payload: %s", data));

flexible/cloudsql/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Cloud SQL sample for Google App Engine Flexible
22

3+
<a href="https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/java-docs-samples&page=editor&open_in_editor=flexible/cloudsql/README.md">
4+
<img alt="Open in Cloud Shell" src ="http://gstatic.com/cloudssh/images/open-btn.png"></a>
5+
36
This sample demonstrates how to use [Cloud SQL](https://cloud.google.com/cloudsql/) on Google App
47
Engine Flexible
58

flexible/cloudsql/pom.xml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@
2020
<groupId>com.example.flexible</groupId>
2121
<artifactId>flexible-cloudsql</artifactId>
2222

23+
<!--
24+
The parent pom defines common style checks and testing strategies for our samples.
25+
Removing or replacing it should not affect the execution of the samples in anyway.
26+
-->
2327
<parent>
24-
<artifactId>appengine-flexible</artifactId>
25-
<groupId>com.google.cloud</groupId>
26-
<version>1.0.0</version>
27-
<relativePath>..</relativePath>
28+
<groupId>com.google.cloud.samples</groupId>
29+
<artifactId>shared-configuration</artifactId>
30+
<version>1.0.8</version>
2831
</parent>
2932

3033
<!-- [START properties] -->

flexible/cloudsql/src/main/java/com/example/cloudsql/CloudSqlServlet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Copyright 2016 Google Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,15 @@
1+
# Copyright 2015 Google Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
sqlUrl=${sqlURL}

0 commit comments

Comments
 (0)