diff --git a/build.gradle b/build.gradle index 15b4fee..b39d00f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,10 +1,25 @@ +plugins { + id 'java' + id 'maven' +} + +sourceCompatibility = 1.7 +targetCompatibility = 1.7 + +configurations.all { +} + +sourceSets { + main.java.srcDir "src/main" + test.java.srcDir "src/test" +} + repositories { mavenCentral() } apply plugin: "java" dependencies { - //compile "com.github.jreddit:jreddit:1.0.3" //not supported by reddit api anymore //jreddit 1.0.4 dependencies compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1' compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.3.3' @@ -15,11 +30,6 @@ dependencies { testCompile group: 'org.mockito', name: 'mockito-core', version: '1.9.5' } -sourceSets { - main.java.srcDir "src/main" - test.java.srcDir "src/test" -} - jar { from configurations.compile.collect { zipTree it } manifest.attributes "Main-Class": "sh.adb.RandomRedditMemesAPI.Main" diff --git a/gradlew b/gradlew index 4f906e0..8e25e6c 100755 --- a/gradlew +++ b/gradlew @@ -82,7 +82,6 @@ esac 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 @@ -126,11 +125,10 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then +# 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 @@ -156,19 +154,19 @@ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then else eval `echo args$i`="\"$arg\"" fi - i=`expr $i + 1` + 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" ;; + (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 @@ -177,9 +175,14 @@ save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=`save "$@"` +APP_ARGS=$(save "$@") # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 107acd3..9618d8d 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -29,9 +29,6 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - @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="-Xmx64m" "-Xms64m" @@ -40,7 +37,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if "%ERRORLEVEL%" == "0" goto init echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -54,7 +51,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto execute +if exist "%JAVA_EXE%" goto init echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -64,14 +61,28 @@ echo location of your Java installation. goto fail +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_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=%* + :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 %* +"%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 diff --git a/src/main/com/github/jreddit/oauth/RedditOAuthAgent.java b/src/main/java/com/github/jreddit/oauth/RedditOAuthAgent.java similarity index 100% rename from src/main/com/github/jreddit/oauth/RedditOAuthAgent.java rename to src/main/java/com/github/jreddit/oauth/RedditOAuthAgent.java diff --git a/src/main/com/github/jreddit/oauth/RedditToken.java b/src/main/java/com/github/jreddit/oauth/RedditToken.java similarity index 100% rename from src/main/com/github/jreddit/oauth/RedditToken.java rename to src/main/java/com/github/jreddit/oauth/RedditToken.java diff --git a/src/main/com/github/jreddit/oauth/app/RedditApp.java b/src/main/java/com/github/jreddit/oauth/app/RedditApp.java similarity index 100% rename from src/main/com/github/jreddit/oauth/app/RedditApp.java rename to src/main/java/com/github/jreddit/oauth/app/RedditApp.java diff --git a/src/main/com/github/jreddit/oauth/app/RedditInstalledApp.java b/src/main/java/com/github/jreddit/oauth/app/RedditInstalledApp.java similarity index 100% rename from src/main/com/github/jreddit/oauth/app/RedditInstalledApp.java rename to src/main/java/com/github/jreddit/oauth/app/RedditInstalledApp.java diff --git a/src/main/com/github/jreddit/oauth/app/RedditScriptApp.java b/src/main/java/com/github/jreddit/oauth/app/RedditScriptApp.java similarity index 100% rename from src/main/com/github/jreddit/oauth/app/RedditScriptApp.java rename to src/main/java/com/github/jreddit/oauth/app/RedditScriptApp.java diff --git a/src/main/com/github/jreddit/oauth/app/RedditWebApp.java b/src/main/java/com/github/jreddit/oauth/app/RedditWebApp.java similarity index 100% rename from src/main/com/github/jreddit/oauth/app/RedditWebApp.java rename to src/main/java/com/github/jreddit/oauth/app/RedditWebApp.java diff --git a/src/main/com/github/jreddit/oauth/client/RedditClient.java b/src/main/java/com/github/jreddit/oauth/client/RedditClient.java similarity index 100% rename from src/main/com/github/jreddit/oauth/client/RedditClient.java rename to src/main/java/com/github/jreddit/oauth/client/RedditClient.java diff --git a/src/main/com/github/jreddit/oauth/client/RedditHttpClient.java b/src/main/java/com/github/jreddit/oauth/client/RedditHttpClient.java similarity index 100% rename from src/main/com/github/jreddit/oauth/client/RedditHttpClient.java rename to src/main/java/com/github/jreddit/oauth/client/RedditHttpClient.java diff --git a/src/main/com/github/jreddit/oauth/client/RedditPoliteClient.java b/src/main/java/com/github/jreddit/oauth/client/RedditPoliteClient.java similarity index 100% rename from src/main/com/github/jreddit/oauth/client/RedditPoliteClient.java rename to src/main/java/com/github/jreddit/oauth/client/RedditPoliteClient.java diff --git a/src/main/com/github/jreddit/oauth/exception/RedditOAuthException.java b/src/main/java/com/github/jreddit/oauth/exception/RedditOAuthException.java similarity index 100% rename from src/main/com/github/jreddit/oauth/exception/RedditOAuthException.java rename to src/main/java/com/github/jreddit/oauth/exception/RedditOAuthException.java diff --git a/src/main/com/github/jreddit/oauth/param/RedditDuration.java b/src/main/java/com/github/jreddit/oauth/param/RedditDuration.java similarity index 100% rename from src/main/com/github/jreddit/oauth/param/RedditDuration.java rename to src/main/java/com/github/jreddit/oauth/param/RedditDuration.java diff --git a/src/main/com/github/jreddit/oauth/param/RedditScope.java b/src/main/java/com/github/jreddit/oauth/param/RedditScope.java similarity index 100% rename from src/main/com/github/jreddit/oauth/param/RedditScope.java rename to src/main/java/com/github/jreddit/oauth/param/RedditScope.java diff --git a/src/main/com/github/jreddit/oauth/param/RedditScopeBuilder.java b/src/main/java/com/github/jreddit/oauth/param/RedditScopeBuilder.java similarity index 100% rename from src/main/com/github/jreddit/oauth/param/RedditScopeBuilder.java rename to src/main/java/com/github/jreddit/oauth/param/RedditScopeBuilder.java diff --git a/src/main/com/github/jreddit/oauth/param/RedditTokenCompleteScope.java b/src/main/java/com/github/jreddit/oauth/param/RedditTokenCompleteScope.java similarity index 100% rename from src/main/com/github/jreddit/oauth/param/RedditTokenCompleteScope.java rename to src/main/java/com/github/jreddit/oauth/param/RedditTokenCompleteScope.java diff --git a/src/main/com/github/jreddit/parser/entity/Comment.java b/src/main/java/com/github/jreddit/parser/entity/Comment.java similarity index 100% rename from src/main/com/github/jreddit/parser/entity/Comment.java rename to src/main/java/com/github/jreddit/parser/entity/Comment.java diff --git a/src/main/com/github/jreddit/parser/entity/Kind.java b/src/main/java/com/github/jreddit/parser/entity/Kind.java similarity index 100% rename from src/main/com/github/jreddit/parser/entity/Kind.java rename to src/main/java/com/github/jreddit/parser/entity/Kind.java diff --git a/src/main/com/github/jreddit/parser/entity/Message.java b/src/main/java/com/github/jreddit/parser/entity/Message.java similarity index 100% rename from src/main/com/github/jreddit/parser/entity/Message.java rename to src/main/java/com/github/jreddit/parser/entity/Message.java diff --git a/src/main/com/github/jreddit/parser/entity/MessageType.java b/src/main/java/com/github/jreddit/parser/entity/MessageType.java similarity index 100% rename from src/main/com/github/jreddit/parser/entity/MessageType.java rename to src/main/java/com/github/jreddit/parser/entity/MessageType.java diff --git a/src/main/com/github/jreddit/parser/entity/More.java b/src/main/java/com/github/jreddit/parser/entity/More.java similarity index 100% rename from src/main/com/github/jreddit/parser/entity/More.java rename to src/main/java/com/github/jreddit/parser/entity/More.java diff --git a/src/main/com/github/jreddit/parser/entity/Submission.java b/src/main/java/com/github/jreddit/parser/entity/Submission.java similarity index 100% rename from src/main/com/github/jreddit/parser/entity/Submission.java rename to src/main/java/com/github/jreddit/parser/entity/Submission.java diff --git a/src/main/com/github/jreddit/parser/entity/Subreddit.java b/src/main/java/com/github/jreddit/parser/entity/Subreddit.java similarity index 100% rename from src/main/com/github/jreddit/parser/entity/Subreddit.java rename to src/main/java/com/github/jreddit/parser/entity/Subreddit.java diff --git a/src/main/com/github/jreddit/parser/entity/Thing.java b/src/main/java/com/github/jreddit/parser/entity/Thing.java similarity index 100% rename from src/main/com/github/jreddit/parser/entity/Thing.java rename to src/main/java/com/github/jreddit/parser/entity/Thing.java diff --git a/src/main/com/github/jreddit/parser/entity/UserInfo.java b/src/main/java/com/github/jreddit/parser/entity/UserInfo.java similarity index 100% rename from src/main/com/github/jreddit/parser/entity/UserInfo.java rename to src/main/java/com/github/jreddit/parser/entity/UserInfo.java diff --git a/src/main/com/github/jreddit/parser/entity/imaginary/CommentTreeElement.java b/src/main/java/com/github/jreddit/parser/entity/imaginary/CommentTreeElement.java similarity index 100% rename from src/main/com/github/jreddit/parser/entity/imaginary/CommentTreeElement.java rename to src/main/java/com/github/jreddit/parser/entity/imaginary/CommentTreeElement.java diff --git a/src/main/com/github/jreddit/parser/entity/imaginary/FullSubmission.java b/src/main/java/com/github/jreddit/parser/entity/imaginary/FullSubmission.java similarity index 100% rename from src/main/com/github/jreddit/parser/entity/imaginary/FullSubmission.java rename to src/main/java/com/github/jreddit/parser/entity/imaginary/FullSubmission.java diff --git a/src/main/com/github/jreddit/parser/entity/imaginary/MixedListingElement.java b/src/main/java/com/github/jreddit/parser/entity/imaginary/MixedListingElement.java similarity index 100% rename from src/main/com/github/jreddit/parser/entity/imaginary/MixedListingElement.java rename to src/main/java/com/github/jreddit/parser/entity/imaginary/MixedListingElement.java diff --git a/src/main/com/github/jreddit/parser/exception/RedditParseException.java b/src/main/java/com/github/jreddit/parser/exception/RedditParseException.java similarity index 100% rename from src/main/com/github/jreddit/parser/exception/RedditParseException.java rename to src/main/java/com/github/jreddit/parser/exception/RedditParseException.java diff --git a/src/main/com/github/jreddit/parser/listing/CommentsListingParser.java b/src/main/java/com/github/jreddit/parser/listing/CommentsListingParser.java similarity index 100% rename from src/main/com/github/jreddit/parser/listing/CommentsListingParser.java rename to src/main/java/com/github/jreddit/parser/listing/CommentsListingParser.java diff --git a/src/main/com/github/jreddit/parser/listing/CommentsMoreParser.java b/src/main/java/com/github/jreddit/parser/listing/CommentsMoreParser.java similarity index 100% rename from src/main/com/github/jreddit/parser/listing/CommentsMoreParser.java rename to src/main/java/com/github/jreddit/parser/listing/CommentsMoreParser.java diff --git a/src/main/com/github/jreddit/parser/listing/MixedListingParser.java b/src/main/java/com/github/jreddit/parser/listing/MixedListingParser.java similarity index 100% rename from src/main/com/github/jreddit/parser/listing/MixedListingParser.java rename to src/main/java/com/github/jreddit/parser/listing/MixedListingParser.java diff --git a/src/main/com/github/jreddit/parser/listing/RedditListingParser.java b/src/main/java/com/github/jreddit/parser/listing/RedditListingParser.java similarity index 100% rename from src/main/com/github/jreddit/parser/listing/RedditListingParser.java rename to src/main/java/com/github/jreddit/parser/listing/RedditListingParser.java diff --git a/src/main/com/github/jreddit/parser/listing/SubmissionsListingParser.java b/src/main/java/com/github/jreddit/parser/listing/SubmissionsListingParser.java similarity index 100% rename from src/main/com/github/jreddit/parser/listing/SubmissionsListingParser.java rename to src/main/java/com/github/jreddit/parser/listing/SubmissionsListingParser.java diff --git a/src/main/com/github/jreddit/parser/listing/SubredditsListingParser.java b/src/main/java/com/github/jreddit/parser/listing/SubredditsListingParser.java similarity index 100% rename from src/main/com/github/jreddit/parser/listing/SubredditsListingParser.java rename to src/main/java/com/github/jreddit/parser/listing/SubredditsListingParser.java diff --git a/src/main/com/github/jreddit/parser/single/FullSubmissionParser.java b/src/main/java/com/github/jreddit/parser/single/FullSubmissionParser.java similarity index 100% rename from src/main/com/github/jreddit/parser/single/FullSubmissionParser.java rename to src/main/java/com/github/jreddit/parser/single/FullSubmissionParser.java diff --git a/src/main/com/github/jreddit/parser/util/CommentTreeUtils.java b/src/main/java/com/github/jreddit/parser/util/CommentTreeUtils.java similarity index 100% rename from src/main/com/github/jreddit/parser/util/CommentTreeUtils.java rename to src/main/java/com/github/jreddit/parser/util/CommentTreeUtils.java diff --git a/src/main/com/github/jreddit/parser/util/JsonUtils.java b/src/main/java/com/github/jreddit/parser/util/JsonUtils.java similarity index 100% rename from src/main/com/github/jreddit/parser/util/JsonUtils.java rename to src/main/java/com/github/jreddit/parser/util/JsonUtils.java diff --git a/src/main/com/github/jreddit/request/RedditGetRequest.java b/src/main/java/com/github/jreddit/request/RedditGetRequest.java similarity index 100% rename from src/main/com/github/jreddit/request/RedditGetRequest.java rename to src/main/java/com/github/jreddit/request/RedditGetRequest.java diff --git a/src/main/com/github/jreddit/request/RedditPostRequest.java b/src/main/java/com/github/jreddit/request/RedditPostRequest.java similarity index 100% rename from src/main/com/github/jreddit/request/RedditPostRequest.java rename to src/main/java/com/github/jreddit/request/RedditPostRequest.java diff --git a/src/main/com/github/jreddit/request/action/MarkActionRequest.java b/src/main/java/com/github/jreddit/request/action/MarkActionRequest.java similarity index 100% rename from src/main/com/github/jreddit/request/action/MarkActionRequest.java rename to src/main/java/com/github/jreddit/request/action/MarkActionRequest.java diff --git a/src/main/com/github/jreddit/request/action/flair/DeleteFlairRequest.java b/src/main/java/com/github/jreddit/request/action/flair/DeleteFlairRequest.java similarity index 100% rename from src/main/com/github/jreddit/request/action/flair/DeleteFlairRequest.java rename to src/main/java/com/github/jreddit/request/action/flair/DeleteFlairRequest.java diff --git a/src/main/com/github/jreddit/request/action/mark/HideRequest.java b/src/main/java/com/github/jreddit/request/action/mark/HideRequest.java similarity index 100% rename from src/main/com/github/jreddit/request/action/mark/HideRequest.java rename to src/main/java/com/github/jreddit/request/action/mark/HideRequest.java diff --git a/src/main/com/github/jreddit/request/action/mark/MarkNsfwRequest.java b/src/main/java/com/github/jreddit/request/action/mark/MarkNsfwRequest.java similarity index 100% rename from src/main/com/github/jreddit/request/action/mark/MarkNsfwRequest.java rename to src/main/java/com/github/jreddit/request/action/mark/MarkNsfwRequest.java diff --git a/src/main/com/github/jreddit/request/action/mark/ReportRequest.java b/src/main/java/com/github/jreddit/request/action/mark/ReportRequest.java similarity index 100% rename from src/main/com/github/jreddit/request/action/mark/ReportRequest.java rename to src/main/java/com/github/jreddit/request/action/mark/ReportRequest.java diff --git a/src/main/com/github/jreddit/request/action/mark/SaveRequest.java b/src/main/java/com/github/jreddit/request/action/mark/SaveRequest.java similarity index 100% rename from src/main/com/github/jreddit/request/action/mark/SaveRequest.java rename to src/main/java/com/github/jreddit/request/action/mark/SaveRequest.java diff --git a/src/main/com/github/jreddit/request/action/mark/UnhideRequest.java b/src/main/java/com/github/jreddit/request/action/mark/UnhideRequest.java similarity index 100% rename from src/main/com/github/jreddit/request/action/mark/UnhideRequest.java rename to src/main/java/com/github/jreddit/request/action/mark/UnhideRequest.java diff --git a/src/main/com/github/jreddit/request/action/mark/UnmarkNsfwRequest.java b/src/main/java/com/github/jreddit/request/action/mark/UnmarkNsfwRequest.java similarity index 100% rename from src/main/com/github/jreddit/request/action/mark/UnmarkNsfwRequest.java rename to src/main/java/com/github/jreddit/request/action/mark/UnmarkNsfwRequest.java diff --git a/src/main/com/github/jreddit/request/action/mark/UnsaveRequest.java b/src/main/java/com/github/jreddit/request/action/mark/UnsaveRequest.java similarity index 100% rename from src/main/com/github/jreddit/request/action/mark/UnsaveRequest.java rename to src/main/java/com/github/jreddit/request/action/mark/UnsaveRequest.java diff --git a/src/main/com/github/jreddit/request/action/mark/VoteRequest.java b/src/main/java/com/github/jreddit/request/action/mark/VoteRequest.java similarity index 100% rename from src/main/com/github/jreddit/request/action/mark/VoteRequest.java rename to src/main/java/com/github/jreddit/request/action/mark/VoteRequest.java diff --git a/src/main/com/github/jreddit/request/retrieval/ListingRequest.java b/src/main/java/com/github/jreddit/request/retrieval/ListingRequest.java similarity index 100% rename from src/main/com/github/jreddit/request/retrieval/ListingRequest.java rename to src/main/java/com/github/jreddit/request/retrieval/ListingRequest.java diff --git a/src/main/com/github/jreddit/request/retrieval/comments/CommentsOfUserRequest.java b/src/main/java/com/github/jreddit/request/retrieval/comments/CommentsOfUserRequest.java similarity index 100% rename from src/main/com/github/jreddit/request/retrieval/comments/CommentsOfUserRequest.java rename to src/main/java/com/github/jreddit/request/retrieval/comments/CommentsOfUserRequest.java diff --git a/src/main/com/github/jreddit/request/retrieval/comments/MoreCommentsRequest.java b/src/main/java/com/github/jreddit/request/retrieval/comments/MoreCommentsRequest.java similarity index 100% rename from src/main/com/github/jreddit/request/retrieval/comments/MoreCommentsRequest.java rename to src/main/java/com/github/jreddit/request/retrieval/comments/MoreCommentsRequest.java diff --git a/src/main/com/github/jreddit/request/retrieval/mixed/FullSubmissionRequest.java b/src/main/java/com/github/jreddit/request/retrieval/mixed/FullSubmissionRequest.java similarity index 100% rename from src/main/com/github/jreddit/request/retrieval/mixed/FullSubmissionRequest.java rename to src/main/java/com/github/jreddit/request/retrieval/mixed/FullSubmissionRequest.java diff --git a/src/main/com/github/jreddit/request/retrieval/mixed/MixedOfUserRequest.java b/src/main/java/com/github/jreddit/request/retrieval/mixed/MixedOfUserRequest.java similarity index 100% rename from src/main/com/github/jreddit/request/retrieval/mixed/MixedOfUserRequest.java rename to src/main/java/com/github/jreddit/request/retrieval/mixed/MixedOfUserRequest.java diff --git a/src/main/com/github/jreddit/request/retrieval/param/CommentSort.java b/src/main/java/com/github/jreddit/request/retrieval/param/CommentSort.java similarity index 100% rename from src/main/com/github/jreddit/request/retrieval/param/CommentSort.java rename to src/main/java/com/github/jreddit/request/retrieval/param/CommentSort.java diff --git a/src/main/com/github/jreddit/request/retrieval/param/QuerySyntax.java b/src/main/java/com/github/jreddit/request/retrieval/param/QuerySyntax.java similarity index 100% rename from src/main/com/github/jreddit/request/retrieval/param/QuerySyntax.java rename to src/main/java/com/github/jreddit/request/retrieval/param/QuerySyntax.java diff --git a/src/main/com/github/jreddit/request/retrieval/param/SearchSort.java b/src/main/java/com/github/jreddit/request/retrieval/param/SearchSort.java similarity index 100% rename from src/main/com/github/jreddit/request/retrieval/param/SearchSort.java rename to src/main/java/com/github/jreddit/request/retrieval/param/SearchSort.java diff --git a/src/main/com/github/jreddit/request/retrieval/param/SubmissionSort.java b/src/main/java/com/github/jreddit/request/retrieval/param/SubmissionSort.java similarity index 100% rename from src/main/com/github/jreddit/request/retrieval/param/SubmissionSort.java rename to src/main/java/com/github/jreddit/request/retrieval/param/SubmissionSort.java diff --git a/src/main/com/github/jreddit/request/retrieval/param/SubredditsView.java b/src/main/java/com/github/jreddit/request/retrieval/param/SubredditsView.java similarity index 100% rename from src/main/com/github/jreddit/request/retrieval/param/SubredditsView.java rename to src/main/java/com/github/jreddit/request/retrieval/param/SubredditsView.java diff --git a/src/main/com/github/jreddit/request/retrieval/param/TimeSpan.java b/src/main/java/com/github/jreddit/request/retrieval/param/TimeSpan.java similarity index 100% rename from src/main/com/github/jreddit/request/retrieval/param/TimeSpan.java rename to src/main/java/com/github/jreddit/request/retrieval/param/TimeSpan.java diff --git a/src/main/com/github/jreddit/request/retrieval/param/UserMixedCategory.java b/src/main/java/com/github/jreddit/request/retrieval/param/UserMixedCategory.java similarity index 100% rename from src/main/com/github/jreddit/request/retrieval/param/UserMixedCategory.java rename to src/main/java/com/github/jreddit/request/retrieval/param/UserMixedCategory.java diff --git a/src/main/com/github/jreddit/request/retrieval/param/UserOverviewSort.java b/src/main/java/com/github/jreddit/request/retrieval/param/UserOverviewSort.java similarity index 100% rename from src/main/com/github/jreddit/request/retrieval/param/UserOverviewSort.java rename to src/main/java/com/github/jreddit/request/retrieval/param/UserOverviewSort.java diff --git a/src/main/com/github/jreddit/request/retrieval/param/UserSubmissionsCategory.java b/src/main/java/com/github/jreddit/request/retrieval/param/UserSubmissionsCategory.java similarity index 100% rename from src/main/com/github/jreddit/request/retrieval/param/UserSubmissionsCategory.java rename to src/main/java/com/github/jreddit/request/retrieval/param/UserSubmissionsCategory.java diff --git a/src/main/com/github/jreddit/request/retrieval/submissions/SubmissionsOfSubredditRequest.java b/src/main/java/com/github/jreddit/request/retrieval/submissions/SubmissionsOfSubredditRequest.java similarity index 100% rename from src/main/com/github/jreddit/request/retrieval/submissions/SubmissionsOfSubredditRequest.java rename to src/main/java/com/github/jreddit/request/retrieval/submissions/SubmissionsOfSubredditRequest.java diff --git a/src/main/com/github/jreddit/request/retrieval/submissions/SubmissionsOfUserRequest.java b/src/main/java/com/github/jreddit/request/retrieval/submissions/SubmissionsOfUserRequest.java similarity index 100% rename from src/main/com/github/jreddit/request/retrieval/submissions/SubmissionsOfUserRequest.java rename to src/main/java/com/github/jreddit/request/retrieval/submissions/SubmissionsOfUserRequest.java diff --git a/src/main/com/github/jreddit/request/retrieval/submissions/SubmissionsSearchRequest.java b/src/main/java/com/github/jreddit/request/retrieval/submissions/SubmissionsSearchRequest.java similarity index 100% rename from src/main/com/github/jreddit/request/retrieval/submissions/SubmissionsSearchRequest.java rename to src/main/java/com/github/jreddit/request/retrieval/submissions/SubmissionsSearchRequest.java diff --git a/src/main/com/github/jreddit/request/retrieval/subreddits/SubredditsOfUserRequest.java b/src/main/java/com/github/jreddit/request/retrieval/subreddits/SubredditsOfUserRequest.java similarity index 100% rename from src/main/com/github/jreddit/request/retrieval/subreddits/SubredditsOfUserRequest.java rename to src/main/java/com/github/jreddit/request/retrieval/subreddits/SubredditsOfUserRequest.java diff --git a/src/main/com/github/jreddit/request/retrieval/subreddits/SubredditsSearchRequest.java b/src/main/java/com/github/jreddit/request/retrieval/subreddits/SubredditsSearchRequest.java similarity index 100% rename from src/main/com/github/jreddit/request/retrieval/subreddits/SubredditsSearchRequest.java rename to src/main/java/com/github/jreddit/request/retrieval/subreddits/SubredditsSearchRequest.java diff --git a/src/main/com/github/jreddit/request/util/KeyValueFormatter.java b/src/main/java/com/github/jreddit/request/util/KeyValueFormatter.java similarity index 100% rename from src/main/com/github/jreddit/request/util/KeyValueFormatter.java rename to src/main/java/com/github/jreddit/request/util/KeyValueFormatter.java diff --git a/src/main/sh/adb/RandomRedditMemesAPI/Main.java b/src/main/java/sh/adb/RandomRedditMemesAPI/Main.java similarity index 59% rename from src/main/sh/adb/RandomRedditMemesAPI/Main.java rename to src/main/java/sh/adb/RandomRedditMemesAPI/Main.java index 3b10022..a019972 100644 --- a/src/main/sh/adb/RandomRedditMemesAPI/Main.java +++ b/src/main/java/sh/adb/RandomRedditMemesAPI/Main.java @@ -1,23 +1,29 @@ package sh.adb.RandomRedditMemesAPI; +import com.github.jreddit.oauth.RedditOAuthAgent; +import com.github.jreddit.oauth.RedditToken; +import com.github.jreddit.oauth.app.RedditApp; +import com.github.jreddit.oauth.app.RedditInstalledApp; import com.github.jreddit.oauth.exception.RedditOAuthException; import com.sun.net.httpserver.HttpServer; +import org.json.simple.parser.ParseException; import java.io.IOException; import java.net.InetSocketAddress; public class Main { - public static void main(String[] args) throws IOException, RedditOAuthException { + public static void main(String[] args) throws IOException, RedditOAuthException, ParseException { HttpServer server = HttpServer.create(new InetSocketAddress(8000), 0); - server.createContext("", new ErrorHandler()); + server.createContext("/", new FallbackHandler()); //server.createContext("/api/v1/", new StandardHandler()); server.createContext("/api/v1/r/", new CommunityHandler()); server.setExecutor(null); server.start(); + System.out.println("server started"); RedditAPI client = new RedditAPI(); System.out.println("the token is"); - System.out.println(client.token); + System.out.println(client.token.getAccessToken()); } } diff --git a/src/main/sh/adb/RandomRedditMemesAPI/RedditAPI.java b/src/main/java/sh/adb/RandomRedditMemesAPI/RedditAPI.java similarity index 77% rename from src/main/sh/adb/RandomRedditMemesAPI/RedditAPI.java rename to src/main/java/sh/adb/RandomRedditMemesAPI/RedditAPI.java index 3a4f84e..4cc9d34 100644 --- a/src/main/sh/adb/RandomRedditMemesAPI/RedditAPI.java +++ b/src/main/java/sh/adb/RandomRedditMemesAPI/RedditAPI.java @@ -9,24 +9,23 @@ import com.github.jreddit.oauth.app.RedditInstalledApp; import com.github.jreddit.oauth.exception.RedditOAuthException; public class RedditAPI { - private RedditApp redditApp; - private RedditOAuthAgent agent; - public RedditToken token; + private final RedditOAuthAgent agent; + protected RedditToken token; - public RedditAPI() throws RedditOAuthException { + public RedditAPI() throws RedditOAuthException, ParseException { // Information about the app String userAgent = "jReddit: Reddit API Wrapper for Java"; - String clientID = "gn9RWt8rgo2GDoZK"; + String clientID = "PfnhLt3VahLrbg"; String redirectURI = "https://github.com/snkas/jReddit"; // Reddit application RedditApp redditApp = new RedditInstalledApp(clientID, redirectURI); // Create OAuth agent - RedditOAuthAgent agent = new RedditOAuthAgent(userAgent, redditApp); + agent = new RedditOAuthAgent(userAgent, redditApp); // Create token (will be valid for 1 hour) - RedditToken token = agent.tokenAppOnly(false); + token = agent.tokenAppOnly(false); System.out.println("Access Token: " + token.getAccessToken()); System.out.println("Token Type: " + token.getTokenType()); System.out.println("Refreshable: " + token.isRefreshable()); @@ -36,6 +35,6 @@ public class RedditAPI { System.out.println("Will expire in 59 minutes: " + token.willExpireIn((long) 3540)); } public void newToken() throws RedditOAuthException { - RedditToken token = this.agent.tokenAppOnly(false); + this.token = this.agent.tokenAppOnly(false); } }