Skip to content

Update of Flexible folder and the top-level parent pom. #1004

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

Merged
merged 26 commits into from
Jan 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1ef8e93
Updated flexible/analytics.
kurtisvg Jan 23, 2018
88b380f
Updated flexible/async-rest
kurtisvg Jan 23, 2018
98c37e0
Update flexible/cloud-tasks.
kurtisvg Jan 23, 2018
49c607e
Updated flexible/cloudsql
kurtisvg Jan 23, 2018
b25f169
Updated flexible/cloudstorage
kurtisvg Jan 23, 2018
e4809f4
Updated flexible/cron
kurtisvg Jan 23, 2018
09e9b46
Updated flexible/disk
kurtisvg Jan 23, 2018
7d86ad4
Updated flexible/endpoints
kurtisvg Jan 23, 2018
cc16175
Updated flexible/errorreporting
kurtisvg Jan 23, 2018
a22519e
Updated flexible/extending-runtime
kurtisvg Jan 23, 2018
49c84cb
Updated flexible/gaeinfo
kurtisvg Jan 23, 2018
e082ba3
Updated flexible/helloworld.
kurtisvg Jan 23, 2018
f485d28
Updated flexible/mailgun
kurtisvg Jan 23, 2018
9a725c2
Updated flexible/mailjet
kurtisvg Jan 23, 2018
0bb8567
Updated flexible/memcache.
kurtisvg Jan 23, 2018
7e0ec6d
Updated flexible/postgres
kurtisvg Jan 23, 2018
685fcd7
Updated flexible/pubsub.
kurtisvg Jan 23, 2018
8a5bc07
Updated flexible/sendgrid
kurtisvg Jan 23, 2018
8c8ec71
Updated flexible/sparkjava
kurtisvg Jan 23, 2018
76f3e58
Update flexible/static-files.
kurtisvg Jan 23, 2018
754e437
Update flexible/twilio.
kurtisvg Jan 23, 2018
aec7062
Updated flexible folder and a few missed violations.
kurtisvg Jan 23, 2018
4a50be0
Updated storage/xmp-api/cmdline-sample
kurtisvg Jan 23, 2018
b3c2b91
Updated storage/xml-api/serviceaccount-appengine/sample
kurtisvg Jan 23, 2018
e7be5c9
Updated vision/beta/cloud-client
kurtisvg Jan 23, 2018
3dfd3a4
Updated final pom.xml.
kurtisvg Jan 23, 2018
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
3 changes: 3 additions & 0 deletions flexible/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Google App Engine Flexible Environment Java Samples

<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">
<img alt="Open in Cloud Shell" src ="http://gstatic.com/cloudssh/images/open-btn.png"></a>

This is a repository that contains Java code samples for [Google App Engine
flexible environment][aeflex-docs].

Expand Down
15 changes: 10 additions & 5 deletions flexible/analytics/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,22 @@
<groupId>com.example.flexible</groupId>
<artifactId>flexible-analytics</artifactId>

<!--
The parent pom defines common style checks and testing strategies for our samples.
Removing or replacing it should not affect the execution of the samples in anyway.
-->
<parent>
<artifactId>appengine-flexible</artifactId>
<groupId>com.google.cloud</groupId>
<version>1.0.0</version>
<relativePath>..</relativePath>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.8</version>
</parent>

<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>

<appengine.maven.plugin>1.3.2</appengine.maven.plugin>
<jetty>9.4.4.v20170414</jetty>

<failOnMissingWebXml>false</failOnMissingWebXml> <!-- REQUIRED -->
</properties>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
/*
* Copyright 2015 Google Inc.
*
* <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* <p>http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing permissions and
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.example.analytics;

import java.io.IOException;
Expand Down
4 changes: 4 additions & 0 deletions flexible/async-rest/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@

# Example Web App Using Asynchronous Servlets #

<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">
<img alt="Open in Cloud Shell" src ="http://gstatic.com/cloudssh/images/open-btn.png"></a>


This web app demonstrates using asynchronous servlet techniques to reduce server resources.

The code for this tutorial is [here](https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/flexible/async-rest).
Expand Down
11 changes: 7 additions & 4 deletions flexible/async-rest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@
<version>1.0.0-SNAPSHOT</version>
<packaging>war</packaging>

<!--
The parent pom defines common style checks and testing strategies for our samples.
Removing or replacing it should not affect the execution of the samples in anyway.
-->
<parent>
<artifactId>appengine-flexible</artifactId>
<groupId>com.google.cloud</groupId>
<version>1.0.0</version>
<relativePath>..</relativePath>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.8</version>
</parent>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Collections;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.Iterator;
import java.util.Map;
import java.util.Queue;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.UnavailableException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,26 @@

package com.google.appengine.demos.asyncrest;

import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.api.Response;
import org.eclipse.jetty.client.api.Result;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Utf8StringBuilder;
import org.eclipse.jetty.util.ajax.JSON;
import org.eclipse.jetty.util.ssl.SslContextFactory;

import java.io.IOException;
import java.io.PrintWriter;
import java.nio.ByteBuffer;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicInteger;

import javax.servlet.AsyncContext;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.api.Response;
import org.eclipse.jetty.client.api.Result;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Utf8StringBuilder;
import org.eclipse.jetty.util.ajax.JSON;
import org.eclipse.jetty.util.ssl.SslContextFactory;

/**
* Servlet which makes REST calls asynchronously.
Expand Down Expand Up @@ -134,8 +132,6 @@ void doComplete() {

// We have results!
// Generate the response
String thumbs = generateResults(results);

response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html><head>");
Expand Down Expand Up @@ -176,6 +172,8 @@ void doComplete() {

out.println("<br/>");
out.print("First 5 results of " + results.size() + ":<br/>");

String thumbs = generateResults(results);
if ("".equals(thumbs)) {
out.print("<i>No results. Ensure " + APPKEY + " property is set correctly.</i>");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package com.google.appengine.demos.asyncrest;

import org.eclipse.jetty.util.ajax.JSON;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
Expand All @@ -27,10 +25,10 @@
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.util.ajax.JSON;

/**
* Servlet which makes REST calls serially.
Expand All @@ -41,17 +39,21 @@
* <dd>The Google app key to use</dd>
* </dl>
*/

