diff --git a/database/.gitignore b/database/.gitignore deleted file mode 100644 index 595bf6a..0000000 --- a/database/.gitignore +++ /dev/null @@ -1 +0,0 @@ -service-account.json diff --git a/database/README.md b/database/README.md deleted file mode 100644 index 18ae923..0000000 --- a/database/README.md +++ /dev/null @@ -1,42 +0,0 @@ -Firebase Java Realtime Database Quickstart -========================================== - -The Java Firebase Database quickstart demonstrates how to connect to and use the Firebase Realtime Database using Java through a simple social blogging app. It will interoperate with the Web, iOS and Android database quickstarts. - -This server will: - - Update the star counts for all posts. - - Send notifications when a post has been stared. - - Run weekly job listing the top 5 posts. - -Introduction ------------- - -- [Read more about Firebase Database](https://firebase.google.com/docs/database/) - -Getting Started ---------------- - -- Create your project on the [Firebase Console](https://console.firebase.google.com). -- Create a service account as described in [Adding Firebase to your Server](https://firebase.google.com/docs/admin/setup) and download the JSON file. - - Copy the json file to this folder and rename it to `service-account.json`. -- Change the `DATATBASE_URL` variable in `Database.java` to be the URL of your Firebase Database. - - -Run --------------- -- From the `database` directory run `./gradlew build run` to start run the quickstart. -- Configure and run one of the Database quickstarts for [Web](https://github.com/firebase/quickstart-js/tree/master/database), - [iOS](https://github.com/firebase/quickstart-ios/tree/master/database) or - [Android](https://github.com/firebase/quickstart-android/tree/master/database). - Then use one of these apps to publish new posts: you should see console output when one of your posts have - received a new star and the starred counter should be kept up to date by the app. - -Support -------- - -https://firebase.google.com/support/ - -License -------- - -© Google, 2016. Licensed under an [Apache-2](../LICENSE) license. diff --git a/database/build.gradle b/database/build.gradle deleted file mode 100644 index 383789e..0000000 --- a/database/build.gradle +++ /dev/null @@ -1,22 +0,0 @@ -group 'com.google.firebase.quickstart' -version '1.0' - -apply plugin: 'java' - -apply plugin: 'application' -mainClassName = 'com.google.firebase.quickstart.Database' - -sourceCompatibility = 1.8 - -repositories { - mavenCentral() - mavenLocal() -} - -dependencies { - // Firebase Java SDK - compile 'com.google.firebase:firebase-admin:5.8.0' - - // Sundial Job Scheduler - compile 'org.knowm:sundial:2.1.1' -} diff --git a/database/gradle/wrapper/gradle-wrapper.jar b/database/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 9411448..0000000 Binary files a/database/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/database/gradle/wrapper/gradle-wrapper.properties b/database/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index dd26f2e..0000000 --- a/database/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Tue Jun 07 10:22:44 PDT 2016 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-all.zip diff --git a/database/gradlew b/database/gradlew deleted file mode 100755 index 9d82f78..0000000 --- a/database/gradlew +++ /dev/null @@ -1,160 +0,0 @@ -#!/usr/bin/env bash - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn ( ) { - echo "$*" -} - -die ( ) { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; -esac - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") -} -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" - -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/database/gradlew.bat b/database/gradlew.bat deleted file mode 100644 index aec9973..0000000 --- a/database/gradlew.bat +++ /dev/null @@ -1,90 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/database/settings.gradle b/database/settings.gradle deleted file mode 100644 index 527b65e..0000000 --- a/database/settings.gradle +++ /dev/null @@ -1,2 +0,0 @@ -rootProject.name = 'database' - diff --git a/database/src/main/java/com/google/firebase/quickstart/Database.java b/database/src/main/java/com/google/firebase/quickstart/Database.java deleted file mode 100644 index c26757c..0000000 --- a/database/src/main/java/com/google/firebase/quickstart/Database.java +++ /dev/null @@ -1,209 +0,0 @@ -/** - * Copyright Google Inc. All Rights Reserved. - * - * 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.google.firebase.quickstart; - -import com.google.auth.oauth2.GoogleCredentials; -import com.google.firebase.FirebaseApp; -import com.google.firebase.FirebaseOptions; -import com.google.firebase.database.*; -import com.google.firebase.quickstart.email.MyEmailer; -import com.google.firebase.quickstart.model.Post; -import com.google.firebase.quickstart.model.User; -import java.io.IOException; -import org.knowm.sundial.SundialJobScheduler; - -import java.io.FileInputStream; - -/** - * Firebase Database quickstart sample for the Java Admin SDK. - * See: https://firebase.google.com/docs/admin/setup#add_firebase_to_your_app - */ -public class Database { - - private static final String DATABASE_URL = "https://.firebaseio.com/"; - - private static DatabaseReference database; - - /** - * Notify a user of a new start and then update the last notification time. - */ - private static void sendNotificationToUser(final String uid, final String postId) { - // [START single_value_read] - final DatabaseReference userRef = database.child("users").child(uid); - userRef.addListenerForSingleValueEvent(new ValueEventListener() { - public void onDataChange(DataSnapshot dataSnapshot) { - User user = dataSnapshot.getValue(User.class); - if (user.email != null) { - // Send email notification - MyEmailer.sendNotificationEmail(user.email, uid, postId); - } - } - - public void onCancelled(DatabaseError databaseError) { - System.out.println("Unable to get user data from " + userRef.getKey()); - System.out.println("Error: " + databaseError.getMessage()); - } - }); - // [END single_value_read] - } - - /** - * Update the startCount value to equal the number of stars in the map. - */ - private static void updateStarCount(DatabaseReference postRef) { - // [START post_stars_transaction] - postRef.runTransaction(new Transaction.Handler() { - public Transaction.Result doTransaction(MutableData mutableData) { - Post post = mutableData.getValue(Post.class); - if (post != null) { - // Update the starCount to be the same as the number of members in the stars map. - if (post.stars != null) { - post.starCount = post.stars.size(); - } else { - post.starCount = 0; - } - - mutableData.setValue(post); - return Transaction.success(mutableData); - } else { - return Transaction.success(mutableData); - } - } - - public void onComplete(DatabaseError databaseError, boolean complete, DataSnapshot dataSnapshot) { - System.out.println("updateStarCount:onComplete:" + complete); - } - }); - // [END post_stars_transaction] - } - - /** - * Start global listener for all Posts. - */ - public static void startListeners() { - database.child("posts").addChildEventListener(new ChildEventListener() { - - public void onChildAdded(DataSnapshot dataSnapshot, String prevChildName) { - final String postId = dataSnapshot.getKey(); - final Post post = dataSnapshot.getValue(Post.class); - - // Listen for changes in the number of stars and update starCount - addStarsChangedListener(post, postId); - - // Listen for new stars on the post, notify users on changes - addNewStarsListener(dataSnapshot.getRef(), post); - } - - public void onChildChanged(DataSnapshot dataSnapshot, String prevChildName) {} - - public void onChildRemoved(DataSnapshot dataSnapshot) {} - - public void onChildMoved(DataSnapshot dataSnapshot, String prevChildName) {} - - public void onCancelled(DatabaseError databaseError) { - System.out.println("startListeners: unable to attach listener to posts"); - System.out.println("startListeners: " + databaseError.getMessage()); - } - }); - } - - /** - * Listen for stars added or removed and update the starCount. - */ - private static void addStarsChangedListener(Post post, String postId) { - // Get references to the post in both locations - final DatabaseReference postRef = database.child("posts").child(postId); - final DatabaseReference userPostRef = database.child("user-posts").child(post.uid).child(postId); - - // When the post changes, update the star counts - // [START post_value_event_listener] - postRef.child("stars").addValueEventListener(new ValueEventListener() { - public void onDataChange(DataSnapshot dataSnapshot) { - updateStarCount(postRef); - // [START_EXCLUDE] - updateStarCount(userPostRef); - // [END_EXCLUDE] - } - - public void onCancelled(DatabaseError databaseError) { - System.out.println("Unable to attach listener to stars for post: " + postRef.getKey()); - System.out.println("Error: " + databaseError.getMessage()); - } - }); - // [END post_value_event_listener] - } - - /** - * Send email to author when new star is received. - */ - private static void addNewStarsListener(final DatabaseReference postRef, final Post post) { - // [START child_event_listener_recycler] - postRef.child("stars").addChildEventListener(new ChildEventListener() { - public void onChildAdded(DataSnapshot dataSnapshot, String prevChildName) { - // New star added, notify the author of the post - sendNotificationToUser(post.uid, postRef.getKey()); - } - - public void onChildChanged(DataSnapshot dataSnapshot, String prevChildName) {} - - public void onChildRemoved(DataSnapshot dataSnapshot) {} - - public void onChildMoved(DataSnapshot dataSnapshot, String prevChildName) {} - - public void onCancelled(DatabaseError databaseError) { - System.out.println("Unable to attach new star listener to: " + postRef.getKey()); - System.out.println("Error: " + databaseError.getMessage()); - } - }); - // [END child_event_listener_recycler] - } - - /** - * Send an email listing the top posts every Sunday. - */ - private static void startWeeklyTopPostEmailer() { - SundialJobScheduler.startScheduler("com.google.firebase.quickstart.email"); - } - - public static void main(String[] args) { - // Initialize Firebase - try { - // [START initialize] - FileInputStream serviceAccount = new FileInputStream("service-account.json"); - FirebaseOptions options = new FirebaseOptions.Builder() - .setCredentials(GoogleCredentials.fromStream(serviceAccount)) - .setDatabaseUrl(DATABASE_URL) - .build(); - FirebaseApp.initializeApp(options); - // [END initialize] - } catch (IOException e) { - System.out.println("ERROR: invalid service account credentials. See README."); - System.out.println(e.getMessage()); - - System.exit(1); - } - - // Shared Database reference - database = FirebaseDatabase.getInstance().getReference(); - - // Start listening to the Database - startListeners(); - - // Kick off weekly email task - startWeeklyTopPostEmailer(); - } - -} diff --git a/database/src/main/java/com/google/firebase/quickstart/email/MyEmailer.java b/database/src/main/java/com/google/firebase/quickstart/email/MyEmailer.java deleted file mode 100644 index a3686c3..0000000 --- a/database/src/main/java/com/google/firebase/quickstart/email/MyEmailer.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright Google Inc. All Rights Reserved. - * - * 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.google.firebase.quickstart.email; - -import com.google.firebase.database.DatabaseReference; -import com.google.firebase.database.FirebaseDatabase; -import com.google.firebase.database.ServerValue; -import com.google.firebase.quickstart.model.Post; -import com.google.firebase.quickstart.model.User; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Class to send email notifications from the server. - */ -public class MyEmailer { - - public static void sendNotificationEmail(String email, String uid, String postId) { - // TODO(developer): send email to user notifying them that one of their posts got a new star - System.out.println("sendNotificationEmail: MOCK IMPLEMENTATION"); - System.out.println("sendNotificationEmail: " + email); - - // Save the date of the last notification sent - // [START write_fan_out] - Map update = new HashMap(); - update.put("/posts/" + postId + "/lastNotificationTimestamp", ServerValue.TIMESTAMP); - update.put("/user-posts/" + uid + "/" + postId + "/lastNotificationTimestamp", ServerValue.TIMESTAMP); - - FirebaseDatabase.getInstance().getReference().updateChildren(update); - // [END write_fan_out] - } - - public static void sendWeeklyEmail(Map users, List topPosts) { - // TODO(developer): send email to each user notifying them about the current top posts - System.out.println("sendWeeklyEmail: MOCK IMPLEMENTATION"); - System.out.println("sendWeeklyEmail: there are " + users.size() + " total users."); - System.out.println("sendWeeklyEmail: the top post is " + topPosts.get(0).title + " by " + topPosts.get(0).author); - - for (String userId : users.keySet()) { - // Mark the last time the weekly email was sent out - // [START basic_write] - DatabaseReference userRef = FirebaseDatabase.getInstance().getReference() - .child("users").child(userId).child("lastSentWeeklyTimestamp"); - userRef.setValue(ServerValue.TIMESTAMP); - // [END basic_write] - } - } - -} diff --git a/database/src/main/java/com/google/firebase/quickstart/email/WeeklyEmailJob.java b/database/src/main/java/com/google/firebase/quickstart/email/WeeklyEmailJob.java deleted file mode 100644 index 40e063c..0000000 --- a/database/src/main/java/com/google/firebase/quickstart/email/WeeklyEmailJob.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Copyright Google Inc. All Rights Reserved. - * - * 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.google.firebase.quickstart.email; - -import com.google.firebase.database.*; -import com.google.firebase.quickstart.model.Post; -import com.google.firebase.quickstart.model.User; -import org.knowm.sundial.Job; -import org.knowm.sundial.annotations.CronTrigger; -import org.knowm.sundial.exceptions.JobInterruptException; - -import java.util.List; -import java.util.Map; - -/** - * Cron job to send weekly emails (Sundays at 2:30pm) - */ -@CronTrigger(cron = "0 30 14 ? * SUN *") -public class WeeklyEmailJob extends Job { - - public void doRun() throws JobInterruptException { - DatabaseReference ref = FirebaseDatabase.getInstance().getReference(); - - // Top 5 Posts in the database, ordered by stars - // [START top_posts_query] - Query topPostsQuery = ref.child("posts").orderByChild("starCount").limitToLast(5); - // [END top_posts_query] - - // All Users - final DatabaseReference allUsersRef = ref.child("users"); - - topPostsQuery.addListenerForSingleValueEvent(new ValueEventListener() { - public void onDataChange(final DataSnapshot topPostsSnapshot) { - allUsersRef.addListenerForSingleValueEvent(new ValueEventListener() { - public void onDataChange(DataSnapshot allUsersSnapshot) { - // Get users and posts as lists - Map users = allUsersSnapshot.getValue(new GenericTypeIndicator>() {}); - List posts = topPostsSnapshot.getValue(new GenericTypeIndicator>() {}); - - // Send email to all users about the top 5 posts - MyEmailer.sendWeeklyEmail(users, posts); - } - - public void onCancelled(DatabaseError databaseError) { - System.out.println("WeeklyEmailJob: could not get all users"); - System.out.println("WeeklyEmailJob: " + databaseError.getMessage()); - } - }); - } - - public void onCancelled(DatabaseError databaseError) { - System.out.println("WeeklyEmailJob: could not get top posts"); - System.out.println("WeeklyEmailJob: " + databaseError.getMessage()); - } - }); - } - -} diff --git a/database/src/main/java/com/google/firebase/quickstart/model/Post.java b/database/src/main/java/com/google/firebase/quickstart/model/Post.java deleted file mode 100644 index f0362b1..0000000 --- a/database/src/main/java/com/google/firebase/quickstart/model/Post.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright Google Inc. All Rights Reserved. - * - * 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.google.firebase.quickstart.model; - -import com.google.firebase.database.IgnoreExtraProperties; - -import java.util.HashMap; -import java.util.Map; - -/** - * POJO class representing a Post stored in the Firebase Database. - */ -// [START post_class] -@IgnoreExtraProperties -public class Post { - - public String uid; - public String author; - public String title; - public String body; - public int starCount = 0; - public Map stars = new HashMap(); - - public Post() { - // Default constructor required for calls to DataSnapshot.getValue(Post.class) - } - - public Post(String uid, String author, String title, String body) { - this.uid = uid; - this.author = author; - this.title = title; - this.body = body; - } -} -// [END post_class] diff --git a/database/src/main/java/com/google/firebase/quickstart/model/User.java b/database/src/main/java/com/google/firebase/quickstart/model/User.java deleted file mode 100644 index 4c037b3..0000000 --- a/database/src/main/java/com/google/firebase/quickstart/model/User.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright Google Inc. All Rights Reserved. - * - * 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.google.firebase.quickstart.model; - -import com.google.firebase.database.IgnoreExtraProperties; - -/** - * POJO representing a User stored in the Firebase Database. - */ -// [START user_class] -@IgnoreExtraProperties -public class User { - - public String username; - public String email; - - public User() { - // Default constructor required for calls to DataSnapshot.getValue(User.class) - } - - public User(String username, String email) { - this.username = username; - this.email = email; - } - -} -// [END user_class] \ No newline at end of file