diff --git a/flexible/README.md b/flexible/README.md index cba94155022..13860e59e6c 100644 --- a/flexible/README.md +++ b/flexible/README.md @@ -1,5 +1,8 @@ # Google App Engine Flexible Environment Java Samples + +Open in Cloud Shell + This is a repository that contains Java code samples for [Google App Engine flexible environment][aeflex-docs]. diff --git a/flexible/analytics/pom.xml b/flexible/analytics/pom.xml index 1d45004c50e..6e927a83ec0 100644 --- a/flexible/analytics/pom.xml +++ b/flexible/analytics/pom.xml @@ -20,17 +20,22 @@ com.example.flexible flexible-analytics + - appengine-flexible - com.google.cloud - 1.0.0 - .. + com.google.cloud.samples + shared-configuration + 1.0.8 + 1.8 + 1.8 + 1.3.2 9.4.4.v20170414 - false diff --git a/flexible/analytics/src/main/java/com/example/analytics/AnalyticsServlet.java b/flexible/analytics/src/main/java/com/example/analytics/AnalyticsServlet.java index 91abafe3e63..6ae1033c9d6 100644 --- a/flexible/analytics/src/main/java/com/example/analytics/AnalyticsServlet.java +++ b/flexible/analytics/src/main/java/com/example/analytics/AnalyticsServlet.java @@ -1,16 +1,19 @@ /* * 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 + * 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 + * 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 + * 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; diff --git a/flexible/async-rest/README.md b/flexible/async-rest/README.md index d9d97614f35..37e823d8894 100644 --- a/flexible/async-rest/README.md +++ b/flexible/async-rest/README.md @@ -1,6 +1,10 @@ # Example Web App Using Asynchronous Servlets # + +Open in Cloud Shell + + 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). diff --git a/flexible/async-rest/pom.xml b/flexible/async-rest/pom.xml index 661d9600271..f297302d1ed 100644 --- a/flexible/async-rest/pom.xml +++ b/flexible/async-rest/pom.xml @@ -21,11 +21,14 @@ 1.0.0-SNAPSHOT war + - appengine-flexible - com.google.cloud - 1.0.0 - .. + com.google.cloud.samples + shared-configuration + 1.0.8 diff --git a/flexible/async-rest/src/main/java/com/google/appengine/demos/DumpServlet.java b/flexible/async-rest/src/main/java/com/google/appengine/demos/DumpServlet.java index 7907f5207cc..aaba6a97ab8 100644 --- a/flexible/async-rest/src/main/java/com/google/appengine/demos/DumpServlet.java +++ b/flexible/async-rest/src/main/java/com/google/appengine/demos/DumpServlet.java @@ -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; diff --git a/flexible/async-rest/src/main/java/com/google/appengine/demos/asyncrest/AbstractRestServlet.java b/flexible/async-rest/src/main/java/com/google/appengine/demos/asyncrest/AbstractRestServlet.java index 101e511245b..5a83279b0c1 100644 --- a/flexible/async-rest/src/main/java/com/google/appengine/demos/asyncrest/AbstractRestServlet.java +++ b/flexible/async-rest/src/main/java/com/google/appengine/demos/asyncrest/AbstractRestServlet.java @@ -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; diff --git a/flexible/async-rest/src/main/java/com/google/appengine/demos/asyncrest/AsyncRestServlet.java b/flexible/async-rest/src/main/java/com/google/appengine/demos/asyncrest/AsyncRestServlet.java index 712e3587cd8..04b8b7e59f9 100644 --- a/flexible/async-rest/src/main/java/com/google/appengine/demos/asyncrest/AsyncRestServlet.java +++ b/flexible/async-rest/src/main/java/com/google/appengine/demos/asyncrest/AsyncRestServlet.java @@ -16,15 +16,6 @@ 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; @@ -32,12 +23,19 @@ 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. @@ -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(""); @@ -176,6 +172,8 @@ void doComplete() { out.println("
"); out.print("First 5 results of " + results.size() + ":
"); + + String thumbs = generateResults(results); if ("".equals(thumbs)) { out.print("No results. Ensure " + APPKEY + " property is set correctly."); } else { diff --git a/flexible/async-rest/src/main/java/com/google/appengine/demos/asyncrest/SerialRestServlet.java b/flexible/async-rest/src/main/java/com/google/appengine/demos/asyncrest/SerialRestServlet.java index 9717300e340..a8fd96a0c82 100644 --- a/flexible/async-rest/src/main/java/com/google/appengine/demos/asyncrest/SerialRestServlet.java +++ b/flexible/async-rest/src/main/java/com/google/appengine/demos/asyncrest/SerialRestServlet.java @@ -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; @@ -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. @@ -41,8 +39,10 @@ *