public class SerialRestServlet extends AbstractRestServlet {

//CHECKSTYLE OFF: VariableDeclarationUsageDistance
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
if (key == null) {
response.sendError(500, APPKEY + " not set");
return;
}

long start = System.nanoTime();


String loc = sanitize(request.getParameter(LOC_PARAM));
String lat = sanitize(request.getParameter(LATITUDE_PARAM));
String longitude = sanitize(request.getParameter(LONGITUDE_PARAM));
Expand Down Expand Up @@ -118,6 +120,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
out.println("</body></html>");
out.close();
}
//CHECKSTYLE ON: VariableDeclarationUsageDistance

/**
* Handle HTTP POST request.
Expand All @@ -130,4 +133,4 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
doGet(request, response);
}

}
}
3 changes: 3 additions & 0 deletions flexible/cloud-tasks/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Google Cloud Tasks App Engine Flexible Queue Samples

<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">
<img alt="Open in Cloud Shell" src ="http://gstatic.com/cloudssh/images/open-btn.png"></a>

This is a sample AppEngine app demonstrating use of the Cloud Tasks API
using App Engine Queues.

Expand Down
11 changes: 7 additions & 4 deletions flexible/cloud-tasks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@
<groupId>com.example.cloudtasks</groupId>
<artifactId>cloudtasks</artifactId>

<!--
The parent pom defines common style checks and testing strategies for our samples.
Removing or replacing it should not affect the execution of the samples in anyway.
-->
<parent>
<artifactId>appengine-flexible</artifactId>
<groupId>com.google.cloud</groupId>
<version>1.0.0</version>
<relativePath>..</relativePath>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.8</version>
</parent>

<properties>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -16,25 +16,23 @@

package com.example.cloudtasks;

import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.services.cloudtasks.v2beta2.CloudTasks;
import com.google.api.services.cloudtasks.v2beta2.CloudTasksScopes;
import com.google.api.services.cloudtasks.v2beta2.model.AppEngineHttpRequest;
import com.google.api.services.cloudtasks.v2beta2.model.CreateTaskRequest;
import com.google.api.services.cloudtasks.v2beta2.model.Task;
import com.google.appengine.api.utils.SystemProperty;
import com.google.common.io.BaseEncoding;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.google.api.services.cloudtasks.v2beta2.CloudTasks;
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.jackson2.JacksonFactory;


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

String message = req.getParameter("message");
if(message == null) message = "Hello World!";
if (message == null) {
message = "Hello World!";
}

String project = req.getParameter("project");
String location = req.getParameter("location");
String queue_id = req.getParameter("queue");
String queueId = req.getParameter("queue");

createTask(project, location, queue_id, message);
createTask(project, location, queueId, message);

PrintWriter out = resp.getWriter();
out.println(String.format("Created a task with the following message: %s", message));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -18,7 +18,6 @@

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -19,7 +19,6 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
Expand All @@ -34,7 +33,9 @@ public class TaskHandlerServlet extends HttpServlet {
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
BufferedReader br = req.getReader();
StringBuffer dataBuffer = new StringBuffer();
while(br.ready()) dataBuffer.append(br.readLine());
while (br.ready()) {
dataBuffer.append(br.readLine());
}
String data = dataBuffer.toString();

System.out.println(String.format("Received task with payload: %s", data));
Expand Down
3 changes: 3 additions & 0 deletions flexible/cloudsql/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Cloud SQL sample for Google App Engine Flexible

<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">
<img alt="Open in Cloud Shell" src ="http://gstatic.com/cloudssh/images/open-btn.png"></a>

This sample demonstrates how to use [Cloud SQL](https://cloud.google.com/cloudsql/) on Google App
Engine Flexible

Expand Down
11 changes: 7 additions & 4 deletions flexible/cloudsql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@
<groupId>com.example.flexible</groupId>
<artifactId>flexible-cloudsql</artifactId>

<!--
The parent pom defines common style checks and testing strategies for our samples.
Removing or replacing it should not affect the execution of the samples in anyway.
-->
<parent>
<artifactId>appengine-flexible</artifactId>
<groupId>com.google.cloud</groupId>
<version>1.0.0</version>
<relativePath>..</relativePath>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.8</version>
</parent>

<!-- [START properties] -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Copyright 2016 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
14 changes: 14 additions & 0 deletions flexible/cloudsql/src/main/resources/config.properties
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
# Copyright 2015 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

sqlUrl=${sqlURL}
Loading