GeezerVison is showing github.com — merge with master, remove tabs inserted by Eclipse · feulf/java-docs-samples@dbe274f
File treeExpand file treeCollapse file tree Open diff view settings guestbook-cloud-datastore/src main/java/com/example/guestbook test/java/com/example/guestbook
guestbook-objectify/src/main/webapp/WEB-INF images/src/main/java/com/example/appengine/images src/main/java/com/example/appengine/logs
multitenancy/src/main/webapp/WEB-INF oauth2/src/main/webapp/WEB-INF requests/src/test/java/com/example/appengine/requests
bigquery/cloud-client/src main/java/com/example/bigquery test/java/com/example/bigquery
main/java/com/example/datastore test/java/com/example/datastore
main/java/com/google/datastore/snippets test/java/com/google/datastore/snippets
endpoints/getting-started/src/main java/com/example/endpoints
cloudstorage/src/main/java/com/example/cloudstorage datastore/src/main/java/com/example/datastore java/com/example/endpoints
main/java/com/google/appengine/sparkdemo test/java/com/google/appengine/sparkdemo
main/java/com/google/cloud/language/samples test/java/com/google/cloud/language/samples
main/java/com/example/pubsub test/java/com/example/pubsub
main/java/com/example/storage test/java/com/example/storage
main/java/com/google/cloud/storage/storagetransfer/samples test/java/com/google/cloud/storage/storagetransfer/samples/test
xml-api/serviceaccount-appengine-sample/src/main/webapp/WEB-INF
main/java/com/example/translate test/java/com/example/translate
main/java/com/google/cloud/translate/samples test/java/com/google/cloud/translate/samples
Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: appengine/guestbook-cloud-datastore/src/main/java/com/example/guestbook/Greeting.java +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -54,7 +54,7 @@ public Greeting(String book, String content, String id, String email) { | 54 | 54 | } | 55 | 55 |
| 56 | 56 | public Greeting(Entity entity) { | 57 | | - key = entity.hasKey() ? entity.key() : null; | | 57 | + key = entity.hasKey() ? entity.getKey() : null; | 58 | 58 | authorEmail = entity.contains("authorEmail") ? entity.getString("authorEmail") : null; | 59 | 59 | authorId = entity.contains("authorId") ? entity.getString("authorId") : null; | 60 | 60 | date = entity.contains("date") ? entity.getDateTime("date").toDate() : null; | @@ -66,7 +66,7 @@ public void save() { | 66 | 66 | key = getDatastore().allocateId(makeIncompleteKey()); // Give this greeting a unique ID | 67 | 67 | } | 68 | 68 |
| 69 | | - Builder<Key> builder = FullEntity.builder(key); | | 69 | + Builder<Key> builder = FullEntity.newBuilder(key); | 70 | 70 |
| 71 | 71 | if (authorEmail != null) { | 72 | 72 | builder.set("authorEmail", authorEmail); | @@ -84,7 +84,7 @@ public void save() { | 84 | 84 |
| 85 | 85 | private IncompleteKey makeIncompleteKey() { | 86 | 86 | // The book is our ancestor key. | 87 | | - return Key.builder(book.getKey(), "Greeting").build(); | | 87 | + return Key.newBuilder(book.getKey(), "Greeting").build(); | 88 | 88 | } | 89 | 89 |
| 90 | 90 | @Override | |
Collapse file Copy file name to clipboardExpand all lines: appengine/guestbook-cloud-datastore/src/main/java/com/example/guestbook/Guestbook.java +5-5Lines changed: 5 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -52,11 +52,11 @@ public Key getKey() { | 52 | 52 | public List<Greeting> getGreetings() { | 53 | 53 | // This query requires the index defined in index.yaml to work because of the orderBy on date. | 54 | 54 | EntityQuery query = | 55 | | - Query.entityQueryBuilder() | 56 | | - .kind("Greeting") | 57 | | - .filter(hasAncestor(key)) | 58 | | - .orderBy(desc("date")) | 59 | | - .limit(5) | | 55 | + Query.newEntityQueryBuilder() | | 56 | + .setKind("Greeting") | | 57 | + .setFilter(hasAncestor(key)) | | 58 | + .setOrderBy(desc("date")) | | 59 | + .setLimit(5) | 60 | 60 | .build(); | 61 | 61 |
| 62 | 62 | QueryResults<Entity> results = getDatastore().run(query); | |
Collapse file Copy file name to clipboardExpand all lines: appengine/guestbook-cloud-datastore/src/main/java/com/example/guestbook/Persistence.java +3-2Lines changed: 3 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -25,7 +25,8 @@ public class Persistence { | 25 | 25 |
| 26 | 26 | public static Datastore getDatastore() { | 27 | 27 | if (datastore.get() == null) { | 28 | | - datastore.set(DatastoreOptions.builder().projectId("your-project-id-here").build().service()); | | 28 | + datastore.set(DatastoreOptions.newBuilder().setProjectId("your-project-id-here") | | 29 | + .build().getService()); | 29 | 30 | } | 30 | 31 |
| 31 | 32 | return datastore.get(); | @@ -36,7 +37,7 @@ public static void setDatastore(Datastore datastore) { | 36 | 37 | } | 37 | 38 |
| 38 | 39 | public static KeyFactory getKeyFactory(Class<?> c) { | 39 | | - return getDatastore().newKeyFactory().kind(c.getSimpleName()); | | 40 | + return getDatastore().newKeyFactory().setKind(c.getSimpleName()); | 40 | 41 | } | 41 | 42 | } | 42 | 43 | //[END all] |
Collapse file Copy file name to clipboardExpand all lines: appengine/guestbook-cloud-datastore/src/test/java/com/example/guestbook/TestUtils.java +3-2Lines changed: 3 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -18,7 +18,7 @@ public class TestUtils { | 18 | 18 | public static void startDatastore() { | 19 | 19 | try { | 20 | 20 | datastore.start(); | 21 | | - Persistence.setDatastore(datastore.options().service()); | | 21 | + Persistence.setDatastore(datastore.getOptions().getService()); | 22 | 22 | } catch (IOException | InterruptedException e) { | 23 | 23 | throw new RuntimeException(e); | 24 | 24 | } | @@ -35,7 +35,8 @@ public static void stopDatastore() { | 35 | 35 |
| 36 | 36 | public static void wipeDatastore() { | 37 | 37 | Datastore datastore = getDatastore(); | 38 | | - QueryResults<Key> guestbooks = datastore.run(Query.keyQueryBuilder().kind("Greeting").build()); | | 38 | + QueryResults<Key> guestbooks = datastore.run(Query.newKeyQueryBuilder().setKind("Greeting") | | 39 | + .build()); | 39 | 40 | ArrayList<Key> keys = Lists.newArrayList(guestbooks); | 40 | 41 |
| 41 | 42 | if (!keys.isEmpty()) { | |
Collapse file Copy file name to clipboardExpand all lines: appengine/guestbook-objectify/src/main/webapp/WEB-INF/appengine-web.xml +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 3 | 3 | <application>your-app-id</application> | 4 | 4 | <version>${appengine.app.version}</version> | 5 | 5 | <threadsafe>true</threadsafe> | 6 | | - | | 6 | + | 7 | 7 | <system-properties> | 8 | 8 | <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/> | 9 | 9 | </system-properties> | |
Collapse file Copy file name to clipboardExpand all lines: appengine/helloworld-new-plugins/README.md +2-2Lines changed: 2 additions & 2 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -18,7 +18,7 @@ Use either: | 18 | 18 | ### Running locally | 19 | 19 |
| 20 | 20 | $ mvn appengine:run | 21 | | - | | 21 | + | 22 | 22 | ### Deploying | 23 | 23 |
| 24 | 24 | $ mvn appengine:deploy | @@ -36,7 +36,7 @@ If you do not have gradle installed, you can run using `./gradlew appengineRun`. | 36 | 36 |
| 37 | 37 | If you do not have gradle installed, you can deploy using `./gradlew appengineDeploy`. | 38 | 38 |
| 39 | | -<!-- | | 39 | +<!-- | 40 | 40 | ## Intelij Idea | 41 | 41 | Limitations - Appengine Standard support in the Intellij plugin is only available for the Ultimate Edition of Idea. | 42 | 42 |
| |
Collapse file Copy file name to clipboardExpand all lines: appengine/images/src/main/java/com/example/appengine/images/ImagesServlet.java +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -61,7 +61,7 @@ public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOExc | 61 | 61 | FileChannel fileChannel = fileInputStream.getChannel(); | 62 | 62 | ByteBuffer byteBuffer = ByteBuffer.allocate((int)fileChannel.size()); | 63 | 63 | fileChannel.read(byteBuffer); | 64 | | - | | 64 | + | 65 | 65 | byte[] imageBytes = byteBuffer.array(); | 66 | 66 |
| 67 | 67 | // Write the original image to Cloud Storage | @@ -103,7 +103,7 @@ public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOExc | 103 | 103 | //[END rotate] | 104 | 104 |
| 105 | 105 | // Output some simple HTML to display the images we wrote to Cloud Storage | 106 | | - // in the browser. | | 106 | + // in the browser. | 107 | 107 | PrintWriter out = resp.getWriter(); | 108 | 108 | out.println("<html><body>\n"); | 109 | 109 | out.println("<img src='//storage.cloud.google.com/" + bucket | |
Collapse file Copy file name to clipboardExpand all lines: appengine/logs/README.md +2-2Lines changed: 2 additions & 2 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -6,12 +6,12 @@ Engine][ae-docs]. | 6 | 6 | [log-docs]: https://cloud.google.com/appengine/docs/java/logs/ | 7 | 7 | [ae-docs]: https://cloud.google.com/appengine/docs/java/ | 8 | 8 |
| 9 | | -## Running locally | | 9 | +## Running locally | 10 | 10 |
| 11 | 11 | The Logs API only generates output for deployed apps, so this program should not be run locally. | 12 | 12 |
| 13 | 13 | ## Deploying | 14 | | - | | 14 | + | 15 | 15 | This example uses the | 16 | 16 | [Maven gcloud plugin](https://cloud.google.com/appengine/docs/java/managed-vms/maven). | 17 | 17 |
| |
Collapse file Copy file name to clipboardExpand all lines: appengine/logs/src/main/java/com/example/appengine/logs/LogsServlet.java +6-6Lines changed: 6 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 34 | 34 | // a time, using a Next link to cycle through to the next 5. | 35 | 35 | public class LogsServlet extends HttpServlet { | 36 | 36 | @Override | 37 | | - public void doGet(HttpServletRequest req, HttpServletResponse resp) | | 37 | + public void doGet(HttpServletRequest req, HttpServletResponse resp) | 38 | 38 | throws IOException { | 39 | 39 |
| 40 | 40 | resp.setContentType("text/html"); | 41 | 41 | PrintWriter writer = resp.getWriter(); | 42 | 42 | writer.println("<!DOCTYPE html>"); | 43 | 43 | writer.println("<meta charset=\"utf-8\">"); | 44 | 44 | writer.println("<title>App Engine Logs Sample</title>"); | 45 | | - | | 45 | + | 46 | 46 | // We use this to break out of our iteration loop, limiting record | 47 | 47 | // display to 5 request logs at a time. | 48 | 48 | int limit = 5; | @@ -81,17 +81,17 @@ public void doGet(HttpServletRequest req, HttpServletResponse resp) | 81 | 81 | writer.println(String.format("<br>Date: %s", appTime.toString())); | 82 | 82 | writer.println("<br>Level: " + appLog.getLogLevel() + "<br>"); | 83 | 83 | writer.println("Message: " + appLog.getLogMessage() + "<br> <br>"); | 84 | | - } | | 84 | + } | 85 | 85 |
| 86 | 86 | if (++count >= limit) { | 87 | 87 | break; | 88 | 88 | } | 89 | | - } | | 89 | + } | 90 | 90 |
| 91 | 91 | // When the user clicks this link, the offset is processed in the | 92 | 92 | // GET handler and used to cycle through to the next 5 request logs. | 93 | 93 | writer.println(String.format("<br><a href=\"/?offset=%s\">Next</a>", lastOffset)); | 94 | | - } | 95 | | -} | | 94 | + } | | 95 | +} | 96 | 96 | // [END logs_API_example] | 97 | 97 |
|
Collapse file Copy file name to clipboardExpand all lines: appengine/multitenancy/src/main/webapp/WEB-INF/appengine-web.xml +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 3 | 3 | <application>your-app-id</application> | 4 | 4 | <version>${appengine.app.version}</version> | 5 | 5 | <threadsafe>true</threadsafe> | 6 | | - | | 6 | + | 7 | 7 | <system-properties> | 8 | 8 | <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/> | 9 | 9 | </system-properties> | |
|