The Google app key to use
* */ + public class SerialRestServlet extends AbstractRestServlet { + //CHECKSTYLE OFF: VariableDeclarationUsageDistance @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { @@ -50,8 +50,10 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) 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)); @@ -118,6 +120,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) out.println(""); out.close(); } + //CHECKSTYLE ON: VariableDeclarationUsageDistance /** * Handle HTTP POST request. @@ -130,4 +133,4 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) doGet(request, response); } -} +} \ No newline at end of file diff --git a/flexible/cloud-tasks/README.md b/flexible/cloud-tasks/README.md index cf53ff3052d..6e47e80f9aa 100644 --- a/flexible/cloud-tasks/README.md +++ b/flexible/cloud-tasks/README.md @@ -1,5 +1,8 @@ # Google Cloud Tasks App Engine Flexible Queue Samples + +Open in Cloud Shell + This is a sample AppEngine app demonstrating use of the Cloud Tasks API using App Engine Queues. diff --git a/flexible/cloud-tasks/pom.xml b/flexible/cloud-tasks/pom.xml index 196f6f8681c..cfd25ad5c9d 100644 --- a/flexible/cloud-tasks/pom.xml +++ b/flexible/cloud-tasks/pom.xml @@ -21,11 +21,14 @@ com.example.cloudtasks cloudtasks + - appengine-flexible - com.google.cloud - 1.0.0 - .. + com.google.cloud.samples + shared-configuration + 1.0.8 diff --git a/flexible/cloud-tasks/src/main/java/com/example/cloudtasks/CreateTaskServlet.java b/flexible/cloud-tasks/src/main/java/com/example/cloudtasks/CreateTaskServlet.java index 3c07a7cd1a7..cc30460f539 100644 --- a/flexible/cloud-tasks/src/main/java/com/example/cloudtasks/CreateTaskServlet.java +++ b/flexible/cloud-tasks/src/main/java/com/example/cloudtasks/CreateTaskServlet.java @@ -1,4 +1,4 @@ -/** +/* * Copyright 2017 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,11 +16,16 @@ 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; @@ -28,13 +33,6 @@ 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") @@ -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)); diff --git a/flexible/cloud-tasks/src/main/java/com/example/cloudtasks/HelloServlet.java b/flexible/cloud-tasks/src/main/java/com/example/cloudtasks/HelloServlet.java index 520c5a5ca29..d0da78b2198 100644 --- a/flexible/cloud-tasks/src/main/java/com/example/cloudtasks/HelloServlet.java +++ b/flexible/cloud-tasks/src/main/java/com/example/cloudtasks/HelloServlet.java @@ -1,4 +1,4 @@ -/** +/* * Copyright 2017 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -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; diff --git a/flexible/cloud-tasks/src/main/java/com/example/cloudtasks/TaskHandlerServlet.java b/flexible/cloud-tasks/src/main/java/com/example/cloudtasks/TaskHandlerServlet.java index 53e10ec4069..a9da53a21f6 100644 --- a/flexible/cloud-tasks/src/main/java/com/example/cloudtasks/TaskHandlerServlet.java +++ b/flexible/cloud-tasks/src/main/java/com/example/cloudtasks/TaskHandlerServlet.java @@ -1,4 +1,4 @@ -/** +/* * Copyright 2017 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -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; @@ -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)); diff --git a/flexible/cloudsql/README.md b/flexible/cloudsql/README.md index 871f5f9f855..4f8bd3df504 100644 --- a/flexible/cloudsql/README.md +++ b/flexible/cloudsql/README.md @@ -1,5 +1,8 @@ # Cloud SQL sample for Google App Engine Flexible + +Open in Cloud Shell + This sample demonstrates how to use [Cloud SQL](https://cloud.google.com/cloudsql/) on Google App Engine Flexible diff --git a/flexible/cloudsql/pom.xml b/flexible/cloudsql/pom.xml index 258126aa34b..05bcdbb25f3 100644 --- a/flexible/cloudsql/pom.xml +++ b/flexible/cloudsql/pom.xml @@ -20,11 +20,14 @@ com.example.flexible flexible-cloudsql + - appengine-flexible - com.google.cloud - 1.0.0 - .. + com.google.cloud.samples + shared-configuration + 1.0.8 diff --git a/flexible/cloudsql/src/main/java/com/example/cloudsql/CloudSqlServlet.java b/flexible/cloudsql/src/main/java/com/example/cloudsql/CloudSqlServlet.java index 7e55cb23bee..80826a40dea 100644 --- a/flexible/cloudsql/src/main/java/com/example/cloudsql/CloudSqlServlet.java +++ b/flexible/cloudsql/src/main/java/com/example/cloudsql/CloudSqlServlet.java @@ -1,4 +1,4 @@ -/** +/* * Copyright 2016 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/flexible/cloudsql/src/main/resources/config.properties b/flexible/cloudsql/src/main/resources/config.properties index 405c4a6848e..649e37bf67b 100644 --- a/flexible/cloudsql/src/main/resources/config.properties +++ b/flexible/cloudsql/src/main/resources/config.properties @@ -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} diff --git a/flexible/cloudstorage/README.md b/flexible/cloudstorage/README.md index 1d0ee071298..64a75ff5413 100644 --- a/flexible/cloudstorage/README.md +++ b/flexible/cloudstorage/README.md @@ -1,4 +1,8 @@ # Cloud Storage sample for Google Managed VMs + + +Open in Cloud Shell + This sample demonstrates how to use [Cloud Storage](https://cloud.google.com/storage/) on Google Managed VMs. ## Setup diff --git a/flexible/cloudstorage/pom.xml b/flexible/cloudstorage/pom.xml index 512392b9918..552e794bbfd 100644 --- a/flexible/cloudstorage/pom.xml +++ b/flexible/cloudstorage/pom.xml @@ -20,11 +20,14 @@ com.example.flexible flexible-cloudstorage + - appengine-flexible - com.google.cloud - 1.0.0 - .. + com.google.cloud.samples + shared-configuration + 1.0.8 diff --git a/flexible/cloudstorage/src/main/java/com/example/cloudstorage/UploadServlet.java b/flexible/cloudstorage/src/main/java/com/example/cloudstorage/UploadServlet.java index 6b7aebb0d8b..22ae9db90a2 100644 --- a/flexible/cloudstorage/src/main/java/com/example/cloudstorage/UploadServlet.java +++ b/flexible/cloudstorage/src/main/java/com/example/cloudstorage/UploadServlet.java @@ -1,4 +1,4 @@ -/** +/* * Copyright 2015 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/flexible/cron/README.md b/flexible/cron/README.md index 3535287907f..1ae81351bef 100644 --- a/flexible/cron/README.md +++ b/flexible/cron/README.md @@ -1,4 +1,8 @@ # App Engine Cron Service sample for Google App Engine + + +Open in Cloud Shell + This sample demonstrates how to deploy App Engine Cron Service to ping a servlet deployed in the app. ## Running locally diff --git a/flexible/cron/pom.xml b/flexible/cron/pom.xml index 92dc43da5cb..cfb72c0ef17 100644 --- a/flexible/cron/pom.xml +++ b/flexible/cron/pom.xml @@ -20,11 +20,14 @@ com.example.managedvms managed-vms-cron + - appengine-flexible - com.google.cloud - 1.0.0 - .. + com.google.cloud.samples + shared-configuration + 1.0.8 diff --git a/flexible/cron/src/main/java/com/example/cron/CronServlet.java b/flexible/cron/src/main/java/com/example/cron/CronServlet.java index 1ef6dcbfc41..908956d6787 100644 --- a/flexible/cron/src/main/java/com/example/cron/CronServlet.java +++ b/flexible/cron/src/main/java/com/example/cron/CronServlet.java @@ -1,4 +1,4 @@ -/** +/* * Copyright 2016 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/flexible/datastore/src/main/java/com/example/datastore/DatastoreServlet.java b/flexible/datastore/src/main/java/com/example/datastore/DatastoreServlet.java index 09d70055b2c..341c0763a7d 100644 --- a/flexible/datastore/src/main/java/com/example/datastore/DatastoreServlet.java +++ b/flexible/datastore/src/main/java/com/example/datastore/DatastoreServlet.java @@ -1,4 +1,4 @@ -/** +/* * Copyright 2015 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/flexible/disk/pom.xml b/flexible/disk/pom.xml index 59f50df8821..375c693f80f 100644 --- a/flexible/disk/pom.xml +++ b/flexible/disk/pom.xml @@ -20,11 +20,14 @@ com.example.flexible flexible-disk + - appengine-flexible - com.google.cloud - 1.0.0 - .. + com.google.cloud.samples + shared-configuration + 1.0.8 diff --git a/flexible/disk/src/main/java/com/example/disk/DiskServlet.java b/flexible/disk/src/main/java/com/example/disk/DiskServlet.java index 5434063c309..2f2fd87a870 100644 --- a/flexible/disk/src/main/java/com/example/disk/DiskServlet.java +++ b/flexible/disk/src/main/java/com/example/disk/DiskServlet.java @@ -1,4 +1,4 @@ -/** +/* * Copyright 2015 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -40,9 +40,6 @@ public class DiskServlet extends HttpServlet { @Override public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { - String instanceId = - System.getenv().containsKey("GAE_INSTANCE") - ? System.getenv("GAE_INSTANCE") : "1"; // store only the first two octets of a users ip address String userIp = req.getRemoteAddr(); InetAddress address = InetAddress.getByName(userIp); @@ -64,6 +61,9 @@ public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOExc for (String s : strings) { sb.append(s + "\n"); } + + String instanceId = + System.getenv().containsKey("GAE_INSTANCE") ? System.getenv("GAE_INSTANCE") : "1"; PrintWriter out = resp.getWriter(); resp.setContentType("text/plain"); out.print("Instance: " + instanceId + "\nSeen:\n" + sb.toString()); diff --git a/flexible/endpoints/README.md b/flexible/endpoints/README.md index ee6dd61a9eb..4f86b4b247a 100644 --- a/flexible/endpoints/README.md +++ b/flexible/endpoints/README.md @@ -1,4 +1,8 @@ # Google Cloud Endpoints on App Engine flexible environment + + +Open in Cloud Shell + This sample demonstrates how to use Google Cloud Endpoints on Google App Engine Flexible Environment using Java. ## Edit the Open API specification diff --git a/flexible/endpoints/pom.xml b/flexible/endpoints/pom.xml index 796b14d3066..b0f9acea51e 100644 --- a/flexible/endpoints/pom.xml +++ b/flexible/endpoints/pom.xml @@ -8,11 +8,14 @@ com.example.flexible flexible-endpoints + - appengine-flexible - com.google.cloud - 1.0.0 - .. + com.google.cloud.samples + shared-configuration + 1.0.8 diff --git a/flexible/endpoints/src/main/java/com/example/endpoints/AuthInfoServlet.java b/flexible/endpoints/src/main/java/com/example/endpoints/AuthInfoServlet.java index 88cc789bf19..f51088b9209 100644 --- a/flexible/endpoints/src/main/java/com/example/endpoints/AuthInfoServlet.java +++ b/flexible/endpoints/src/main/java/com/example/endpoints/AuthInfoServlet.java @@ -1,4 +1,4 @@ -/** +/* * Copyright 2015 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/flexible/endpoints/src/main/java/com/example/endpoints/EchoServlet.java b/flexible/endpoints/src/main/java/com/example/endpoints/EchoServlet.java index 729d14e7687..84e3152f404 100644 --- a/flexible/endpoints/src/main/java/com/example/endpoints/EchoServlet.java +++ b/flexible/endpoints/src/main/java/com/example/endpoints/EchoServlet.java @@ -1,4 +1,4 @@ -/** +/* * Copyright 2015 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/flexible/errorreporting/README.md b/flexible/errorreporting/README.md index b27ba8ca1f0..fe4056b9fd5 100644 --- a/flexible/errorreporting/README.md +++ b/flexible/errorreporting/README.md @@ -1,5 +1,8 @@ # Error reporting sample for Google App Engine Flexible + +Open in Cloud Shell + [Stackdriver Error Reporting][error-reporting] Stackdriver Error Reporting counts, analyzes and aggregates the crashes in your running cloud services. A [centralized error management interface](https://console.cloud.google.com/errors) displays the results with sorting and filtering capabilities. diff --git a/flexible/errorreporting/pom.xml b/flexible/errorreporting/pom.xml index 6442e7d89c1..d6e7289a609 100644 --- a/flexible/errorreporting/pom.xml +++ b/flexible/errorreporting/pom.xml @@ -21,11 +21,14 @@ com.example.flexible flexible-error-reporting + - appengine-flexible - com.google.cloud - 1.0.0 - .. + com.google.cloud.samples + shared-configuration + 1.0.8 diff --git a/flexible/errorreporting/src/main/java/com/example/flexible/errorreporting/ErrorReportingExample.java b/flexible/errorreporting/src/main/java/com/example/flexible/errorreporting/ErrorReportingExample.java index 1b9f4eebcd2..4c3583381c2 100644 --- a/flexible/errorreporting/src/main/java/com/example/flexible/errorreporting/ErrorReportingExample.java +++ b/flexible/errorreporting/src/main/java/com/example/flexible/errorreporting/ErrorReportingExample.java @@ -1,16 +1,19 @@ -/** +/* * Copyright 2017 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 + * 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 + * 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 + * 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.flexible.errorreporting; import com.google.cloud.ServiceOptions; diff --git a/flexible/extending-runtime/README.md b/flexible/extending-runtime/README.md index a1c5801e06a..fdb535c4c63 100644 --- a/flexible/extending-runtime/README.md +++ b/flexible/extending-runtime/README.md @@ -1,6 +1,7 @@ # Java extending runtime sample for Google App Engine Flexible -This sample demonstrates how to use custom runtime on Google App Engine Flexible -## Setup + +Open in Cloud Shell + +This sample demonstrates how to use custom runtime on Google App Engine Flexible -... ?? diff --git a/flexible/extending-runtime/pom.xml b/flexible/extending-runtime/pom.xml index b6259c7c636..d4dc865f80d 100644 --- a/flexible/extending-runtime/pom.xml +++ b/flexible/extending-runtime/pom.xml @@ -20,11 +20,14 @@ com.example.flexible extendingruntime + - appengine-flexible - com.google.cloud - 1.0.0 - .. + com.google.cloud.samples + shared-configuration + 1.0.8 diff --git a/flexible/extending-runtime/src/main/java/com/example/extendingruntime/FortuneServlet.java b/flexible/extending-runtime/src/main/java/com/example/extendingruntime/FortuneServlet.java index 9e43738563a..d255bd4bf25 100644 --- a/flexible/extending-runtime/src/main/java/com/example/extendingruntime/FortuneServlet.java +++ b/flexible/extending-runtime/src/main/java/com/example/extendingruntime/FortuneServlet.java @@ -1,4 +1,4 @@ -/** +/* * Copyright 2015 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/flexible/gaeinfo/README.md b/flexible/gaeinfo/README.md index bbc44092165..abef6c7ac28 100644 --- a/flexible/gaeinfo/README.md +++ b/flexible/gaeinfo/README.md @@ -1,5 +1,8 @@ # Google App Engine Information + +Open in Cloud Shell + ## WARNING - this version runs on App Engine Flexible using the deprecated COMPAT runtime. ## Most users will prefer to use the Metadata example for flex (in progress) This sample displays what's going on in your app. It dumps the environment and lots more. diff --git a/flexible/gaeinfo/pom.xml b/flexible/gaeinfo/pom.xml index bd6c8796789..63b441bb6eb 100644 --- a/flexible/gaeinfo/pom.xml +++ b/flexible/gaeinfo/pom.xml @@ -21,11 +21,14 @@ Copyright 2017 Google Inc. com.example.appengine gaeinfo-flex-compat + - appengine-flexible - com.google.cloud - 1.0.0 - .. + com.google.cloud.samples + shared-configuration + 1.0.8 diff --git a/flexible/gaeinfo/src/main/java/com/example/appengine/flex_compat/GaeInfoServlet.java b/flexible/gaeinfo/src/main/java/com/example/appengine/flex_compat/GaeInfoServlet.java index e47028afa71..5442d816760 100644 --- a/flexible/gaeinfo/src/main/java/com/example/appengine/flex_compat/GaeInfoServlet.java +++ b/flexible/gaeinfo/src/main/java/com/example/appengine/flex_compat/GaeInfoServlet.java @@ -1,19 +1,25 @@ -/** +/* * Copyright 2017 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 + * 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. + * 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. */ +//CHECKSTYLE OFF: PackageName + package com.example.appengine.flex_compat; +//CHECKSTYLE ON: PackageName + import com.google.appengine.api.appidentity.AppIdentityService; import com.google.appengine.api.appidentity.AppIdentityServiceFactory; import com.google.appengine.api.utils.SystemProperty; @@ -55,16 +61,16 @@ public class GaeInfoServlet extends HttpServlet { "/computeMetadata/v1/instance/service-accounts/default/aliases", "/computeMetadata/v1/instance/service-accounts/default/", "/computeMetadata/v1/instance/service-accounts/default/scopes", -// Tokens work - but are a security risk to display -// "/computeMetadata/v1/instance/service-accounts/default/token" + // Tokens work - but are a security risk to display + // "/computeMetadata/v1/instance/service-accounts/default/token" }; final String[] metaServiceAcct = { "/computeMetadata/v1/instance/service-accounts/{account}/aliases", "/computeMetadata/v1/instance/service-accounts/{account}/email", "/computeMetadata/v1/instance/service-accounts/{account}/scopes", -// Tokens work - but are a security risk to display -// "/computeMetadata/v1/instance/service-accounts/{account}/token" + // Tokens work - but are a security risk to display + // "/computeMetadata/v1/instance/service-accounts/{account}/token" }; private final String metadata = "http://metadata.google.internal"; @@ -94,7 +100,7 @@ String fetchMetadata(String key) throws IOException { Response response = ok.newCall(request).execute(); return response.body().string(); } catch (Exception e) { - log("fetchMetadata - "+metadata+key+": ", e); + log("fetchMetadata - " + metadata + key + ": ", e); } return ""; } @@ -102,19 +108,18 @@ String fetchMetadata(String key) throws IOException { String fetchJsonMetadata(String prefix) throws IOException { String json = ""; try { - Request request = new Request.Builder() - .url(metadata + prefix ) - .addHeader("Metadata-Flavor", "Google") - .get() - .build(); + Request request = new Request.Builder() + .url(metadata + prefix) + .addHeader("Metadata-Flavor", "Google") + .get() + .build(); Response response = ok.newCall(request).execute(); // Convert json to prety json json = response.body().string(); return gson.toJson(jp.parse(json)); } catch (Exception e) { - log("fetchJsonMetadata - "+metadata+prefix+" : ", e); - log(" body: "+json); + log("fetchJsonMetadata - " + metadata + prefix + " : ", e); } return "{}"; } @@ -140,7 +145,7 @@ public void init() { @Override public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { - String key =""; + String key = ""; final AppIdentityService appIdentity = AppIdentityServiceFactory.getAppIdentityService(); WebContext ctx = new WebContext(req, resp, getServletContext(), req.getLocale()); diff --git a/flexible/helloworld/README.md b/flexible/helloworld/README.md index 84f224b4095..6b7ccb0a057 100644 --- a/flexible/helloworld/README.md +++ b/flexible/helloworld/README.md @@ -1,5 +1,8 @@ # Appengine Helloworld sample for Google App Engine Flexible + +Open in Cloud Shell + This sample is used as part of the [Quickstart for Java in the App Engine Flexible Environment](https://cloud.google.com/java/getting-started/hello-world) ## Setup diff --git a/flexible/helloworld/pom.xml b/flexible/helloworld/pom.xml index 0e2edccba9f..f42b04c9f0e 100644 --- a/flexible/helloworld/pom.xml +++ b/flexible/helloworld/pom.xml @@ -21,11 +21,14 @@ com.example.flexible flexible-helloworld + - appengine-flexible - com.google.cloud - 1.0.0 - .. + com.google.cloud.samples + shared-configuration + 1.0.8 diff --git a/flexible/helloworld/src/main/java/com/example/flexible/helloworld/HelloServlet.java b/flexible/helloworld/src/main/java/com/example/flexible/helloworld/HelloServlet.java index e15d13a91af..de5439c9f68 100644 --- a/flexible/helloworld/src/main/java/com/example/flexible/helloworld/HelloServlet.java +++ b/flexible/helloworld/src/main/java/com/example/flexible/helloworld/HelloServlet.java @@ -1,4 +1,4 @@ -/** +/* * Copyright 2015 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/flexible/mailgun/README.md b/flexible/mailgun/README.md index cbd6b6d3460..4a665d63862 100644 --- a/flexible/mailgun/README.md +++ b/flexible/mailgun/README.md @@ -1,4 +1,9 @@ # Java Mailgun email sample for Google App Engine Managed VMs + + +Open in Cloud Shell + + This sample demonstrates how to use [Mailgun](https://www.mailgun.com) on [Google App Engine Managed VMs](https://cloud.google.com/appengine). For more information about Mailgun, see their [documentation](https://documentation.mailgun.com/). diff --git a/flexible/mailgun/pom.xml b/flexible/mailgun/pom.xml index 7b774b7c31f..c743b80d462 100644 --- a/flexible/mailgun/pom.xml +++ b/flexible/mailgun/pom.xml @@ -20,11 +20,14 @@ com.example.flexible mailgun + - appengine-flexible - com.google.cloud - 1.0.0 - .. + com.google.cloud.samples + shared-configuration + 1.0.8 diff --git a/flexible/mailgun/src/main/java/com/example/mailgun/MailgunServlet.java b/flexible/mailgun/src/main/java/com/example/mailgun/MailgunServlet.java index d5845190013..8d990fb2289 100644 --- a/flexible/mailgun/src/main/java/com/example/mailgun/MailgunServlet.java +++ b/flexible/mailgun/src/main/java/com/example/mailgun/MailgunServlet.java @@ -1,4 +1,4 @@ -/** +/* * Copyright 2015 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -56,6 +56,7 @@ public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOEx } } + //CHECKSTYLE OFF: VariableDeclarationUsageDistance // [START simple] private ClientResponse sendSimpleMessage(String recipient) { Client client = Client.create(); @@ -90,5 +91,6 @@ private ClientResponse sendComplexMessage(String recipient) { .post(ClientResponse.class, formData); } // [END complex] + //CHECKSTYLE ON: VariableDeclarationUsageDistance } // [END example] diff --git a/flexible/mailjet/README.md b/flexible/mailjet/README.md index 0f51f24cf69..0942deeecfc 100644 --- a/flexible/mailjet/README.md +++ b/flexible/mailjet/README.md @@ -1,4 +1,8 @@ # Mailjet sample for Google Managed VMs + + +Open in Cloud Shell + This sample demonstrates how to use [Mailjet](https://www.mailjet.com/) on Google Managed VMs to send emails from a verified sender you own. diff --git a/flexible/mailjet/pom.xml b/flexible/mailjet/pom.xml index 84e13b262a7..dc6a97fa8db 100644 --- a/flexible/mailjet/pom.xml +++ b/flexible/mailjet/pom.xml @@ -20,11 +20,14 @@ com.example.flexible mailjet + - com.google.cloud - appengine-flexible - 1.0.0 - .. + com.google.cloud.samples + shared-configuration + 1.0.8 diff --git a/flexible/mailjet/src/main/java/com/example/mailjet/MailjetServlet.java b/flexible/mailjet/src/main/java/com/example/mailjet/MailjetServlet.java index 021b49964da..3ba5e4f9d9b 100644 --- a/flexible/mailjet/src/main/java/com/example/mailjet/MailjetServlet.java +++ b/flexible/mailjet/src/main/java/com/example/mailjet/MailjetServlet.java @@ -1,4 +1,4 @@ -/** +/* * Copyright 2016 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,27 +15,26 @@ */ // [START mailjet_imports] + package com.example.mailjet; +import com.mailjet.client.ClientOptions; import com.mailjet.client.MailjetClient; import com.mailjet.client.MailjetRequest; import com.mailjet.client.MailjetResponse; import com.mailjet.client.errors.MailjetException; import com.mailjet.client.errors.MailjetSocketTimeoutException; -import com.mailjet.client.ClientOptions; import com.mailjet.client.resource.Emailv31; -// [END mailjet_imports] - -import org.json.JSONArray; -import org.json.JSONObject; - import java.io.IOException; - import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.json.JSONArray; +import org.json.JSONObject; + +// [END mailjet_imports] // [START app] @SuppressWarnings("serial") @@ -43,7 +42,8 @@ public class MailjetServlet extends HttpServlet { private static final String MAILJET_API_KEY = System.getenv("MAILJET_API_KEY"); private static final String MAILJET_SECRET_KEY = System.getenv("MAILJET_SECRET_KEY"); - private MailjetClient client = new MailjetClient(MAILJET_API_KEY, MAILJET_SECRET_KEY, new ClientOptions("v3.1")); + private MailjetClient client = + new MailjetClient(MAILJET_API_KEY, MAILJET_SECRET_KEY, new ClientOptions("v3.1")); @Override public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException, @@ -52,7 +52,7 @@ public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOEx String sender = req.getParameter("from"); MailjetRequest email = new MailjetRequest(Emailv31.resource) - .property(Emailv31.MESSAGES, new JSONArray() + .property(Emailv31.MESSAGES, new JSONArray() .put(new JSONObject() .put(Emailv31.Message.FROM, new JSONObject() .put("Email", sender) @@ -61,8 +61,11 @@ public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOEx .put(new JSONObject() .put("Email", recipient))) .put(Emailv31.Message.SUBJECT, "Your email flight plan!") - .put(Emailv31.Message.TEXTPART, "Dear passenger, welcome to Mailjet! May the delivery force be with you!") - .put(Emailv31.Message.HTMLPART, "

Dear passenger, welcome to Mailjet!


May the delivery force be with you!"))); + .put(Emailv31.Message.TEXTPART, + "Dear passenger, welcome to Mailjet! May the delivery force be with you!") + .put(Emailv31.Message.HTMLPART, + "

Dear passenger, welcome to Mailjet!


" + + "May the delivery force be with you!"))); try { // trigger the API call diff --git a/flexible/memcache/README.md b/flexible/memcache/README.md index aab8ddf0d2e..286b3197d42 100644 --- a/flexible/memcache/README.md +++ b/flexible/memcache/README.md @@ -1,5 +1,8 @@ # flexible/memcache + +Open in Cloud Shell + How to use memcache on flexible. # NEEDS WORK diff --git a/flexible/memcache/pom.xml b/flexible/memcache/pom.xml index 761237d46ab..4163759e5d6 100644 --- a/flexible/memcache/pom.xml +++ b/flexible/memcache/pom.xml @@ -20,13 +20,17 @@ com.example.flexible memcache + - appengine-flexible - com.google.cloud - 1.0.0 - .. + com.google.cloud.samples + shared-configuration + 1.0.8 + 1.8 1.8 diff --git a/flexible/memcache/src/main/java/com/example/memcache/MemcacheServlet.java b/flexible/memcache/src/main/java/com/example/memcache/MemcacheServlet.java index 4621d91f3ca..fd2917be956 100644 --- a/flexible/memcache/src/main/java/com/example/memcache/MemcacheServlet.java +++ b/flexible/memcache/src/main/java/com/example/memcache/MemcacheServlet.java @@ -1,4 +1,4 @@ -/** +/* * Copyright 2015 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,20 +16,18 @@ package com.example.memcache; -import net.rubyeye.xmemcached.MemcachedClient; -import net.rubyeye.xmemcached.MemcachedClientBuilder; -import net.rubyeye.xmemcached.XMemcachedClientBuilder; -import net.rubyeye.xmemcached.exception.MemcachedException; -import net.rubyeye.xmemcached.utils.AddrUtil; - import java.io.IOException; import java.util.concurrent.TimeoutException; - import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import net.rubyeye.xmemcached.MemcachedClient; +import net.rubyeye.xmemcached.MemcachedClientBuilder; +import net.rubyeye.xmemcached.XMemcachedClientBuilder; +import net.rubyeye.xmemcached.exception.MemcachedException; +import net.rubyeye.xmemcached.utils.AddrUtil; // [START example] @SuppressWarnings("serial") diff --git a/flexible/pom.xml b/flexible/pom.xml index b20fc12bf72..73d1911a9f9 100644 --- a/flexible/pom.xml +++ b/flexible/pom.xml @@ -21,12 +21,14 @@ appengine-flexible pom - + - doc-samples - com.google.cloud - 1.0.0 - .. + com.google.cloud.samples + shared-configuration + 1.0.8 diff --git a/flexible/postgres/README.md b/flexible/postgres/README.md index 72474868eb0..90e620d81e8 100644 --- a/flexible/postgres/README.md +++ b/flexible/postgres/README.md @@ -1,5 +1,8 @@ # PostgreSQL sample for Google App Engine Flexible + +Open in Cloud Shell + This sample demonstrates how to use [Cloud SQL](https://cloud.google.com/sql/) on Google App Engine Flexible diff --git a/flexible/postgres/pom.xml b/flexible/postgres/pom.xml index 1590c81b189..9d91da5dccd 100644 --- a/flexible/postgres/pom.xml +++ b/flexible/postgres/pom.xml @@ -20,11 +20,14 @@ com.example.flexible flexible-postgres + - appengine-flexible - com.google.cloud - 1.0.0 - .. + com.google.cloud.samples + shared-configuration + 1.0.8 diff --git a/flexible/postgres/src/main/java/com/example/postgres/PostgresSqlServlet.java b/flexible/postgres/src/main/java/com/example/postgres/PostgresSqlServlet.java index 21684e6ad92..381757db852 100644 --- a/flexible/postgres/src/main/java/com/example/postgres/PostgresSqlServlet.java +++ b/flexible/postgres/src/main/java/com/example/postgres/PostgresSqlServlet.java @@ -1,4 +1,4 @@ -/** +/* * Copyright 2017 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/flexible/postgres/src/main/resources/config.properties b/flexible/postgres/src/main/resources/config.properties index 405c4a6848e..ae75c10fb77 100644 --- a/flexible/postgres/src/main/resources/config.properties +++ b/flexible/postgres/src/main/resources/config.properties @@ -1 +1,15 @@ +# Copyright 2017 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} diff --git a/flexible/pubsub/README.md b/flexible/pubsub/README.md index a1706e14aad..fe6a0633ede 100644 --- a/flexible/pubsub/README.md +++ b/flexible/pubsub/README.md @@ -1,5 +1,9 @@ # App Engine Flexible Environment - Pub/Sub Sample + +Open in Cloud Shell + + ## Clone the sample app Copy the sample apps to your local machine, and cd to the pubsub directory: diff --git a/flexible/pubsub/pom.xml b/flexible/pubsub/pom.xml index e2345ab94fb..e7f3fbdb48d 100644 --- a/flexible/pubsub/pom.xml +++ b/flexible/pubsub/pom.xml @@ -21,11 +21,14 @@ com.example.flexible flexible-pubsub + - appengine-flexible - com.google.cloud - 1.0.0 - .. + com.google.cloud.samples + shared-configuration + 1.0.8 @@ -89,6 +92,7 @@ junit junit + 4.12 test diff --git a/flexible/pubsub/src/main/java/com/example/flexible/pubsub/Message.java b/flexible/pubsub/src/main/java/com/example/flexible/pubsub/Message.java index de2c7e9d85a..587e594b8c0 100644 --- a/flexible/pubsub/src/main/java/com/example/flexible/pubsub/Message.java +++ b/flexible/pubsub/src/main/java/com/example/flexible/pubsub/Message.java @@ -1,16 +1,19 @@ -/** +/* * Copyright 2017 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 + * 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 + * 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 + * 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.flexible.pubsub; /** diff --git a/flexible/pubsub/src/main/java/com/example/flexible/pubsub/MessageRepository.java b/flexible/pubsub/src/main/java/com/example/flexible/pubsub/MessageRepository.java index 2ec79d71c9a..0fb8d52ca13 100644 --- a/flexible/pubsub/src/main/java/com/example/flexible/pubsub/MessageRepository.java +++ b/flexible/pubsub/src/main/java/com/example/flexible/pubsub/MessageRepository.java @@ -1,16 +1,19 @@ -/** +/* * Copyright 2017 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 + * 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 + * 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 + * 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.flexible.pubsub; import java.util.List; diff --git a/flexible/pubsub/src/main/java/com/example/flexible/pubsub/MessageRepositoryImpl.java b/flexible/pubsub/src/main/java/com/example/flexible/pubsub/MessageRepositoryImpl.java index ff6e7eab137..d463ce454d1 100644 --- a/flexible/pubsub/src/main/java/com/example/flexible/pubsub/MessageRepositoryImpl.java +++ b/flexible/pubsub/src/main/java/com/example/flexible/pubsub/MessageRepositoryImpl.java @@ -1,16 +1,19 @@ -/** +/* * Copyright 2017 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 + * 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 + * 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 + * 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.flexible.pubsub; import com.google.cloud.datastore.Datastore; @@ -21,7 +24,6 @@ import com.google.cloud.datastore.Query; import com.google.cloud.datastore.QueryResults; import com.google.cloud.datastore.StructuredQuery; - import java.util.ArrayList; import java.util.List; diff --git a/flexible/pubsub/src/main/java/com/example/flexible/pubsub/PubSubHome.java b/flexible/pubsub/src/main/java/com/example/flexible/pubsub/PubSubHome.java index c65e3ed9e00..55ff7277c3b 100644 --- a/flexible/pubsub/src/main/java/com/example/flexible/pubsub/PubSubHome.java +++ b/flexible/pubsub/src/main/java/com/example/flexible/pubsub/PubSubHome.java @@ -1,14 +1,16 @@ -/** +/* * Copyright 2017 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 + * 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 + * 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 + * 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. */ diff --git a/flexible/pubsub/src/main/java/com/example/flexible/pubsub/PubSubPublish.java b/flexible/pubsub/src/main/java/com/example/flexible/pubsub/PubSubPublish.java index 58df271205e..11706cf755d 100644 --- a/flexible/pubsub/src/main/java/com/example/flexible/pubsub/PubSubPublish.java +++ b/flexible/pubsub/src/main/java/com/example/flexible/pubsub/PubSubPublish.java @@ -1,16 +1,19 @@ -/** +/* * Copyright 2017 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 + * 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 + * 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 + * 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.flexible.pubsub; import com.google.cloud.ServiceOptions; @@ -18,14 +21,13 @@ import com.google.protobuf.ByteString; import com.google.pubsub.v1.PubsubMessage; import com.google.pubsub.v1.TopicName; -import org.apache.http.HttpStatus; - import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.http.HttpStatus; // [START pubsub_appengine_flex_publish] @WebServlet(name = "Publish with PubSub", value = "/pubsub/publish") @@ -55,7 +57,7 @@ public void doPost(HttpServletRequest req, HttpServletResponse resp) resp.sendError(HttpStatus.SC_INTERNAL_SERVER_ERROR, e.getMessage()); } } -// [END pubsub_appengine_flex_publish] + // [END pubsub_appengine_flex_publish] private Publisher publisher; diff --git a/flexible/pubsub/src/main/java/com/example/flexible/pubsub/PubSubPush.java b/flexible/pubsub/src/main/java/com/example/flexible/pubsub/PubSubPush.java index 75f8dc5595d..4436c91213f 100644 --- a/flexible/pubsub/src/main/java/com/example/flexible/pubsub/PubSubPush.java +++ b/flexible/pubsub/src/main/java/com/example/flexible/pubsub/PubSubPush.java @@ -1,22 +1,24 @@ -/** +/* * Copyright 2017 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 + * 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 + * 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 + * 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.flexible.pubsub; import com.google.gson.Gson; import com.google.gson.JsonElement; import com.google.gson.JsonParser; - import java.io.IOException; import java.util.Base64; import java.util.stream.Collectors; @@ -50,7 +52,7 @@ public void doPost(HttpServletRequest req, HttpServletResponse resp) resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } } -// [END pubsub_appengine_flex_push] + // [END pubsub_appengine_flex_push] private Message getMessage(HttpServletRequest request) throws IOException { String requestBody = request.getReader().lines().collect(Collectors.joining("\n")); diff --git a/flexible/pubsub/src/main/test/com/example/flexible/pubsub/PubSubPublishTest.java b/flexible/pubsub/src/main/test/com/example/flexible/pubsub/PubSubPublishTest.java index c01c0b9a44f..1d8820c2b2c 100644 --- a/flexible/pubsub/src/main/test/com/example/flexible/pubsub/PubSubPublishTest.java +++ b/flexible/pubsub/src/main/test/com/example/flexible/pubsub/PubSubPublishTest.java @@ -1,16 +1,19 @@ -/** +/* * Copyright 2017 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 + * 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 + * 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 + * 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.flexible.pubsub; import static org.junit.Assert.assertNotNull; @@ -24,10 +27,9 @@ import com.google.cloud.pubsub.v1.Publisher; import com.google.protobuf.ByteString; import com.google.pubsub.v1.PubsubMessage; -import org.junit.Test; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.junit.Test; public class PubSubPublishTest { diff --git a/flexible/pubsub/src/main/test/com/example/flexible/pubsub/PubSubPushTest.java b/flexible/pubsub/src/main/test/com/example/flexible/pubsub/PubSubPushTest.java index ebb84c3156c..5b57af5b116 100644 --- a/flexible/pubsub/src/main/test/com/example/flexible/pubsub/PubSubPushTest.java +++ b/flexible/pubsub/src/main/test/com/example/flexible/pubsub/PubSubPushTest.java @@ -1,14 +1,34 @@ +/* + * Copyright 2017 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. + */ + package com.example.flexible.pubsub; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.any; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import org.junit.Before; +import java.io.BufferedReader; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import org.junit.Test; /** @@ -24,12 +44,6 @@ * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ -import java.io.BufferedReader; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Stream; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; public class PubSubPushTest { diff --git a/flexible/sendgrid/README.md b/flexible/sendgrid/README.md index d7786659624..4c144d4396a 100644 --- a/flexible/sendgrid/README.md +++ b/flexible/sendgrid/README.md @@ -1,5 +1,9 @@ # Java SendGrid Email Sample for Google App Engine Flexible Environment + +Open in Cloud Shell + + This sample demonstrates how to use [SendGrid](https://www.sendgrid.com) on [Google App Engine flexible environment][aeflex-docs]. diff --git a/flexible/sendgrid/pom.xml b/flexible/sendgrid/pom.xml index fd2936cffa3..c3fa3d34349 100644 --- a/flexible/sendgrid/pom.xml +++ b/flexible/sendgrid/pom.xml @@ -20,11 +20,14 @@ com.example.managedvms managed-vms-sendgrid + - appengine-flexible - com.google.cloud - 1.0.0 - .. + com.google.cloud.samples + shared-configuration + 1.0.8 diff --git a/flexible/sendgrid/src/main/java/com/example/sendgrid/SendEmailServlet.java b/flexible/sendgrid/src/main/java/com/example/sendgrid/SendEmailServlet.java index cc8e0bdf1cb..62084136490 100644 --- a/flexible/sendgrid/src/main/java/com/example/sendgrid/SendEmailServlet.java +++ b/flexible/sendgrid/src/main/java/com/example/sendgrid/SendEmailServlet.java @@ -1,4 +1,4 @@ -/** +/* * Copyright 2015 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/flexible/sparkjava/README.md b/flexible/sparkjava/README.md index 92c63df65cd..eb02812c4a9 100644 --- a/flexible/sparkjava/README.md +++ b/flexible/sparkjava/README.md @@ -1,5 +1,8 @@ # SparkJava on App Engine Flexible Environment + +Open in Cloud Shell + This app demonstrates how to use [Datastore with the Google Cloud client library](https://github.com/GoogleCloudPlatform/google-cloud-java/tree/master/google-cloud-datastore) from within an [App Engine flexible diff --git a/flexible/sparkjava/pom.xml b/flexible/sparkjava/pom.xml index 5b5f6125feb..679081a5323 100644 --- a/flexible/sparkjava/pom.xml +++ b/flexible/sparkjava/pom.xml @@ -22,11 +22,14 @@ limitations under the License. spark 1.0 + - appengine-flexible - com.google.cloud - 1.0.0 - .. + com.google.cloud.samples + shared-configuration + 1.0.8 diff --git a/flexible/sparkjava/src/main/java/com/google/appengine/sparkdemo/Main.java b/flexible/sparkjava/src/main/java/com/google/appengine/sparkdemo/Main.java index 4fb571c0569..036751f80a4 100644 --- a/flexible/sparkjava/src/main/java/com/google/appengine/sparkdemo/Main.java +++ b/flexible/sparkjava/src/main/java/com/google/appengine/sparkdemo/Main.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2015 Google Inc. + * 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 + * 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 + * 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. + * 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.google.appengine.sparkdemo; diff --git a/flexible/sparkjava/src/main/java/com/google/appengine/sparkdemo/ResponseError.java b/flexible/sparkjava/src/main/java/com/google/appengine/sparkdemo/ResponseError.java index d5d6dc5c107..7654a80dbbc 100644 --- a/flexible/sparkjava/src/main/java/com/google/appengine/sparkdemo/ResponseError.java +++ b/flexible/sparkjava/src/main/java/com/google/appengine/sparkdemo/ResponseError.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2015 Google Inc. + * 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 + * 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 + * 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. + * 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.google.appengine.sparkdemo; diff --git a/flexible/sparkjava/src/main/java/com/google/appengine/sparkdemo/User.java b/flexible/sparkjava/src/main/java/com/google/appengine/sparkdemo/User.java index 770fdc23b71..2aa82c6c598 100644 --- a/flexible/sparkjava/src/main/java/com/google/appengine/sparkdemo/User.java +++ b/flexible/sparkjava/src/main/java/com/google/appengine/sparkdemo/User.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2015 Google Inc. + * 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 + * 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 + * 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. + * 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.google.appengine.sparkdemo; diff --git a/flexible/sparkjava/src/main/java/com/google/appengine/sparkdemo/UserController.java b/flexible/sparkjava/src/main/java/com/google/appengine/sparkdemo/UserController.java index 64be0be8958..53fee59e3ba 100644 --- a/flexible/sparkjava/src/main/java/com/google/appengine/sparkdemo/UserController.java +++ b/flexible/sparkjava/src/main/java/com/google/appengine/sparkdemo/UserController.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2015 Google Inc. + * 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 + * 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 + * 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. + * 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.google.appengine.sparkdemo; @@ -24,7 +24,6 @@ import static spark.Spark.put; import com.google.gson.Gson; - import spark.ResponseTransformer; import spark.Spark; diff --git a/flexible/sparkjava/src/main/java/com/google/appengine/sparkdemo/UserService.java b/flexible/sparkjava/src/main/java/com/google/appengine/sparkdemo/UserService.java index 46dc4f5fdf0..d2661fc649c 100644 --- a/flexible/sparkjava/src/main/java/com/google/appengine/sparkdemo/UserService.java +++ b/flexible/sparkjava/src/main/java/com/google/appengine/sparkdemo/UserService.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2015 Google Inc. + * 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 + * 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 + * 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. + * 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.google.appengine.sparkdemo; @@ -24,7 +24,6 @@ import com.google.cloud.datastore.KeyFactory; import com.google.cloud.datastore.Query; import com.google.cloud.datastore.QueryResults; - import java.util.ArrayList; import java.util.List; diff --git a/flexible/sparkjava/src/test/java/com/google/appengine/sparkdemo/UserControllerTest.java b/flexible/sparkjava/src/test/java/com/google/appengine/sparkdemo/UserControllerTest.java index 39e37bdc068..6700600899c 100644 --- a/flexible/sparkjava/src/test/java/com/google/appengine/sparkdemo/UserControllerTest.java +++ b/flexible/sparkjava/src/test/java/com/google/appengine/sparkdemo/UserControllerTest.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2015 Google Inc. + * 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 + * 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 + * 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. + * 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.google.appengine.sparkdemo; @@ -23,21 +23,18 @@ import static org.junit.Assert.fail; import com.google.gson.Gson; - +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.UUID; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; - import spark.Spark; import spark.utils.IOUtils; -import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.UUID; - public class UserControllerTest { private static final String USER_NAME = "myName"; diff --git a/flexible/sparkjava/src/test/java/com/google/appengine/sparkdemo/UserServiceTest.java b/flexible/sparkjava/src/test/java/com/google/appengine/sparkdemo/UserServiceTest.java index 410572f9d78..24c7f8677c8 100644 --- a/flexible/sparkjava/src/test/java/com/google/appengine/sparkdemo/UserServiceTest.java +++ b/flexible/sparkjava/src/test/java/com/google/appengine/sparkdemo/UserServiceTest.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2015 Google Inc. + * 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 + * 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 + * 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. + * 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.google.appengine.sparkdemo; @@ -30,17 +30,15 @@ import com.google.cloud.datastore.StructuredQuery; import com.google.cloud.datastore.testing.LocalDatastoreHelper; import com.google.common.collect.Iterators; - +import java.io.IOException; +import java.util.List; +import java.util.concurrent.TimeoutException; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.threeten.bp.Duration; -import java.io.IOException; -import java.util.List; -import java.util.concurrent.TimeoutException; - public class UserServiceTest { private static final LocalDatastoreHelper HELPER = LocalDatastoreHelper.create(1.0); diff --git a/flexible/static-files/pom.xml b/flexible/static-files/pom.xml index 6f9a1ad0104..81fc6956b2b 100644 --- a/flexible/static-files/pom.xml +++ b/flexible/static-files/pom.xml @@ -20,11 +20,14 @@ com.example.flexible staticfiles + - appengine-flexible - com.google.cloud - 1.0.0 - .. + com.google.cloud.samples + shared-configuration + 1.0.8 diff --git a/flexible/twilio/README.md b/flexible/twilio/README.md index a1234c78af6..2091089d907 100644 --- a/flexible/twilio/README.md +++ b/flexible/twilio/README.md @@ -1,5 +1,8 @@ # Java Twilio Voice and SMS Sample for Google App Engine Flexible Environment + +Open in Cloud Shell + This sample demonstrates how to use [Twilio](https://www.twilio.com) on [Google App flexible environment][aeflex-docs]. diff --git a/flexible/twilio/pom.xml b/flexible/twilio/pom.xml index e00375929ce..55a0c441c07 100644 --- a/flexible/twilio/pom.xml +++ b/flexible/twilio/pom.xml @@ -20,11 +20,14 @@ com.example.flexible twilio + - appengine-flexible - com.google.cloud - 1.0.0 - .. + com.google.cloud.samples + shared-configuration + 1.0.8 diff --git a/flexible/twilio/src/main/java/com/example/twilio/ReceiveCallServlet.java b/flexible/twilio/src/main/java/com/example/twilio/ReceiveCallServlet.java index 83c099cda42..48b22671dc9 100644 --- a/flexible/twilio/src/main/java/com/example/twilio/ReceiveCallServlet.java +++ b/flexible/twilio/src/main/java/com/example/twilio/ReceiveCallServlet.java @@ -1,4 +1,4 @@ -/** +/* * Copyright 2015 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,9 +19,7 @@ import com.twilio.sdk.verbs.Say; import com.twilio.sdk.verbs.TwiMLException; import com.twilio.sdk.verbs.TwiMLResponse; - import java.io.IOException; - import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; diff --git a/flexible/twilio/src/main/java/com/example/twilio/ReceiveSmsServlet.java b/flexible/twilio/src/main/java/com/example/twilio/ReceiveSmsServlet.java index 6868040e7eb..f13d774c18f 100644 --- a/flexible/twilio/src/main/java/com/example/twilio/ReceiveSmsServlet.java +++ b/flexible/twilio/src/main/java/com/example/twilio/ReceiveSmsServlet.java @@ -1,4 +1,4 @@ -/** +/* * Copyright 2015 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,9 +19,7 @@ import com.twilio.sdk.verbs.Message; import com.twilio.sdk.verbs.TwiMLException; import com.twilio.sdk.verbs.TwiMLResponse; - import java.io.IOException; - import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; diff --git a/flexible/twilio/src/main/java/com/example/twilio/SendSmsServlet.java b/flexible/twilio/src/main/java/com/example/twilio/SendSmsServlet.java index 7371124dd8e..3c54f9eb3ae 100644 --- a/flexible/twilio/src/main/java/com/example/twilio/SendSmsServlet.java +++ b/flexible/twilio/src/main/java/com/example/twilio/SendSmsServlet.java @@ -1,4 +1,4 @@ -/** +/* * Copyright 2015 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,18 +21,16 @@ import com.twilio.sdk.resource.factory.MessageFactory; import com.twilio.sdk.resource.instance.Account; import com.twilio.sdk.resource.instance.Message; -import org.apache.http.NameValuePair; -import org.apache.http.message.BasicNameValuePair; - import java.io.IOException; import java.util.ArrayList; import java.util.List; - import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.http.NameValuePair; +import org.apache.http.message.BasicNameValuePair; // [START example] @SuppressWarnings("serial") diff --git a/pom.xml b/pom.xml index 50f3c866997..eb3b98e070b 100644 --- a/pom.xml +++ b/pom.xml @@ -20,17 +20,17 @@ doc-samples pom - + com.google.cloud.samples shared-configuration - 1.0.6 + 1.0.8 - 1.19.0 - 1.19.0 - 1.8 1.8 @@ -97,35 +97,4 @@ vision/text - - - - - - jstl - jstl - 1.2 - - - - - junit - junit - 4.12 - test - - - org.mockito - mockito-core - 2.13.0 - test - - - com.jcabi - jcabi-matchers - 1.4 - - - - diff --git a/storage/xml-api/cmdline-sample/README.md b/storage/xml-api/cmdline-sample/README.md index 8cd94a22510..460339f8ea8 100644 --- a/storage/xml-api/cmdline-sample/README.md +++ b/storage/xml-api/cmdline-sample/README.md @@ -1,5 +1,8 @@ This is the sample used in the [Cloud Storage Java documentation](https://cloud.google.com/storage/docs/xml-api-java-samples). + +Open in Cloud Shell + Using the Command Line Sample ============================================================== diff --git a/storage/xml-api/cmdline-sample/pom.xml b/storage/xml-api/cmdline-sample/pom.xml index 275abacfbc1..92c7c7c9269 100644 --- a/storage/xml-api/cmdline-sample/pom.xml +++ b/storage/xml-api/cmdline-sample/pom.xml @@ -19,18 +19,22 @@ storage-xml-cmdline-sample 1 + - doc-samples - com.google.cloud - 1.0.0 - ../../.. + com.google.cloud.samples + shared-configuration + 1.0.8 1.23.0 UTF-8 1.6.0 - 3.7.0 + 1.8 + 1.8 @@ -38,7 +42,7 @@ org.codehaus.mojo exec-maven-plugin - ${codehaus-exec-maven-plugin} + 1.6.0 @@ -53,7 +57,7 @@ org.apache.maven.plugins maven-compiler-plugin - ${maven-compiler-plugin-version} + 3.7.0 7 7 diff --git a/storage/xml-api/cmdline-sample/src/main/java/StorageSample.java b/storage/xml-api/cmdline-sample/src/main/java/StorageSample.java index 8046f70c7e5..b0cd953b729 100644 --- a/storage/xml-api/cmdline-sample/src/main/java/StorageSample.java +++ b/storage/xml-api/cmdline-sample/src/main/java/StorageSample.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2014 Google Inc. + * Copyright 2014 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 + * 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. + * 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. */ import com.google.api.client.googleapis.auth.oauth2.GoogleCredential; diff --git a/storage/xml-api/serviceaccount-appengine-sample/pom.xml b/storage/xml-api/serviceaccount-appengine-sample/pom.xml index 6eb61e1159a..d63e2712796 100644 --- a/storage/xml-api/serviceaccount-appengine-sample/pom.xml +++ b/storage/xml-api/serviceaccount-appengine-sample/pom.xml @@ -16,12 +16,14 @@ 4.0.0 - + - doc-samples - com.google.cloud - 1.0.0 - ../../.. + com.google.cloud.samples + shared-configuration + 1.0.8 com.google.apis-samples @@ -33,7 +35,6 @@ 1.7 1.7 - 1.9.60 1.23.0 ${project.build.directory}/${project.build.finalName} @@ -87,7 +88,7 @@ com.google.appengine appengine-maven-plugin - ${appengine.sdk.version} + 1.9.59 8888 @@ -111,7 +112,7 @@ com.google.appengine appengine-api-1.0-sdk - ${appengine.sdk.version} + 1.9.59 diff --git a/storage/xml-api/serviceaccount-appengine-sample/src/main/java/com/google/api/client/sample/storage/appengine/serviceaccount/StorageSample.java b/storage/xml-api/serviceaccount-appengine-sample/src/main/java/com/google/api/client/sample/storage/appengine/serviceaccount/StorageSample.java index 78604c3f9bd..54daa10313e 100644 --- a/storage/xml-api/serviceaccount-appengine-sample/src/main/java/com/google/api/client/sample/storage/appengine/serviceaccount/StorageSample.java +++ b/storage/xml-api/serviceaccount-appengine-sample/src/main/java/com/google/api/client/sample/storage/appengine/serviceaccount/StorageSample.java @@ -1,15 +1,17 @@ /* - * Copyright (c) 2012 Google Inc. + * Copyright 2012 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. + * 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. + * 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.google.api.client.sample.storage.appengine.serviceaccount; @@ -59,9 +61,8 @@ public class StorageSample extends HttpServlet { "\n\n"; @Override - protected void doGet( - final HttpServletRequest req, final HttpServletResponse resp) - throws IOException { + protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) + throws IOException { try { AppIdentityCredential credential = new AppIdentityCredential( diff --git a/storage/xml-api/serviceaccount-appengine-sample/src/main/resources/log4j.properties b/storage/xml-api/serviceaccount-appengine-sample/src/main/resources/log4j.properties index d9c3edc9fee..b2a0ff6c84a 100644 --- a/storage/xml-api/serviceaccount-appengine-sample/src/main/resources/log4j.properties +++ b/storage/xml-api/serviceaccount-appengine-sample/src/main/resources/log4j.properties @@ -1,3 +1,17 @@ +# 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. + # A default log4j configuration for log4j users. # # To use this configuration, deploy it into your application's WEB-INF/classes diff --git a/vision/beta/cloud-client/README.md b/vision/beta/cloud-client/README.md index 6c91ddbc61b..108cfbdff58 100644 --- a/vision/beta/cloud-client/README.md +++ b/vision/beta/cloud-client/README.md @@ -1,5 +1,8 @@ # Image Feature Detection Sample + +Open in Cloud Shell + [Google Cloud Vision API][vision] provides feature detection for images. This API is part of the larger collection of Cloud Machine Learning APIs. diff --git a/vision/beta/cloud-client/pom.xml b/vision/beta/cloud-client/pom.xml index 99f11c5073d..931e33254a6 100644 --- a/vision/beta/cloud-client/pom.xml +++ b/vision/beta/cloud-client/pom.xml @@ -19,12 +19,14 @@ vision-detect-beta jar - + - doc-samples - com.google.cloud - 1.0.0 - ../../.. + com.google.cloud.samples + shared-configuration + 1.0.8 diff --git a/vision/beta/cloud-client/src/main/java/com/example/vision/Detect.java b/vision/beta/cloud-client/src/main/java/com/example/vision/Detect.java index 8e53680d1f5..f42323a6aa2 100644 --- a/vision/beta/cloud-client/src/main/java/com/example/vision/Detect.java +++ b/vision/beta/cloud-client/src/main/java/com/example/vision/Detect.java @@ -1,18 +1,18 @@ /* - Copyright 2017, 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. -*/ + * Copyright 2017 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. + */ package com.example.vision; diff --git a/vision/beta/cloud-client/src/test/java/com/example/vision/DetectIT.java b/vision/beta/cloud-client/src/test/java/com/example/vision/DetectIT.java index c71623ff863..b79a7471202 100644 --- a/vision/beta/cloud-client/src/test/java/com/example/vision/DetectIT.java +++ b/vision/beta/cloud-client/src/test/java/com/example/vision/DetectIT.java @@ -1,18 +1,18 @@ /* - Copyright 2017, 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. -*/ + * Copyright 2017 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. + */ package com.example.vision;