Merged ported Apigee android sdk to 1.0
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/21b60593 Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/21b60593 Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/21b60593 Branch: refs/heads/master Commit: 21b605932b422e71f8fbf1abaaa20cb88b3ba90b Parents: 464d10a Author: amuramoto <[email protected]> Authored: Wed Nov 12 17:32:32 2014 -0800 Committer: amuramoto <[email protected]> Committed: Wed Nov 12 17:32:32 2014 -0800 ---------------------------------------------------------------------- sdks/android/.gitignore | 20 + sdks/android/README.md | 33 + sdks/android/README.txt | 2 - sdks/android/build_release_zip.sh | 167 + sdks/android/dependency-reduced-pom.xml | 109 + sdks/android/dist/jackson-core-asl-1.9.1.jar | Bin 0 -> 228286 bytes sdks/android/dist/jackson-mapper-asl-1.9.1.jar | Bin 0 -> 764465 bytes .../dist/spring-android-core-1.0.0.M4.jar | Bin 0 -> 83065 bytes .../spring-android-rest-template-1.0.0.M4.jar | Bin 0 -> 137368 bytes .../0.0.6/usergrid-java-client-0.0.6.jar | Bin 0 -> 46389 bytes .../0.0.6/usergrid-java-client-0.0.6.jar.sha1 | 1 + .../0.0.6/usergrid-java-client-0.0.6.pom | 95 + .../0.0.6/usergrid-java-client-0.0.6.pom.sha1 | 1 + .../maven-metadata-local.xml | 12 + sdks/android/pom.xml | 47 +- .../apache/usergrid/android/client/Client.java | 1036 ------ .../client/callbacks/ApiResponseCallback.java | 26 - .../client/callbacks/ClientAsyncTask.java | 54 - .../client/callbacks/ClientCallback.java | 25 - .../callbacks/DeviceRegistrationCallback.java | 25 - .../callbacks/GroupsRetrievedCallback.java | 29 - .../client/callbacks/QueryResultsCallback.java | 25 - .../android/client/utils/DeviceUuidFactory.java | 170 - .../android/client/utils/ObjectUtils.java | 36 - .../usergrid/android/sdk/CounterIncrement.java | 53 + .../sdk/DefaultURLConnectionFactory.java | 17 + .../apache/usergrid/android/sdk/UGClient.java | 3160 ++++++++++++++++++ .../android/sdk/URLConnectionFactory.java | 12 + .../sdk/callbacks/ApiResponseCallback.java | 12 + .../android/sdk/callbacks/ClientAsyncTask.java | 47 + .../android/sdk/callbacks/ClientCallback.java | 12 + .../sdk/callbacks/GroupsRetrievedCallback.java | 16 + .../sdk/callbacks/QueryResultsCallback.java | 14 + .../usergrid/android/sdk/entities/Activity.java | 1019 ++++++ .../android/sdk/entities/Collection.java | 319 ++ .../usergrid/android/sdk/entities/Device.java | 103 + .../usergrid/android/sdk/entities/Entity.java | 533 +++ .../usergrid/android/sdk/entities/Group.java | 132 + .../usergrid/android/sdk/entities/Message.java | 140 + .../usergrid/android/sdk/entities/User.java | 296 ++ .../android/sdk/exception/ClientException.java | 40 + .../android/sdk/response/AggregateCounter.java | 39 + .../sdk/response/AggregateCounterSet.java | 98 + .../android/sdk/response/ApiResponse.java | 755 +++++ .../sdk/response/ClientCredentialsInfo.java | 45 + .../android/sdk/response/QueueInfo.java | 28 + .../android/sdk/utils/DeviceUuidFactory.java | 154 + .../usergrid/android/sdk/utils/JsonUtils.java | 166 + .../usergrid/android/sdk/utils/MapUtils.java | 23 + .../usergrid/android/sdk/utils/ObjectUtils.java | 20 + .../usergrid/android/sdk/utils/UrlUtils.java | 108 + 51 files changed, 7811 insertions(+), 1463 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21b60593/sdks/android/.gitignore ---------------------------------------------------------------------- diff --git a/sdks/android/.gitignore b/sdks/android/.gitignore new file mode 100644 index 0000000..3dfc800 --- /dev/null +++ b/sdks/android/.gitignore @@ -0,0 +1,20 @@ +.idea +*.DS_Store +hector.iml +releases +target +tmp +bin +build +.classpath +.project +.settings +out +*.svn +*.ipr +*.iws +DS_Store +/.DS_Store +*.class +.class + http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21b60593/sdks/android/README.md ---------------------------------------------------------------------- diff --git a/sdks/android/README.md b/sdks/android/README.md new file mode 100755 index 0000000..4fe667a --- /dev/null +++ b/sdks/android/README.md @@ -0,0 +1,33 @@ +Usergrid Android SDK Overview +======================= + +Installing the SDK +-------------------- + +To initialize the Usergrid SDK, do the following: + +1. Add 'usergrid-android-<version>.jar' to the build path for your project. +2. Add the following to your source code to import commonly used SDK classes: +<pre> + import org.apache.usergrid.android.sdk.UGClient; + import org.apache.usergrid.android.sdk.callbacks.ApiResponseCallback; + import org.apache.usergrid.android.sdk.response.ApiResponse; +</pre> +3. Add the following to your 'AndroidManifest.xml': +<pre> + <uses-permission android:name="android.permission.INTERNET" /> +</pre> +4. Instantiate the 'UGClient' class to initialize the Usergrid SDK: +<pre> + //Usergrid app credentials, available in the admin portal + String ORGNAME = "your-org"; + String APPNAME = "your-app"; + UGClient client = new UGClient(ORGNAME,APPNAME); +</pre> + +Building From Source +-------------------- +To build from source, do the following: + +1. Update the path in <android.libs> +2. Run <code>sh build_release_zip.sh <version></code> - <version> is the SDK version number specified in UGClient.java. http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21b60593/sdks/android/README.txt ---------------------------------------------------------------------- diff --git a/sdks/android/README.txt b/sdks/android/README.txt index e9b2a71..5540ba4 100644 --- a/sdks/android/README.txt +++ b/sdks/android/README.txt @@ -11,5 +11,3 @@ Requires the following permissions: <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> -This client relies on an old copy of the Usergrid Java SDK 0.0.6, which is -included in the sdks directory, make sure you build it first. http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21b60593/sdks/android/build_release_zip.sh ---------------------------------------------------------------------- diff --git a/sdks/android/build_release_zip.sh b/sdks/android/build_release_zip.sh new file mode 100755 index 0000000..b68b356 --- /dev/null +++ b/sdks/android/build_release_zip.sh @@ -0,0 +1,167 @@ +#!/bin/sh +#****************************************************************************** +# This shell script pulls together the pieces that make up the Android SDK +# distribution and builds a single zip file containing those pieces. +# +# The version of the SDK should be passed in as an argument. +# Example: build_sdk_zip.sh 1.4.3 +#****************************************************************************** + +# variables used for javadoc generation +MAVEN_REPO="${HOME}/.m2/repository" +ANDROID_SDK_PATH="/Applications/adt-bundle-mac/sdk/platforms/android-4.2" +JAVADOC_EXE_PATH="${JAVA_HOME}/bin" +JAVA_VERSION="1.6" + + +# verify that we've been given an argument (the version string) +if [ $# -eq 0 ] + then + echo "Error: SDK version string should be passed as argument" + exit 1 +fi + +# SDK version string is passed in as an argument to this script +SDK_VERSION="$1" + +# the following command extracts the version string from the sdk source +SDK_SOURCE_VERSION=`grep "String SDK_VERSION" src/main/java/org/apache/usergrid/android/sdk/UGClient.java | awk '{print $7}' | cut -d'"' -f2` + +if [ "${SDK_VERSION}" != "${SDK_SOURCE_VERSION}" ]; then + echo "Error: sdk source version (${SDK_SOURCE_VERSION}) does not match specified version (${SDK_VERSION})" + exit 1 +fi + + +# set up our tools +MVN_COMMAND="mvn" + +# set our paths and file names +LIBRARY_BASE_NAME="usergrid-android" +JAR_FILE_NAME="${LIBRARY_BASE_NAME}-${SDK_VERSION}.jar" +ZIP_BASE_NAME="${LIBRARY_BASE_NAME}-sdk" +ZIP_FILE_NAME="${ZIP_BASE_NAME}.zip" +TOPLEVEL_ZIP_DIR="zip" +DEST_ZIP_DIR="${TOPLEVEL_ZIP_DIR}/${LIBRARY_BASE_NAME}-sdk-${SDK_VERSION}" +BUILT_SDK_JAR_FILE="target/${JAR_FILE_NAME}" +ZIP_JAR_DIR="${DEST_ZIP_DIR}/lib" +NEW_PROJECT_TEMPLATE_DIR="new-project-template" +SAMPLES_DIR="samples" +DEST_SAMPLES_DIR="${DEST_ZIP_DIR}/${SAMPLES_DIR}" + +# make a clean build +"${MVN_COMMAND}" clean +"${MVN_COMMAND}" install -Dmaven.test.skip=true + +# new jar file found? +if [ ! -f "${BUILT_SDK_JAR_FILE}" ] ; then + echo "Error: unable to find jar file '${BUILT_SDK_JAR_FILE}'" + exit 1 +fi + +# zip directory exists? +if [ -d "${DEST_ZIP_DIR}" ]; then + # erase all existing files there + find "${DEST_ZIP_DIR}" -type f -exec rm {} \; +else + mkdir -p "${DEST_ZIP_DIR}" +fi + +# copy everything from repository +for entry in * +do + if [ -f "$entry" ]; then + cp "$entry" "${DEST_ZIP_DIR}" + elif [ -d "$entry" ]; then + if [ "$entry" != "${TOPLEVEL_ZIP_DIR}" ]; then + cp -r "$entry" "${DEST_ZIP_DIR}" + fi + fi +done + + +# if we have source/target in zip directory, delete everything under source/target +if [ -d "${DEST_ZIP_DIR}/src/target" ]; then + rm -rf "${DEST_ZIP_DIR}/src/target" + rmdir "${DEST_ZIP_DIR}/src/target" +fi + +# create directory for jar file +mkdir -p "${ZIP_JAR_DIR}" + +# copy jar file to destination directory +cp "${BUILT_SDK_JAR_FILE}" "${ZIP_JAR_DIR}" + + +# copy new jar file to new-project-template +# missing libs directory? +PROJECT_TEMPLATE_LIBS_DIR="${DEST_ZIP_DIR}/${NEW_PROJECT_TEMPLATE_DIR}/libs" +if [ ! -d "${PROJECT_TEMPLATE_LIBS_DIR}" ]; then + mkdir -p "${PROJECT_TEMPLATE_LIBS_DIR}" +fi + +cp "${BUILT_SDK_JAR_FILE}" "${PROJECT_TEMPLATE_LIBS_DIR}" + +# does new-project-template have 'bin' subdirectory? +if [ -d "${DEST_ZIP_DIR}/${NEW_PROJECT_TEMPLATE_DIR}/bin" ]; then + # delete it + rm -r "${DEST_ZIP_DIR}/${NEW_PROJECT_TEMPLATE_DIR}/bin" + rmdir "${DEST_ZIP_DIR}/${NEW_PROJECT_TEMPLATE_DIR}/bin" +fi + +# copy new jar file to each sample app lib directory +for sample_entry in ${DEST_SAMPLES_DIR}/* +do + if [ -d "${sample_entry}" ]; then + # is it missing a libs subdirectory? + SAMPLE_LIBS_DIR="${sample_entry}/libs" + if [ ! -d "${SAMPLE_LIBS_DIR}" ]; then + mkdir "${SAMPLE_LIBS_DIR}" + fi + + # copy jar file to libs dir for sample app + cp "${BUILT_SDK_JAR_FILE}" "${SAMPLE_LIBS_DIR}" + + # does the sample app directory have a 'bin' subdirectory? + if [ -d "${sample_entry}/bin" ]; then + # delete it + rm -r "${sample_entry}/bin" + rmdir "${sample_entry}/bin" + fi + fi +done + +# have sdk-explorer in samples? +if [ -d "${DEST_SAMPLES_DIR}/sdk-explorer" ]; then + # delete it + rm -r "${DEST_SAMPLES_DIR}/sdk-explorer" + rmdir "${DEST_SAMPLES_DIR}/sdk-explorer" +fi + +# have build_release_zip.sh? +if [ -f "${DEST_ZIP_DIR}/build_release_zip.sh" ]; then + # delete it + rm "${DEST_ZIP_DIR}/build_release_zip.sh" +fi + +# generate javadocs +JAVADOC_OUTPUT_DIR="${DEST_ZIP_DIR}/docs" +if [ -d "${JAVADOC_OUTPUT_DIR}" ]; then + # delete everything that may be there + rm -r "${JAVADOC_OUTPUT_DIR}/*" +else + mkdir "${JAVADOC_OUTPUT_DIR}" +fi + +CLASSPATH="./src/target/test-classes:${MAVEN_REPO}/com/fasterxml/jackson/core/jackson-core/2.2.3/jackson-core-2.2.3.jar:${MAVEN_REPO}/com/fasterxml/jackson/core/jackson-annotations/2.2.3/jackson-annotations-2.2.3.jar:${MAVEN_REPO}/com/fasterxml/jackson/core/jackson-databind/2.2.3/jackson-databind-2.2.3.jar:${MAVEN_REPO}/commons-codec/commons-codec/1.4/commons-codec-1.4.jar:${MAVEN_REPO}/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar:${MAVEN_REPO}/org/apache/httpcomponents/httpclient/4.1.2/httpclient-4.1.2.jar:${MAVEN_REPO}/org/apache/httpcomponents/httpcore/4.1.2/httpcore-4.1.2.jar" +SOURCEPATH="./src/main/java" +JAVADOC_OPTIONS="-splitindex -use -version -public -author" +PACKAGE_LIST="org.apache.usergrid.android.sdk.exception org.apache.usergrid.android.sdk.response org.apache.usergrid.android.sdk org.apache.usergrid.android.sdk.utils org.apache.usergrid.android.sdk.entities org.apache.usergrid.android.sdk.callbacks" + +JDOC_CMD="${JAVADOC_EXE_PATH}/javadoc ${JAVADOC_OPTIONS} -classpath ${CLASSPATH} -d ${JAVADOC_OUTPUT_DIR} -source ${JAVA_VERSION} -sourcepath ${SOURCEPATH} ${PACKAGE_LIST}" +echo ${JDOC_CMD} +${JDOC_CMD} + +# create the zip file +cd ${TOPLEVEL_ZIP_DIR} && zip -r -y ${ZIP_FILE_NAME} . + http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21b60593/sdks/android/dependency-reduced-pom.xml ---------------------------------------------------------------------- diff --git a/sdks/android/dependency-reduced-pom.xml b/sdks/android/dependency-reduced-pom.xml new file mode 100755 index 0000000..6274319 --- /dev/null +++ b/sdks/android/dependency-reduced-pom.xml @@ -0,0 +1,109 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.usergrid</groupId> + <artifactId>android</artifactId> + <name>android</name> + <version>0.0.8</version> + <url>http://maven.apache.org</url> + <developers> + <developer> + <id>eanuff</id> + <name>Ed Anuff</name> + </developer> + <developer> + <id>tnine</id> + <name>Todd Nine</name> + </developer> + <developer> + <id>sganyo</id> + <name>Scott Ganyo</name> + <email>[email protected]</email> + </developer> + <developer> + <id>pdardeau</id> + <name>Paul Dardeau</name> + <email>[email protected]</email> + </developer> + </developers> + <build> + <finalName>usergrid-android-${project.version}</finalName> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>${maven-compiler-plugin-version}</source> + <target>${maven-compiler-plugin-version}</target> + </configuration> + </plugin> + <plugin> + <artifactId>maven-shade-plugin</artifactId> + <version>${maven-shade-plugin-version}</version> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>shade</goal> + </goals> + <configuration> + <artifactSet> + <excludes> + <exclude>commons-logging:commons-logging</exclude> + <exclude>commons-codec:commons-codec</exclude> + <exclude>org.apache.httpcomponents:httpclient</exclude> + <exclude>org.apache.httpcomponents:httpcore</exclude> + <exclude>junit:junit</exclude> + </excludes> + </artifactSet> + <filters> + <filter> + <includes> + <include>com/fasterxml/**</include> + </includes> + </filter> + </filters> + <relocations> + <relocation> + <pattern>com.fasterxml.jackson</pattern> + <shadedPattern>com.apigee.fasterxml.jackson</shadedPattern> + </relocation> + </relocations> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + <dependencies> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + <version>4.1.2</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.apache.usergrid</groupId> + <artifactId>android-platform</artifactId> + <version>18</version> + <scope>system</scope> + <systemPath>/Users/ApigeeCorporation/Desktop/adt-bundle-mac/sdk/platforms/android-18/android.jar</systemPath> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> + </dependencies> + <properties> + <android-api-version>18</android-api-version> + <maven-compiler-plugin-version>1.6</maven-compiler-plugin-version> + <jackson-version>2.2.3</jackson-version> + <apache-http-version>4.1.2</apache-http-version> + <maven-shade-plugin-version>2.1</maven-shade-plugin-version> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <junit-version>3.8.1</junit-version> + <android.libs>/Users/ApigeeCorporation/Desktop/adt-bundle-mac/sdk/platforms/android-18</android.libs> + </properties> +</project> + http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21b60593/sdks/android/dist/jackson-core-asl-1.9.1.jar ---------------------------------------------------------------------- diff --git a/sdks/android/dist/jackson-core-asl-1.9.1.jar b/sdks/android/dist/jackson-core-asl-1.9.1.jar new file mode 100644 index 0000000..1f47861 Binary files /dev/null and b/sdks/android/dist/jackson-core-asl-1.9.1.jar differ http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21b60593/sdks/android/dist/jackson-mapper-asl-1.9.1.jar ---------------------------------------------------------------------- diff --git a/sdks/android/dist/jackson-mapper-asl-1.9.1.jar b/sdks/android/dist/jackson-mapper-asl-1.9.1.jar new file mode 100644 index 0000000..959d8c4 Binary files /dev/null and b/sdks/android/dist/jackson-mapper-asl-1.9.1.jar differ http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21b60593/sdks/android/dist/spring-android-core-1.0.0.M4.jar ---------------------------------------------------------------------- diff --git a/sdks/android/dist/spring-android-core-1.0.0.M4.jar b/sdks/android/dist/spring-android-core-1.0.0.M4.jar new file mode 100644 index 0000000..dc9444e Binary files /dev/null and b/sdks/android/dist/spring-android-core-1.0.0.M4.jar differ http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21b60593/sdks/android/dist/spring-android-rest-template-1.0.0.M4.jar ---------------------------------------------------------------------- diff --git a/sdks/android/dist/spring-android-rest-template-1.0.0.M4.jar b/sdks/android/dist/spring-android-rest-template-1.0.0.M4.jar new file mode 100644 index 0000000..069d511 Binary files /dev/null and b/sdks/android/dist/spring-android-rest-template-1.0.0.M4.jar differ http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21b60593/sdks/android/m2/repository/org/usergrid/usergrid-java-client/0.0.6/usergrid-java-client-0.0.6.jar ---------------------------------------------------------------------- diff --git a/sdks/android/m2/repository/org/usergrid/usergrid-java-client/0.0.6/usergrid-java-client-0.0.6.jar b/sdks/android/m2/repository/org/usergrid/usergrid-java-client/0.0.6/usergrid-java-client-0.0.6.jar new file mode 100644 index 0000000..fe979a1 Binary files /dev/null and b/sdks/android/m2/repository/org/usergrid/usergrid-java-client/0.0.6/usergrid-java-client-0.0.6.jar differ http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21b60593/sdks/android/m2/repository/org/usergrid/usergrid-java-client/0.0.6/usergrid-java-client-0.0.6.jar.sha1 ---------------------------------------------------------------------- diff --git a/sdks/android/m2/repository/org/usergrid/usergrid-java-client/0.0.6/usergrid-java-client-0.0.6.jar.sha1 b/sdks/android/m2/repository/org/usergrid/usergrid-java-client/0.0.6/usergrid-java-client-0.0.6.jar.sha1 new file mode 100644 index 0000000..c20c1e2 --- /dev/null +++ b/sdks/android/m2/repository/org/usergrid/usergrid-java-client/0.0.6/usergrid-java-client-0.0.6.jar.sha1 @@ -0,0 +1 @@ +bb9caaeca9317dca02df039a21dd55b46d165eb4 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21b60593/sdks/android/m2/repository/org/usergrid/usergrid-java-client/0.0.6/usergrid-java-client-0.0.6.pom ---------------------------------------------------------------------- diff --git a/sdks/android/m2/repository/org/usergrid/usergrid-java-client/0.0.6/usergrid-java-client-0.0.6.pom b/sdks/android/m2/repository/org/usergrid/usergrid-java-client/0.0.6/usergrid-java-client-0.0.6.pom new file mode 100644 index 0000000..78993bb --- /dev/null +++ b/sdks/android/m2/repository/org/usergrid/usergrid-java-client/0.0.6/usergrid-java-client-0.0.6.pom @@ -0,0 +1,95 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <bundle.symbolicName>org.usergrid</bundle.symbolicName> + <bundle.namespace>org.usergrid</bundle.namespace> + <spring-java-version>1.0.1.RELEASE</spring-java-version> + <jackson-version>2.1.1</jackson-version> + </properties> + + <parent> + <groupId>org.sonatype.oss</groupId> + <artifactId>oss-parent</artifactId> + <version>7</version> + </parent> + + <modelVersion>4.0.0</modelVersion> + <groupId>org.usergrid</groupId> + <artifactId>usergrid-java-client</artifactId> + <version>0.0.6</version> + <packaging>jar</packaging> + <description>A simple java client for usergrid</description> + <url>https://github.com/apigee/usergrid-stack-internal</url> + + <licenses> + <license> + <name>The Apache Software License, Version 2.0</name> + <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> + <distribution>repo</distribution> + </license> + </licenses> + + <developers> + <developer> + <id>eanuff</id> + <name>Ed Anuff</name> + </developer> + <developer> + <id>tnine</id> + <name>Todd Nine</name> + </developer> + <developer> + <id>sganyo</id> + <name>Scott Ganyo</name> + </developer> + </developers> + <dependencies> + <!-- <dependency> <groupId>com.google.android</groupId> <artifactId>android</artifactId> + <version>2.2.1</version> <scope>provided</scope> </dependency> --> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-core</artifactId> + <version>${jackson-version}</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-annotations</artifactId> + <version>${jackson-version}</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + <version>${jackson-version}</version> + </dependency> + <dependency> + <groupId>org.springframework.android</groupId> + <artifactId>spring-android-rest-template</artifactId> + <version>${spring-java-version}</version> + </dependency> + <dependency> + <groupId>org.springframework.android</groupId> + <artifactId>spring-android-core</artifactId> + <version>${spring-java-version}</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>1.6.4</version> + </dependency> + </dependencies> + <repositories> + <repository> + <snapshots> + <enabled>false</enabled> + </snapshots> + <id>springsource-milestone</id> + <name>Spring Framework Milestone Repository</name> + <url>http://maven.springframework.org/milestone</url> + </repository> + </repositories> + <scm> + <connection>scm:git:[email protected]:apigee/usergrid-java-sdk.git</connection> + <developerConnection>scm:git:[email protected]:apigee/usergrid-java-sdk.git</developerConnection> + <url>[email protected]:apigee/usergrid-java-sdk.git</url> + </scm> +</project> http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21b60593/sdks/android/m2/repository/org/usergrid/usergrid-java-client/0.0.6/usergrid-java-client-0.0.6.pom.sha1 ---------------------------------------------------------------------- diff --git a/sdks/android/m2/repository/org/usergrid/usergrid-java-client/0.0.6/usergrid-java-client-0.0.6.pom.sha1 b/sdks/android/m2/repository/org/usergrid/usergrid-java-client/0.0.6/usergrid-java-client-0.0.6.pom.sha1 new file mode 100644 index 0000000..38a32d9 --- /dev/null +++ b/sdks/android/m2/repository/org/usergrid/usergrid-java-client/0.0.6/usergrid-java-client-0.0.6.pom.sha1 @@ -0,0 +1 @@ +b3b97c25a37250b2cd01925f430d9e785abef652 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21b60593/sdks/android/m2/repository/org/usergrid/usergrid-java-client/maven-metadata-local.xml ---------------------------------------------------------------------- diff --git a/sdks/android/m2/repository/org/usergrid/usergrid-java-client/maven-metadata-local.xml b/sdks/android/m2/repository/org/usergrid/usergrid-java-client/maven-metadata-local.xml new file mode 100644 index 0000000..456be57 --- /dev/null +++ b/sdks/android/m2/repository/org/usergrid/usergrid-java-client/maven-metadata-local.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<metadata> + <groupId>org.usergrid</groupId> + <artifactId>usergrid-java-client</artifactId> + <versioning> + <release>0.0.6</release> + <versions> + <version>0.0.6</version> + </versions> + <lastUpdated>20140207142624</lastUpdated> + </versioning> +</metadata> http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21b60593/sdks/android/pom.xml ---------------------------------------------------------------------- diff --git a/sdks/android/pom.xml b/sdks/android/pom.xml index 2802a03..f3bf61e 100644 --- a/sdks/android/pom.xml +++ b/sdks/android/pom.xml @@ -1,21 +1,3 @@ -<!-- -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> @@ -24,20 +6,19 @@ </properties> <parent> - <groupId>org.apache.usergrid</groupId> - <artifactId>usergrid</artifactId> - <version>1.0.0</version> - <relativePath>../../stack</relativePath> + <groupId>org.sonatype.oss</groupId> + <artifactId>oss-parent</artifactId> + <version>7</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>org.apache.usergrid</groupId> - <artifactId>usergrid-android-client</artifactId> - <version>0.0.8-SNAPSHOT</version> + <artifactId>usergrid-android</artifactId> + <version>0.0.8</version> <packaging>jar</packaging> - <description>An Android client for usergrid</description> - <url>http://usergrid.incubator.apache.org</url> + <description>A simple java client for usergrid</description> + <url>https://github.com/apigee/usergrid-stack-internal</url> <licenses> <license> @@ -61,6 +42,11 @@ <name>Scott Ganyo</name> </developer> </developers> + <scm> + <connection>scm:git:[email protected]:apigee/usergrid-android-sdk.git</connection> + <developerConnection>scm:git:[email protected]:apigee/usergrid-android-sdk.git</developerConnection> + <url>[email protected]:apigee/usergrid-android-sdk.git</url> + </scm> <build> <plugins> @@ -96,13 +82,4 @@ <url>file://${project.basedir}/m2/repository</url> </repository> </repositories> - <name>Apache Usergrid Android SDK</name> - <issueManagement> - <system>JIRA</system> - <url>https://issues.apache.org/jira/browse/USERGRID</url> - </issueManagement> - <organization> - <name>The Apache Software Foundation</name> - <url>http://apache.org</url> - </organization> </project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21b60593/sdks/android/src/main/java/org/apache/usergrid/android/client/Client.java ---------------------------------------------------------------------- diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/client/Client.java b/sdks/android/src/main/java/org/apache/usergrid/android/client/Client.java deleted file mode 100644 index c2e874a..0000000 --- a/sdks/android/src/main/java/org/apache/usergrid/android/client/Client.java +++ /dev/null @@ -1,1036 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.usergrid.android.client; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; -import java.util.ArrayList; - -import org.springframework.http.HttpMethod; -import org.springframework.web.client.RestTemplate; -import org.apache.usergrid.android.client.callbacks.ApiResponseCallback; -import org.apache.usergrid.android.client.callbacks.ClientAsyncTask; -import org.apache.usergrid.android.client.callbacks.DeviceRegistrationCallback; -import org.apache.usergrid.android.client.callbacks.GroupsRetrievedCallback; -import org.apache.usergrid.android.client.callbacks.QueryResultsCallback; -import org.usergrid.java.client.entities.Device; -import org.usergrid.java.client.entities.Entity; -import org.usergrid.java.client.entities.Group; -import org.usergrid.java.client.entities.User; -import org.usergrid.java.client.response.ApiResponse; -import org.apache.usergrid.android.client.utils.DeviceUuidFactory; - -import android.content.Context; -import android.location.Location; -import android.util.Log; - -/** - * The Client class for accessing the Usergrid API. Start by instantiating this - * class though the appropriate constructor. - * - */ -public class Client extends org.usergrid.java.client.Client { - - - /** - * Default tag applied to all logging messages sent from an instance of Client - */ - public static final String LOGGING_TAG = "UsergridClient"; - - private static final String TAG = "UsergridClient"; - - public static boolean FORCE_PUBLIC_API = false; - - // Public API - public static String PUBLIC_API_URL = "http://api.usergrid.com"; - - // Local API of standalone server - public static String LOCAL_STANDALONE_API_URL = "http://localhost:8080"; - - // Local API of Tomcat server in Eclipse - public static String LOCAL_TOMCAT_API_URL = "http://localhost:8080/ROOT"; - - // Local API - public static String LOCAL_API_URL = LOCAL_STANDALONE_API_URL; - - /** - * Standard HTTP methods use in generic request methods - * @see apiRequest - * @see doHttpRequest - */ - protected static final HttpMethod HTTP_METHOD_DELETE = HttpMethod.DELETE; - - /** - * Standard HTTP methods use in generic request methods - * @see apiRequest - * @see doHttpRequest - */ - protected static final HttpMethod HTTP_METHOD_GET = HttpMethod.GET; - - /** - * Standard HTTP methods use in generic request methods - * @see apiRequest - * @see doHttpRequest - */ - protected static final HttpMethod HTTP_METHOD_POST = HttpMethod.POST; - - /** - * Standard HTTP methods use in generic request methods - * @see apiRequest - * @see doHttpRequest - */ - protected static final HttpMethod HTTP_METHOD_PUT = HttpMethod.PUT; - - private String organizationId; - private String applicationId; - private String clientId; - private String clientSecret; - - static RestTemplate restTemplate = new RestTemplate(true); - - /** - * Default constructor for instantiating a client. - */ - public Client() { - init(); - } - - /** - * Instantiate client for a specific app - * - * @param applicationId - * the application id or name - */ - public Client(String organizationId, String applicationId) { - super(organizationId, applicationId); - this.organizationId = organizationId; - this.applicationId = applicationId; - } - - /** - * Logs a trace-level logging message with tag 'UsergridClient' - * - * @param logMessage the message to log - */ - public void logTrace(String logMessage) { - if(logMessage != null) { - Log.v(LOGGING_TAG,logMessage); - } - } - - /** - * Logs a debug-level logging message with tag 'UsergridClient' - * - * @param logMessage the message to log - */ - public void logDebug(String logMessage) { - if(logMessage != null) { - Log.d(LOGGING_TAG,logMessage); - } - } - - /** - * Logs an info-level logging message with tag 'UsergridClient' - * - * @param logMessage the message to log - */ - public void logInfo(String logMessage) { - if(logMessage != null) { - Log.i(LOGGING_TAG,logMessage); - } - } - - /** - * Logs a warn-level logging message with tag 'UsergridClient' - * - * @param logMessage the message to log - */ - public void logWarn(String logMessage) { - if(logMessage != null) { - Log.w(LOGGING_TAG,logMessage); - } - } - - /** - * Logs an error-level logging message with tag 'UsergridClient' - * - * @param logMessage the message to log - */ - public void logError(String logMessage) { - if(logMessage != null) { - Log.e(LOGGING_TAG,logMessage); - } - } - - /** - * Logs a debug-level logging message with tag 'UsergridClient' - * - * @param logMessage the message to log - */ - public void writeLog(String logMessage) { - //TODO: do we support different log levels in this class? - Log.d(LOGGING_TAG, logMessage); - } - - public static boolean isEmpty(Object s) { - if (s == null) { - return true; - } - if ((s instanceof String) && (((String) s).trim().length() == 0)) { - return true; - } - if (s instanceof Map) { - return ((Map<?, ?>) s).isEmpty(); - } - return false; - } - - /** - * Log the user in and get a valid access token. Executes asynchronously in - * background and the callbacks are called in the UI thread. - * - * @param email - * @param password - * @param callback - */ - public void authorizeAppUserAsync(final String email, - final String password, final ApiResponseCallback callback) { - (new ClientAsyncTask<ApiResponse>(callback) { - @Override - public ApiResponse doTask() { - return authorizeAppUser(email, password); - } - }).execute(); - } - - - - /** - * Log the user in with their numeric pin-code and get a valid access token. - * Executes asynchronously in background and the callbacks are called in the - * UI thread. - * - * @param email - * @param pin - * @param callback - */ - public void authorizeAppUserViaPinAsync(final String email, - final String pin, final ApiResponseCallback callback) { - (new ClientAsyncTask<ApiResponse>(callback) { - @Override - public ApiResponse doTask() { - return authorizeAppUserViaPin(email, pin); - } - }).execute(); - } - - - /** - * Log the user in with their numeric pin-code and get a valid access token. - * Executes asynchronously in background and the callbacks are called in the - * UI thread. - * - * @param email - * @param pin - * @param callback - */ - public void authorizeAppUserViaFacebookAsync(final String fb_access_token, - final ApiResponseCallback callback) { - (new ClientAsyncTask<ApiResponse>(callback) { - @Override - public ApiResponse doTask() { - return authorizeAppUserViaFacebook(fb_access_token); - } - }).execute(); - } - - - - /** - * Log the app in with it's client id and client secret key. Not recommended - * for production apps. Executes asynchronously in background and the - * callbacks are called in the UI thread. - * - * @param clientId - * @param clientSecret - * @param callback - */ - public void authorizeAppClientAsync(final String clientId, - final String clientSecret, final ApiResponseCallback callback) { - (new ClientAsyncTask<ApiResponse>(callback) { - - @Override - public ApiResponse doTask() { - return authorizeAppClient(clientId, clientSecret); - } - }).execute(); - } - - /** - * Log out a user and destroy the access token currently stored in DataClient - * on the server and in the DataClient. - * - * @param username The username to be logged out - * @return non-null ApiResponse if request succeeds - */ - public ApiResponse logOutAppUser(String username) { - String token = getAccessToken(); - Map<String,Object> params = new HashMap<String,Object>(); - params.put("token",token); - ApiResponse response = apiRequest(HTTP_METHOD_PUT, params, null, - organizationId, applicationId, "users",username,"revoketoken?"); - if (response == null) { - return response; - } else { - logInfo("logoutAppUser(): Response: " + response); - setAccessToken(null); - } - return response; - } - - /** - * Log out a user and destroy the access token currently stored in DataClient - * on the server and in the DataClient. - * Executes asynchronously in background and the callbacks are called in the - * UI thread. - * - * @param username The username to be logged out - * @param callback an ApiResponseCallback to handle the async response - */ - public void logOutAppUserAsync(final String username, final ApiResponseCallback callback) { - (new ClientAsyncTask<ApiResponse>(callback) { - @Override - public ApiResponse doTask() { - return logOutAppUser(username); - } - }).execute(); - } - - /** - * Destroy a specific user token on the server. The token will also be cleared - * from the DataClient instance, if it matches the token provided. - * - * @param username The username to be logged out - * @param token The access token to be destroyed on the server - * @return non-null ApiResponse if request succeeds - */ - public ApiResponse logOutAppUserForToken(String username, String token) { - Map<String,Object> params = new HashMap<String,Object>(); - params.put("token",token); - ApiResponse response = apiRequest(HTTP_METHOD_PUT, params, null, - organizationId, applicationId, "users",username,"revoketoken?"); - if (response == null) { - return response; - } else { - logInfo("logoutAppWithTokenUser(): Response: " + response); - if (token.equals(getAccessToken())) { - setAccessToken(null); - } - } - return response; - } - - /** - * Destroy a specific user token on the server. The token will also be cleared - * from the DataClient instance, if it matches the token provided. - * Executes asynchronously in background and the callbacks are called in the UI thread. - * - * @param username The username to be logged out - * @param token The access token to be destroyed on the server - * @param callback A callback for the async response - */ - public void logOutAppUserForTokenAsync(final String username, final String token, final ApiResponseCallback callback) { - (new ClientAsyncTask<ApiResponse>(callback) { - @Override - public ApiResponse doTask() { - return logOutAppUserForToken(username, token); - } - }).execute(); - } - - /** - * Log out a user and destroy all associated tokens on the server. - * The token stored in DataClient will also be destroyed. - * - * @param username The username to be logged out - * @return non-null ApiResponse if request succeeds - */ - public ApiResponse logOutAppUserForAllTokens(String username) { - ApiResponse response = apiRequest(HTTP_METHOD_PUT, null, null, - organizationId, applicationId, "users",username,"revoketokens"); - if (response == null) { - return response; - } else { - logInfo("logoutAppUserForAllTokens(): Response: " + response); - setAccessToken(null); - } - return response; - } - - /** - * Log out a user and destroy all associated tokens on the server. - * The token stored in DataClient will also be destroyed. - * Executes asynchronously in background and the callbacks are called in the UI thread. - * - * @param username The username to be logged out - * @param callback A callback for the response - */ - public void logOutAppUserForAllTokensAsync(final String username, final ApiResponseCallback callback) { - (new ClientAsyncTask<ApiResponse>(callback) { - @Override - public ApiResponse doTask() { - return logOutAppUserForAllTokens(username); - } - }).execute(); - } - - /** - * Registers a device using the device's unique device ID. Executes - * asynchronously in background and the callbacks are called in the UI - * thread. - * - * @param context - * @param properties - * @param callback - */ - public void registerDeviceAsync(final Context context, - final Map<String, Object> properties, - final DeviceRegistrationCallback callback) { - (new ClientAsyncTask<Device>(callback) { - @Override - public Device doTask() { - UUID deviceId = new DeviceUuidFactory(context).getDeviceUuid(); - - return registerDevice(deviceId, properties); - } - }).execute(); - } - - - /** - * Registers a device using the device's unique device ID. Executes - * asynchronously in background and the callbacks are called in the UI - * thread. - * - * @param context - * @param properties - * @param callback - */ - public void registerDeviceForPushAsync(final Context context, - final String notifier, - final String token, - final Map<String, Object> properties, - final DeviceRegistrationCallback callback) { - (new ClientAsyncTask<Device>(callback) { - @Override - public Device doTask() { - UUID deviceId = new DeviceUuidFactory(context).getDeviceUuid(); - - return registerDeviceForPush(deviceId, notifier, token, properties); - } - }).execute(); - } - - /** - * Requests all entities of specified type that match the provided query string. - * - * @param type the entity type to be retrieved - * @param queryString a query string to send with the request - * @return a non-null ApiResponse object if successful - */ - public ApiResponse getEntities(String type,String queryString) - { - Map<String, Object> params = null; - - if (queryString.length() > 0) { - params = new HashMap<String, Object>(); - params.put("ql", queryString); - } - - return apiRequest(HTTP_METHOD_GET, // method - params, // params - null, // data - organizationId, - applicationId, - type); - } - - /** - * Asynchronously requests all entities of specified type that match the provided query string. - * - * @param type the entity type to be retrieved - * @param queryString a query string to send with the request - * @param callback an ApiResponseCallback to handle the async response - */ - public void getEntitiesAsync(final String type, - final String queryString, final ApiResponseCallback callback) { - (new ClientAsyncTask<ApiResponse>(callback) { - @Override - public ApiResponse doTask() { - return getEntities(type, queryString); - } - }).execute(); - } - - /** - * Create a new entity on the server. Executes asynchronously in background - * and the callbacks are called in the UI thread. - * - * @param entity - * @param callback - */ - public void createEntityAsync(final Entity entity, - final ApiResponseCallback callback) { - (new ClientAsyncTask<ApiResponse>(callback) { - @Override - public ApiResponse doTask() { - return createEntity(entity); - } - }).execute(); - } - - - /** - * Create a new entity on the server from a set of properties. Properties - * must include a "type" property. Executes asynchronously in background and - * the callbacks are called in the UI thread. - * - * @param properties - * @param callback - */ - public void createEntityAsync(final Map<String, Object> properties, - final ApiResponseCallback callback) { - (new ClientAsyncTask<ApiResponse>(callback) { - @Override - public ApiResponse doTask() { - return createEntity(properties); - } - }).execute(); - } - - /** - * Create a set of entities on the server from an ArrayList. Each item in the array - * contains a set of properties that define a entity. - * - * @param type The type of entities to create. - * @param entities A list of maps where keys are entity property names and values - * are property values. - * @return An instance with response data from the server. - */ - public ApiResponse createEntities(String type, ArrayList<Map<String, Object>> entities) { - assertValidApplicationId(); - if (isEmpty(type)) { - throw new IllegalArgumentException("Missing entity type"); - } - ApiResponse response = apiRequest(HTTP_METHOD_POST, null, entities, - organizationId, applicationId, type); - return response; - } - - /** - * Create a set of entities on the server from an ArrayList. Each item in the array - * contains a set of properties that define a entity. Executes asynchronously in - * background and the callbacks are called in the UI thread. - * - * @param type The type of entities to create. - * @param entities A list of maps where keys are entity property names and values - * are property values. - * @param callback A callback for the async response - */ - public void createEntitiesAsync(final String type, final ArrayList<Map<String, Object>> entities, - final ApiResponseCallback callback) { - (new ClientAsyncTask<ApiResponse>(callback) { - @Override - public ApiResponse doTask() { - return createEntities(type, entities); - } - }).execute(); - } - - /** - * Creates a user. Executes asynchronously in background and the callbacks - * are called in the UI thread. - * - * @param username - * @param name - * @param email - * @param password - * @param callback - */ - public void createUserAsync(final String username, final String name, - final String email, final String password, - final ApiResponseCallback callback) { - (new ClientAsyncTask<ApiResponse>(callback) { - @Override - public ApiResponse doTask() { - return createUser(username, name, email, password); - } - }).execute(); - } - - - - /** - * Get the groups for the user. Executes asynchronously in background and - * the callbacks are called in the UI thread. - * - * @param userId - * @param callback - */ - public void getGroupsForUserAsync(final String userId, - final GroupsRetrievedCallback callback) { - (new ClientAsyncTask<Map<String, Group>>(callback) { - @Override - public Map<String, Group> doTask() { - return getGroupsForUser(userId); - } - }).execute(); - } - - /** - * Get a user's activity feed. Returned as a query to ease paging. Executes - * asynchronously in background and the callbacks are called in the UI - * thread. - * - * - * @param userId - * @param callback - */ - public void queryActivityFeedForUserAsync(final String userId, final QueryResultsCallback callback) { - (new ClientAsyncTask<Query>(callback) { - @Override - public Query doTask() { - return queryActivityFeedForUser(userId); - } - }).execute(); - } - - - /** - * Creates and posts an activity to a user. Executes asynchronously in - * background and the callbacks are called in the UI thread. - * - * @param verb - * @param title - * @param content - * @param category - * @param user - * @param object - * @param objectType - * @param objectName - * @param objectContent - * @param callback - */ - public void postUserActivityAsync(final String verb, final String title, - final String content, final String category, final User user, - final Entity object, final String objectType, - final String objectName, final String objectContent, - final ApiResponseCallback callback) { - (new ClientAsyncTask<ApiResponse>(callback) { - @Override - public ApiResponse doTask() { - return postUserActivity(verb, title, content, category, user, - object, objectType, objectName, objectContent); - } - }).execute(); - } - - - /** - * Creates and posts an activity to a group. Executes asynchronously in - * background and the callbacks are called in the UI thread. - * - * @param groupId - * @param verb - * @param title - * @param content - * @param category - * @param user - * @param object - * @param objectType - * @param objectName - * @param objectContent - * @param callback - */ - public void postGroupActivityAsync(final String groupId, final String verb, final String title, - final String content, final String category, final User user, - final Entity object, final String objectType, - final String objectName, final String objectContent, - final ApiResponseCallback callback) { - (new ClientAsyncTask<ApiResponse>(callback) { - @Override - public ApiResponse doTask() { - return postGroupActivity(groupId, verb, title, content, category, user, - object, objectType, objectName, objectContent); - } - }).execute(); - } - - - /** - * Get a group's activity feed. Returned as a query to ease paging. Executes - * asynchronously in background and the callbacks are called in the UI - * thread. - * - * - * @param userId - * @param callback - */ - public void queryActivityFeedForGroupAsync(final String groupId, - final QueryResultsCallback callback) { - (new ClientAsyncTask<Query>(callback) { - @Override - public Query doTask() { - return queryActivityFeedForGroup(groupId); - } - }).execute(); - } - - - /** - * Perform a query request and return a query object. The Query object - * provides a simple way of dealing with result sets that need to be - * iterated or paged through. Executes asynchronously in background and the - * callbacks are called in the UI thread. - * - * @param callback - * @param method - * @param params - * @param data - * @param segments - */ - public void queryEntitiesRequestAsync(final QueryResultsCallback callback, - final HttpMethod method, final Map<String, Object> params, - final Object data, final String... segments) { - (new ClientAsyncTask<Query>(callback) { - @Override - public Query doTask() { - return queryEntitiesRequest(method, params, data, segments); - } - }).execute(); - } - - - /** - * Perform a query of the users collection. Executes asynchronously in - * background and the callbacks are called in the UI thread. - * - * @param callback - */ - public void queryUsersAsync(QueryResultsCallback callback) { - queryEntitiesRequestAsync(callback, HttpMethod.GET, null, null, - organizationId, applicationId, "users"); - } - - /** - * Perform a query of the users collection using the provided query command. - * For example: "name contains 'ed'". Executes asynchronously in background - * and the callbacks are called in the UI thread. - * - * @param ql - * @param callback - */ - public void queryUsersAsync(String ql, QueryResultsCallback callback) { - Map<String, Object> params = new HashMap<String, Object>(); - params.put("ql", ql); - queryEntitiesRequestAsync(callback, HttpMethod.GET, params, null, - organizationId, applicationId, "users"); - } - - - /** - * Queries the users for the specified group. Executes asynchronously in - * background and the callbacks are called in the UI thread. - * - * @param groupId - * @param callback - */ - public void queryUsersForGroupAsync(String groupId, - QueryResultsCallback callback) { - queryEntitiesRequestAsync(callback, HttpMethod.GET, null, null, - applicationId, "groups", groupId, "users"); - } - - /** - * Adds a user to the specified groups. Executes asynchronously in - * background and the callbacks are called in the UI thread. - * - * @param userId - * @param groupId - * @param callback - */ - public void addUserToGroupAsync(final String userId, final String groupId, - final ApiResponseCallback callback) { - (new ClientAsyncTask<ApiResponse>(callback) { - @Override - public ApiResponse doTask() { - return addUserToGroup(userId, groupId); - } - }).execute(); - } - - - /** - * Creates a group with the specified group path. Group paths can be slash - * ("/") delimited like file paths for hierarchical group relationships. - * Executes asynchronously in background and the callbacks are called in the - * UI thread. - * - * @param groupPath - * @param callback - */ - public void createGroupAsync(String groupPath, - final ApiResponseCallback callback) { - createGroupAsync(groupPath, null); - } - - - - /** - * Creates a group with the specified group path and group title. Group - * paths can be slash ("/") deliminted like file paths for hierarchical - * group relationships. Executes asynchronously in background and the - * callbacks are called in the UI thread. - * - * @param groupPath - * @param groupTitle - * @param callback - */ - public void createGroupAsync(final String groupPath, - final String groupTitle, final ApiResponseCallback callback) { - (new ClientAsyncTask<ApiResponse>(callback) { - @Override - public ApiResponse doTask() { - return createGroup(groupPath, groupTitle); - } - }).execute(); - } - - /** - * Connect two entities together. - * - * @param connectingEntityType The type of the first entity. - * @param connectingEntityId The ID of the first entity. - * @param connectionType The type of connection between the entities. - * @param connectedEntityId The ID of the second entity. - * @return An instance with the server's response. - */ - public ApiResponse connectEntities(String connectingEntityType, - String connectingEntityId, String connectionType, - String connectedEntityId) { - return apiRequest(HTTP_METHOD_POST, null, null, organizationId, applicationId, - connectingEntityType, connectingEntityId, connectionType, - connectedEntityId); - } - - /** - * Connect two entities together - * - * @param connectorType The type of the first entity in the connection. - * @param connectorID The first entity's ID. - * @param connectionType The type of connection to make. - * @param connecteeType The type of the second entity. - * @param connecteeID The second entity's ID - * @return An instance with the server's response. - */ - public ApiResponse connectEntities(String connectorType, - String connectorID, - String connectionType, - String connecteeType, - String connecteeID) { - return apiRequest(HTTP_METHOD_POST, null, null, organizationId, applicationId, - connectorType, connectorID, connectionType, connecteeType, connecteeID); - } - - /** - * Connect two entities together. Executes asynchronously in background and - * the callbacks are called in the UI thread. - * - * @param connectingEntityType - * @param connectingEntityId - * @param connectionType - * @param connectedEntityId - * @param callback - */ - public void connectEntitiesAsync(final String connectingEntityType, - final String connectingEntityId, final String connectionType, - final String connectedEntityId, final ApiResponseCallback callback) { - (new ClientAsyncTask<ApiResponse>(callback) { - @Override - public ApiResponse doTask() { - return connectEntities(connectingEntityType, - connectingEntityId, connectionType, connectedEntityId); - } - }).execute(); - } - - /** - * Connect two entities together. Allows the 'name' of the connected entity - * to be specified but requires the type also be specified. Executes asynchronously - * in background and the callbacks are called in the UI thread. - * - * @param connectingEntityType The type of the first entity. - * @param connectingEntityId The UUID or 'name' property of the first entity. - * @param connectionType The type of connection between the entities. - * @param connectedEntityType The type of connection between the entities. - * @param connectedEntityId The UUID or 'name' property of the second entity. - * @param callback A callback with the async response. - */ - public void connectEntitiesAsync(final String connectingEntityType, - final String connectingEntityId, final String connectionType, - final String connectedEntityType, final String connectedEntityId, - final ApiResponseCallback callback) { - (new ClientAsyncTask<ApiResponse>(callback) { - @Override - public ApiResponse doTask() { - return connectEntities(connectingEntityType, - connectingEntityId, connectionType, connectedEntityType, connectedEntityId); - } - }).execute(); - } - - /** - * Disconnect two entities. - * - * @param connectingEntityType The collection name or UUID of the first entity. - * @param connectingEntityId The name or UUID of the first entity. - * @param connectionType The type of connection between the entities. - * @param connectedEntityId The name or UUID of the second entity. - * @return An instance with the server's response. - */ - public ApiResponse disconnectEntities(String connectingEntityType, - String connectingEntityId, String connectionType, - String connectedEntityId) { - return apiRequest(HTTP_METHOD_DELETE, null, null, organizationId, applicationId, - connectingEntityType, connectingEntityId, connectionType, - connectedEntityId); - } - - /** - * Disconnect two entities. Executes asynchronously in background and the - * callbacks are called in the UI thread. - * - * @param connectingEntityType - * @param connectingEntityId - * @param connectionType - * @param connectedEntityId - * @param callback - */ - public void disconnectEntitiesAsync(final String connectingEntityType, - final String connectingEntityId, final String connectionType, - final String connectedEntityId, final ApiResponseCallback callback) { - (new ClientAsyncTask<ApiResponse>(callback) { - @Override - public ApiResponse doTask() { - return disconnectEntities(connectingEntityType, - connectingEntityId, connectionType, connectedEntityId); - } - }).execute(); - } - - /** - * Disconnect two entities. - * - * @param connectingEntityType The collection name or UUID of the first entity. - * @param connectingEntityId The name or UUID of the first entity. - * @param connectionType The type of connection between the entities. - * @param connectedEntityType The collection name or UUID of the second entity. - * @param connectedEntityId The name or UUID of the second entity. - * @return An instance with the server's response. - */ - public ApiResponse disconnectEntities(String connectingEntityType, - String connectingEntityId, String connectionType, - String connectedEntityType, String connectedEntityId) { - return apiRequest(HTTP_METHOD_DELETE, null, null, organizationId, applicationId, - connectingEntityType, connectingEntityId, connectionType, - connectedEntityType, connectedEntityId); - } - - /** - * Disconnect two entities. Executes asynchronously in background and the - * callbacks are called in the UI thread. - * - * @param connectingEntityType The collection name or UUID of the first entity. - * @param connectingEntityId The name or UUID of the first entity. - * @param connectionType The type of connection between the entities. - * @param connectedEntityType The collection name or UUID of the second entity. - * @param connectedEntityId The name or UUID of the second entity. - * @param callback A callback with the async response. - */ - public void disconnectEntitiesAsync(final String connectingEntityType, - final String connectingEntityId, final String connectionType, - final String connectedEntityType, final String connectedEntityId, - final ApiResponseCallback callback) { - (new ClientAsyncTask<ApiResponse>(callback) { - @Override - public ApiResponse doTask() { - return disconnectEntities(connectingEntityType, - connectingEntityId, connectionType, connectedEntityType, connectedEntityId); - } - }).execute(); - } - - /** - * Query the connected entities. Executes asynchronously in background and - * the callbacks are called in the UI thread. - * - * @param connectingEntityType - * @param connectingEntityId - * @param connectionType - * @param ql - * @param callback - */ - public void queryEntityConnectionsAsync(String connectingEntityType, - String connectingEntityId, String connectionType, String ql, - QueryResultsCallback callback) { - Map<String, Object> params = new HashMap<String, Object>(); - params.put("ql", ql); - queryEntitiesRequestAsync(callback, HttpMethod.GET, params, null, - organizationId, applicationId, connectingEntityType, connectingEntityId, - connectionType); - } - - - /** - * Query the connected entities within distance of a specific point. . - * Executes asynchronously in background and the callbacks are called in the - * UI thread. - * - * @param connectingEntityType - * @param connectingEntityId - * @param connectionType - * @param distance - * @param latitude - * @param longitude - * @param callback - */ - public void queryEntityConnectionsWithinLocationAsync( - String connectingEntityType, String connectingEntityId, - String connectionType, float distance, Location location, - String ql, QueryResultsCallback callback) { - Map<String, Object> params = new HashMap<String, Object>(); - params.put("ql", makeLocationQL(distance, location.getLatitude(), location.getLongitude(), ql)); - params.put("ql", ql); - queryEntitiesRequestAsync(callback, HttpMethod.GET, params, null, - organizationId, applicationId, connectingEntityType, connectingEntityId, - connectionType); - } - - - -} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21b60593/sdks/android/src/main/java/org/apache/usergrid/android/client/callbacks/ApiResponseCallback.java ---------------------------------------------------------------------- diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/client/callbacks/ApiResponseCallback.java b/sdks/android/src/main/java/org/apache/usergrid/android/client/callbacks/ApiResponseCallback.java deleted file mode 100644 index 19c256f..0000000 --- a/sdks/android/src/main/java/org/apache/usergrid/android/client/callbacks/ApiResponseCallback.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.usergrid.android.client.callbacks; - -import org.usergrid.java.client.response.ApiResponse; - - -public interface ApiResponseCallback extends ClientCallback<ApiResponse> { - - public void onResponse(ApiResponse response); - -} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21b60593/sdks/android/src/main/java/org/apache/usergrid/android/client/callbacks/ClientAsyncTask.java ---------------------------------------------------------------------- diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/client/callbacks/ClientAsyncTask.java b/sdks/android/src/main/java/org/apache/usergrid/android/client/callbacks/ClientAsyncTask.java deleted file mode 100644 index 2ad074e..0000000 --- a/sdks/android/src/main/java/org/apache/usergrid/android/client/callbacks/ClientAsyncTask.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.usergrid.android.client.callbacks; - -import android.os.AsyncTask; - -public abstract class ClientAsyncTask<T> extends AsyncTask<Void, Exception, T> { - - ClientCallback<T> callback; - - public ClientAsyncTask(ClientCallback<T> callback) { - this.callback = callback; - } - - @Override - protected T doInBackground(Void... v) { - try { - return doTask(); - } catch (Exception e) { - this.publishProgress(e); - } - return null; - } - - public abstract T doTask(); - - @Override - protected void onPostExecute(T response) { - if (callback != null) { - callback.onResponse(response); - } - } - - @Override - protected void onProgressUpdate(Exception... e) { - if ((callback != null) && (e != null) && (e.length > 0)) { - callback.onException(e[0]); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21b60593/sdks/android/src/main/java/org/apache/usergrid/android/client/callbacks/ClientCallback.java ---------------------------------------------------------------------- diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/client/callbacks/ClientCallback.java b/sdks/android/src/main/java/org/apache/usergrid/android/client/callbacks/ClientCallback.java deleted file mode 100644 index 0b834d5..0000000 --- a/sdks/android/src/main/java/org/apache/usergrid/android/client/callbacks/ClientCallback.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.usergrid.android.client.callbacks; - -public interface ClientCallback<T> { - - public void onResponse(T response); - - public void onException(Exception e); - -} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21b60593/sdks/android/src/main/java/org/apache/usergrid/android/client/callbacks/DeviceRegistrationCallback.java ---------------------------------------------------------------------- diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/client/callbacks/DeviceRegistrationCallback.java b/sdks/android/src/main/java/org/apache/usergrid/android/client/callbacks/DeviceRegistrationCallback.java deleted file mode 100644 index 462bebb..0000000 --- a/sdks/android/src/main/java/org/apache/usergrid/android/client/callbacks/DeviceRegistrationCallback.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.usergrid.android.client.callbacks; - -import org.usergrid.java.client.entities.Device; - -public interface DeviceRegistrationCallback extends ClientCallback<Device> { - - public void onDeviceRegistration(Device device); - -} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21b60593/sdks/android/src/main/java/org/apache/usergrid/android/client/callbacks/GroupsRetrievedCallback.java ---------------------------------------------------------------------- diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/client/callbacks/GroupsRetrievedCallback.java b/sdks/android/src/main/java/org/apache/usergrid/android/client/callbacks/GroupsRetrievedCallback.java deleted file mode 100644 index 806110b..0000000 --- a/sdks/android/src/main/java/org/apache/usergrid/android/client/callbacks/GroupsRetrievedCallback.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.usergrid.android.client.callbacks; - -import java.util.Map; - -import org.usergrid.java.client.entities.Group; - - -public interface GroupsRetrievedCallback extends - ClientCallback<Map<String, Group>> { - - public void onGroupsRetrieved(Map<String, Group> groups); - -} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21b60593/sdks/android/src/main/java/org/apache/usergrid/android/client/callbacks/QueryResultsCallback.java ---------------------------------------------------------------------- diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/client/callbacks/QueryResultsCallback.java b/sdks/android/src/main/java/org/apache/usergrid/android/client/callbacks/QueryResultsCallback.java deleted file mode 100644 index 3bc683a..0000000 --- a/sdks/android/src/main/java/org/apache/usergrid/android/client/callbacks/QueryResultsCallback.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.usergrid.android.client.callbacks; - -import org.usergrid.java.client.Client.Query; - -public interface QueryResultsCallback extends ClientCallback<Query> { - - public void onQueryResults(Query query); - -} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21b60593/sdks/android/src/main/java/org/apache/usergrid/android/client/utils/DeviceUuidFactory.java ---------------------------------------------------------------------- diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/client/utils/DeviceUuidFactory.java b/sdks/android/src/main/java/org/apache/usergrid/android/client/utils/DeviceUuidFactory.java deleted file mode 100644 index 6c731c2..0000000 --- a/sdks/android/src/main/java/org/apache/usergrid/android/client/utils/DeviceUuidFactory.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.usergrid.android.client.utils; - -import static org.apache.usergrid.android.client.utils.ObjectUtils.isEmpty; - -import java.io.UnsupportedEncodingException; -import java.util.UUID; - -import android.content.Context; -import android.content.SharedPreferences; -import android.net.wifi.WifiManager; -import android.os.Build; -import android.provider.Settings.Secure; -import android.telephony.TelephonyManager; - -/** - * Tries to get the device ID as a UUID and fallsback to a generated UUID value - * if it doesn't work. - * - * @see http - * ://stackoverflow.com/questions/2785485/is-there-a-unique-android-device - * -id - * - */ -public class DeviceUuidFactory { - protected static final String PREFS_FILE = "device_id.xml"; - protected static final String PREFS_DEVICE_ID = "device_id"; - - protected static UUID uuid; - - public DeviceUuidFactory(Context context) { - - if (uuid == null) { - synchronized (DeviceUuidFactory.class) { - if (uuid == null) { - final SharedPreferences prefs = context - .getSharedPreferences(PREFS_FILE, 0); - final String id = prefs.getString(PREFS_DEVICE_ID, null); - - if (id != null) { - // Use the ids previously computed and stored in the - // prefs file - uuid = UUID.fromString(id); - - } else { - - final String androidId = Secure - .getString(context.getContentResolver(), - Secure.ANDROID_ID); - - // Use the Android ID unless it's broken, in which case - // fallback on deviceId, - // unless it's not available, then fallback on a random - // number which we store - // to a prefs file - try { - if (!"9774d56d682e549c".equals(androidId)) { - uuid = UUID.nameUUIDFromBytes(androidId - .getBytes("utf8")); - } else { - final String deviceId = ((TelephonyManager) context - .getSystemService(Context.TELEPHONY_SERVICE)) - .getDeviceId(); - uuid = deviceId != null ? UUID - .nameUUIDFromBytes(deviceId - .getBytes("utf8")) - : generateDeviceUuid(context); - } - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - - // Write the value out to the prefs file - prefs.edit() - .putString(PREFS_DEVICE_ID, uuid.toString()) - .commit(); - - } - - } - } - } - - } - - private UUID generateDeviceUuid(Context context) { - - // Get some of the hardware information - String buildParams = Build.BOARD + Build.BRAND + Build.CPU_ABI - + Build.DEVICE + Build.DISPLAY + Build.FINGERPRINT + Build.HOST - + Build.ID + Build.MANUFACTURER + Build.MODEL + Build.PRODUCT - + Build.TAGS + Build.TYPE + Build.USER; - - // Requires READ_PHONE_STATE - TelephonyManager tm = (TelephonyManager) context - .getSystemService(Context.TELEPHONY_SERVICE); - - // gets the imei (GSM) or MEID/ESN (CDMA) - String imei = tm.getDeviceId(); - - // gets the android-assigned id - String androidId = Secure.getString(context.getContentResolver(), - Secure.ANDROID_ID); - - // requires ACCESS_WIFI_STATE - WifiManager wm = (WifiManager) context - .getSystemService(Context.WIFI_SERVICE); - - // gets the MAC address - String mac = wm.getConnectionInfo().getMacAddress(); - - // if we've got nothing, return a random UUID - if (isEmpty(imei) && isEmpty(androidId) && isEmpty(mac)) { - return UUID.randomUUID(); - } - - // concatenate the string - String fullHash = buildParams.toString() + imei + androidId + mac; - - return UUID.nameUUIDFromBytes(fullHash.getBytes()); - } - - /** - * Returns a unique UUID for the current android device. As with all UUIDs, - * this unique ID is "very highly likely" to be unique across all Android - * devices. Much more so than ANDROID_ID is. - * - * The UUID is generated by using ANDROID_ID as the base key if appropriate, - * falling back on TelephonyManager.getDeviceID() if ANDROID_ID is known to - * be incorrect, and finally falling back on a random UUID that's persisted - * to SharedPreferences if getDeviceID() does not return a usable value. - * - * In some rare circumstances, this ID may change. In particular, if the - * device is factory reset a new device ID may be generated. In addition, if - * a user upgrades their phone from certain buggy implementations of Android - * 2.2 to a newer, non-buggy version of Android, the device ID may change. - * Or, if a user uninstalls your app on a device that has neither a proper - * Android ID nor a Device ID, this ID may change on reinstallation. - * - * Note that if the code falls back on using TelephonyManager.getDeviceId(), - * the resulting ID will NOT change after a factory reset. Something to be - * aware of. - * - * Works around a bug in Android 2.2 for many devices when using ANDROID_ID - * directly. - * - * @see http://code.google.com/p/android/issues/detail?id=10603 - * - * @return a UUID that may be used to uniquely identify your device for most - * purposes. - */ - public UUID getDeviceUuid() { - return uuid; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21b60593/sdks/android/src/main/java/org/apache/usergrid/android/client/utils/ObjectUtils.java ---------------------------------------------------------------------- diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/client/utils/ObjectUtils.java b/sdks/android/src/main/java/org/apache/usergrid/android/client/utils/ObjectUtils.java deleted file mode 100644 index f0ef8fb..0000000 --- a/sdks/android/src/main/java/org/apache/usergrid/android/client/utils/ObjectUtils.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.usergrid.android.client.utils; - -import java.util.Map; - -public class ObjectUtils { - - public static boolean isEmpty(Object s) { - if (s == null) { - return true; - } - if ((s instanceof String) && (((String) s).trim().length() == 0)) { - return true; - } - if (s instanceof Map) { - return ((Map<?, ?>) s).isEmpty(); - } - return false; - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21b60593/sdks/android/src/main/java/org/apache/usergrid/android/sdk/CounterIncrement.java ---------------------------------------------------------------------- diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/CounterIncrement.java b/sdks/android/src/main/java/org/apache/usergrid/android/sdk/CounterIncrement.java new file mode 100755 index 0000000..6532ac8 --- /dev/null +++ b/sdks/android/src/main/java/org/apache/usergrid/android/sdk/CounterIncrement.java @@ -0,0 +1,53 @@ +package org.apache.usergrid.android.sdk; + +/** + * Represents an incrementing counter, including the counter's + * name and increment value. + * + * You can use a counter when creating a number of similar + * Event entity instances. An Event entity's "counters" property + * is a Map in which the key is the counter name and value is the + * increment value. + */ +public class CounterIncrement { + + private String counterName; + private long counterIncrementValue; + + + /** + * Constructs an instance, specifying the increment value + * as 1. + */ + public CounterIncrement() { + this.counterIncrementValue = 1; + } + + /** + * Constructs an instance with the specified counter name + * and increment value. + * + * @param counterName The counter name. + * @param counterIncrementValue The counter's increment value. + */ + public CounterIncrement(String counterName, long counterIncrementValue) { + this.counterName = counterName; + this.counterIncrementValue = counterIncrementValue; + } + + public String getCounterName() { + return this.counterName; + } + + public void setCounterName(String counterName) { + this.counterName = counterName; + } + + public long getCounterIncrementValue() { + return this.counterIncrementValue; + } + + public void setCounterIncrementValue(long counterIncrementValue) { + this.counterIncrementValue = counterIncrementValue; + } +} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/21b60593/sdks/android/src/main/java/org/apache/usergrid/android/sdk/DefaultURLConnectionFactory.java ---------------------------------------------------------------------- diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/DefaultURLConnectionFactory.java b/sdks/android/src/main/java/org/apache/usergrid/android/sdk/DefaultURLConnectionFactory.java new file mode 100755 index 0000000..5f70902 --- /dev/null +++ b/sdks/android/src/main/java/org/apache/usergrid/android/sdk/DefaultURLConnectionFactory.java @@ -0,0 +1,17 @@ +package org.apache.usergrid.android.sdk; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLConnection; + +/** + * @y.exclude + */ +public class DefaultURLConnectionFactory implements URLConnectionFactory { + public URLConnection openConnection(String urlAsString) throws MalformedURLException, IOException { + URL url = new URL(urlAsString); + return url.openConnection(); + } + +}
