From 0acc57d582d63079c4df2ffe6ef5231835b290b5 Mon Sep 17 00:00:00 2001 From: Jerjou Date: Tue, 29 Nov 2016 20:43:49 -0800 Subject: [PATCH] deprecated methods -> undeprecated versions. (#428) --- .../java/com/example/guestbook/Greeting.java | 6 +- .../java/com/example/guestbook/Guestbook.java | 10 +- .../com/example/guestbook/Persistence.java | 5 +- .../java/com/example/guestbook/TestUtils.java | 5 +- .../src/main/webapp/WEB-INF/appengine-web.xml | 2 +- appengine/helloworld-new-plugins/README.md | 4 +- .../appengine/images/ImagesServlet.java | 4 +- appengine/logs/README.md | 4 +- .../example/appengine/logs/LogsServlet.java | 12 +- .../src/main/webapp/WEB-INF/appengine-web.xml | 2 +- .../oauth2/src/main/webapp/WEB-INF/web.xml | 2 +- .../requests/LoggingServletTest.java | 6 +- .../requests/RequestsServletTest.java | 2 +- .../example/bigquery/QuickstartSample.java | 6 +- .../java/com/example/bigquery/SimpleApp.java | 20 +- .../com/example/bigquery/SyncQuerySample.java | 14 +- .../example/bigquery/QuickstartSampleIT.java | 2 +- .../src/main/java/ComputeEngineSample.java | 2 +- compute/error-reporting/README.md | 2 +- .../example/datastore/QuickstartSample.java | 6 +- .../example/datastore/QuickstartSampleIT.java | 4 +- .../google/datastore/snippets/TaskList.java | 18 +- .../datastore/snippets/ConceptsTest.java | 319 +++++++++--------- flexible/async-rest/README.md | 14 +- .../example/cloudstorage/UploadServlet.java | 6 +- .../example/datastore/DatastoreServlet.java | 12 +- flexible/helloworld/README.md | 2 +- .../com/google/appengine/sparkdemo/Main.java | 4 +- .../appengine/sparkdemo/UserService.java | 8 +- .../appengine/sparkdemo/UserServiceTest.java | 10 +- monitoring/v3/README.md | 14 +- .../com/example/pubsub/QuickstartSample.java | 4 +- .../example/pubsub/QuickstartSampleIT.java | 2 +- .../com/example/storage/QuickstartSample.java | 4 +- .../example/storage/QuickstartSampleIT.java | 2 +- storage/storage-transfer/README.md | 6 +- .../src/main/webapp/WEB-INF/web.xml | 2 +- translate/README.md | 8 +- .../example/translate/QuickstartSample.java | 2 +- .../translate/samples/TranslateText.java | 2 +- .../translate/samples/TranslateTextTest.java | 4 +- 41 files changed, 284 insertions(+), 279 deletions(-) diff --git a/appengine/guestbook-cloud-datastore/src/main/java/com/example/guestbook/Greeting.java b/appengine/guestbook-cloud-datastore/src/main/java/com/example/guestbook/Greeting.java index 12eb3d6c6de..a32777318c3 100644 --- a/appengine/guestbook-cloud-datastore/src/main/java/com/example/guestbook/Greeting.java +++ b/appengine/guestbook-cloud-datastore/src/main/java/com/example/guestbook/Greeting.java @@ -54,7 +54,7 @@ public Greeting(String book, String content, String id, String email) { } public Greeting(Entity entity) { - key = entity.hasKey() ? entity.key() : null; + key = entity.hasKey() ? entity.getKey() : null; authorEmail = entity.contains("authorEmail") ? entity.getString("authorEmail") : null; authorId = entity.contains("authorId") ? entity.getString("authorId") : null; date = entity.contains("date") ? entity.getDateTime("date").toDate() : null; @@ -66,7 +66,7 @@ public void save() { key = getDatastore().allocateId(makeIncompleteKey()); // Give this greeting a unique ID } - Builder builder = FullEntity.builder(key); + Builder builder = FullEntity.newBuilder(key); if (authorEmail != null) { builder.set("authorEmail", authorEmail); @@ -84,7 +84,7 @@ public void save() { private IncompleteKey makeIncompleteKey() { // The book is our ancestor key. - return Key.builder(book.getKey(), "Greeting").build(); + return Key.newBuilder(book.getKey(), "Greeting").build(); } @Override diff --git a/appengine/guestbook-cloud-datastore/src/main/java/com/example/guestbook/Guestbook.java b/appengine/guestbook-cloud-datastore/src/main/java/com/example/guestbook/Guestbook.java index ae407175ecb..218a7e292b8 100644 --- a/appengine/guestbook-cloud-datastore/src/main/java/com/example/guestbook/Guestbook.java +++ b/appengine/guestbook-cloud-datastore/src/main/java/com/example/guestbook/Guestbook.java @@ -52,11 +52,11 @@ public Key getKey() { public List getGreetings() { // This query requires the index defined in index.yaml to work because of the orderBy on date. EntityQuery query = - Query.entityQueryBuilder() - .kind("Greeting") - .filter(hasAncestor(key)) - .orderBy(desc("date")) - .limit(5) + Query.newEntityQueryBuilder() + .setKind("Greeting") + .setFilter(hasAncestor(key)) + .setOrderBy(desc("date")) + .setLimit(5) .build(); QueryResults results = getDatastore().run(query); diff --git a/appengine/guestbook-cloud-datastore/src/main/java/com/example/guestbook/Persistence.java b/appengine/guestbook-cloud-datastore/src/main/java/com/example/guestbook/Persistence.java index 3dbc2285743..bb6b53a16fe 100644 --- a/appengine/guestbook-cloud-datastore/src/main/java/com/example/guestbook/Persistence.java +++ b/appengine/guestbook-cloud-datastore/src/main/java/com/example/guestbook/Persistence.java @@ -25,7 +25,8 @@ public class Persistence { public static Datastore getDatastore() { if (datastore.get() == null) { - datastore.set(DatastoreOptions.builder().projectId("your-project-id-here").build().service()); + datastore.set(DatastoreOptions.newBuilder().setProjectId("your-project-id-here") + .build().getService()); } return datastore.get(); @@ -36,7 +37,7 @@ public static void setDatastore(Datastore datastore) { } public static KeyFactory getKeyFactory(Class c) { - return getDatastore().newKeyFactory().kind(c.getSimpleName()); + return getDatastore().newKeyFactory().setKind(c.getSimpleName()); } } //[END all] diff --git a/appengine/guestbook-cloud-datastore/src/test/java/com/example/guestbook/TestUtils.java b/appengine/guestbook-cloud-datastore/src/test/java/com/example/guestbook/TestUtils.java index 7a9716e467b..3780f0266f2 100644 --- a/appengine/guestbook-cloud-datastore/src/test/java/com/example/guestbook/TestUtils.java +++ b/appengine/guestbook-cloud-datastore/src/test/java/com/example/guestbook/TestUtils.java @@ -18,7 +18,7 @@ public class TestUtils { public static void startDatastore() { try { datastore.start(); - Persistence.setDatastore(datastore.options().service()); + Persistence.setDatastore(datastore.getOptions().getService()); } catch (IOException | InterruptedException e) { throw new RuntimeException(e); } @@ -35,7 +35,8 @@ public static void stopDatastore() { public static void wipeDatastore() { Datastore datastore = getDatastore(); - QueryResults guestbooks = datastore.run(Query.keyQueryBuilder().kind("Greeting").build()); + QueryResults guestbooks = datastore.run(Query.newKeyQueryBuilder().setKind("Greeting") + .build()); ArrayList keys = Lists.newArrayList(guestbooks); if (!keys.isEmpty()) { diff --git a/appengine/guestbook-objectify/src/main/webapp/WEB-INF/appengine-web.xml b/appengine/guestbook-objectify/src/main/webapp/WEB-INF/appengine-web.xml index 8bf645d1013..4d46047edb6 100644 --- a/appengine/guestbook-objectify/src/main/webapp/WEB-INF/appengine-web.xml +++ b/appengine/guestbook-objectify/src/main/webapp/WEB-INF/appengine-web.xml @@ -3,7 +3,7 @@ your-app-id ${appengine.app.version} true - + diff --git a/appengine/helloworld-new-plugins/README.md b/appengine/helloworld-new-plugins/README.md index fe76dd711f2..c3624160fb0 100644 --- a/appengine/helloworld-new-plugins/README.md +++ b/appengine/helloworld-new-plugins/README.md @@ -18,7 +18,7 @@ Use either: ### Running locally $ mvn appengine:run - + ### Deploying $ mvn appengine:deploy @@ -36,7 +36,7 @@ If you do not have gradle installed, you can run using `./gradlew appengineRun`. If you do not have gradle installed, you can deploy using `./gradlew appengineDeploy`. -