You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by mr...@apache.org on 2016/09/02 17:25:23 UTC
[01/12] usergrid git commit: Removing old android SDK.
Repository: usergrid
Updated Branches:
refs/heads/master 49e0f50bd -> ae5684164
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7e0ffbc0/sdks/android/src/main/java/org/apache/usergrid/android/sdk/entities/User.java
----------------------------------------------------------------------
diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/entities/User.java b/sdks/android/src/main/java/org/apache/usergrid/android/sdk/entities/User.java
deleted file mode 100755
index 8807ada..0000000
--- a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/entities/User.java
+++ /dev/null
@@ -1,315 +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.sdk.entities;
-
-import static org.apache.usergrid.android.sdk.utils.JsonUtils.getBooleanProperty;
-import static org.apache.usergrid.android.sdk.utils.JsonUtils.setBooleanProperty;
-import static org.apache.usergrid.android.sdk.utils.JsonUtils.setStringProperty;
-import static com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion.NON_NULL;
-
-import java.util.List;
-
-import org.apache.usergrid.android.sdk.UGClient;
-import org.apache.usergrid.android.sdk.response.ApiResponse;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
-/**
- * Models the 'user' entity as a local object.
- *
- * @see <a href="http://apigee.com/docs/app-services/content/user-management">User entity documentation</a>
- */
-public class User extends Entity {
-
- public final static String ENTITY_TYPE = "user";
-
- public final static String PROPERTY_USERNAME = "username";
- public final static String PROPERTY_EMAIL = "email";
- public final static String PROPERTY_NAME = "name";
- public final static String PROPERTY_FIRSTNAME = "firstname";
- public final static String PROPERTY_MIDDLENAME = "middlename";
- public final static String PROPERTY_LASTNAME = "lastname";
- public final static String PROPERTY_ACTIVATED = "activated";
- public final static String PROPERTY_PICTURE = "picture";
- public final static String PROPERTY_DISABLED = "disabled";
-
- public static final String OLD_PASSWORD = "oldpassword";
- public static final String NEW_PASSWORD = "newpassword";
-
- /**
- * Checks if the provided entity 'type' equals 'user'.
- *
- * @return Boolen true/false
- */
- public static boolean isSameType(String type) {
- return type.equals(ENTITY_TYPE);
- }
-
- /**
- * Default constructor for the User object. Sets the 'type' property to 'user'.
- */
- public User() {
- setType(ENTITY_TYPE);
- }
-
- /**
- * Constructs the User object with a UGClient.
- * Sets the 'type' property to 'user'.
- *
- * @param UGClient an instance of the UGClient class
- */
- public User(UGClient client) {
- super(client);
- setType(ENTITY_TYPE);
- }
-
- /**
- * Constructs the User object from an Entity object. Sets the
- * properties of the User identical to Entity, except the 'type'
- * property is set to 'user' no matter what the Entity type is.
- *
- * @param entity an Entity object
- */
- public User(Entity entity) {
- super(entity.getUGClient());
- properties = entity.properties;
- setType(ENTITY_TYPE);
- }
-
- /**
- * Returns the type property of the User object. Should always
- * be 'user'
- *
- * @return the type property of the User object
- */
- @Override
- @JsonIgnore
- public String getNativeType() {
- return ENTITY_TYPE;
- }
-
- /**
- * Gets the properties already set in User and adds the following
- * user-specific properties: username, email. name, firstname,
- * middlename, lastname, activated, picture, disabled.
- *
- * @return a List object containing the properties of the User
- */
- @Override
- @JsonIgnore
- public List<String> getPropertyNames() {
- List<String> properties = super.getPropertyNames();
- properties.add(PROPERTY_USERNAME);
- properties.add(PROPERTY_EMAIL);
- properties.add(PROPERTY_NAME);
- properties.add(PROPERTY_FIRSTNAME);
- properties.add(PROPERTY_MIDDLENAME);
- properties.add(PROPERTY_LASTNAME);
- properties.add(PROPERTY_ACTIVATED);
- properties.add(PROPERTY_PICTURE);
- properties.add(PROPERTY_DISABLED);
- return properties;
- }
-
- /**
- * Returns the value of the 'username' property currently
- * set in the User object.
- *
- * @return the value of the username property
- */
- @JsonSerialize(include = NON_NULL)
- public String getUsername() {
- return getStringProperty(PROPERTY_USERNAME);
- }
-
- /**
- * Sets the username property in the User object.
- *
- * @param username the username
- */
- public void setUsername(String username) {
- setStringProperty(properties, PROPERTY_USERNAME, username);
- }
-
- /**
- * Returns the value of the 'name' property currently set in
- * the User object.
- *
- * @return the value of the name property
- */
- @JsonSerialize(include = NON_NULL)
- public String getName() {
- return getStringProperty(PROPERTY_NAME);
- }
-
- /**
- * Sets the value of the 'name' property in the User object.
- *
- * @param name the name of the entity
- */
- public void setName(String name) {
- setStringProperty(properties, PROPERTY_NAME, name);
- }
-
- /**
- * Returns the value of the 'email' property currently set in the User object.
- *
- * @return the value of the email property
- */
- @JsonSerialize(include = NON_NULL)
- public String getEmail() {
- return getStringProperty(PROPERTY_EMAIL);
- }
-
- /**
- * Sets the value of the 'email' property in the User object.
- *
- * @param email the user's email address
- */
- public void setEmail(String email) {
- setStringProperty(properties, PROPERTY_EMAIL, email);
- }
-
- /**
- * Returns the value of the 'activated' property in the User object.
- *
- * @return a Boolean true/false
- */
- @JsonSerialize(include = NON_NULL)
- public Boolean isActivated() {
- return getBooleanProperty(properties, PROPERTY_ACTIVATED);
- }
-
- /**
- * Sets the value of the 'activated' property in the User object.
- *
- * @param activated boolean whether the user is activated
- */
- public void setActivated(Boolean activated) {
- setBooleanProperty(properties, PROPERTY_ACTIVATED, activated);
- }
-
- /**
- * Returns the value of the 'disabled' property in the User object.
- *
- * @return a Boolean true/false
- */
- @JsonSerialize(include = NON_NULL)
- public Boolean isDisabled() {
- return getBooleanProperty(properties, PROPERTY_DISABLED);
- }
-
- /**
- * Sets the value of the 'disabled' property in the User object.
- *
- * @param disabled Boolean true/false
- */
- public void setDisabled(Boolean disabled) {
- setBooleanProperty(properties, PROPERTY_DISABLED, disabled);
- }
-
- /**
- * Returns the value of the 'firstname' property in the User object.
- *
- * @return the user's first name
- */
- @JsonSerialize(include = NON_NULL)
- public String getFirstname() {
- return getStringProperty(PROPERTY_FIRSTNAME);
- }
-
- /**
- * Sets the value of the 'firstname' property in the User object.
- *
- * @param firstname the user's first name
- */
- public void setFirstname(String firstname) {
- setStringProperty(properties, PROPERTY_FIRSTNAME, firstname);
- }
-
- /**
- * Returns the value of the 'middlename' property in the User object.
- *
- * @return the user's middle name
- */
- @JsonSerialize(include = NON_NULL)
- public String getMiddlename() {
- return getStringProperty(PROPERTY_MIDDLENAME);
- }
-
- /**
- * Sets the value of the 'middlename' property in the User object.
- *
- * @param middlename the user's middle name
- */
- public void setMiddlename(String middlename) {
- setStringProperty(properties, PROPERTY_MIDDLENAME, middlename);
- }
-
- /**
- * Returns the value of the 'lastname' property in the User object.
- *
- * @return the user's last name
- */
- @JsonSerialize(include = NON_NULL)
- public String getLastname() {
- return getStringProperty(PROPERTY_LASTNAME);
- }
-
- /**
- * Sets the value of the 'lastname' property in the User object.
- *
- * @param lastname the user's last name
- */
- public void setLastname(String lastname) {
- setStringProperty(properties, PROPERTY_LASTNAME, lastname);
- }
-
- /**
- * Returns the value of the 'picture' property in the User object.
- *
- * @return the URL of the user's picture
- */
- @JsonSerialize(include = NON_NULL)
- public String getPicture() {
- return getStringProperty(PROPERTY_PICTURE);
- }
-
- /**
- * Sets the value of the 'picture' property in the User object.
- *
- * @param picture the URL of the user's picture
- */
- public void setPicture(String picture) {
- setStringProperty(properties, PROPERTY_PICTURE, picture);
- }
-
- /**
- * Saves the current state of the User object on the server. Any property
- * conflicts will overwrite what is on the server.
- *
- * @return an ApiResponse object
- */
- public ApiResponse save() {
- ApiResponse response = super.save();
- return response;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7e0ffbc0/sdks/android/src/main/java/org/apache/usergrid/android/sdk/exception/ClientException.java
----------------------------------------------------------------------
diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/exception/ClientException.java b/sdks/android/src/main/java/org/apache/usergrid/android/sdk/exception/ClientException.java
deleted file mode 100755
index 7d39193..0000000
--- a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/exception/ClientException.java
+++ /dev/null
@@ -1,43 +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.sdk.exception;
-
-/**
- * Simple wrapper for client exceptions
- * @author tnine
- *
- */
-public class ClientException extends RuntimeException{
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- /**
- * @param message
- * @param cause
- */
- public ClientException(String message, Throwable cause) {
- super(message, cause);
- }
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7e0ffbc0/sdks/android/src/main/java/org/apache/usergrid/android/sdk/response/AggregateCounter.java
----------------------------------------------------------------------
diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/response/AggregateCounter.java b/sdks/android/src/main/java/org/apache/usergrid/android/sdk/response/AggregateCounter.java
deleted file mode 100755
index d085acb..0000000
--- a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/response/AggregateCounter.java
+++ /dev/null
@@ -1,58 +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.sdk.response;
-
-import static org.apache.usergrid.android.sdk.utils.JsonUtils.toJsonString;
-
-public class AggregateCounter {
-
- private long timestamp;
- private long value;
-
- public AggregateCounter() {
- }
-
- public AggregateCounter(long timestamp, long value) {
- this.timestamp = timestamp;
- this.value = value;
- }
-
- public long getTimestamp() {
- return timestamp;
- }
-
- public void setTimestamp(long timestamp) {
- this.timestamp = timestamp;
- }
-
- public long getValue() {
- return value;
- }
-
- public void setValue(long value) {
- this.value = value;
- }
-
- @Override
- public String toString() {
- return toJsonString(this);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7e0ffbc0/sdks/android/src/main/java/org/apache/usergrid/android/sdk/response/AggregateCounterSet.java
----------------------------------------------------------------------
diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/response/AggregateCounterSet.java b/sdks/android/src/main/java/org/apache/usergrid/android/sdk/response/AggregateCounterSet.java
deleted file mode 100755
index f127946..0000000
--- a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/response/AggregateCounterSet.java
+++ /dev/null
@@ -1,117 +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.sdk.response;
-
-import static org.apache.usergrid.android.sdk.utils.JsonUtils.toJsonString;
-
-import java.util.List;
-import java.util.UUID;
-
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion;
-
-public class AggregateCounterSet {
- private String name;
- private UUID user;
- private UUID group;
- private UUID queue;
- private String category;
- private List<AggregateCounter> values;
-
- public AggregateCounterSet() {
- }
-
- public AggregateCounterSet(String name, UUID user, UUID group,
- String category, List<AggregateCounter> values) {
- this.name = name;
- this.user = user;
- this.group = group;
- this.category = category;
- this.values = values;
- }
-
- public AggregateCounterSet(String name, UUID queue, String category,
- List<AggregateCounter> values) {
- this.name = name;
- setQueue(queue);
- this.category = category;
- this.values = values;
- }
-
- @JsonSerialize(include = Inclusion.NON_NULL)
- public UUID getUser() {
- return user;
- }
-
- public void setUser(UUID user) {
- this.user = user;
- }
-
- @JsonSerialize(include = Inclusion.NON_NULL)
- public UUID getGroup() {
- return group;
- }
-
- public void setGroup(UUID group) {
- this.group = group;
- }
-
- @JsonSerialize(include = Inclusion.NON_NULL)
- public String getCategory() {
- return category;
- }
-
- public void setCategory(String category) {
- this.category = category;
- }
-
- @JsonSerialize(include = Inclusion.NON_NULL)
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- @JsonSerialize(include = Inclusion.NON_NULL)
- public List<AggregateCounter> getValues() {
- return values;
- }
-
- public void setValues(List<AggregateCounter> values) {
- this.values = values;
- }
-
- @JsonSerialize(include = Inclusion.NON_NULL)
- public UUID getQueue() {
- return queue;
- }
-
- public void setQueue(UUID queue) {
- this.queue = queue;
- }
-
- @Override
- public String toString() {
- return toJsonString(this);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7e0ffbc0/sdks/android/src/main/java/org/apache/usergrid/android/sdk/response/ApiResponse.java
----------------------------------------------------------------------
diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/response/ApiResponse.java b/sdks/android/src/main/java/org/apache/usergrid/android/sdk/response/ApiResponse.java
deleted file mode 100755
index 68df46f..0000000
--- a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/response/ApiResponse.java
+++ /dev/null
@@ -1,774 +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.sdk.response;
-
-import static org.apache.usergrid.android.sdk.utils.JsonUtils.toJsonString;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import org.apache.usergrid.android.sdk.UGClient;
-import org.apache.usergrid.android.sdk.entities.Entity;
-import org.apache.usergrid.android.sdk.entities.Message;
-import org.apache.usergrid.android.sdk.entities.User;
-
-import com.fasterxml.jackson.annotation.JsonAnyGetter;
-import com.fasterxml.jackson.annotation.JsonAnySetter;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion;
-
-public class ApiResponse {
-
- private String accessToken;
-
- private String error;
- private String errorDescription;
- private String errorUri;
- private String exception;
-
- private String path;
- private String uri;
- private String status;
- private long timestamp;
- private UUID application;
- private List<Entity> entities;
- private UUID next;
- private String cursor;
- private String action;
- private List<Object> list;
- private Object data;
- private Map<String, UUID> applications;
- private Map<String, JsonNode> metadata;
- private Map<String, List<String>> params;
- private List<AggregateCounterSet> counters;
- private ClientCredentialsInfo credentials;
-
- private List<Message> messages;
- private List<QueueInfo> queues;
- private UUID last;
- private UUID queue;
- private UUID consumer;
-
- private User user;
- private String rawResponse;
-
- private final Map<String, JsonNode> properties = new HashMap<String, JsonNode>();
-
- /**
- * @y.exclude
- */
- public ApiResponse() {
- }
-
- /**
- * Returns the 'properties' property of the request.
- *
- * @return a Map object of the properties
- */
- @JsonAnyGetter
- public Map<String, JsonNode> getProperties() {
- return properties;
- }
-
- /**
- * @y.exclude
- */
- @JsonAnySetter
- public void setProperty(String key, JsonNode value) {
- properties.put(key, value);
- }
-
- /**
- * Returns the OAuth token that was sent with the request
- *
- * @return the OAuth token
- */
- @JsonProperty("access_token")
- @JsonSerialize(include = Inclusion.NON_NULL)
- public String getAccessToken() {
- return accessToken;
- }
-
- /**
- * @y.exclude
- */
- @JsonProperty("access_token")
- public void setAccessToken(String accessToken) {
- this.accessToken = accessToken;
- }
-
- /**
- * Returns the 'error' property of the response.
- *
- * @return the error
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public String getError() {
- return error;
- }
-
- /**
- * Sets the 'error' property of the response.
- *
- * @param error the error
- */
- public void setError(String error) {
- this.error = error;
- }
-
- /**
- * Returns the 'error_description' property of the response.
- *
- * @return the error description
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- @JsonProperty("error_description")
- public String getErrorDescription() {
- return errorDescription;
- }
-
- /**
- * Sets the 'error_description' property of the response.
- *
- * @param errorDescription the error description
- */
- @JsonProperty("error_description")
- public void setErrorDescription(String errorDescription) {
- this.errorDescription = errorDescription;
- }
-
- /**
- * Returns the 'error_uri' property of the response.
- *
- * @return the error URI
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- @JsonProperty("error_uri")
- public String getErrorUri() {
- return errorUri;
- }
-
- /**
- * Sets the 'error_uri' property of the response.
- *
- * @param errorUri the error URI
- */
- @JsonProperty("error_uri")
- public void setErrorUri(String errorUri) {
- this.errorUri = errorUri;
- }
-
- /**
- * Returns the 'exception' property of the response.
- *
- * @return the exception
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public String getException() {
- return exception;
- }
-
- /**
- * Sets the 'exception' property of the response.
- *
- * @param exception the exception
- */
- public void setException(String exception) {
- this.exception = exception;
- }
-
- /**
- * Returns the path of the request, i.e. the portion of the
- * request URI after the application name.
- *
- * @return the request path
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public String getPath() {
- return path;
- }
-
- /**
- * @y.exclude
- */
- public void setPath(String path) {
- this.path = path;
- }
-
- /**
- * Returns the full URI of the request.
- *
- * @return the full request URI
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public String getUri() {
- return uri;
- }
-
- /**
- * @y.exclude
- */
- public void setUri(String uri) {
- this.uri = uri;
- }
-
- /**
- * Returns the status property from the response. Only
- * applies to certain organization and application-level requests.
- *
- * @return the status
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public String getStatus() {
- return status;
- }
-
- /**
- * @y.exclude
- */
- public void setStatus(String status) {
- this.status = status;
- }
-
- /**
- * Returns the timestamp of the response
- *
- * @return the UNIX timestamp
- */
- public long getTimestamp() {
- return timestamp;
- }
-
- /**
- * @y.exclude
- */
- public void setTimestamp(long timestamp) {
- this.timestamp = timestamp;
- }
-
- /**
- * Returns the UUID of the application that was targeted
- * by the request.
- *
- * @return the application UUID
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public UUID getApplication() {
- return application;
- }
-
- /**
- * @y.exclude
- */
- public void setApplication(UUID application) {
- this.application = application;
- }
-
- /**
- * Returns the entities from the response as a List
- * of Entity objects.
- *
- * @return the entities
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public List<Entity> getEntities() {
- return entities;
- }
-
- /**
- * @y.exclude
- */
- public void setEntities(List<Entity> entities) {
- this.entities = entities;
- }
-
- /**
- * Returns a count of the number of entities in the response.
- *
- * @return the number of entities in the response
- */
- public int getEntityCount() {
- if (entities == null) {
- return 0;
- }
- return entities.size();
- }
-
- /**
- * Returns the first entity in the result set, or null
- * if there were no entities.
- *
- * @return an Entity object
- * @see org.apache.usergrid.android.sdk.entities.Entity
- */
- public Entity getFirstEntity() {
- if ((entities != null) && (entities.size() > 0)) {
- return entities.get(0);
- }
- return null;
- }
-
- /**
- * Returns the first entity in the result set.
- *
- * @return an Entity object
- * @see org.apache.usergrid.android.sdk.entities.Entity
- */
- public <T extends Entity> T getFirstEntity(Class<T> t) {
- return Entity.toType(getFirstEntity(), t);
- }
-
- /**
- * Returns the last entity in the result set.
- *
- * @return an Entity object
- * @see org.apache.usergrid.android.sdk.entities.Entity
- */
- public Entity getLastEntity() {
- if ((entities != null) && (entities.size() > 0)) {
- return entities.get(entities.size() - 1);
- }
- return null;
- }
-
- /**
- * Returns the last entity in the result set.
- *
- * @return an Entity object
- * @see org.apache.usergrid.android.sdk.entities.Entity
- */
- public <T extends Entity> T getLastEntity(Class<T> t) {
- return Entity.toType(getLastEntity(), t);
- }
-
- /**
- * Returns the a List of all entitie from the response.
- *
- * @return a List object
- * @see org.apache.usergrid.android.sdk.entities.Entity
- */
- public <T extends Entity> List<T> getEntities(Class<T> t) {
- return Entity.toType(entities, t);
- }
-
- /**
- * Returns the 'next' property of the response.
- *
- * @return the 'next' property
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public UUID getNext() {
- return next;
- }
-
- /**
- * @y.exclude
- */
- public void setNext(UUID next) {
- this.next = next;
- }
-
- /**
- * Returns the cursor for retrieving the next page of results
- *
- * @return the cursor
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public String getCursor() {
- return cursor;
- }
-
- /**
- * @y.exclude
- */
- public void setCursor(String cursor) {
- this.cursor = cursor;
- }
-
- /**
- * Returns the 'action' property from the response.
- *
- * @return the 'action' property
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public String getAction() {
- return action;
- }
-
- /**
- * @y.exclude
- */
- public void setAction(String action) {
- this.action = action;
- }
-
- /**
- * Returns the 'list' property from the response.
- *
- * @return the 'list' property
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public List<Object> getList() {
- return list;
- }
-
- /**
- * @y.exclude
- */
- public void setList(List<Object> list) {
- this.list = list;
- }
-
- /**
- * Returns the 'data' property of the response from a
- * request to create, retrieve or update an admin user.
- *
- * @return the 'data' property of the user entity
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public Object getData() {
- return data;
- }
-
- /**
- * @y.exclude
- */
- public void setData(Object data) {
- this.data = data;
- }
-
- /**
- * For requests to get all applications in an organization, returns
- * the applications and their UUIDs as a Map object.
- *
- * @return the applications in the organization
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public Map<String, UUID> getApplications() {
- return applications;
- }
-
- /**
- * @y.exclude
- */
- public void setApplications(Map<String, UUID> applications) {
- this.applications = applications;
- }
-
- /**
- * Returns the 'metadata' property of the response as a Map object.
- *
- * @return the 'metadata' property
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public Map<String, JsonNode> getMetadata() {
- return metadata;
- }
-
- /**
- * @y.exclude
- */
- public void setMetadata(Map<String, JsonNode> metadata) {
- this.metadata = metadata;
- }
-
- /**
- * Returns the URL parameters that were sent with the request.
- *
- * @return the URL parameters of the request
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public Map<String, List<String>> getParams() {
- return params;
- }
-
- /**
- * @y.exclude
- */
- public void setParams(Map<String, List<String>> params) {
- this.params = params;
- }
-
- /**
- * Returns the counters from the response.
- *
- * @return a List of the counters
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public List<AggregateCounterSet> getCounters() {
- return counters;
- }
-
- /**
- * @y.exclude
- */
- public void setCounters(List<AggregateCounterSet> counters) {
- this.counters = counters;
- }
-
- /**
- * Returns the client id and client secret from the response. This is
- * used only for requests that generate or retrieve credentials.
- *
- * @return the client id and client secret
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public ClientCredentialsInfo getCredentials() {
- return credentials;
- }
-
- /**
- * @y.exclude
- */
- public void setCredentials(ClientCredentialsInfo credentials) {
- this.credentials = credentials;
- }
-
-
- /**
- * For requests to retrieve the admin users in an organization, returns
- * the 'user' property from the response.
- *
- * @return a User object
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public User getUser() {
- return user;
- }
-
- /**
- * @y.exclude
- */
- public void setUser(User user) {
- this.user = user;
- }
-
- /**
- * Returns the ApiResponse as a String
- *
- * @return the ApiResponse in String format
- */
- @Override
- public String toString() {
- return toJsonString(this);
- }
-
- /**
- * For messaging queue requests, returns the 'messages' property.
- *
- * @return the 'messages' property
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public List<Message> getMessages() {
- return messages;
- }
-
- /**
- * @y.exclude
- */
- public void setMessages(List<Message> messages) {
- this.messages = messages;
- }
-
- /**
- * For messaging queue requests, returns the number of messages
- * in the response.
- *
- * @return the number of messages in the 'messages' property
- */
- @JsonIgnore
- public int getMessageCount() {
- if (messages == null) {
- return 0;
- }
- return messages.size();
- }
-
- /**
- * For messaging queue requests, returns the first message
- * in the response.
- *
- * @return the first message in the 'messages' property
- */
- @JsonIgnore
- public Message getFirstMessage() {
- if ((messages != null) && (messages.size() > 0)) {
- return messages.get(0);
- }
- return null;
- }
-
- /**
- * For messaging queue requests, returns the last message
- * in the response.
- *
- * @return the last message in the 'messages' property
- */
- @JsonIgnore
- public Entity getLastMessage() {
- if ((messages != null) && (messages.size() > 0)) {
- return messages.get(messages.size() - 1);
- }
- return null;
- }
-
- @JsonSerialize(include = Inclusion.NON_NULL)
- public UUID getLast() {
- return last;
- }
-
- /**
- * @y.exclude
- */
- public void setLast(UUID last) {
- this.last = last;
- }
-
- /**
- * For messaging queue requests, returns the queues
- * in the response.
- *
- * @return the 'queues' property
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public List<QueueInfo> getQueues() {
- return queues;
- }
-
- /**
- * @y.exclude
- */
- public void setQueues(List<QueueInfo> queues) {
- this.queues = queues;
- }
-
- /**
- * For messaging queue requests, returns the first queue
- * in the response.
- *
- * @return the first queue in the 'queues' property
- */
- @JsonIgnore
- public QueueInfo getFirstQueue() {
- if ((queues != null) && (queues.size() > 0)) {
- return queues.get(0);
- }
- return null;
- }
-
- /**
- * For messaging queue requests, returns the last queue
- * in the response.
- *
- * @return the last queue in the 'queues' property
- */
- @JsonIgnore
- public QueueInfo getLastQueue() {
- if ((queues != null) && (queues.size() > 0)) {
- return queues.get(queues.size() - 1);
- }
- return null;
- }
-
- /**
- * For messaging queue requests, returns the UUID of the
- * last queue in the response.
- *
- * @return the queue UUID
- */
- @JsonIgnore
- public UUID getLastQueueId() {
- QueueInfo q = getLastQueue();
- if (q != null) {
- return q.getQueue();
- }
- return null;
- }
-
- /**
- * For messaging queue requests, returns the UUID of the
- * queue in the response.
- *
- * @return the queue UUID
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public UUID getQueue() {
- return queue;
- }
-
- /**
- * @y.exclude
- */
- public void setQueue(UUID queue) {
- this.queue = queue;
- }
-
- /**
- * Returns the 'consumer' property from message queue requests.
- *
- * @return the 'consumer' property
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public UUID getConsumer() {
- return consumer;
- }
-
- /**
- * @y.exclude
- */
- public void setConsumer(UUID consumer) {
- this.consumer = consumer;
- }
-
- /**
- * @y.exclude
- */
- public void setRawResponse(String rawResponse) {
- this.rawResponse = rawResponse;
- }
-
- /**
- * Returns the raw JSON response as a String.
- *
- * @return the JSON response
- */
- public String getRawResponse() {
- return rawResponse;
- }
-
- /**
- * Sets the UGClient instance for all Entity objects in the response.
- *
- * @param UGClient an instance of UGClient
- */
- public void setUGClient(UGClient client) {
- if( (entities != null) && !entities.isEmpty() ) {
- for ( Entity entity : entities ) {
- entity.setUGClient(client);
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7e0ffbc0/sdks/android/src/main/java/org/apache/usergrid/android/sdk/response/ClientCredentialsInfo.java
----------------------------------------------------------------------
diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/response/ClientCredentialsInfo.java b/sdks/android/src/main/java/org/apache/usergrid/android/sdk/response/ClientCredentialsInfo.java
deleted file mode 100755
index 95c3a68..0000000
--- a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/response/ClientCredentialsInfo.java
+++ /dev/null
@@ -1,64 +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.sdk.response;
-
-import static org.apache.usergrid.android.sdk.utils.JsonUtils.toJsonString;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-/**
- * @y.exclude
- */
-public class ClientCredentialsInfo {
-
- private String id;
- private String secret;
-
- public ClientCredentialsInfo(String id, String secret) {
- this.id = id;
- this.secret = secret;
- }
-
- @JsonProperty("client_id")
- public String getId() {
- return id;
- }
-
- @JsonProperty("client_id")
- public void setId(String id) {
- this.id = id;
- }
-
- @JsonProperty("client_secret")
- public String getSecret() {
- return secret;
- }
-
- @JsonProperty("client_secret")
- public void setSecret(String secret) {
- this.secret = secret;
- }
-
- @Override
- public String toString() {
- return toJsonString(this);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7e0ffbc0/sdks/android/src/main/java/org/apache/usergrid/android/sdk/response/QueueInfo.java
----------------------------------------------------------------------
diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/response/QueueInfo.java b/sdks/android/src/main/java/org/apache/usergrid/android/sdk/response/QueueInfo.java
deleted file mode 100755
index 1f049b0..0000000
--- a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/response/QueueInfo.java
+++ /dev/null
@@ -1,47 +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.sdk.response;
-
-import java.util.UUID;
-
-public class QueueInfo {
-
- String path;
- UUID queue;
-
- public QueueInfo() {
- }
-
- public String getPath() {
- return path;
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
- public UUID getQueue() {
- return queue;
- }
-
- public void setQueue(UUID queue) {
- this.queue = queue;
- }
-}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7e0ffbc0/sdks/android/src/main/java/org/apache/usergrid/android/sdk/utils/DeviceUuidFactory.java
----------------------------------------------------------------------
diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/utils/DeviceUuidFactory.java b/sdks/android/src/main/java/org/apache/usergrid/android/sdk/utils/DeviceUuidFactory.java
deleted file mode 100755
index b3b3dd9..0000000
--- a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/utils/DeviceUuidFactory.java
+++ /dev/null
@@ -1,173 +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.sdk.utils;
-
-import static org.apache.usergrid.android.sdk.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;
- }
-}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7e0ffbc0/sdks/android/src/main/java/org/apache/usergrid/android/sdk/utils/JsonUtils.java
----------------------------------------------------------------------
diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/utils/JsonUtils.java b/sdks/android/src/main/java/org/apache/usergrid/android/sdk/utils/JsonUtils.java
deleted file mode 100755
index 5f617a2..0000000
--- a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/utils/JsonUtils.java
+++ /dev/null
@@ -1,185 +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.sdk.utils;
-
-import java.io.IOException;
-import java.util.Map;
-import java.util.UUID;
-
-import org.apache.usergrid.android.sdk.exception.ClientException;
-import com.fasterxml.jackson.core.JsonGenerationException;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;
-
-public class JsonUtils {
-
-
- static ObjectMapper mapper = new ObjectMapper();
-
- public static String getStringProperty(Map<String, JsonNode> properties,
- String name) {
- JsonNode value = properties.get(name);
- if (value != null) {
- return value.asText();
- }
- return null;
- }
-
- public static void setStringProperty(Map<String, JsonNode> properties,
- String name, String value) {
- if (value == null) {
- properties.remove(name);
- } else {
- properties.put(name, JsonNodeFactory.instance.textNode(value));
- }
- }
-
- public static Long getLongProperty(Map<String, JsonNode> properties,
- String name) {
- JsonNode value = properties.get(name);
- if (value != null) {
- return value.asLong(0);
- }
- return null;
- }
-
- public static void setLongProperty(Map<String, JsonNode> properties,
- String name, Long value) {
- if (value == null) {
- properties.remove(name);
- } else {
- properties.put(name, JsonNodeFactory.instance.numberNode(value));
- }
- }
-
- public static void setFloatProperty(Map<String, JsonNode> properties, String name, Float value){
- if(value == null){
- properties.remove(name);
- }else{
- properties.put(name, JsonNodeFactory.instance.numberNode(value));
- }
- }
-
- public static Boolean getBooleanProperty(Map<String, JsonNode> properties,
- String name) {
- JsonNode value = properties.get(name);
- if (value != null) {
- return value.asBoolean();
- }
- return false;
- }
-
- public static void setBooleanProperty(Map<String, JsonNode> properties,
- String name, Boolean value) {
- if (value == null) {
- properties.remove(name);
- } else {
- properties.put(name, JsonNodeFactory.instance.booleanNode(value));
- }
- }
-
- public static UUID getUUIDProperty(Map<String, JsonNode> properties,
- String name) {
- JsonNode value = properties.get(name);
- if (value != null) {
- UUID uuid = null;
- try {
- uuid = UUID.fromString(value.asText());
- } catch (Exception e) {
- }
- return uuid;
- }
- return null;
- }
-
- public static void setUUIDProperty(Map<String, JsonNode> properties,
- String name, UUID value) {
- if (value == null) {
- properties.remove(name);
- } else {
- properties.put(name,
- JsonNodeFactory.instance.textNode(value.toString()));
- }
- }
-
- public static String toJsonString(Object obj) {
- try {
- return mapper.writeValueAsString(obj);
- } catch (JsonGenerationException e) {
- throw new ClientException("Unable to generate json", e);
- } catch (JsonMappingException e) {
- throw new ClientException("Unable to map json", e);
- } catch (IOException e) {
- throw new ClientException("IO error", e);
- }
- }
-
- public static <T> T parse(String json, Class<T> c) {
- try {
- return mapper.readValue(json, c);
- } catch (JsonGenerationException e) {
- throw new ClientException("Unable to generate json", e);
- } catch (JsonMappingException e) {
- throw new ClientException("Unable to map json", e);
- } catch (IOException e) {
- throw new ClientException("IO error", e);
- }
- }
-
- public static JsonNode toJsonNode(Object obj) {
- return mapper.convertValue(obj, JsonNode.class);
- }
-
- public static <T> T fromJsonNode(JsonNode json, Class<T> c) {
- try {
- JsonParser jp = json.traverse();
- return mapper.readValue(jp, c);
- } catch (JsonGenerationException e) {
- throw new ClientException("Unable to generate json", e);
- } catch (JsonMappingException e) {
- throw new ClientException("Unable to map json", e);
- } catch (IOException e) {
- throw new ClientException("IO error", e);
- }
- }
-
- public static <T> T getObjectProperty(Map<String, JsonNode> properties,
- String name, Class<T> c) {
- JsonNode value = properties.get(name);
- if (value != null) {
- return fromJsonNode(value, c);
- }
- return null;
- }
-
- public static void setObjectProperty(Map<String, JsonNode> properties,
- String name, Object value) {
- if (value == null) {
- properties.remove(name);
- } else {
- properties.put(name,
- JsonNodeFactory.instance.textNode(value.toString()));
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7e0ffbc0/sdks/android/src/main/java/org/apache/usergrid/android/sdk/utils/MapUtils.java
----------------------------------------------------------------------
diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/utils/MapUtils.java b/sdks/android/src/main/java/org/apache/usergrid/android/sdk/utils/MapUtils.java
deleted file mode 100755
index 8da5b45..0000000
--- a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/utils/MapUtils.java
+++ /dev/null
@@ -1,42 +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.sdk.utils;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class MapUtils {
-
- public static <T> Map<String, T> newMapWithoutKeys(Map<String, T> map,
- List<String> keys) {
- Map<String, T> newMap = null;
- if (map != null) {
- newMap = new HashMap<String, T>(map);
- } else {
- newMap = new HashMap<String, T>();
- }
- for (String key : keys) {
- newMap.remove(key);
- }
- return newMap;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7e0ffbc0/sdks/android/src/main/java/org/apache/usergrid/android/sdk/utils/ObjectUtils.java
----------------------------------------------------------------------
diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/utils/ObjectUtils.java b/sdks/android/src/main/java/org/apache/usergrid/android/sdk/utils/ObjectUtils.java
deleted file mode 100755
index efdcaca..0000000
--- a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/utils/ObjectUtils.java
+++ /dev/null
@@ -1,39 +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.sdk.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;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7e0ffbc0/sdks/android/src/main/java/org/apache/usergrid/android/sdk/utils/UrlUtils.java
----------------------------------------------------------------------
diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/utils/UrlUtils.java b/sdks/android/src/main/java/org/apache/usergrid/android/sdk/utils/UrlUtils.java
deleted file mode 100755
index b7e6be3..0000000
--- a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/utils/UrlUtils.java
+++ /dev/null
@@ -1,127 +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.sdk.utils;
-
-import static org.apache.usergrid.android.sdk.utils.ObjectUtils.isEmpty;
-import static java.net.URLEncoder.encode;
-
-import java.io.UnsupportedEncodingException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.apache.usergrid.android.sdk.exception.ClientException;
-
-public class UrlUtils {
-
-
- public static URL url(String s) {
- try {
- return new URL(s);
- } catch (MalformedURLException e) {
- throw new ClientException("Incorrect URL format", e);
- }
- }
-
- public static URL url(URL u, String s) {
- try {
- return new URL(u, s);
- } catch (MalformedURLException e) {
- throw new ClientException("Incorrect URL format", e);
- }
- }
-
- public static String path(Object... segments) {
- String path = "";
- boolean first = true;
- for (Object segment : segments) {
- if (segment instanceof Object[]) {
- segment = path((Object[]) segment);
- }
- if (!isEmpty(segment)) {
- if (first) {
- path = segment.toString();
- first = false;
- } else {
- if (!path.endsWith("/")) {
- path += "/";
- }
- path += segment.toString();
- }
- }
- }
- return path;
- }
-
- @SuppressWarnings("rawtypes")
- public static String encodeParams(Map<String, Object> params) {
- if (params == null) {
- return "";
- }
- boolean first = true;
- StringBuilder results = new StringBuilder();
- for (Entry<String, Object> entry : params.entrySet()) {
- if (entry.getValue() instanceof List) {
- for (Object o : (List) entry.getValue()) {
- if (!isEmpty(o)) {
- if (!first) {
- results.append('&');
- }
- first = false;
- results.append(entry.getKey());
- results.append("=");
- try {
- results.append(encode(o.toString(), "UTF-8"));
- } catch (UnsupportedEncodingException e) {
- throw new ClientException("Unknown encoding", e);
- }
- }
- }
- } else if (!isEmpty(entry.getValue())) {
- if (!first) {
- results.append('&');
- }
- first = false;
- results.append(entry.getKey());
- results.append("=");
- try {
- results.append(encode(entry.getValue().toString(), "UTF-8"));
- } catch (UnsupportedEncodingException e) {
- throw new ClientException("Unsupported string encoding", e);
- }
- }
- }
- return results.toString();
- }
-
- public static String addQueryParams(String url, Map<String, Object> params) {
- if (params == null) {
- return url;
- }
- if (!url.contains("?")) {
- url += "?";
- }
- url += encodeParams(params);
- return url;
- }
-
-}
[12/12] usergrid git commit: Merge commit 'refs/pull/556/head' of
github.com:apache/usergrid
Posted by mr...@apache.org.
Merge commit 'refs/pull/556/head' of github.com:apache/usergrid
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/ae568416
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/ae568416
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/ae568416
Branch: refs/heads/master
Commit: ae5684164f3eb2da702f7ecb00983b295169ea4d
Parents: 49e0f50 f1b0f98
Author: Michael Russo <mr...@apigee.com>
Authored: Fri Sep 2 10:25:09 2016 -0700
Committer: Michael Russo <mr...@apigee.com>
Committed: Fri Sep 2 10:25:09 2016 -0700
----------------------------------------------------------------------
sdks/android/.gitignore | 20 -
sdks/android/LICENSE | 202 --
sdks/android/LICENSE.txt | 19 +
sdks/android/NOTICE | 12 -
sdks/android/README.md | 622 +++-
sdks/android/README.txt | 13 -
sdks/android/Samples/ActivityFeed/.gitignore | 8 +
.../ActivityFeed/activityfeed/.gitignore | 1 +
.../ActivityFeed/activityfeed/build.gradle | 27 +
.../ActivityFeed/activityfeed/libs/gcm.jar | Bin 0 -> 13662 bytes
.../activityfeed/proguard-rules.pro | 17 +
.../usergrid/activityfeed/ApplicationTest.java | 13 +
.../activityfeed/src/main/AndroidManifest.xml | 53 +
.../usergrid/activityfeed/ActivityEntity.java | 86 +
.../usergrid/activityfeed/GCMIntentService.java | 87 +
.../usergrid/activityfeed/UsergridManager.java | 259 ++
.../activities/CreateAccountActivity.java | 67 +
.../activityfeed/activities/FeedActivity.java | 142 +
.../activityfeed/activities/FollowActivity.java | 59 +
.../activityfeed/activities/MainActivity.java | 87 +
.../callbacks/GetFeedMessagesCallback.java | 27 +
.../callbacks/PostFeedMessageCallback.java | 25 +
.../activityfeed/helpers/ActionBarHelpers.java | 53 +
.../helpers/AlertDialogHelpers.java | 61 +
.../activityfeed/helpers/FeedAdapter.java | 153 +
.../src/main/res/drawable/in_message_bg.9.png | Bin 0 -> 1160 bytes
.../src/main/res/drawable/out_message_bg.9.png | Bin 0 -> 1072 bytes
.../src/main/res/drawable/usergridguy.png | Bin 0 -> 6230 bytes
.../src/main/res/layout/action_bar_layout.xml | 29 +
.../main/res/layout/activity_create_account.xml | 101 +
.../src/main/res/layout/activity_feed.xml | 46 +
.../src/main/res/layout/activity_follow.xml | 44 +
.../src/main/res/layout/activity_main.xml | 85 +
.../src/main/res/layout/message_layout.xml | 43 +
.../main/res/layout/scrollable_alert_view.xml | 35 +
.../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 3418 bytes
.../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 2206 bytes
.../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 4842 bytes
.../src/main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 7718 bytes
.../src/main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 10486 bytes
.../src/main/res/values-w820dp/dimens.xml | 6 +
.../activityfeed/src/main/res/values/colors.xml | 8 +
.../activityfeed/src/main/res/values/dimens.xml | 5 +
.../src/main/res/values/strings.xml | 3 +
.../activityfeed/src/main/res/values/styles.xml | 19 +
.../usergrid/activityfeed/ExampleUnitTest.java | 15 +
sdks/android/Samples/ActivityFeed/build.gradle | 23 +
.../Samples/ActivityFeed/gradle.properties | 18 +
.../gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 53636 bytes
.../gradle/wrapper/gradle-wrapper.properties | 6 +
sdks/android/Samples/ActivityFeed/gradlew | 160 +
sdks/android/Samples/ActivityFeed/gradlew.bat | 90 +
.../Samples/ActivityFeed/settings.gradle | 2 +
sdks/android/Samples/Push/.gitignore | 8 +
sdks/android/Samples/Push/build.gradle | 22 +
sdks/android/Samples/Push/gradle.properties | 18 +
.../Push/gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 53636 bytes
.../gradle/wrapper/gradle-wrapper.properties | 6 +
sdks/android/Samples/Push/gradlew | 160 +
sdks/android/Samples/Push/gradlew.bat | 90 +
sdks/android/Samples/Push/push/.gitignore | 1 +
sdks/android/Samples/Push/push/build.gradle | 27 +
sdks/android/Samples/Push/push/libs/gcm.jar | Bin 0 -> 13662 bytes
.../Samples/Push/push/proguard-rules.pro | 17 +
.../apache/usergrid/push/ApplicationTest.java | 13 +
.../Push/push/src/main/AndroidManifest.xml | 51 +
.../apache/usergrid/push/GCMIntentService.java | 85 +
.../org/apache/usergrid/push/MainActivity.java | 162 +
.../apache/usergrid/push/SettingsActivity.java | 68 +
.../Push/push/src/main/res/drawable/info.png | Bin 0 -> 44546 bytes
.../push/src/main/res/drawable/usergridguy.png | Bin 0 -> 6230 bytes
.../push/src/main/res/layout/activity_main.xml | 69 +
.../src/main/res/layout/activity_settings.xml | 95 +
.../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 3418 bytes
.../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 2206 bytes
.../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 4842 bytes
.../src/main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 7718 bytes
.../src/main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 10486 bytes
.../push/src/main/res/values-w820dp/dimens.xml | 6 +
.../Push/push/src/main/res/values/colors.xml | 6 +
.../Push/push/src/main/res/values/dimens.xml | 5 +
.../Push/push/src/main/res/values/strings.xml | 3 +
.../Push/push/src/main/res/values/styles.xml | 11 +
.../apache/usergrid/push/ExampleUnitTest.java | 15 +
sdks/android/Samples/Push/settings.gradle | 2 +
sdks/android/UsergridAndroidSDK/.gitignore | 8 +
sdks/android/UsergridAndroidSDK/build.gradle | 70 +
.../gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 53636 bytes
.../gradle/wrapper/gradle-wrapper.properties | 6 +
sdks/android/UsergridAndroidSDK/gradlew | 160 +
sdks/android/UsergridAndroidSDK/gradlew.bat | 90 +
.../libs/usergrid-java-client-2.1.0.jar | Bin 0 -> 1991936 bytes
.../UsergridAndroidSDK/proguard-rules.pro | 17 +
.../usergrid/android/ApplicationTest.java | 75 +
.../java/org/apache/usergrid/android/Book.java | 26 +
.../src/main/AndroidManifest.xml | 17 +
.../apache/usergrid/android/UsergridAsync.java | 474 +++
.../usergrid/android/UsergridEntityAsync.java | 110 +
.../usergrid/android/UsergridResponseAsync.java | 38 +
.../usergrid/android/UsergridSharedDevice.java | 175 +
.../usergrid/android/UsergridUserAsync.java | 125 +
.../UsergridCheckAvailabilityCallback.java | 21 +
.../callbacks/UsergridResponseCallback.java | 24 +
.../android/tasks/UsergridAsyncTask.java | 45 +
.../src/main/res/values/strings.xml | 3 +
sdks/android/assembly.xml | 55 -
sdks/android/build_release_zip.sh | 10 -
sdks/android/pom.xml | 106 -
.../usergrid/android/sdk/CounterIncrement.java | 72 -
.../sdk/DefaultURLConnectionFactory.java | 36 -
.../apache/usergrid/android/sdk/UGClient.java | 3181 ------------------
.../android/sdk/URLConnectionFactory.java | 30 -
.../sdk/callbacks/ApiResponseCallback.java | 31 -
.../android/sdk/callbacks/ClientAsyncTask.java | 66 -
.../android/sdk/callbacks/ClientCallback.java | 31 -
.../sdk/callbacks/GroupsRetrievedCallback.java | 35 -
.../sdk/callbacks/QueryResultsCallback.java | 33 -
.../usergrid/android/sdk/entities/Activity.java | 1019 ------
.../android/sdk/entities/Collection.java | 338 --
.../usergrid/android/sdk/entities/Device.java | 122 -
.../usergrid/android/sdk/entities/Entity.java | 552 ---
.../usergrid/android/sdk/entities/Group.java | 151 -
.../usergrid/android/sdk/entities/Message.java | 159 -
.../usergrid/android/sdk/entities/User.java | 315 --
.../android/sdk/exception/ClientException.java | 43 -
.../android/sdk/response/AggregateCounter.java | 58 -
.../sdk/response/AggregateCounterSet.java | 117 -
.../android/sdk/response/ApiResponse.java | 774 -----
.../sdk/response/ClientCredentialsInfo.java | 64 -
.../android/sdk/response/QueueInfo.java | 47 -
.../android/sdk/utils/DeviceUuidFactory.java | 173 -
.../usergrid/android/sdk/utils/JsonUtils.java | 185 -
.../usergrid/android/sdk/utils/MapUtils.java | 42 -
.../usergrid/android/sdk/utils/ObjectUtils.java | 39 -
.../usergrid/android/sdk/utils/UrlUtils.java | 127 -
135 files changed, 4996 insertions(+), 8290 deletions(-)
----------------------------------------------------------------------
[11/12] usergrid git commit: Added LISCENSE.txt
Posted by mr...@apache.org.
Added LISCENSE.txt
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/f1b0f987
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/f1b0f987
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/f1b0f987
Branch: refs/heads/master
Commit: f1b0f9876e7e6c9935757bbe944d5536786c8884
Parents: 22110ae
Author: Robert Walsh <rj...@gmail.com>
Authored: Mon Aug 8 17:26:14 2016 -0500
Committer: Robert Walsh <rj...@gmail.com>
Committed: Mon Aug 8 17:26:14 2016 -0500
----------------------------------------------------------------------
sdks/android/LICENSE.txt | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/f1b0f987/sdks/android/LICENSE.txt
----------------------------------------------------------------------
diff --git a/sdks/android/LICENSE.txt b/sdks/android/LICENSE.txt
new file mode 100644
index 0000000..34193ba
--- /dev/null
+++ b/sdks/android/LICENSE.txt
@@ -0,0 +1,19 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ *
+ */
[06/12] usergrid git commit: Adding new Android SDK
Posted by mr...@apache.org.
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/scrollable_alert_view.xml
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/scrollable_alert_view.xml b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/scrollable_alert_view.xml
new file mode 100644
index 0000000..a630675
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/scrollable_alert_view.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/scrollableAlertTitle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="16dip"
+ android:layout_marginRight="16dip"
+ android:layout_marginTop="10dip"
+ android:textAppearance="?android:attr/textAppearanceLarge" />
+
+ <ScrollView
+ android:layout_width="wrap_content" android:layout_height="wrap_content">
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/scrollableAlertMessage"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="16dip"
+ android:layout_marginRight="16dip"
+ android:layout_marginTop="20dip"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textColor="@color/colorPrimary"
+ android:background="@color/lightBlue"/>
+ </LinearLayout>
+ </ScrollView>
+</LinearLayout>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/mipmap-hdpi/ic_launcher.png
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/mipmap-hdpi/ic_launcher.png b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000..cde69bc
Binary files /dev/null and b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/mipmap-hdpi/ic_launcher.png differ
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/mipmap-mdpi/ic_launcher.png
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/mipmap-mdpi/ic_launcher.png b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000..c133a0c
Binary files /dev/null and b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/mipmap-mdpi/ic_launcher.png differ
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/mipmap-xhdpi/ic_launcher.png
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/mipmap-xhdpi/ic_launcher.png b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..bfa42f0
Binary files /dev/null and b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/mipmap-xhdpi/ic_launcher.png differ
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/mipmap-xxhdpi/ic_launcher.png
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/mipmap-xxhdpi/ic_launcher.png b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..324e72c
Binary files /dev/null and b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/mipmap-xxxhdpi/ic_launcher.png
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 0000000..aee44e1
Binary files /dev/null and b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/values-w820dp/dimens.xml
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/values-w820dp/dimens.xml b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/values-w820dp/dimens.xml
new file mode 100644
index 0000000..63fc816
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/values-w820dp/dimens.xml
@@ -0,0 +1,6 @@
+<resources>
+ <!-- Example customization of dimensions originally defined in res/values/dimens.xml
+ (such as screen margins) for screens with more than 820dp of available width. This
+ would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
+ <dimen name="activity_horizontal_margin">64dp</dimen>
+</resources>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/values/colors.xml
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/values/colors.xml b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/values/colors.xml
new file mode 100644
index 0000000..b26cbd3
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/values/colors.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <color name="colorPrimary">#135480</color>
+ <color name="colorPrimaryDark">#135480</color>
+ <color name="colorAccent">#FF4081</color>
+ <color name="lightBlue">#E8EEED</color>
+ <color name="white">#ffffff</color>
+</resources>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/values/dimens.xml
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/values/dimens.xml b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..47c8224
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/values/dimens.xml
@@ -0,0 +1,5 @@
+<resources>
+ <!-- Default screen margins, per the Android Design guidelines. -->
+ <dimen name="activity_horizontal_margin">16dp</dimen>
+ <dimen name="activity_vertical_margin">16dp</dimen>
+</resources>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/values/strings.xml
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/values/strings.xml b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/values/strings.xml
new file mode 100644
index 0000000..583eb46
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+<resources>
+ <string name="app_name">ActivityFeed</string>
+</resources>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/values/styles.xml
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/values/styles.xml b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/values/styles.xml
new file mode 100644
index 0000000..8690628
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/values/styles.xml
@@ -0,0 +1,19 @@
+<resources>
+
+ <!-- Base application theme. -->
+ <style name="AppTheme" parent="Theme.AppCompat.Light">
+ <!-- Customize your theme here. -->
+ <item name="colorPrimary">@color/colorPrimary</item>
+ <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
+ <item name="colorAccent">@color/colorAccent</item>
+ </style>
+ <style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
+ <item name="background">@color/lightBlue</item>
+ <item name="titleTextStyle">@style/MyActionBarTitle</item>
+ </style>
+
+ <style name="MyActionBarTitle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
+ <item name="android:textColor">@color/white</item>
+ </style>
+
+</resources>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/test/java/org/apache/usergrid/activityfeed/ExampleUnitTest.java
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/test/java/org/apache/usergrid/activityfeed/ExampleUnitTest.java b/sdks/android/Samples/ActivityFeed/activityfeed/src/test/java/org/apache/usergrid/activityfeed/ExampleUnitTest.java
new file mode 100644
index 0000000..8230157
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/activityfeed/src/test/java/org/apache/usergrid/activityfeed/ExampleUnitTest.java
@@ -0,0 +1,15 @@
+package org.apache.usergrid.activityfeed;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * To work on unit tests, switch the Test Artifact in the Build Variants view.
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() throws Exception {
+ assertEquals(4, 2 + 2);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/build.gradle
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/build.gradle b/sdks/android/Samples/ActivityFeed/build.gradle
new file mode 100644
index 0000000..03bced9
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/build.gradle
@@ -0,0 +1,23 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+ repositories {
+ jcenter()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:2.1.0'
+
+ // NOTE: Do not place your application dependencies here; they belong
+ // in the individual module build.gradle files
+ }
+}
+
+allprojects {
+ repositories {
+ jcenter()
+ }
+}
+
+task clean(type: Delete) {
+ delete rootProject.buildDir
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/gradle.properties
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/gradle.properties b/sdks/android/Samples/ActivityFeed/gradle.properties
new file mode 100644
index 0000000..1d3591c
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/gradle.properties
@@ -0,0 +1,18 @@
+# Project-wide Gradle settings.
+
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+# Default value: -Xmx10248m -XX:MaxPermSize=256m
+# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
+
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/gradle/wrapper/gradle-wrapper.jar
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/gradle/wrapper/gradle-wrapper.jar b/sdks/android/Samples/ActivityFeed/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..13372ae
Binary files /dev/null and b/sdks/android/Samples/ActivityFeed/gradle/wrapper/gradle-wrapper.jar differ
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/gradle/wrapper/gradle-wrapper.properties
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/gradle/wrapper/gradle-wrapper.properties b/sdks/android/Samples/ActivityFeed/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..122a0dc
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Mon Dec 28 10:00:20 PST 2015
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/gradlew
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/gradlew b/sdks/android/Samples/ActivityFeed/gradlew
new file mode 100755
index 0000000..9d82f78
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/gradlew
@@ -0,0 +1,160 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/gradlew.bat
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/gradlew.bat b/sdks/android/Samples/ActivityFeed/gradlew.bat
new file mode 100644
index 0000000..aec9973
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/settings.gradle
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/settings.gradle b/sdks/android/Samples/ActivityFeed/settings.gradle
new file mode 100644
index 0000000..05d5d93
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/settings.gradle
@@ -0,0 +1,2 @@
+include ':activityfeed', ':UsergridAndroidSDK'
+project (":UsergridAndroidSDK").projectDir = new File("../../UsergridAndroidSDK")
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/Push/.gitignore
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/.gitignore b/sdks/android/Samples/Push/.gitignore
new file mode 100644
index 0000000..c6cbe56
--- /dev/null
+++ b/sdks/android/Samples/Push/.gitignore
@@ -0,0 +1,8 @@
+*.iml
+.gradle
+/local.properties
+/.idea/workspace.xml
+/.idea/libraries
+.DS_Store
+/build
+/captures
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/Push/build.gradle
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/build.gradle b/sdks/android/Samples/Push/build.gradle
new file mode 100644
index 0000000..12e80f1
--- /dev/null
+++ b/sdks/android/Samples/Push/build.gradle
@@ -0,0 +1,22 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+ repositories {
+ jcenter()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:2.1.0'
+ // NOTE: Do not place your application dependencies here; they belong
+ // in the individual module build.gradle files
+ }
+}
+
+allprojects {
+ repositories {
+ jcenter()
+ }
+}
+
+task clean(type: Delete) {
+ delete rootProject.buildDir
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/Push/gradle.properties
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/gradle.properties b/sdks/android/Samples/Push/gradle.properties
new file mode 100644
index 0000000..1d3591c
--- /dev/null
+++ b/sdks/android/Samples/Push/gradle.properties
@@ -0,0 +1,18 @@
+# Project-wide Gradle settings.
+
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+# Default value: -Xmx10248m -XX:MaxPermSize=256m
+# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
+
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/Push/gradle/wrapper/gradle-wrapper.jar
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/gradle/wrapper/gradle-wrapper.jar b/sdks/android/Samples/Push/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..13372ae
Binary files /dev/null and b/sdks/android/Samples/Push/gradle/wrapper/gradle-wrapper.jar differ
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/Push/gradle/wrapper/gradle-wrapper.properties
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/gradle/wrapper/gradle-wrapper.properties b/sdks/android/Samples/Push/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..122a0dc
--- /dev/null
+++ b/sdks/android/Samples/Push/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Mon Dec 28 10:00:20 PST 2015
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/Push/gradlew
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/gradlew b/sdks/android/Samples/Push/gradlew
new file mode 100755
index 0000000..9d82f78
--- /dev/null
+++ b/sdks/android/Samples/Push/gradlew
@@ -0,0 +1,160 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/Push/gradlew.bat
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/gradlew.bat b/sdks/android/Samples/Push/gradlew.bat
new file mode 100644
index 0000000..aec9973
--- /dev/null
+++ b/sdks/android/Samples/Push/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/Push/push/.gitignore
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/push/.gitignore b/sdks/android/Samples/Push/push/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/sdks/android/Samples/Push/push/.gitignore
@@ -0,0 +1 @@
+/build
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/Push/push/build.gradle
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/push/build.gradle b/sdks/android/Samples/Push/push/build.gradle
new file mode 100644
index 0000000..2b845b3
--- /dev/null
+++ b/sdks/android/Samples/Push/push/build.gradle
@@ -0,0 +1,27 @@
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 23
+ buildToolsVersion "22.0.1"
+
+ defaultConfig {
+ applicationId "org.apache.usergrid.push"
+ minSdkVersion 17
+ targetSdkVersion 23
+ versionCode 1
+ versionName "1.0"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+}
+
+dependencies {
+ compile fileTree(include: ['*.jar'], dir: 'libs')
+ testCompile 'junit:junit:4.12'
+ compile 'com.android.support:appcompat-v7:23.3.0'
+ compile project(':UsergridAndroidSDK')
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/Push/push/libs/gcm.jar
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/push/libs/gcm.jar b/sdks/android/Samples/Push/push/libs/gcm.jar
new file mode 100755
index 0000000..ac109a8
Binary files /dev/null and b/sdks/android/Samples/Push/push/libs/gcm.jar differ
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/Push/push/proguard-rules.pro
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/push/proguard-rules.pro b/sdks/android/Samples/Push/push/proguard-rules.pro
new file mode 100644
index 0000000..73ed137
--- /dev/null
+++ b/sdks/android/Samples/Push/push/proguard-rules.pro
@@ -0,0 +1,17 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in /Users/ApigeeCorporation/Developer/android_sdk_files/sdk/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/Push/push/src/androidTest/java/org/apache/usergrid/push/ApplicationTest.java
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/push/src/androidTest/java/org/apache/usergrid/push/ApplicationTest.java b/sdks/android/Samples/Push/push/src/androidTest/java/org/apache/usergrid/push/ApplicationTest.java
new file mode 100644
index 0000000..a9f1c73
--- /dev/null
+++ b/sdks/android/Samples/Push/push/src/androidTest/java/org/apache/usergrid/push/ApplicationTest.java
@@ -0,0 +1,13 @@
+package org.apache.usergrid.push;
+
+import android.app.Application;
+import android.test.ApplicationTestCase;
+
+/**
+ * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
+ */
+public class ApplicationTest extends ApplicationTestCase<Application> {
+ public ApplicationTest() {
+ super(Application.class);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/Push/push/src/main/AndroidManifest.xml
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/push/src/main/AndroidManifest.xml b/sdks/android/Samples/Push/push/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..bbfaaf4
--- /dev/null
+++ b/sdks/android/Samples/Push/push/src/main/AndroidManifest.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="org.apache.usergrid.push" >
+
+ <uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.READ_PHONE_STATE" />
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+ <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
+ <uses-permission android:name="android.permission.GET_ACCOUNTS" />
+ <uses-permission android:name="android.permission.WAKE_LOCK" />
+
+ <permission
+ android:name="org.apache.usergrid.push.gcm.permission.C2D_MESSAGE"
+ android:protectionLevel="signature" />
+
+ <uses-permission android:name="org.apache.usergrid.push.gcm.permission.C2D_MESSAGE" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@mipmap/ic_launcher"
+ android:label="@string/app_name"
+ android:supportsRtl="true"
+ android:theme="@style/AppTheme" >
+ <receiver
+ android:name="com.google.android.gcm.GCMBroadcastReceiver"
+ android:permission="com.google.android.c2dm.permission.SEND" >
+ <intent-filter>
+ <action android:name="com.google.android.c2dm.intent.RECEIVE" />
+ <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
+
+ <category android:name="org.apache.usergrid.push" />
+ </intent-filter>
+ </receiver>
+
+ <service android:name=".GCMIntentService" />
+
+ <activity android:name=".MainActivity" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity android:name=".SettingsActivity" >
+ </activity>
+ </application>
+
+</manifest>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/Push/push/src/main/java/org/apache/usergrid/push/GCMIntentService.java
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/push/src/main/java/org/apache/usergrid/push/GCMIntentService.java b/sdks/android/Samples/Push/push/src/main/java/org/apache/usergrid/push/GCMIntentService.java
new file mode 100644
index 0000000..5faeb01
--- /dev/null
+++ b/sdks/android/Samples/Push/push/src/main/java/org/apache/usergrid/push/GCMIntentService.java
@@ -0,0 +1,85 @@
+package org.apache.usergrid.push;
+
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.Intent;
+import android.support.v4.app.NotificationCompat;
+import android.util.Log;
+
+import com.google.android.gcm.GCMBaseIntentService;
+
+public class GCMIntentService extends GCMBaseIntentService {
+
+ public GCMIntentService() {
+ super(MainActivity.GCM_SENDER_ID);
+ }
+
+ @Override
+ protected void onRegistered(Context context, String registrationId) {
+ Log.i(TAG, "Device registered: " + registrationId);
+ MainActivity.registerPush(context,registrationId);
+ }
+
+ @Override
+ protected void onUnregistered(Context context, String registrationId) {
+ Log.i(TAG, "Device unregistered");
+ }
+
+ @Override
+ protected void onMessage(Context context, Intent intent) {
+ String message = intent.getExtras().getString("data");
+ Log.i(TAG, "Received message: " + message);
+ generateNotification(context, message);
+ }
+
+ @Override
+ protected void onDeletedMessages(Context context, int total) {
+ Log.i(TAG, "Received deleted messages notification");
+ String message = "GCM server deleted " + total +" pending messages!";
+ generateNotification(context, message);
+ }
+
+ @Override
+ public void onError(Context context, String errorId) {
+ Log.i(TAG, "Received error: " + errorId);
+ }
+
+ @Override
+ protected boolean onRecoverableError(Context context, String errorId) {
+ Log.i(TAG, "Received recoverable error: " + errorId);
+ return super.onRecoverableError(context, errorId);
+ }
+
+ /**
+ * Issues a Notification to inform the user that server has sent a message.
+ */
+ private static void generateNotification(Context context, String message) {
+ long when = System.currentTimeMillis();
+ NotificationManager notificationManager = (NotificationManager)
+ context.getSystemService(Context.NOTIFICATION_SERVICE);
+
+ Intent notificationIntent = new Intent(context, MainActivity.class);
+ // set intent so it does not start a new activity
+ notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
+ PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
+
+ Notification notification = new NotificationCompat.Builder(context)
+ .setContentText(message)
+ .setContentTitle(context.getString(R.string.app_name))
+ .setWhen(when)
+ .setSmallIcon(R.drawable.usergridguy)
+ .setContentIntent(intent)
+ .build();
+
+ notification.flags |= Notification.FLAG_AUTO_CANCEL;
+
+ // Play default notification sound
+ notification.defaults |= Notification.DEFAULT_SOUND;
+
+ // Vibrate if vibrate is enabled
+ notification.defaults |= Notification.DEFAULT_VIBRATE;
+ notificationManager.notify(0, notification);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/Push/push/src/main/java/org/apache/usergrid/push/MainActivity.java
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/push/src/main/java/org/apache/usergrid/push/MainActivity.java b/sdks/android/Samples/Push/push/src/main/java/org/apache/usergrid/push/MainActivity.java
new file mode 100644
index 0000000..084dceb
--- /dev/null
+++ b/sdks/android/Samples/Push/push/src/main/java/org/apache/usergrid/push/MainActivity.java
@@ -0,0 +1,162 @@
+package org.apache.usergrid.push;
+
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.v7.app.AppCompatActivity;
+import android.util.Log;
+import android.view.View;
+import android.widget.Button;
+import android.widget.ImageButton;
+
+import com.google.android.gcm.GCMRegistrar;
+
+import org.apache.usergrid.android.UsergridAsync;
+import org.apache.usergrid.android.UsergridSharedDevice;
+import org.apache.usergrid.android.callbacks.UsergridResponseCallback;
+import org.apache.usergrid.java.client.Usergrid;
+import org.apache.usergrid.java.client.UsergridClientConfig;
+import org.apache.usergrid.java.client.UsergridEnums;
+import org.apache.usergrid.java.client.UsergridRequest;
+import org.apache.usergrid.java.client.response.UsergridResponse;
+
+import java.util.HashMap;
+
+public class MainActivity extends AppCompatActivity {
+
+ public static String ORG_ID = "rwalsh";
+ public static String APP_ID = "sandbox";
+ public static String BASE_URL = "https://api.usergrid.com";
+
+ public static String NOTIFIER_ID = "androidPushNotifier";
+ public static String GCM_SENDER_ID = "186455511595";
+ public static String GCM_REGISTRATION_ID = "";
+
+ public static boolean USERGRID_PREFS_NEEDS_REFRESH = false;
+ private static final String USERGRID_PREFS_FILE_NAME = "usergrid_prefs.xml";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ retrieveSavedPrefs();
+ Usergrid.initSharedInstance(ORG_ID,APP_ID,BASE_URL);
+ MainActivity.registerPush(this);
+
+ final ImageButton infoButton = (ImageButton) findViewById(R.id.infoButton);
+ if( infoButton != null ) {
+ final Intent settingsActivity = new Intent(this, SettingsActivity.class);
+ infoButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ MainActivity.this.startActivity(settingsActivity);
+ }
+ });
+ }
+
+ final Button pushToThisDeviceButton = (Button) findViewById(R.id.pushToThisDevice);
+ if( pushToThisDeviceButton != null ) {
+ pushToThisDeviceButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ MainActivity.this.sendPush(UsergridSharedDevice.getSharedDeviceUUID(MainActivity.this),"Push To This Device");
+ }
+ });
+ }
+ final Button pushToAllDevicesButton = (Button) findViewById(R.id.pushToAllDevices);
+ if( pushToAllDevicesButton != null ) {
+ pushToAllDevicesButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ MainActivity.this.sendPush("*","Push To All Devices");
+ }
+ });
+ }
+ }
+
+ @Override
+ protected void onResume() {
+ if( USERGRID_PREFS_NEEDS_REFRESH ) {
+ Usergrid.setConfig(new UsergridClientConfig(ORG_ID,APP_ID,BASE_URL));
+ if( GCM_REGISTRATION_ID != null && !GCM_REGISTRATION_ID.isEmpty() ) {
+ UsergridAsync.applyPushToken(this, GCM_REGISTRATION_ID, MainActivity.NOTIFIER_ID, new UsergridResponseCallback() {
+ @Override
+ public void onResponse(@NonNull UsergridResponse response) { }
+ });
+ }
+ this.savePrefs();
+ USERGRID_PREFS_NEEDS_REFRESH = false;
+ }
+ super.onResume();
+ }
+
+ @Override
+ protected void onDestroy() {
+ this.savePrefs();
+ super.onDestroy();
+ }
+
+ public static void registerPush(Context context) {
+ final String regId = GCMRegistrar.getRegistrationId(context);
+ if ("".equals(regId)) {
+ GCMRegistrar.register(context, GCM_SENDER_ID);
+ } else {
+ if (GCMRegistrar.isRegisteredOnServer(context)) {
+ Log.i("", "Already registered with GCM");
+ } else {
+ MainActivity.registerPush(context, regId);
+ }
+ }
+ }
+
+ public static void registerPush(@NonNull final Context context, @NonNull final String registrationId) {
+ MainActivity.GCM_REGISTRATION_ID = registrationId;
+ UsergridAsync.applyPushToken(context, registrationId, MainActivity.NOTIFIER_ID, new UsergridResponseCallback() {
+ @Override
+ public void onResponse(@NonNull UsergridResponse response) {
+ if( !response.ok() ) {
+ System.out.print("Error Description :" + response.getResponseError().toString());
+ }
+ }
+ });
+ }
+
+ public void sendPush(@NonNull final String deviceId, @NonNull final String message) {
+ HashMap<String,String> notificationMap = new HashMap<>();
+ notificationMap.put(MainActivity.NOTIFIER_ID,message);
+ HashMap<String,HashMap<String,String>> payloadMap = new HashMap<>();
+ payloadMap.put("payloads",notificationMap);
+
+ UsergridRequest notificationRequest = new UsergridRequest(UsergridEnums.UsergridHttpMethod.POST,UsergridRequest.APPLICATION_JSON_MEDIA_TYPE,Usergrid.clientAppUrl(),null,payloadMap,Usergrid.authForRequests(),"devices", deviceId, "notifications");
+ UsergridAsync.sendRequest(notificationRequest, new UsergridResponseCallback() {
+ @Override
+ public void onResponse(@NonNull UsergridResponse response) {
+ System.out.print("Push request completed successfully :" + response.ok());
+ if(!response.ok() && response.getResponseError() != null) {
+ System.out.print("Error Description :" + response.getResponseError().toString());
+ }
+ }
+ });
+ }
+
+ public void savePrefs() {
+ SharedPreferences prefs = this.getSharedPreferences(USERGRID_PREFS_FILE_NAME, Context.MODE_PRIVATE);
+ SharedPreferences.Editor editor = prefs.edit();
+ editor.putString("ORG_ID", ORG_ID);
+ editor.putString("APP_ID", APP_ID);
+ editor.putString("BASE_URL", BASE_URL);
+ editor.putString("NOTIFIER_ID", NOTIFIER_ID);
+ editor.apply();
+ }
+
+ public void retrieveSavedPrefs() {
+ SharedPreferences prefs = this.getSharedPreferences(USERGRID_PREFS_FILE_NAME, Context.MODE_PRIVATE);
+ ORG_ID = prefs.getString("ORG_ID", ORG_ID);
+ APP_ID = prefs.getString("APP_ID", APP_ID);
+ BASE_URL = prefs.getString("BASE_URL",BASE_URL);
+ NOTIFIER_ID = prefs.getString("NOTIFIER_ID",NOTIFIER_ID);
+ }
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/Push/push/src/main/java/org/apache/usergrid/push/SettingsActivity.java
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/push/src/main/java/org/apache/usergrid/push/SettingsActivity.java b/sdks/android/Samples/Push/push/src/main/java/org/apache/usergrid/push/SettingsActivity.java
new file mode 100644
index 0000000..54ea269
--- /dev/null
+++ b/sdks/android/Samples/Push/push/src/main/java/org/apache/usergrid/push/SettingsActivity.java
@@ -0,0 +1,68 @@
+package org.apache.usergrid.push;
+
+import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+import org.apache.usergrid.java.client.Usergrid;
+
+public class SettingsActivity extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_settings);
+
+ final EditText orgIdEditText = (EditText) findViewById(R.id.orgId);
+ if( orgIdEditText != null ) {
+ orgIdEditText.setText(Usergrid.getOrgId());
+ }
+ final EditText appIdEditText = (EditText) findViewById(R.id.appId);
+ if( appIdEditText != null ) {
+ appIdEditText.setText(Usergrid.getAppId());
+ }
+ final EditText urlEditText = (EditText) findViewById(R.id.url);
+ if( urlEditText != null ) {
+ urlEditText.setText(Usergrid.getBaseUrl());
+ }
+ final EditText notifierIdEditText = (EditText) findViewById(R.id.notifierId);
+ if( notifierIdEditText != null ) {
+ notifierIdEditText.setText(MainActivity.NOTIFIER_ID);
+ }
+
+ final Button saveButton = (Button) findViewById(R.id.saveButton);
+ if( saveButton != null ) {
+ saveButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if( orgIdEditText != null ) {
+ MainActivity.ORG_ID = orgIdEditText.getText().toString();
+ }
+ if( appIdEditText != null ) {
+ MainActivity.APP_ID = appIdEditText.getText().toString();
+ }
+ if( urlEditText != null ) {
+ MainActivity.BASE_URL = urlEditText.getText().toString();
+ }
+ if( notifierIdEditText != null ) {
+ MainActivity.NOTIFIER_ID = notifierIdEditText.getText().toString();
+ }
+ MainActivity.USERGRID_PREFS_NEEDS_REFRESH = true;
+ SettingsActivity.this.finish();
+ }
+ });
+ }
+
+ final Button cancelButton = (Button) findViewById(R.id.cancelButton);
+ if( cancelButton != null ) {
+ cancelButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ SettingsActivity.this.finish();
+ }
+ });
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/Push/push/src/main/res/drawable/info.png
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/push/src/main/res/drawable/info.png b/sdks/android/Samples/Push/push/src/main/res/drawable/info.png
new file mode 100644
index 0000000..534d0ae
Binary files /dev/null and b/sdks/android/Samples/Push/push/src/main/res/drawable/info.png differ
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/Push/push/src/main/res/drawable/usergridguy.png
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/push/src/main/res/drawable/usergridguy.png b/sdks/android/Samples/Push/push/src/main/res/drawable/usergridguy.png
new file mode 100644
index 0000000..b8a6844
Binary files /dev/null and b/sdks/android/Samples/Push/push/src/main/res/drawable/usergridguy.png differ
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/Push/push/src/main/res/layout/activity_main.xml
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/push/src/main/res/layout/activity_main.xml b/sdks/android/Samples/Push/push/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..a365c94
--- /dev/null
+++ b/sdks/android/Samples/Push/push/src/main/res/layout/activity_main.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingBottom="@dimen/activity_vertical_margin"
+ android:paddingLeft="@dimen/activity_horizontal_margin"
+ android:paddingRight="@dimen/activity_horizontal_margin"
+ android:paddingTop="@dimen/activity_vertical_margin"
+ tools:context=".MainActivity"
+ android:background="@color/colorPrimary">
+
+ <ImageView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/usergridGuy"
+ android:minWidth="175dp"
+ android:minHeight="175dp"
+ android:maxHeight="175dp"
+ android:maxWidth="175dp"
+ android:clickable="false"
+ android:src="@drawable/usergridguy"
+ android:layout_centerVertical="true"
+ android:layout_alignStart="@+id/pushToAllDevices" />
+
+ <Button
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Push To All Devices"
+ android:id="@+id/pushToAllDevices"
+ android:layout_alignParentBottom="true"
+ android:layout_centerHorizontal="true"
+ android:minHeight="175dp"
+ android:maxWidth="175dp"
+ android:minWidth="175dp"
+ android:maxHeight="175dp"
+ android:background="#95b8cb"
+ android:textColor="#ffffff"
+ android:textSize="10dp"
+ android:clickable="true" />
+
+ <Button
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Push To This Device"
+ android:id="@+id/pushToThisDevice"
+ android:minHeight="175dp"
+ android:maxWidth="175dp"
+ android:minWidth="175dp"
+ android:maxHeight="175dp"
+ android:background="#95b8cb"
+ android:textColor="@color/background_floating_material_light"
+ android:textSize="10dp"
+ android:layout_alignParentTop="true"
+ android:layout_alignStart="@+id/usergridGuy"
+ android:clickable="true" />
+
+ <ImageButton
+ android:layout_width="30dp"
+ android:layout_height="30dp"
+ android:id="@+id/infoButton"
+ android:src="@drawable/info"
+ android:background="@null"
+ android:layout_alignParentBottom="true"
+ android:layout_alignParentEnd="true"
+ android:adjustViewBounds="true"
+ android:scaleType="centerCrop" />
+
+</RelativeLayout>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/Push/push/src/main/res/layout/activity_settings.xml
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/push/src/main/res/layout/activity_settings.xml b/sdks/android/Samples/Push/push/src/main/res/layout/activity_settings.xml
new file mode 100644
index 0000000..0f6626b
--- /dev/null
+++ b/sdks/android/Samples/Push/push/src/main/res/layout/activity_settings.xml
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingLeft="@dimen/activity_horizontal_margin"
+ android:paddingRight="@dimen/activity_horizontal_margin"
+ android:paddingTop="@dimen/activity_vertical_margin"
+ android:paddingBottom="@dimen/activity_vertical_margin"
+ tools:context="org.apache.usergrid.push.SettingsActivity"
+ android:background="@color/colorPrimary"
+ android:minHeight="30dp">
+
+ <EditText
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/orgId"
+ android:layout_alignParentTop="true"
+ android:layout_centerHorizontal="true"
+ android:minWidth="300dp"
+ android:background="@android:color/white"
+ android:layout_marginTop="30dp"
+ android:hint="Org Id"
+ android:paddingStart="10dp"
+ android:minHeight="30dp"
+ android:maxLines="1"
+ android:singleLine="true"
+ android:maxWidth="300dp" />
+
+ <EditText
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/appId"
+ android:minWidth="300dp"
+ android:background="@android:color/white"
+ android:layout_marginTop="30dp"
+ android:layout_below="@+id/orgId"
+ android:layout_centerHorizontal="true"
+ android:hint="App Id"
+ android:paddingStart="10dp"
+ android:minHeight="30dp"
+ android:maxLines="1"
+ android:singleLine="true"
+ android:maxWidth="300dp" />
+
+ <EditText
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/url"
+ android:minWidth="300dp"
+ android:background="@android:color/white"
+ android:layout_marginTop="30dp"
+ android:layout_below="@+id/appId"
+ android:layout_centerHorizontal="true"
+ android:hint="URL"
+ android:paddingStart="10dp"
+ android:minHeight="30dp"
+ android:maxLines="1"
+ android:singleLine="true"
+ android:maxWidth="300dp" />
+
+ <EditText
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/notifierId"
+ android:minWidth="300dp"
+ android:background="@android:color/white"
+ android:layout_marginTop="30dp"
+ android:layout_below="@+id/url"
+ android:layout_centerHorizontal="true"
+ android:hint="Notifier Id"
+ android:paddingStart="10dp"
+ android:minHeight="30dp"
+ android:maxLines="1"
+ android:singleLine="true"
+ android:maxWidth="300dp" />
+
+ <Button
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Save"
+ android:id="@+id/saveButton"
+ android:layout_marginTop="23dp"
+ android:layout_below="@+id/notifierId"
+ android:layout_alignEnd="@+id/notifierId" />
+
+ <Button
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Cancel"
+ android:id="@+id/cancelButton"
+ android:layout_alignTop="@+id/saveButton"
+ android:layout_alignStart="@+id/notifierId" />
+</RelativeLayout>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/Push/push/src/main/res/mipmap-hdpi/ic_launcher.png
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/push/src/main/res/mipmap-hdpi/ic_launcher.png b/sdks/android/Samples/Push/push/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000..cde69bc
Binary files /dev/null and b/sdks/android/Samples/Push/push/src/main/res/mipmap-hdpi/ic_launcher.png differ
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/Push/push/src/main/res/mipmap-mdpi/ic_launcher.png
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/push/src/main/res/mipmap-mdpi/ic_launcher.png b/sdks/android/Samples/Push/push/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000..c133a0c
Binary files /dev/null and b/sdks/android/Samples/Push/push/src/main/res/mipmap-mdpi/ic_launcher.png differ
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/Push/push/src/main/res/mipmap-xhdpi/ic_launcher.png
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/push/src/main/res/mipmap-xhdpi/ic_launcher.png b/sdks/android/Samples/Push/push/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..bfa42f0
Binary files /dev/null and b/sdks/android/Samples/Push/push/src/main/res/mipmap-xhdpi/ic_launcher.png differ
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/Push/push/src/main/res/mipmap-xxhdpi/ic_launcher.png
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/push/src/main/res/mipmap-xxhdpi/ic_launcher.png b/sdks/android/Samples/Push/push/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..324e72c
Binary files /dev/null and b/sdks/android/Samples/Push/push/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/Push/push/src/main/res/mipmap-xxxhdpi/ic_launcher.png
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/push/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/sdks/android/Samples/Push/push/src/main/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 0000000..aee44e1
Binary files /dev/null and b/sdks/android/Samples/Push/push/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/Push/push/src/main/res/values-w820dp/dimens.xml
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/push/src/main/res/values-w820dp/dimens.xml b/sdks/android/Samples/Push/push/src/main/res/values-w820dp/dimens.xml
new file mode 100644
index 0000000..63fc816
--- /dev/null
+++ b/sdks/android/Samples/Push/push/src/main/res/values-w820dp/dimens.xml
@@ -0,0 +1,6 @@
+<resources>
+ <!-- Example customization of dimensions originally defined in res/values/dimens.xml
+ (such as screen margins) for screens with more than 820dp of available width. This
+ would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
+ <dimen name="activity_horizontal_margin">64dp</dimen>
+</resources>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/Push/push/src/main/res/values/colors.xml
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/push/src/main/res/values/colors.xml b/sdks/android/Samples/Push/push/src/main/res/values/colors.xml
new file mode 100644
index 0000000..75703af
--- /dev/null
+++ b/sdks/android/Samples/Push/push/src/main/res/values/colors.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <color name="colorPrimary">#1b5d89</color>
+ <color name="colorPrimaryDark">#303F9F</color>
+ <color name="colorAccent">#FF4081</color>
+</resources>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/Push/push/src/main/res/values/dimens.xml
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/push/src/main/res/values/dimens.xml b/sdks/android/Samples/Push/push/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..47c8224
--- /dev/null
+++ b/sdks/android/Samples/Push/push/src/main/res/values/dimens.xml
@@ -0,0 +1,5 @@
+<resources>
+ <!-- Default screen margins, per the Android Design guidelines. -->
+ <dimen name="activity_horizontal_margin">16dp</dimen>
+ <dimen name="activity_vertical_margin">16dp</dimen>
+</resources>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/Push/push/src/main/res/values/strings.xml
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/push/src/main/res/values/strings.xml b/sdks/android/Samples/Push/push/src/main/res/values/strings.xml
new file mode 100644
index 0000000..f0817ce
--- /dev/null
+++ b/sdks/android/Samples/Push/push/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+<resources>
+ <string name="app_name">Apigee Push</string>
+</resources>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/Push/push/src/main/res/values/styles.xml
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/push/src/main/res/values/styles.xml b/sdks/android/Samples/Push/push/src/main/res/values/styles.xml
new file mode 100644
index 0000000..0eb88fe
--- /dev/null
+++ b/sdks/android/Samples/Push/push/src/main/res/values/styles.xml
@@ -0,0 +1,11 @@
+<resources>
+
+ <!-- Base application theme. -->
+ <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
+ <!-- Customize your theme here. -->
+ <item name="colorPrimary">@color/colorPrimary</item>
+ <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
+ <item name="colorAccent">@color/colorAccent</item>
+ </style>
+
+</resources>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/Push/push/src/test/java/org/apache/usergrid/push/ExampleUnitTest.java
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/push/src/test/java/org/apache/usergrid/push/ExampleUnitTest.java b/sdks/android/Samples/Push/push/src/test/java/org/apache/usergrid/push/ExampleUnitTest.java
new file mode 100644
index 0000000..fcc42bf
--- /dev/null
+++ b/sdks/android/Samples/Push/push/src/test/java/org/apache/usergrid/push/ExampleUnitTest.java
@@ -0,0 +1,15 @@
+package org.apache.usergrid.push;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * To work on unit tests, switch the Test Artifact in the Build Variants view.
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() throws Exception {
+ assertEquals(4, 2 + 2);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/Push/settings.gradle
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/settings.gradle b/sdks/android/Samples/Push/settings.gradle
new file mode 100644
index 0000000..f1ac978
--- /dev/null
+++ b/sdks/android/Samples/Push/settings.gradle
@@ -0,0 +1,2 @@
+include ':push', ':UsergridAndroidSDK'
+project (":UsergridAndroidSDK").projectDir = new File("../../UsergridAndroidSDK")
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/UsergridAndroidSDK/.gitignore
----------------------------------------------------------------------
diff --git a/sdks/android/UsergridAndroidSDK/.gitignore b/sdks/android/UsergridAndroidSDK/.gitignore
new file mode 100644
index 0000000..c6cbe56
--- /dev/null
+++ b/sdks/android/UsergridAndroidSDK/.gitignore
@@ -0,0 +1,8 @@
+*.iml
+.gradle
+/local.properties
+/.idea/workspace.xml
+/.idea/libraries
+.DS_Store
+/build
+/captures
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/UsergridAndroidSDK/build.gradle
----------------------------------------------------------------------
diff --git a/sdks/android/UsergridAndroidSDK/build.gradle b/sdks/android/UsergridAndroidSDK/build.gradle
new file mode 100644
index 0000000..ef2db46
--- /dev/null
+++ b/sdks/android/UsergridAndroidSDK/build.gradle
@@ -0,0 +1,70 @@
+apply plugin: 'com.android.library'
+apply plugin: 'com.jfrog.bintray'
+apply plugin: 'com.github.dcendents.android-maven'
+
+buildscript {
+ repositories {
+ jcenter()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:2.1.0'
+ classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
+ classpath "com.github.dcendents:android-maven-gradle-plugin:1.3"
+ }
+}
+
+android {
+ compileSdkVersion 17
+ buildToolsVersion "22.0.1"
+
+ group = 'org.apache.usergrid.android'
+ version = '2.1.0'
+
+ defaultConfig {
+ minSdkVersion 17
+ targetSdkVersion 23
+ versionCode 1
+ versionName "2.1.0"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+}
+
+dependencies {
+ repositories {
+ mavenCentral()
+ }
+ compile fileTree(dir: 'libs', include: ['*.jar'])
+ testCompile 'junit:junit:4.12'
+}
+
+task generateSourcesJar(type: Jar) {
+ from android.sourceSets.main.java.srcDirs
+ classifier 'sources'
+}
+artifacts {
+ archives generateSourcesJar
+}
+
+bintray {
+ user = 'rwalsh'
+ key = '3ae2887b2af626dab61faffd57b99303e146feb6'
+ pkg {
+ repo = 'maven'
+ name = 'org.apache.usergrid.android'
+ version {
+ name = '2.1.0'
+ desc = 'Usergrid Android Client'
+ released = new Date()
+ }
+
+ licenses = ['Apache-2.0']
+ vcsUrl = 'https://github.com/apache/usergrid.git'
+ websiteUrl = 'https://github.com/apache/usergrid'
+ }
+ configurations = ['archives']
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/UsergridAndroidSDK/gradle/wrapper/gradle-wrapper.jar
----------------------------------------------------------------------
diff --git a/sdks/android/UsergridAndroidSDK/gradle/wrapper/gradle-wrapper.jar b/sdks/android/UsergridAndroidSDK/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..13372ae
Binary files /dev/null and b/sdks/android/UsergridAndroidSDK/gradle/wrapper/gradle-wrapper.jar differ
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/UsergridAndroidSDK/gradle/wrapper/gradle-wrapper.properties
----------------------------------------------------------------------
diff --git a/sdks/android/UsergridAndroidSDK/gradle/wrapper/gradle-wrapper.properties b/sdks/android/UsergridAndroidSDK/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..122a0dc
--- /dev/null
+++ b/sdks/android/UsergridAndroidSDK/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Mon Dec 28 10:00:20 PST 2015
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/UsergridAndroidSDK/gradlew
----------------------------------------------------------------------
diff --git a/sdks/android/UsergridAndroidSDK/gradlew b/sdks/android/UsergridAndroidSDK/gradlew
new file mode 100644
index 0000000..9d82f78
--- /dev/null
+++ b/sdks/android/UsergridAndroidSDK/gradlew
@@ -0,0 +1,160 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/UsergridAndroidSDK/gradlew.bat
----------------------------------------------------------------------
diff --git a/sdks/android/UsergridAndroidSDK/gradlew.bat b/sdks/android/UsergridAndroidSDK/gradlew.bat
new file mode 100644
index 0000000..aec9973
--- /dev/null
+++ b/sdks/android/UsergridAndroidSDK/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/UsergridAndroidSDK/libs/usergrid-java-client-2.1.0.jar
----------------------------------------------------------------------
diff --git a/sdks/android/UsergridAndroidSDK/libs/usergrid-java-client-2.1.0.jar b/sdks/android/UsergridAndroidSDK/libs/usergrid-java-client-2.1.0.jar
new file mode 100644
index 0000000..d77cd88
Binary files /dev/null and b/sdks/android/UsergridAndroidSDK/libs/usergrid-java-client-2.1.0.jar differ
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/UsergridAndroidSDK/proguard-rules.pro
----------------------------------------------------------------------
diff --git a/sdks/android/UsergridAndroidSDK/proguard-rules.pro b/sdks/android/UsergridAndroidSDK/proguard-rules.pro
new file mode 100644
index 0000000..73ed137
--- /dev/null
+++ b/sdks/android/UsergridAndroidSDK/proguard-rules.pro
@@ -0,0 +1,17 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in /Users/ApigeeCorporation/Developer/android_sdk_files/sdk/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
[09/12] usergrid git commit: Added initial ReadMe but will need to
update it for async operations.
Posted by mr...@apache.org.
Added initial ReadMe but will need to update it for async operations.
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/8ddc90de
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/8ddc90de
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/8ddc90de
Branch: refs/heads/master
Commit: 8ddc90de57fee175d08e07c5292ef0a2add28458
Parents: 2e80d24
Author: Robert Walsh <rj...@gmail.com>
Authored: Mon Aug 8 16:20:01 2016 -0500
Committer: Robert Walsh <rj...@gmail.com>
Committed: Mon Aug 8 16:20:01 2016 -0500
----------------------------------------------------------------------
sdks/android/README.md | 580 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 580 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/8ddc90de/sdks/android/README.md
----------------------------------------------------------------------
diff --git a/sdks/android/README.md b/sdks/android/README.md
new file mode 100644
index 0000000..a1cbf41
--- /dev/null
+++ b/sdks/android/README.md
@@ -0,0 +1,580 @@
+# Usergrid Android SDK
+
+Usergrid SDK written for Android
+
+## Initialization
+
+There are two different ways of initializing the Usergrid Android SDK:
+
+1. The singleton pattern is both convenient and enables the developer to use a globally available and always-initialized instance of Usergrid.
+
+```java
+Usergrid.initSharedInstance("orgId", "appId");
+```
+
+2. The Instance pattern enables the developer to manage instances of the Usergrid client independently and in an isolated fashion. The primary use-case for this is when an application connects to multiple Usergrid targets.
+
+```java
+UsergridClient client = new UsergridClient("orgId","appId");
+```
+
+_Note: Examples in this readme assume you are using the `Usergrid` shared instance. If you've implemented the instance pattern instead, simply replace `Usergrid` with your client instance variable._
+
+## RESTful operations
+
+When making any RESTful call, a `type` parameter (or `path`) is always required. Whether you specify this as an argument or in an object as a parameter is up to you.
+
+### GET
+
+- To get entities in a collection:
+
+```java
+UsergridResponse response = Usergrid.GET("collection");
+List<UsergridEntity> entities = response.getEntities();
+```
+
+- To get a specific entity in a collection by uuid or name:
+
+```java
+UsergridResponse response = Usergrid.GET("collection","<uuid-or-name>");
+UsergridEntity entities = response.entity();
+```
+
+- To get specific entities in a collection by passing a `UsergridQuery` object:
+
+```java
+UsergridQuery query = new UsergridQuery("cats").gt("weight", 2.4)
+ .contains("color", "bl*")
+ .not()
+ .eq("color", "blue")
+ .or()
+ .eq("color", "orange");
+
+// this will build out the following query:
+// select * where weight > 2.4 and color contains 'bl*' and not color = 'blue' or color = 'orange'
+
+UsergridResponse response = Usergrid.GET(query);
+List<UsergridEntity> entities = response.getEntities();
+```
+
+### POST and PUT
+
+POST and PUT requests both require a JSON body payload. You can pass either a Java object or a `UsergridEntity` instance. While the former works in principle, best practise is to use a `UsergridEntity` wherever practical. When an entity has a uuid or name property and already exists on the server, use a PUT request to update it. If it does not, use POST to create it.
+
+- To create a new entity in a collection (**POST**):
+
+```java
+HashMap<String,String> propertyMap = new HashMap<>();
+propertyMap.put("cuisine","pizza");
+UsergridEntity entity = new UsergridEntity("restaurant","Dino's Deep Dish", propertyMap);
+Usergrid.POST(entity); // entity should now have a uuid property and be created
+
+// you can also POST an array of entities:
+
+HashMap<String,String> propertyMap = new HashMap<>();
+propertyMap.put("cuisine","pizza");
+
+ArrayList<UsergridEntity> entities = new ArrayList<>();
+entities.add(new UsergridEntity("restaurant","Dino's Deep Dish", propertyMap));
+entities.add(new UsergridEntity("restaurant","Pizza da Napoli", propertyMap));
+UsergridResponse response = Usergrid.POST(entities);
+List<UsergridEntity> responseEntities = response.getEntities(); // responseEntities should now contain now valid posted entities.
+```
+
+- To update an entity in a collection (**PUT**):
+
+```java
+HashMap<String,String> propertyMap = new HashMap<>();
+propertyMap.put("cuisine","pizza");
+UsergridEntity entity = new UsergridEntity("restaurant","Dino's Deep Dish", propertyMap);
+UsergridResponse response = Usergrid.POST(entity);
+if( response.ok() ) {
+ entity.putProperty("owner","Mia Carrara");
+ Usergrid.PUT(entity); // entity now has the property 'owner'
+}
+
+// or update a set of entities by passing a UsergridQuery object
+
+HashMap<String,String> propertiesToUpdate = new HashMap<>();
+propertiesToUpdate.put("cuisine","pizza");
+UsergridQuery query = new UsergridQuery("restaurants").eq("cuisine","italian");
+
+UsergridResponse response = Usergrid.PUT(query, propertiesToUpdate);
+
+ /* the first 10 entities matching this query criteria will be updated:
+ e.g.:
+ [
+ {
+ "type": "restaurant",
+ "restaurant": "Il Tarazzo",
+ "cuisine": "italian",
+ "keywords": ["pasta"]
+ },
+ {
+ "type": "restaurant",
+ "restaurant": "Cono Sur Pizza & Pasta",
+ "cuisine": "italian",
+ "keywords": ["pasta"]
+ }
+ ]
+ */
+```
+
+### DELETE
+
+DELETE requests require either a specific entity or a `UsergridQuery` object to be passed as an argument.
+
+- To delete a specific entity in a collection by uuid or name:
+
+```java
+UsergridResponse response = Usergrid.DELETE("collection", "<uuid-or-name>"); // if successful, entity will now be deleted
+```
+
+- To specific entities in a collection to delete by passing a `UsergridQuery` object:
+
+```java
+UsergridQuery query = new UsergridQuery("cats").eq("color","black").or().eq("color","white");
+
+// this will build out the following query:
+// select * where color = 'black' or color = 'white'
+
+UsergridResponse response = Usergrid.DELETE(query); // the first 10 entities matching this query criteria will be deleted
+```
+
+## Entity operations and convenience methods
+
+`UsergridEntity` has a number of helper/convenience methods to make working with entities more convenient.
+
+### reload()
+
+Reloads the entity from the server:
+
+```java
+entity.reload(); // entity is now reloaded from the server
+```
+
+### save()
+
+Saves (or creates) the entity on the server:
+
+
+```java
+entity.putProperty("aNewProperty","A new value");
+entity.save(); // entity is now updated on the server
+```
+
+### remove()
+
+Deletes the entity from the server:
+
+```java
+entity.remove(); // entity is now deleted on the server and the local instance should be destroyed
+```
+
+## Authentication, current user, and auth-fallback
+
+### appAuth and authenticateApp()
+
+`Usergrid` can use the app client ID and secret that were passed upon initialization and automatically retrieve an app-level token for these credentials.
+
+```java
+Usergrid.setAppAuth(new UsergridAppAuth("<client-id>", "<client-secret>"));
+Usergrid.authenticateApp(); // Usergrid.appAuth is authenticated automatically when this call is successful
+```
+
+### currentUser, userAuth, and authenticateUser()
+
+`Usergrid` has a special `currentUser` property.
+
+By default, when calling `authenticateUser()`, `.currentUser` will be set to this user if the authentication flow is successful.
+
+```java
+UsergridUserAuth userAuth = new UsergridUserAuth("<username>","<password>");
+Usergrid.authenticateUser(userAuth); // Usergrid.currentUser is set to the authenticated user and the token is stored within that context
+```
+
+If you want to utilize authenticateUser without setting as the current user, simply pass a `false` boolean value as the second parameter:
+
+```java
+UsergridUserAuth userAuth = new UsergridUserAuth("<username>","<password>");
+Usergrid.authenticateUser(userAuth,false); // user is authenticated but Usergrid.currentUser is not set.
+```
+
+### authMode
+
+Auth-mode defines what the client should pass in for the authorization header.
+
+By default, `Usergrid.authMode` is set to `.User`, when a `Usergrid.currentUser` is present and authenticated, an API call will be performed using the token for the user.
+
+If `Usergrid.authMode` is set to `.None`, all API calls will be performed unauthenticated.
+
+If instead `Usergrid.authMode` is set to `.App`, the API call will instead be performed using client credentials, _if_ they're available (i.e. `authenticateApp()` was performed at some point).
+
+### usingAuth()
+
+At times it is desireable to have complete, granular control over the authentication context of an API call.
+
+To facilitate this, the passthrough function `.usingAuth()` allows you to pre-define the auth context of the next API call.
+
+```java
+// assume Usergrid.authMode = UsergridAuthMode.NONE.
+
+Map<String, String> permissionsMap = new HashMap<>();
+permissionsMap.put("permission","get,post,put,delete:/**");
+UsergridResponse response = Usergrid.usingAuth(Usergrid.getAppAuth()).POST("roles/guest/permissions",permissionsMap);
+
+// here we've temporarily used the client credentials to modify permissions
+// subsequent calls will not use this auth context
+```
+
+## User operations and convenience methods
+
+`UsergridUser` has a number of helper/convenience methods to make working with user entities more convenient. If you are _not_ utilizing the `Usergrid` shared instance, you must pass an instance of `UsergridClient` as the first argument to any of these helper methods.
+
+### create()
+
+Creating a new user:
+
+```java
+UsergridUser user = new UsergridUser("username","password");
+user.create(); // user has now been created and should have a valid uuid
+```
+
+### login()
+
+A simpler means of retrieving a user-level token:
+
+```java
+user.login("username","password"); // user is now logged in
+```
+
+### logout()
+
+Logs out the selected user. You can also use this convenience method on `Usergrid.currentUser`.
+
+```java
+user.logout(); // user is now logged out
+```
+
+### resetPassword()
+
+Resets the password for the selected user.
+
+```java
+// if it was done correctly, the new password will be changed
+user.resetPassword("oldPassword", "newPassword");
+```
+
+### UsergridUser.CheckAvailable()
+
+This is a class (static) method that allows you to check whether a username or email address is available or not.
+
+```java
+boolean available = UsergridUser.checkAvailable("email", null); // 'available' == whether an email already exists for a user
+
+available = UsergridUser.checkAvailable(null, "username"); // 'available' == whether an username already exists for a user
+
+available = UsergridUser.checkAvailable("email", "username"); // 'available' == whether an email or username already exist for a user
+```
+
+## Querying and filtering data
+
+### UsergridQuery initialization
+
+The `UsergridQuery` class allows you to build out complex query filters using the Usergrid [query syntax](http://docs.apigee.com/app-services/content/querying-your-data).
+
+The first parameter of the `UsergridQuery` builder pattern should be the collection (or type) you intend to query. You can either pass this as an argument, or as the first builder object:
+
+```java
+UsergridQuery query = new UsergridQuery("cats");
+// or
+UsergridQuery query = new UsergridQuery().collection("cats");
+```
+
+You then can layer on additional queries:
+
+```java
+UsergridQuery query = new UsergridQuery("cats").gt("weight",2.4).contains("color","bl*")
+ .not()
+ .eq("color","white")
+ .or()
+ .eq("color","orange");
+```
+
+You can also adjust the number of results returned:
+
+```java
+UsergridQuery query = new UsergridQuery("cats").eq("color","black").limit(100);
+
+// returns a maximum of 100 entities
+```
+
+And sort the results:
+
+```java
+UsergridQuery query = new UsergridQuery("cats").eq("color","black").limit(100).asc("name")
+
+// sorts by 'name', ascending
+```
+
+And you can do geo-location queries:
+
+```java
+UsergridQuery query = new UsergridQuery("devices").locationWithin(<distance>, <lat>, <long>);
+```
+
+### Using a query in a request
+
+Queries can be passed as parameters to GET, PUT, and DELETE requests:
+
+```java
+// Gets entities matching the query.
+Usergrid.GET(query);
+
+// Updates the entities matching the query with the new property.
+Usergrid.PUT(query, Collections.singletonMap("aNewProperty","A new value"));
+
+// Deletes entities of a given type matching the query.
+Usergrid.DELETE(query);
+```
+### List of query builder objects
+
+`type("string")`
+
+> The collection name to query
+
+`collection("string")`
+
+> An alias for `type`
+
+`eq("key","value")` or
+`equals("key","value")` or
+`filter("key","value")`
+
+> Equal to (e.g. `where color = 'black'`)
+
+`contains("key","value")` or
+`containsString("key","value")` or
+`containsWord("key","value")`
+
+> Contains a string (e.g.` where color contains 'bl*'`)
+
+`gt("key","value")` or
+`greaterThan("key","value")`
+
+> Greater than (e.g. `where weight > 2.4`)
+
+`gte("key","value")` or
+`greaterThanOrEqual("key","value")`
+
+> Greater than or equal to (e.g. `where weight >= 2.4`)
+
+`lt("key","value")` or `lessThan("key","value")`
+
+> Less than (e.g. `where weight < 2.4`)
+
+`lte("key","value")` or `lessThanOrEqual("key","value")`
+
+> Less than or equal to (e.g. `where weight <= 2.4`)
+
+`not()`
+
+> Negates the next block in the builder pattern, e.g.:
+
+```java
+UsergridQuery query = new UsergridQuery("cats").not().eq("color","black");
+// select * from cats where not color = 'black'
+```
+
+`and()`
+
+> Joins two queries by requiring both of them. `and` is also implied when joining two queries _without_ an operator. E.g.:
+
+```java
+UsergridQuery query = new UsergridQuery("cats").eq("color","black").eq("fur","longHair");
+// is identical to:
+UsergridQuery query = new UsergridQuery("cats").eq("color","black").and().eq("fur","longHair");
+```
+
+`or()`
+
+> Joins two queries by requiring only one of them. `or` is never implied. e.g.:
+
+```java
+UsergridQuery query = new UsergridQuery("cats").eq("color","black").or().eq("color", "white");
+```
+
+> When using `or()` and `and()` operators, `and()` joins will take precedence over `or()` joins. You can read more about query operators and precedence [here](http://docs.apigee.com/api-baas/content/supported-query-operators-data-types).
+
+`locationWithin(distanceInMeters, latitude, longitude)`
+
+> Returns entities which have a location within the specified radius. Arguments can be `float` or `int`.
+
+`asc("key")` or `ascending("key")`
+
+> Sorts the results by the specified property, ascending
+
+`desc("key")` or `descending("key")`
+
+> Sorts the results by the specified property, descending
+
+`sort("key",UsergridQuerySortOrder.ASC)`
+
+> Sorts the results by the specified property, in the specified `UsergridQuerySortOrder` (`.ASC` or `.DESC`).
+
+`limit(int)`
+
+> The maximum number of entities to return
+
+`cursor("string")`
+
+> A pagination cursor string
+
+`fromString("query string")`
+
+> A special builder property that allows you to input a pre-defined query string. All builder properties will be ignored when this property is defined. For example:
+
+```java
+UsergridQuery query = new UsergridQuery().fromString("select * where color = 'black' order by name asc");
+```
+
+## UsergridResponse object
+
+`UsergridResponse` is the core class that handles both successful and unsuccessful HTTP responses from Usergrid.
+
+If a request is successful, any entities returned in the response will be automatically parsed into `UsergridEntity` objects and pushed to the `entities` property.
+
+If a request fails, the `error` property will contain information about the problem encountered.
+
+### ok
+
+You can check `UsergridResponse.ok`, a `Bool` value, to see if the response was successful. Any status code `< 400` returns true.
+
+```java
+UsergridResponse response = Usergrid.GET("collection");
+if( response.ok() ) {
+ // woo!
+}
+```
+
+### entity, entities, user, users, first, last
+
+Depending on the call you make, any entities returned in the response will be automatically parsed into `UsergridEntity` objects and pushed to the `entities` property. If you're querying the `users` collection, these will also be `UsergridUser` objects, a subclass of `UsergridEntity`.
+
+- `.first()` returns the first entity in an array of entities; `.entity()` is an alias to `.first()`. If there are no entities, both of these will be undefined.
+
+- `.last()` returns the last entity in an array of entities; if there is only one entity in the array, this will be the same as `.first()` _and_ `.entity()`, and will be undefined if there are no entities in the response.
+
+- `.getEntities()` will either be an array of entities in the response, or an empty array.
+
+- `.user()` is a special alias for `.entity()` for when querying the `users()` collection. Instead of being a `UsergridEntity`, it will be its subclass, `UsergridUser`.
+
+- `.users()` is the same as `.user()`, though behaves as `.getEntities()` does by returning either an array of UsergridUser objects or an empty array.
+
+Examples:
+
+```java
+UsergridResponse response = Usergrid.GET("collection");
+ // you can access:
+ // response.getEntities() (the returned entities)
+ // response.first() (the first entity)
+ // response.entity() (same as response.first)
+ // response.last() (the last entity returned)
+
+UsergridResponse response = Usergrid.GET("collection","<uuid-or-name>");
+ // you can access:
+ // response.entity() (the returned entity)
+ // response.getEntities() (containing only the returned entity)
+ // response.first() (same as response.entity)
+ // response.last() (same as response.entity)
+
+UsergridResponse response = Usergrid.GET("users");
+ // you can access:
+ // response.users() (the returned users)
+ // response.getEntities() (same as response.users)
+ // response.user() (the first user)
+ // response.entity() (same as response.user)
+ // response.first() (same as response.user)
+ // response.last() (the last user)
+
+UsergridResponse response = Usergrid.GET("users","<uuid-or-name>");
+ // you can access;
+ // response.users() (containing only the one user)
+ // response.getEntities() (same as response.users)
+ // response.user() (the returned user)
+ // response.entity() (same as response.user)
+ // response.first() (same as response.user)
+ // response.last() (same as response.user)
+```
+
+## Connections
+
+Connections can be managed using `Usergrid.connect()`, `Usergrid.disconnect()`, and `Usergrid.getConnections()`, or entity convenience methods of the same name.
+
+When retrieving connections via `Usergrid.getConnections()`, you can pass in a optional `UsergridQuery` object in order to filter the connectioned entities returned.
+
+### Connect
+
+Create a connection between two entities:
+
+```java
+Usergrid.connect(entity1, "relationship", entity2); // entity1 now has an outbound connection to entity2
+```
+
+### Retrieve Connections
+
+Retrieve outbound connections:
+
+```java
+Usergrid.getConnections(UsergridDirection.OUT, entity1, "relationship");
+ // entities is an array of entities that entity1 is connected to via 'relationship'
+ // in this case, we'll see entity2 in the array
+```
+
+Retrieve inbound connections:
+
+```java
+Usergrid.getConnections(UsergridDirection.IN, entity2, "relationship");
+ // entities is an array of entities that connect to entity2 via 'relationship'
+ // in this case, we'll see entity1 in the array
+```
+
+### Disconnect
+
+Delete a connection between two entities:
+
+```java
+Usergrid.disconnect(entity1, "relationship", entity2);
+ // entity1's outbound connection to entity2 has been destroyed
+```
+
+## Custom UsergridEntity Subclasses
+
+Creating custom subclasses of the base `UsergridEntity` class (just like `UsergridUser` and `UsergridDevice`) is possible.
+
+- To do so, subclass `UsergridEntity` and implement the required methods:
+
+```java
+public class ActivityEntity extends UsergridEntity {
+ public static final String ACTIVITY_ENTITY_TYPE = "activity";
+
+ public ActivityEntity(){
+ super(ACTIVITY_ENTITY_TYPE);
+ }
+}
+```
+- You will also need to register the custom subclass:
+
+```java
+Usergrid.initSharedInstance("orgId","appId");
+UsergridEntity.mapCustomSubclassToType("activity", ActivityEntity.class);
+```
+
+By registering your custom subclass, the `UsergridEntity` and `UsergridResponse` classes are able to generate instances of these classes based on the an entities `type`.
+
+In the above example, entities which have a `type` value of `activity` can now be cast as `ActivityEntity` objects. e.g.:
+
+```java
+UsergridResponse response = Usergrid.GET("activity");
+ActivityEntity activityEntity = (ActivityEntity)response.entity();
+```
[08/12] usergrid git commit: Updates to remove static text and build
tools version.
Posted by mr...@apache.org.
Updates to remove static text and build tools version.
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/2e80d24f
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/2e80d24f
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/2e80d24f
Branch: refs/heads/master
Commit: 2e80d24f3bdd06c33cf42a8524e24c77626b4c0a
Parents: b30b60b
Author: Robert Walsh <rj...@gmail.com>
Authored: Mon Aug 8 16:17:21 2016 -0500
Committer: Robert Walsh <rj...@gmail.com>
Committed: Mon Aug 8 16:17:21 2016 -0500
----------------------------------------------------------------------
.../activityfeed/src/main/res/layout/activity_main.xml | 6 ++----
sdks/android/Samples/ActivityFeed/build.gradle | 2 +-
sdks/android/Samples/Push/build.gradle | 2 +-
3 files changed, 4 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/2e80d24f/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/activity_main.xml
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/activity_main.xml b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/activity_main.xml
index db63ae4..af8038b 100644
--- a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/activity_main.xml
+++ b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/activity_main.xml
@@ -37,8 +37,7 @@
android:maxLines="1"
android:minHeight="30dp"
android:paddingEnd="10dp"
- android:maxWidth="250dp"
- android:text="fc" />
+ android:maxWidth="250dp" />
<EditText
android:layout_width="wrap_content"
@@ -58,8 +57,7 @@
android:minHeight="30dp"
android:maxWidth="250dp"
android:paddingEnd="10dp"
- android:inputType="textPassword"
- android:text="fc" />
+ android:inputType="textPassword" />
<Button
android:layout_width="wrap_content"
http://git-wip-us.apache.org/repos/asf/usergrid/blob/2e80d24f/sdks/android/Samples/ActivityFeed/build.gradle
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/build.gradle b/sdks/android/Samples/ActivityFeed/build.gradle
index 03bced9..aff4f41 100644
--- a/sdks/android/Samples/ActivityFeed/build.gradle
+++ b/sdks/android/Samples/ActivityFeed/build.gradle
@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.1.0'
+ classpath 'com.android.tools.build:gradle:2.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
http://git-wip-us.apache.org/repos/asf/usergrid/blob/2e80d24f/sdks/android/Samples/Push/build.gradle
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/Push/build.gradle b/sdks/android/Samples/Push/build.gradle
index 12e80f1..6056b85 100644
--- a/sdks/android/Samples/Push/build.gradle
+++ b/sdks/android/Samples/Push/build.gradle
@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.1.0'
+ classpath 'com.android.tools.build:gradle:2.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
[03/12] usergrid git commit: Removing old android SDK.
Posted by mr...@apache.org.
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7e0ffbc0/sdks/android/src/main/java/org/apache/usergrid/android/sdk/UGClient.java
----------------------------------------------------------------------
diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/UGClient.java b/sdks/android/src/main/java/org/apache/usergrid/android/sdk/UGClient.java
deleted file mode 100755
index 06325af..0000000
--- a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/UGClient.java
+++ /dev/null
@@ -1,3181 +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.sdk;
-
-import static org.apache.usergrid.android.sdk.utils.ObjectUtils.isEmpty;
-import static org.apache.usergrid.android.sdk.utils.UrlUtils.addQueryParams;
-import static org.apache.usergrid.android.sdk.utils.UrlUtils.encodeParams;
-import static org.apache.usergrid.android.sdk.utils.UrlUtils.path;
-
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.Date;
-
-import android.location.Location;
-import android.location.LocationManager;
-import android.location.LocationListener;
-import android.os.Build;
-import android.os.Bundle;
-import android.util.Log;
-
-import org.apache.usergrid.android.sdk.URLConnectionFactory;
-import org.apache.usergrid.android.sdk.callbacks.ApiResponseCallback;
-import org.apache.usergrid.android.sdk.callbacks.ClientAsyncTask;
-import org.apache.usergrid.android.sdk.callbacks.GroupsRetrievedCallback;
-import org.apache.usergrid.android.sdk.callbacks.QueryResultsCallback;
-import org.apache.usergrid.android.sdk.entities.Activity;
-import org.apache.usergrid.android.sdk.entities.Collection;
-import org.apache.usergrid.android.sdk.entities.Device;
-import org.apache.usergrid.android.sdk.entities.Entity;
-import org.apache.usergrid.android.sdk.entities.Group;
-import org.apache.usergrid.android.sdk.entities.Message;
-import org.apache.usergrid.android.sdk.entities.User;
-import org.apache.usergrid.android.sdk.response.ApiResponse;
-import org.apache.usergrid.android.sdk.utils.DeviceUuidFactory;
-import org.apache.usergrid.android.sdk.utils.JsonUtils;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-
-
-/**
- * The UGClient class for accessing the Usergrid API. Start by instantiating this
- * class though the appropriate constructor. Most calls to the API will be handled
- * by the methods in this class.
- *
- * @see org.apache.usergrid.android.sdk.UGClient
- * @see <a href="http://apigee.com/docs/app-services/content/installing-apigee-sdk-android">Usergrid SDK install guide</a>
- */
-public class UGClient {
-
- /**
- * Most current version of the Usergrid Android SDK
- */
- public static final String SDK_VERSION = "0.0.8";
- /**
- * Platform type of this SDK
- */
- public static final String SDK_TYPE = "Android";
-
- /**
- * @y.exclude
- */
- public static final String OPTION_KEY_BASE_URL = "baseURL";
-
- /**
- * @y.exclude
- */
- public static boolean FORCE_PUBLIC_API = false;
-
- /**
- * Public API
- */
- public static String PUBLIC_API_URL = "https://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 String HTTP_METHOD_DELETE = "DELETE";
- /**
- * Standard HTTP methods use in generic request methods
- * @see apiRequest
- * @see doHttpRequest
- */
- protected static final String HTTP_METHOD_GET = "GET";
- /**
- * Standard HTTP methods use in generic request methods
- * @see apiRequest
- * @see doHttpRequest
- */
- protected static final String HTTP_METHOD_POST = "POST";
- /**
- * Standard HTTP methods use in generic request methods
- * @see apiRequest
- * @see doHttpRequest
- */
- protected static final String HTTP_METHOD_PUT = "PUT";
-
- protected static final String LOGGING_TAG = "UGCLIENT";
-
- private String apiUrl = PUBLIC_API_URL;
-
- private String organizationId;
- private String applicationId;
- private String clientId;
- private String clientSecret;
-
- private User loggedInUser = null;
-
- private String accessToken = null;
-
- private String currentOrganization = null;
- private URLConnectionFactory urlConnectionFactory = new DefaultURLConnectionFactory();
-
- private LocationManager locationManager;
- private UUID deviceID;
-
- /**
- * Interface for EntityQuery and QueueQuery
- */
- public interface Query {
-
- public ApiResponse getResponse();
-
- public boolean more();
-
- public Query next();
-
- }
-
- /**
- * @y.exclude
- */
- public static boolean isUuidValid(UUID uuid) {
- return( uuid != null );
- }
-
- protected static String arrayToDelimitedString(String[] arrayOfStrings, String delimiter) {
- StringBuilder sb = new StringBuilder();
-
- for( int i = 0; i < arrayOfStrings.length; ++i ) {
- if( i > 0 ) {
- sb.append(delimiter);
- }
-
- sb.append(arrayOfStrings[i]);
- }
-
- return sb.toString();
- }
-
- protected static String[] tokenizeToStringArray(String str, String delimiters, boolean trimTokens, boolean ignoreEmptyTokens) {
- if (str == null) {
- return null;
- }
-
- StringTokenizer st = new StringTokenizer(str, delimiters);
-
- int numTokens = st.countTokens();
- List<String> listTokens;
-
- if( numTokens > 0 ) {
-
- listTokens = new ArrayList<String>(numTokens);
-
- while (st.hasMoreTokens()) {
-
- String token = st.nextToken();
-
- if (trimTokens) {
- token = token.trim();
- }
-
- if (!ignoreEmptyTokens || token.length() > 0) {
- listTokens.add(token);
- }
- }
- } else {
- listTokens = new ArrayList<String>();
- }
-
- return listTokens.toArray(new String[listTokens.size()]);
- }
-
-
- /****************** CONSTRUCTORS ***********************/
- /****************** CONSTRUCTORS ***********************/
-
- /**
- * @y.exclude
- */
- public UGClient() {
- init();
- }
-
- /**
- * Instantiate a data client for a specific app. This is used to call most
- * SDK methods.
- *
- * @param organizationId the Usergrid organization name
- * @param applicationId the Usergrid application id or name
- */
- public UGClient(String organizationId, String applicationId) {
- init();
- this.organizationId = organizationId;
- this.applicationId = applicationId;
- }
-
- /**
- * Instantiate a data client for a specific app with a base URL other than the default
- * api.usergrid.com. This is used to call most SDK methods.
- *
- * @param organizationId the Usergrid organization name
- * @param applicationId the Usergrid application id or name
- * @param baseURL the base URL to use for all API calls
- */
- public UGClient(String organizationId, String applicationId, String baseURL) {
- init();
- this.organizationId = organizationId;
- this.applicationId = applicationId;
-
- if( baseURL != null ) {
- this.setApiUrl(baseURL);
- }
- }
-
- public void init() {
- }
-
-
- /****************** ACCESSORS/MUTATORS ***********************/
- /****************** ACCESSORS/MUTATORS ***********************/
-
- /**
- * Sets a new URLConnectionFactory object in the UGClient
- *
- * @param urlConnectionFactory a new URLConnectionFactory object
- * @y.exclude
- */
- public void setUrlConnectionFactory(URLConnectionFactory urlConnectionFactory) {
- if (urlConnectionFactory == null) {
- this.urlConnectionFactory = new DefaultURLConnectionFactory();
- } else {
- this.urlConnectionFactory = urlConnectionFactory;
- }
- }
-
- /**
- * @return the Usergrid API url (default: http://api.usergrid.com)
- */
- public String getApiUrl() {
- return apiUrl;
- }
-
- /**
- * Sets the base URL for API requests
- *
- * @param apiUrl the API base url to be set (default: http://api.usergrid.com)
- */
- public void setApiUrl(String apiUrl) {
- this.apiUrl = apiUrl;
- }
-
- /**
- * Sets the base URL for API requests and returns the updated UGClient object
- *
- * @param apiUrl the Usergrid API url (default: http://api.usergrid.com)
- * @return UGClient object for method call chaining
- */
- public UGClient withApiUrl(String apiUrl) {
- this.apiUrl = apiUrl;
- return this;
- }
-
-
- /**
- * Sets the Usergrid organization ID and returns the UGClient object
- *
- * @param organizationId the organizationId to set
- * @return the updated UGClient object
- */
- public UGClient withOrganizationId(String organizationId){
- this.organizationId = organizationId;
- return this;
- }
-
-
-
- /**
- * Gets the current Usergrid organization ID set in the UGClient
- *
- * @return the current organizationId
- */
- public String getOrganizationId() {
- return organizationId;
- }
-
- /**
- * Sets the Usergrid organization ID
- *
- * @param organizationId the organizationId to set
- */
- public void setOrganizationId(String organizationId) {
- this.organizationId = organizationId;
- }
-
- /**
- * Gets the current Usergrid application ID set in the UGClient
- *
- * @return the current organizationId or name
- */
- public String getApplicationId() {
- return applicationId;
- }
-
- /**
- * Sets the Usergrid application Id
- *
- * @param applicationId the application id or name
- */
- public void setApplicationId(String applicationId) {
- this.applicationId = applicationId;
- }
-
-
- /**
- * Sets the Usergrid application ID and returns the UGClient object
- *
- * @param applicationId the application ID to set
- * @return the updated UGClient object
- */
- public UGClient withApplicationId(String applicationId) {
- this.applicationId = applicationId;
- return this;
- }
-
- /**
- * Gets the application (not organization) client ID credential for making calls as the
- * application-owner. Not safe for most mobile use.
- * @return the client id
- */
- public String getClientId() {
- return clientId;
- }
-
- /**
- * Sets the application (not organization) client ID credential, used for making
- * calls as the application-owner. Not safe for most mobile use.
- * @param clientId the client id
- */
- public void setClientId(String clientId) {
- this.clientId = clientId;
- }
-
- /**
- * Sets the client ID credential in the UGClient object. Not safe for most mobile use.
- *
- * @param clientId the client key id
- * @return UGClient object for method call chaining
- */
- public UGClient withClientId(String clientId) {
- this.clientId = clientId;
- return this;
- }
-
- /**
- * Gets the application (not organization) client secret credential for making calls as the
- * application-owner. Not safe for most mobile use.
- * @return the client secret
- */
- public String getClientSecret() {
- return clientSecret;
- }
-
- /**
- * Sets the application (not organization) client secret credential, used for making
- * calls as the application-owner. Not safe for most mobile use.
- *
- * @param clientSecret the client secret
- */
- public void setClientSecret(String clientSecret) {
- this.clientSecret = clientSecret;
- }
-
- /**
- * Sets the client secret credential in the UGClient object. Not safe for most mobile use.
- *
- * @param clientSecret the client secret
- * @return UGClient object for method call chaining
- */
- public UGClient withClientSecret(String clientSecret) {
- this.clientSecret = clientSecret;
- return this;
- }
-
- /**
- * Gets the UUID of the logged-in user after a successful authorizeAppUser request
- * @return the UUID of the logged-in user
- */
- public User getLoggedInUser() {
- return loggedInUser;
- }
-
- /**
- * Sets the UUID of the logged-in user. Usually not set by host application
- * @param loggedInUser the UUID of the logged-in user
- */
- public void setLoggedInUser(User loggedInUser) {
- this.loggedInUser = loggedInUser;
- }
-
- /**
- * Gets the OAuth2 access token for the current logged-in user after a
- * successful authorize request
- *
- * @return the OAuth2 access token
- */
- public String getAccessToken() {
- return accessToken;
- }
-
- /**
- * Saves the OAuth2 access token in the UGClient after a successful authorize
- * request. Usually not set by host application.
- *
- * @param accessToken an OAuth2 access token
- */
- public void setAccessToken(String accessToken) {
- this.accessToken = accessToken;
- }
-
- /**
- * Gets the current organization from UGClient
- *
- * @return the currentOrganization
- */
- public String getCurrentOrganization() {
- return currentOrganization;
- }
-
- /**
- * Sets the current organizanization from UGClient
- *
- * @param currentOrganization The organization this data client should use.
- */
- public void setCurrentOrganization(String currentOrganization) {
- this.currentOrganization = currentOrganization;
- }
-
- /****************** LOGGING ***********************/
- /****************** LOGGING ***********************/
-
-
- /**
- * Logs a trace-level logging message with tag 'DATA_CLIENT'
- *
- * @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 'DATA_CLIENT'
- *
- * @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 'DATA_CLIENT'
- *
- * @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 'DATA_CLIENT'
- *
- * @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 'DATA_CLIENT'
- *
- * @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 'DATA_CLIENT'
- *
- * @param logMessage the message to log
- */
- public void writeLog(String logMessage) {
- if( logMessage != null ) {
- //TODO: do we support different log levels in this class?
- Log.d(LOGGING_TAG, logMessage);
- }
- }
-
- /****************** API/HTTP REQUEST ***********************/
- /****************** API/HTTP REQUEST ***********************/
-
- /**
- * Forms and initiates a raw synchronous http request and processes the response.
- *
- * @param httpMethod the HTTP method in the format:
- * HTTP_METHOD_<method_name> (e.g. HTTP_METHOD_POST)
- * @param params the URL parameters to append to the request URL
- * @param data the body of the request
- * @param segments additional URL path segments to append to the request URL
- * @return ApiResponse object
- */
- public ApiResponse doHttpRequest(String httpMethod, Map<String, Object> params, Object data, String... segments) {
-
- ApiResponse response = null;
- OutputStream out = null;
- InputStream in = null;
- HttpURLConnection conn = null;
-
- String urlAsString = path(apiUrl, segments);
-
- try {
- String contentType = "application/json";
- if (httpMethod.equals(HTTP_METHOD_POST) && isEmpty(data) && !isEmpty(params)) {
- data = encodeParams(params);
- contentType = "application/x-www-form-urlencoded";
- } else {
- urlAsString = addQueryParams(urlAsString, params);
- }
-
- //logTrace("Invoking " + httpMethod + " to '" + urlAsString + "'");
- conn = (HttpURLConnection) urlConnectionFactory.openConnection(urlAsString);
-
- conn.setRequestMethod(httpMethod);
- conn.setRequestProperty("Content-Type", contentType);
- conn.setUseCaches(false);
-
- if ((accessToken != null) && (accessToken.length() > 0)) {
- String authStr = "Bearer " + accessToken;
- conn.setRequestProperty("Authorization", authStr);
- }
-
- conn.setDoInput(true);
-
- if (httpMethod.equals(HTTP_METHOD_POST) || httpMethod.equals(HTTP_METHOD_PUT)) {
- if (isEmpty(data)) {
- data = JsonNodeFactory.instance.objectNode();
- }
-
- String dataAsString = null;
-
- if ((data != null) && (!(data instanceof String))) {
- ObjectMapper objectMapper = new ObjectMapper();
- objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
- dataAsString = objectMapper.writeValueAsString(data);
- } else {
- dataAsString = (String) data;
- }
-
- //logTrace("Posting/putting data: '" + dataAsString + "'");
-
- byte[] dataAsBytes = dataAsString.getBytes();
-
- conn.setRequestProperty("Content-Length", Integer.toString(dataAsBytes.length));
- conn.setDoOutput(true);
-
- out = conn.getOutputStream();
- out.write(dataAsBytes);
- out.flush();
- out.close();
- out = null;
- }
-
- in = conn.getInputStream();
- if( in != null ) {
- BufferedReader reader = new BufferedReader(new InputStreamReader(in));
- StringBuilder sb = new StringBuilder();
- String line;
-
- while( (line = reader.readLine()) != null ) {
- sb.append(line);
- sb.append('\n');
- }
-
- String responseAsString = sb.toString();
-
- //logTrace("response from server: '" + responseAsString + "'");
- ObjectMapper objectMapper = new ObjectMapper();
- objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
- response = (ApiResponse) objectMapper.readValue(responseAsString, ApiResponse.class);
- response.setRawResponse(responseAsString);
-
- response.setUGClient(this);
- } else {
- response = null;
- logTrace("no response body from server");
- }
-
- //final int responseCode = conn.getResponseCode();
- //logTrace("responseCode from server = " + responseCode);
- }
- catch(Exception e) {
- logError("Error " + httpMethod + " to '" + urlAsString + "'" );
- if( e != null ) {
- e.printStackTrace();
- logError(e.getLocalizedMessage());
- }
- response = null;
- }
- catch(Throwable t) {
- logError("Error " + httpMethod + " to '" + urlAsString + "'" );
- if( t != null ) {
- t.printStackTrace();
- logError(t.getLocalizedMessage());
- }
- response = null;
- }
- finally {
- try {
- if( out != null ) {
- out.close();
- }
-
- if( in != null ) {
- in.close();
- }
-
- if( conn != null ) {
- conn.disconnect();
- }
- } catch(Exception ignored) {
- }
- }
-
- return response;
- }
-
-
- /**
- * High-level synchronous API request. Implements the http request
- * for most SDK methods by calling
- * {@link #doHttpRequest(String,Map,Object,String...)}
- *
- * @param httpMethod the HTTP method in the format:
- * HTTP_METHOD_<method_name> (e.g. HTTP_METHOD_POST)
- * @param params the URL parameters to append to the request URL
- * @param data the body of the request
- * @param segments additional URL path segments to append to the request URL
- * @return ApiResponse object
- */
- public ApiResponse apiRequest(String httpMethod,
- Map<String, Object> params, Object data, String... segments) {
- ApiResponse response = null;
-
- response = doHttpRequest(httpMethod, params, data, segments);
-
- if( (response == null) ) {
- logError("doHttpRequest returned null");
- }
-
- return response;
- }
-
- protected void assertValidApplicationId() {
- if (isEmpty(applicationId)) {
- throw new IllegalArgumentException("No application id specified");
- }
- }
-
- /****************** ROLES/PERMISSIONS ***********************/
- /****************** ROLES/PERMISSIONS ***********************/
-
- /**
- * Assigns permissions to the specified user, group, or role.
- *
- * @param entityType the entity type of the entity the permissions are being assigned to. 'user', 'group' and 'role' are valid.
- * @param entityID the UUID of 'name' property of the entity the permissions are being assigned to.
- * @param permissions a comma-separated list of the permissions to be assigned in the format: <operations>:<path>, e.g. get, put, post, delete: /users
- * @throws IllegalArgumentException thrown if an entityType other than 'group' or 'user' is passed to the method
- * @return ApiResponse object
- */
- public ApiResponse assignPermissions(String entityType, String entityID, String permissions) {
-
- if (!entityType.substring(entityType.length() - 1 ).equals("s")) {
- entityType += "s";
- }
-
- if (!validateTypeForPermissionsAndRoles(entityType, "permission")) {
- throw new IllegalArgumentException("Permissions can only be assigned to group, user, or role entities");
- }
-
- Map<String, Object> data = new HashMap<String, Object>();
- if (permissions != null){
- data.put("permission", permissions);
- }
-
- return apiRequest(HTTP_METHOD_POST, null, data, organizationId, applicationId, entityType,
- entityID, "permissions");
-
- }
-
- /**
- * Assigns permissions to the specified user, group, or role. Executes asynchronously in
- * background and the callbacks are called in the UI thread.
- *
- * @param entityType the entity type of the entity the permissions are being assigned to. 'user', 'group' and 'role' are valid.
- * @param entityID the UUID of 'name' property of the entity the permissions are being assigned to.
- * @param permissions a comma-separated list of the permissions to be assigned in the format: <operations>:<path>, e.g. get, put, post, delete: /users
- * @param callback an ApiResponseCallback to handle the async response
- */
- public void assignPermissionsAsync(final String entityType,
- final String entityID, final String permissions, final ApiResponseCallback callback) {
- (new ClientAsyncTask<ApiResponse>(callback) {
- @Override
- public ApiResponse doTask() {
- return assignPermissions(entityType, entityID, permissions);
- }
- }).execute();
- }
-
- /**
- * Removes permissions from the specified user, group or role.
- *
- * @param entityType the entity type of the entity the permissions are being removed from. 'user', 'group' and 'role' are valid.
- * @param entityID the UUID of 'name' property of the entity the permissions are being removed from.
- * @param permissions a comma-separated list of the permissions to be removed in the format: <operations>:<path>, e.g. get, put, post, delete: /users
- * @throws IllegalArgumentException thrown if an entityType other than 'group' or 'user' is passed to the method
- * @return ApiResponse object
- */
- public ApiResponse removePermissions(String entityType, String entityID, String permissions) {
-
- if (!validateTypeForPermissionsAndRoles(entityType, "permission")) {
- throw new IllegalArgumentException("Permissions can only be assigned to group, user, or role entities");
- }
-
- Map<String, Object> params = new HashMap<String, Object>();
- if (permissions != null){
- params.put("permission", permissions);
- }
-
- return apiRequest(HTTP_METHOD_DELETE, params, null, organizationId, applicationId, entityType,
- entityID, "permissions");
-
- }
-
- /**
- * Removes permissions from the specified user, group or role. Executes asynchronously in
- * background and the callbacks are called in the UI thread.
- *
- * @param entityType the entity type of the entity the permissions are being removed from. 'user', 'group', and 'role' are valid.
- * @param entityID the UUID of 'name' property of the entity the permissions are being removed from.
- * @param permissions a comma-separated list of the permissions to be removed in the format: <operations>:<path>, e.g. get, put, post, delete: /users
- * @param callback an ApiResponseCallback to handle the async response
- */
- public void removePermissionsAsync(final String entityType,
- final String entityID, final String permissions, final ApiResponseCallback callback) {
- (new ClientAsyncTask<ApiResponse>(callback) {
- @Override
- public ApiResponse doTask() {
- return removePermissions(entityType, entityID, permissions);
- }
- }).execute();
- }
-
- /**
- * Creates a new role and assigns permissions to it.
- *
- * @param roleName the name of the new role
- * @param permissions a comma-separated list of the permissions to be assigned in the format: <operations>:<path>, e.g. get, put, post, delete: /users
- * @return ApiResponse object
- */
- public ApiResponse createRole(String roleName, String permissions) {
-
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("type", "role");
- properties.put("name", roleName);
-
- ApiResponse response = this.createEntity(properties);
-
- String uuid = null;
-
- if (response.getEntityCount() == 1){
- uuid = response.getFirstEntity().getUuid().toString();
- }
-
- return assignPermissions("role", uuid, permissions);
-
- }
-
- /**
- * Creates a new role and assigns permissions to it.
- *
- * @param roleName the name of the new role
- * @param permissions a comma-separated list of the permissions to be assigned in the format: <operations>:<path>, e.g. get, put, post, delete: /users
- * @param callback an ApiResponseCallback to handle the async response
- */
- public void createRoleAsync(final String roleName, final String permissions,
- final ApiResponseCallback callback) {
- (new ClientAsyncTask<ApiResponse>(callback) {
- @Override
- public ApiResponse doTask() {
- return createRole(roleName, permissions);
- }
- }).execute();
- }
-
- /**
- * Assigns a role to a user or group entity.
- *
- * @param roleName the name of the role to be assigned to the entity
- * @param entityType the entity type of the entity the role is being assigned to. 'user' and 'group' are valid.
- * @param entityID the UUID or 'name' property of the entity the role is being assigned to.
- * @throws IllegalArgumentException thrown if an entityType other than 'group' or 'user' is passed to the method
- * @return ApiResponse object
- */
- public ApiResponse assignRole(String roleName, String entityType, String entityID) {
-
- if (!entityType.substring(entityType.length() - 1 ).equals("s")) {
- entityType += "s";
- }
-
- if (!validateTypeForPermissionsAndRoles(entityType, "role")) {
- throw new IllegalArgumentException("Permissions can only be assigned to a group or user");
- }
-
- return apiRequest(HTTP_METHOD_POST, null, null, organizationId, applicationId, "roles", roleName,
- entityType, entityID);
-
- }
-
- /**
- * Assigns a role to a user or group entity. Executes asynchronously in
- * background and the callbacks are called in the UI thread.
- *
- * @param roleName the name of the role to be assigned to the entity
- * @param entityType the entity type of the entity the role is being assigned to. 'user' and 'group' are valid.
- * @param entityID the UUID or 'name' property of the entity the role is being removed from.
- * @param callback an ApiResponseCallback to handle the async response
- */
- public void assignRoleAsync(final String roleName, final String entityType,
- final String entityID, final ApiResponseCallback callback) {
- (new ClientAsyncTask<ApiResponse>(callback) {
- @Override
- public ApiResponse doTask() {
- return assignRole(roleName, entityType, entityID);
- }
- }).execute();
- }
-
- /**
- * Removes a role from a user or group entity.
- *
- * @param roleName the name of the role to be removed from the entity
- * @param entityType the entity type of the entity the role is being removed from. 'user' and 'group' are valid.
- * @param entityID the UUID or 'name' property of the entity the role is being removed from.
- * @throws IllegalArgumentException thrown if an entityType other than 'group' or 'user' is passed to the method
- * @return ApiResponse object
- */
- public ApiResponse removeRole(String roleName, String entityType, String entityID) {
-
- if (!entityType.substring(entityType.length() - 1 ).equals("s")) {
- entityType += "s";
- }
-
- if (!validateTypeForPermissionsAndRoles(entityType, "role")) {
- throw new IllegalArgumentException("Permissions can only be removed from a group or user");
- }
-
- return apiRequest(HTTP_METHOD_DELETE, null, null, organizationId, applicationId, "roles", roleName,
- entityType, entityID);
-
- }
-
- /**
- * Removes a role from a user or group entity. Executes asynchronously in
- * background and the callbacks are called in the UI thread.
- *
- * @param roleName the name of the role to be removed from the entity
- * @param entityType the entity type of the entity the role is being removed from. 'user' and 'group' are valid.
- * @param entityID the UUID or 'name' property of the entity the role is being removed from.
- * @param callback an ApiResponseCallback to handle the async response
- */
- public void removeRoleAsync(final String roleName, final String entityType,
- final String entityID, final ApiResponseCallback callback) {
- (new ClientAsyncTask<ApiResponse>(callback) {
- @Override
- public ApiResponse doTask() {
- return removeRole(roleName, entityType, entityID);
- }
- }).execute();
- }
-
- /**
- * Checks if a permission or role can be assigned to an entity
- * @y.exclude
- */
- private Boolean validateTypeForPermissionsAndRoles(String type, String permissionOrRole){
- ArrayList<String> validTypes = new ArrayList<String>();
- validTypes.add("groups");
- validTypes.add("users");
-
- if (permissionOrRole.equals("permission")){
- validTypes.add("roles");
- }
-
- return validTypes.contains(type);
- }
-
- /****************** LOG IN/LOG OUT/OAUTH ***********************/
- /****************** LOG IN/LOG OUT/OAUTH ***********************/
-
- /**
- * Logs the user in and get a valid access token.
- *
- * @param usernameOrEmail the username or email associated with the user entity in Usergrid
- * @param password the user's Usergrid password
- * @return non-null ApiResponse if request succeeds, check getError() for
- * "invalid_grant" to see if access is denied.
- */
- public ApiResponse authorizeAppUser(String usernameOrEmail, String password) {
- validateNonEmptyParam(usernameOrEmail, "email");
- validateNonEmptyParam(password,"password");
- assertValidApplicationId();
- loggedInUser = null;
- accessToken = null;
- currentOrganization = null;
- Map<String, Object> formData = new HashMap<String, Object>();
- formData.put("grant_type", "password");
- formData.put("username", usernameOrEmail);
- formData.put("password", password);
- ApiResponse response = apiRequest(HTTP_METHOD_POST, formData, null,
- organizationId, applicationId, "token");
- if (response == null) {
- return response;
- }
- if (!isEmpty(response.getAccessToken()) && (response.getUser() != null)) {
- loggedInUser = response.getUser();
- accessToken = response.getAccessToken();
- currentOrganization = null;
- logInfo("authorizeAppUser(): Access token: " + accessToken);
- } else {
- logInfo("authorizeAppUser(): Response: " + response);
- }
- return response;
- }
-
- /**
- * Log the user in and get a valid access token. Executes asynchronously in
- * background and the callbacks are called in the UI thread.
- *
- * @param usernameOrEmail the username or email associated with the user entity in Usergrid
- * @param password the users Usergrid password
- * @param callback an ApiResponseCallback to handle the async response
- */
- public void authorizeAppUserAsync(final String usernameOrEmail,
- final String password, final ApiResponseCallback callback) {
- (new ClientAsyncTask<ApiResponse>(callback) {
- @Override
- public ApiResponse doTask() {
- return authorizeAppUser(usernameOrEmail, password);
- }
- }).execute();
- }
-
- /**
- * Change the password for the currently logged in user. You must supply the
- * old password and the new password.
- *
- * @param username the username or email address associated with the user entity in Usergrid
- * @param oldPassword the user's old password
- * @param newPassword the user's new password
- * @return ApiResponse object
- */
- public ApiResponse changePassword(String username, String oldPassword,
- String newPassword) {
-
- Map<String, Object> data = new HashMap<String, Object>();
- data.put("newpassword", newPassword);
- data.put("oldpassword", oldPassword);
-
- return apiRequest(HTTP_METHOD_POST, null, data, organizationId, applicationId, "users",
- username, "password");
-
- }
-
- public void changePasswordAsync(final String username, final String oldPassword,
- final String newPassword, final ApiResponseCallback callback) {
- (new ClientAsyncTask<ApiResponse>(callback) {
- @Override
- public ApiResponse doTask() {
- return changePassword(username, oldPassword, newPassword);
- }
- }).execute();
- }
-
- /**
- * Log the user in with their numeric pin-code and get a valid access token.
- *
- * @param email the email address associated with the user entity in Usergrid
- * @param pin the pin associated with the user entity in Usergrid
- * @return non-null ApiResponse if request succeeds, check getError() for
- * "invalid_grant" to see if access is denied.
- */
- public ApiResponse authorizeAppUserViaPin(String email, String pin) {
- validateNonEmptyParam(email, "email");
- validateNonEmptyParam(pin, "pin");
- assertValidApplicationId();
- loggedInUser = null;
- accessToken = null;
- currentOrganization = null;
- Map<String, Object> formData = new HashMap<String, Object>();
- formData.put("grant_type", "pin");
- formData.put("username", email);
- formData.put("pin", pin);
- ApiResponse response = apiRequest(HTTP_METHOD_POST, formData, null,
- organizationId, applicationId, "token");
- if (response == null) {
- return response;
- }
- if (!isEmpty(response.getAccessToken()) && (response.getUser() != null)) {
- loggedInUser = response.getUser();
- accessToken = response.getAccessToken();
- currentOrganization = null;
- logInfo("authorizeAppUser(): Access token: " + accessToken);
- } else {
- logInfo("authorizeAppUser(): Response: " + response);
- }
- return response;
- }
-
- /**
- * 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 the email address associated with the user entity in Usergrid
- * @param pin the pin associated with the user entity in Usergrid
- * @param callback A callback for the async response.
- */
- 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 app in with it's application (not organization) 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 the Usergrid application's client ID
- * @param clientSecret the Usergrid application's client secret
- * @param callback an ApiResponseCallback to handle the async response
- */
- 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();
- }
-
- private void validateNonEmptyParam(Object param, String paramName) {
- if ( isEmpty(param) ) {
- throw new IllegalArgumentException(paramName + " cannot be null or empty");
- }
- }
-
- /**
- * Log the user in with their Facebook access token retrieved via Facebook
- * OAuth. Sets the user's identifier and Usergrid OAuth2 access token in UGClient
- * if successfully authorized.
- *
- * @param fb_access_token the valid OAuth token returned by Facebook
- * @return non-null ApiResponse if request succeeds, check getError() for
- * "invalid_grant" to see if access is denied.
- */
- public ApiResponse authorizeAppUserViaFacebook(String fb_access_token) {
- validateNonEmptyParam(fb_access_token, "Facebook token");
- assertValidApplicationId();
- loggedInUser = null;
- accessToken = null;
- currentOrganization = null;
- Map<String, Object> formData = new HashMap<String, Object>();
- formData.put("fb_access_token", fb_access_token);
- ApiResponse response = apiRequest(HTTP_METHOD_POST, formData, null,
- organizationId, applicationId, "auth", "facebook");
- if (response == null) {
- return response;
- }
- if (!isEmpty(response.getAccessToken()) && (response.getUser() != null)) {
- loggedInUser = response.getUser();
- accessToken = response.getAccessToken();
- currentOrganization = null;
- logInfo("authorizeAppUserViaFacebook(): Access token: "
- + accessToken);
- } else {
- logInfo("authorizeAppUserViaFacebook(): Response: "
- + response);
- }
- return response;
- }
-
- /**
- * Log the user in with their Facebook access token retrieved via Facebook
- * OAuth. Sets the user's identifier and Usergrid OAuth2 access token in UGClient
- * if successfully authorized. Executes asynchronously in background and the
- * callbacks are called in the UI thread.
- *
- * @param fb_access_token the valid OAuth token returned by Facebook
- * @param callback an ApiResponseCallback to handle the async response
- */
- 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 out a user and destroy the access token currently stored in UGClient
- * on the server and in the UGClient.
- *
- * @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 UGClient
- * on the server and in the UGClient.
- * 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 UGClient 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 UGClient 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 UGClient 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 UGClient 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();
- }
-
- /**
- * Log the app in with it's application (not organization) client id and
- * client secret key. Not recommended for production apps.
- *
- * @param clientId the Usergrid application's client ID
- * @param clientSecret the Usergrid application's client secret
- */
- public ApiResponse authorizeAppClient(String clientId, String clientSecret) {
- validateNonEmptyParam(clientId, "client identifier");
- validateNonEmptyParam(clientSecret, "client secret");
- assertValidApplicationId();
- loggedInUser = null;
- accessToken = null;
- currentOrganization = null;
- Map<String, Object> formData = new HashMap<String, Object>();
- formData.put("grant_type", "client_credentials");
- formData.put("client_id", clientId);
- formData.put("client_secret", clientSecret);
- ApiResponse response = apiRequest(HTTP_METHOD_POST, formData, null,
- organizationId, applicationId, "token");
- if (response == null) {
- return response;
- }
- if (!isEmpty(response.getAccessToken())) {
- loggedInUser = null;
- accessToken = response.getAccessToken();
- currentOrganization = null;
- logInfo("authorizeAppClient(): Access token: "
- + accessToken);
- } else {
- logInfo("authorizeAppClient(): Response: " + response);
- }
- return response;
- }
-
-
- /****************** GENERIC ENTITY MANAGEMENT ***********************/
- /****************** GENERIC ENTITY MANAGEMENT ***********************/
-
- /**
- * Create a new entity on the server.
- *
- * @param entity
- * @return an ApiResponse with the new entity in it.
- */
- public ApiResponse createEntity(Entity entity) {
- assertValidApplicationId();
- if (isEmpty(entity.getType())) {
- throw new IllegalArgumentException("Missing entity type");
- }
- ApiResponse response = apiRequest(HTTP_METHOD_POST, null, entity,
- organizationId, applicationId, entity.getType());
- return response;
- }
-
- /**
- * Create a new entity on the server from a set of properties. Properties
- * must include a "type" property.
- *
- * @param properties
- * @return an ApiResponse with the new entity in it.
- */
- public ApiResponse createEntity(Map<String, Object> properties) {
- assertValidApplicationId();
- if (isEmpty(properties.get("type"))) {
- throw new IllegalArgumentException("Missing entity type");
- }
- ApiResponse response = apiRequest(HTTP_METHOD_POST, null, properties,
- organizationId, applicationId, properties.get("type").toString());
- return response;
- }
-
- /**
- * Create a new entity on the server. Executes asynchronously in background
- * and the callbacks are called in the UI thread.
- *
- * @param entity An instance with data to use to create the entity
- * @param callback A callback for the async response
- */
- 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 The values to use, with keys as property names and values
- * as property values
- * @param callback A callback for the async response
- */
- 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 an object instance that corresponds to the provided entity type.
- * Supported object types are Activity, Device, Group, Message, and User.
- * All other types will return a generic Entity instance with no type assigned.
- *
- * @param type the entity type of which to create an object instance
- * @return an object instance that corresponds to the type provided
- */
- public Entity createTypedEntity(String type) {
- Entity entity = null;
-
- if( Activity.isSameType(type) ) {
- entity = new Activity(this);
- } else if( Device.isSameType(type) ) {
- entity = new Device(this);
- } else if( Group.isSameType(type) ) {
- entity = new Group(this);
- } else if( Message.isSameType(type) ) {
- entity = new Message(this);
- } else if( User.isSameType(type) ) {
- entity = new User(this);
- } else {
- entity = new Entity(this);
- }
-
- return entity;
- }
-
- /**
- * 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();
- }
-
- /**
- * Update an existing entity on the server.
- *
- * @param entityID the entity to update
- * @param updatedProperties the new properties
- * @return an ApiResponse with the updated entity in it.
- */
- public ApiResponse updateEntity(String entityID, Map<String, Object> updatedProperties) {
- assertValidApplicationId();
- if (isEmpty(updatedProperties.get("type"))) {
- throw new IllegalArgumentException("Missing entity type");
- }
- ApiResponse response = apiRequest(HTTP_METHOD_PUT, null, updatedProperties,
- organizationId, applicationId, updatedProperties.get("type").toString(), entityID);
- return response;
- }
-
-
- /**
- * Update an existing entity on the server. Properties
- * must include a "type" property. Executes asynchronously in background and
- * the callbacks are called in the UI thread.
- *
- * @param entityID the entity to update
- * @param updatedProperties the new properties
- * @param callback A callback for the async response
- */
- public void updateEntityAsync(final String entityID, final Map<String, Object> updatedProperties,
- final ApiResponseCallback callback) {
- (new ClientAsyncTask<ApiResponse>(callback) {
- @Override
- public ApiResponse doTask() {
- return updateEntity(entityID, updatedProperties);
- }
- }).execute();
- }
-
- /**
- * Updates the password associated with a user entity
- *
- * @param usernameOrEmail the username or email address associated with the user entity
- * @param oldPassword the user's old password
- * @param newPassword the user's new password
- * @return an ApiResponse with the updated entity in it.
- */
- public ApiResponse updateUserPassword(String usernameOrEmail, String oldPassword, String newPassword) {
- Map<String,Object> updatedProperties = new HashMap<String,Object>();
- updatedProperties.put("oldpassword", oldPassword);
- updatedProperties.put("newpassword", newPassword);
- return apiRequest(HTTP_METHOD_POST, null, updatedProperties,
- organizationId, applicationId, "users", usernameOrEmail);
- }
-
-
- /**
- * Remove an existing entity on the server.
- *
- * @param entityType the collection of the entity
- * @param entityID the specific entity to delete
- * @return an ApiResponse indicating whether the removal was successful
- */
- public ApiResponse removeEntity(String entityType, String entityID) {
- assertValidApplicationId();
- if (isEmpty(entityType)) {
- throw new IllegalArgumentException("Missing entity type");
- }
- ApiResponse response = apiRequest(HTTP_METHOD_DELETE, null, null,
- organizationId, applicationId, entityType, entityID);
- return response;
- }
-
- /**
- * Remove an existing entity on the server.
- * Executes asynchronously in background and
- * the callbacks are called in the UI thread.
- *
- * @param entityType the collection of the entity
- * @param entityID the specific entity to delete
- * @param callback A callback with the async response
- */
- public void removeEntityAsync(final String entityType, final String entityID,
- final ApiResponseCallback callback) {
- (new ClientAsyncTask<ApiResponse>(callback) {
- @Override
- public ApiResponse doTask() {
- return removeEntity(entityType, entityID);
- }
- }).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.
- *
- * See {@link #doHttpRequest(String,Map,Object,String...)} for
- * more on the parameters.
- *
- * @param httpMethod The HTTP method to use in the query
- * @param params Query parameters.
- * @param data The request body.
- * @param segments Additional URL path segments to append to the request URL
- * @return An instance representing query results
- */
- public Query queryEntitiesRequest(String httpMethod,
- Map<String, Object> params, Object data, String... segments) {
- ApiResponse response = apiRequest(httpMethod, params, data, segments);
- return new EntityQuery(response, httpMethod, params, data, segments);
- }
-
- /**
- * 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.
- *
- * See {@link #doHttpRequest(String,Map,Object,String...)} for
- * more on the parameters.
- *
- * @param callback A callback for the async response
- * @param httpMethod The HTTP method to use in the query
- * @param params Query parameters.
- * @param data The request body.
- * @param segments Additional URL path segments to append to the request URL
- */
- public void queryEntitiesRequestAsync(final QueryResultsCallback callback,
- final String httpMethod, final Map<String, Object> params,
- final Object data, final String... segments) {
- (new ClientAsyncTask<Query>(callback) {
- @Override
- public Query doTask() {
- return queryEntitiesRequest(httpMethod, params, data, segments);
- }
- }).execute();
- }
-
- /**
- * Query object for handling the response from certain query requests
- * @y.exclude
- */
- private class EntityQuery implements Query {
- final String httpMethod;
- final Map<String, Object> params;
- final Object data;
- final String[] segments;
- final ApiResponse response;
-
- private EntityQuery(ApiResponse response, String httpMethod,
- Map<String, Object> params, Object data, String[] segments) {
- this.response = response;
- this.httpMethod = httpMethod;
- this.params = params;
- this.data = data;
- this.segments = segments;
- }
-
- private EntityQuery(ApiResponse response, EntityQuery q) {
- this.response = response;
- httpMethod = q.httpMethod;
- params = q.params;
- data = q.data;
- segments = q.segments;
- }
-
- /**
- * Gets the API response from the last request
- *
- * @return an ApiResponse object
- */
- public ApiResponse getResponse() {
- return response;
- }
-
- /**
- * Checks if there are more results available based on whether a
- * 'cursor' property was present in the last result set.
- *
- * @return true if the server indicates more results are available
- */
- public boolean more() {
- if ((response != null) && (response.getCursor() != null)
- && (response.getCursor().length() > 0)) {
- return true;
- }
- return false;
- }
-
- /**
- * Performs a request for the next set of results based on the cursor
- * from the last result set.
- *
- * @return query that contains results and where to get more.
- */
- public Query next() {
- if (more()) {
- Map<String, Object> nextParams = null;
- if (params != null) {
- nextParams = new HashMap<String, Object>(params);
- } else {
- nextParams = new HashMap<String, Object>();
- }
- nextParams.put("cursor", response.getCursor());
- ApiResponse nextResponse = apiRequest(httpMethod, nextParams, data,
- segments);
- return new EntityQuery(nextResponse, this);
- }
- return null;
- }
-
- }
-
-
- /****************** USER ENTITY MANAGEMENT ***********************/
- /****************** USER ENTITY MANAGEMENT ***********************/
-
- /**
- * Creates a user entity.
- *
- * @param username required. The username to be associated with the user entity.
- * @param name the user's full name. Can be null.
- * @param email the user's email address.
- * @param password the user's password
- * @return an ApiResponse object
- */
- public ApiResponse createUser(String username, String name, String email,
- String password) {
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("type", "user");
- if (username != null) {
- properties.put("username", username);
- }
- if (name != null) {
- properties.put("name", name);
- }
- if (email != null) {
- properties.put("email", email);
- }
- if (password != null) {
- properties.put("password", password);
- }
- return createEntity(properties);
- }
-
- /**
- * Creates a user. Executes asynchronously in background and the callbacks
- * are called in the UI thread.
- *
- * @param username required. The username to be associated with the user entity.
- * @param name the user's full name. Can be null.
- * @param email the user's email address.
- * @param password the user's password.
- * @param callback an ApiResponse callback for handling the async response.
- */
- 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();
- }
-
- /**
- * Retrieves the /users collection.
- *
- * @return a Query object
- */
- public Query queryUsers() {
- Query q = queryEntitiesRequest(HTTP_METHOD_GET, null, null,
- organizationId, applicationId, "users");
- return q;
- }
-
- /**
- * Retrieves the /users collection. Executes asynchronously in
- * background and the callbacks are called in the UI thread.
- *
- * @param callback a QueryResultsCallback object to handle the async response
- */
- public void queryUsersAsync(QueryResultsCallback callback) {
- queryEntitiesRequestAsync(callback, HTTP_METHOD_GET, null, null,
- organizationId, applicationId, "users");
- }
-
-
- /**
- * Performs a query of the users collection using the provided query command.
- * For example: "name contains 'ed'".
- *
- * @param ql the query to execute
- * @return a Query object
- */
- public Query queryUsers(String ql) {
- Map<String, Object> params = new HashMap<String, Object>();
- params.put("ql", ql);
- Query q = queryEntitiesRequest(HTTP_METHOD_GET, params, null,organizationId,
- applicationId, "users");
- return q;
- }
-
- /**
- * 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 the query to execute
- * @param callback a QueryResultsCallback object to handle the async response
- */
- public void queryUsersAsync(String ql, QueryResultsCallback callback) {
- Map<String, Object> params = new HashMap<String, Object>();
- params.put("ql", ql);
- queryEntitiesRequestAsync(callback, HTTP_METHOD_GET, params, null,
- organizationId, applicationId, "users");
- }
-
- /**
- * Perform a query of the users collection within the specified distance of
- * the specified location and optionally using the provided additional query.
- * For example: "name contains 'ed'".
- *
- * @param distance distance from the location in meters
- * @param latitude the latitude of the location to measure from
- * @param longitude the longitude of the location to measure from
- * @param ql an optional additional query to send with the request
- * @return a Query object
- */
- public Query queryUsersWithinLocation(float distance, float latitude,
- float longitude, String ql) {
- Map<String, Object> params = new HashMap<String, Object>();
- params.put("ql",
- this.makeLocationQL(distance, latitude, longitude, ql));
- Query q = queryEntitiesRequest(HTTP_METHOD_GET, params, null, organizationId,
- applicationId, "users");
- return q;
- }
-
-
- /****************** GROUP ENTITY MANAGEMENT ***********************/
- /****************** GROUP ENTITY MANAGEMENT ***********************/
-
- /**
- * Creates a group with the specified group path. Group paths can be slash
- * ("/") delimited like file paths for hierarchical group relationships.
- *
- * @param groupPath the path to use for the new group.
- * @return an ApiResponse object
- */
- public ApiResponse createGroup(String groupPath) {
- return createGroup(groupPath, null);
- }
-
- /**
- * Creates a group with the specified group path and group title. Group
- * paths can be slash ("/") delimited like file paths for hierarchical group
- * relationships.
- *
- * @param groupPath the path to use for the new group
- * @param groupTitle the title to use for the new group
- * @return an ApiResponse object
- */
- public ApiResponse createGroup(String groupPath, String groupTitle) {
- return createGroup(groupPath, groupTitle, null);
- }
-
- /**
- * Create a group with a path, title and name. Group
- * paths can be slash ("/") delimited like file paths for hierarchical group
- * relationships.
- *
- * @param groupPath the path to use for the new group
- * @param groupTitle the title to use for the new group
- * @param groupName the name to use for the new group
- * @return an ApiResponse object
- */
- public ApiResponse createGroup(String groupPath, String groupTitle, String groupName){
- Map<String, Object> data = new HashMap<String, Object>();
- data.put("type", "group");
- data.put("path", groupPath);
-
- if (groupTitle != null) {
- data.put("title", groupTitle);
- }
-
- if(groupName != null){
- data.put("name", groupName);
- }
-
- return apiRequest(HTTP_METHOD_POST, null, data, organizationId, applicationId, "groups");
- }
-
- /**
- * 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 the path to use for the new group.
- * @param callback an ApiResponseCallback object to handle the async response
- */
- public void createGroupAsync(String groupPath,
- final ApiResponseCallback callback) {
- createGroupAsync(groupPath, null, 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 the path to use for the new group.
- * @param groupTitle the title to use for the new group.
- * @param callback an ApiResponseCallback object to handle the async response
- */
- 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();
- }
-
- /**
- * Gets the groups associated with a user entity
- *
- * @param userId the UUID of the user entity
- * @return a map with the group path as the key and a Group object as the value
- */
- public Map<String, Group> getGroupsForUser(String userId) {
- ApiResponse response = apiRequest(HTTP_METHOD_GET, null, null,
- organizationId, applicationId, "users", userId, "groups");
- Map<String, Group> groupMap = new HashMap<String, Group>();
- if (response != null) {
- List<Group> groups = response.getEntities(Group.class);
- for (Group group : groups) {
- groupMap.put(group.getPath(), group);
- }
- }
- return groupMap;
- }
-
- /**
- * Gets the groups associated with a user entity. Executes asynchronously in background and
- * the callbacks are called in the UI thread.
- *
- * @param userId the UUID of the user entity
- * @param callback a GroupsRetrievedCallback object to handle the async response
- */
- 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();
- }
-
- /**
- * Gets the user entities associated with the specified group.
- *
- * @param groupId UUID of the group entity
- * @return a Query object with the results of the query
- */
- public Query queryUsersForGroup(String groupId) {
- Query q = queryEntitiesRequest(HTTP_METHOD_GET, null, null, organizationId,
- applicationId, "groups", groupId, "users");
- return q;
- }
-
- /**
- * Gets the user entities associated with the specified group. Executes
- * asynchronously in background and the callbacks are called in the UI thread.
- *
- * @param groupId UUID of the group entity
- * @param callback a QueryResultsCallback object to handle the async response
- */
- public void queryUsersForGroupAsync(String groupId,
- QueryResultsCallback callback) {
- queryEntitiesRequestAsync(callback, HTTP_METHOD_GET, null, null,
- getApplicationId(), "groups", groupId, "users");
- }
-
- /**
- * Connects a user entity to the specified group entity.
- *
- * @param userId UUID of the user entity
- * @param groupId UUID of the group entity
- * @return an ApiResponse object
- */
- public ApiResponse addUserToGroup(String userId, String groupId) {
- return apiRequest(HTTP_METHOD_POST, null, null, organizationId, applicationId, "groups",
- groupId, "users", userId);
- }
-
- /**
- * Connects a user entity to the specified group entity. Executes asynchronously in
- * background and the callbacks are called in the UI thread.
- *
- * @param userId UUID of the user entity
- * @param groupId UUID of the group entity
- * @param callback an ApiResponseCallback object to handle the async response
- */
- 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();
- }
-
- /**
- * Disconnects a user entity from the specified group entity.
- *
- * @param userId UUID of the user entity
- * @param groupId UUID of the group entity
- * @return an ApiResponse object
- */
- public ApiResponse removeUserFromGroup(String userId, String groupId) {
- return apiRequest(HTTP_METHOD_DELETE, null, null, organizationId, applicationId, "groups",
- groupId, "users", userId);
- }
-
- /**
- * Disconnects a user entity from the specified group entity. Executes asynchronously in
- * background and the callbacks are called in the UI thread.
- *
- * @param userId UUID of the user entity
- * @param groupId UUID of the group entity
- * @param callback an ApiResponseCallback object to handle the async response
- */
- public void removeUserFromGroupAsync(final String userId, final String groupId,
- final ApiResponseCallback callback) {
- (new ClientAsyncTask<ApiResponse>(callback) {
- @Override
- public ApiResponse doTask() {
- return removeUserFromGroup(userId, groupId);
- }
- }).execute();
- }
-
- /****************** ACTIVITY ENTITY MANAGEMENT ***********************/
- /****************** ACTIVITY ENTITY MANAGEMENT ***********************/
-
- /**
- * Get a user's activity feed. Returned as a query to ease paging.
- *
- * @param userId UUID of user entity
- * @return a Query object
- */
- public Query queryActivityFeedForUser(String userId) {
- Query q = queryEntitiesRequest(HTTP_METHOD_GET, null, null,
- organizationId, applicationId, "users", userId, "feed");
- return q;
- }
-
- /**
- * 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 UUID of user entity
- * @param callback a QueryResultsCallback object to handle the async response
- */
- public void queryActivityFeedForUserAsync(final String userId, final QueryResultsCallback callback) {
- (new ClientAsyncTask<Query>(callback) {
- @Override
- public Query doTask() {
- return queryActivityFeedForUser(userId);
- }
- }).execute();
- }
-
-
- /**
- * Posts an activity to a user entity's activity stream. Activity must already be created.
- *
- * @param userId
- * @param activity
- * @return An instance with the server response
- */
- public ApiResponse postUserActivity(String userId, Activity activity) {
- return apiRequest(HTTP_METHOD_POST, null, activity, organizationId, applicationId, "users",
- userId, "activities");
- }
-
- /**
- * Creates and posts an activity to a user entity's activity stream.
- *
- * @param verb
- * @param title
- * @param content
- * @param category
- * @param user
- * @param object
- * @param objectType
- * @param objectName
- * @param objectContent
- * @return
- */
- public ApiResponse postUserActivity(String verb, String title,
- String content, String category, User user, Entity object,
- String objectType, String objectName, String objectContent) {
- Activity activity = Activity.newActivity(this, verb, title, content,
- category, user, object, objectType, objectName, objectContent);
- return postUserActivity(user.getUuid().toString(), activity);
- }
-
- /**
- * 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();
- }
-
- /**
- * Posts an activity to a group. Activity must already be created.
- *
- * @param groupId
- * @param activity
- * @return
- */
- public ApiResponse postGroupActivity(String groupId, Activity activity) {
- return apiRequest(HTTP_METHOD_POST, null, activity, organizationId, applicationId, "groups",
- groupId, "activities");
- }
-
- /**
- * Creates and posts an activity to a group.
- *
- * @param groupId
- * @param verb
- * @param title
- * @param content
- * @param category
- * @param user
- * @param object
- * @param objectType
- * @param objectName
- * @param objectContent
- * @return
- */
- public ApiResponse postGroupActivity(String groupId, String verb, String title,
- String content, String category, User user, Entity object,
- String objectType, String objectName, String objectContent) {
- Activity activity = Activity.newActivity(this, verb, title, content,
- category, user, object, objectType, objectName, objectContent);
- return postGroupActivity(groupId, activity);
- }
-
- /**
- * 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();
- }
-
- /**
- * Post an activity to the stream.
- *
- * @param activity
- * @return
- */
- public ApiResponse postActivity(Activity activity) {
- return createEntity(activity);
- }
-
- /**
- * Creates and posts an activity to a group.
- *
- * @param verb
- * @param title
- * @param content
- * @param category
- * @param user
- * @param object
- * @param objectType
- * @param objectName
- * @param objectContent
- * @return
- */
- public ApiResponse postActivity(String verb, String title,
- String content, String category, User user, Entity object,
- String objectType, String objectName, String objectContent) {
- Activity activity = Activity.newActivity(this, verb, title, content,
- category, user, object, objectType, objectName, objectContent);
- return createEntity(activity);
- }
-
- /**
- * Get a group's activity feed. Returned as a query to ease paging.
- *
- * @return
- */
- public Query queryActivity() {
- Query q = queryEntitiesRequest(HTTP_METHOD_GET, null, null,
- organizationId, applicationId, "activities");
- return q;
- }
-
-
-
- /**
- * Get a group's activity feed. Returned as a query to ease paging.
- *
- * @param groupId
- * @return
- */
- public Query queryActivityFeedForGroup(String groupId) {
- Query q = queryEntitiesRequest(HTTP_METHOD_GET, null, null,
- organizationId, applicationId, "groups", groupId, "feed");
- return q;
- }
-
- /**
- * 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 groupId
- * @param callback
- */
- public void queryActivityFeedForGroupAsync(final String groupId,
- final QueryResultsCallback callback) {
- (new ClientAsyncTask<Query>(callback) {
- @Override
- public Query doTask() {
- return queryActivityFeedForGroup(groupId);
- }
- }).execute();
- }
-
-
- /****************** ENTITY CONNECTIONS ***********************/
- /****************** ENTITY CONNECTIONS ***********************/
-
- /**
- * 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 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 connectedEntityId The UUID 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 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 c
<TRUNCATED>
[05/12] usergrid git commit: Adding new Android SDK
Posted by mr...@apache.org.
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/UsergridAndroidSDK/src/androidTest/java/org/apache/usergrid/android/ApplicationTest.java
----------------------------------------------------------------------
diff --git a/sdks/android/UsergridAndroidSDK/src/androidTest/java/org/apache/usergrid/android/ApplicationTest.java b/sdks/android/UsergridAndroidSDK/src/androidTest/java/org/apache/usergrid/android/ApplicationTest.java
new file mode 100644
index 0000000..484d85e
--- /dev/null
+++ b/sdks/android/UsergridAndroidSDK/src/androidTest/java/org/apache/usergrid/android/ApplicationTest.java
@@ -0,0 +1,75 @@
+package org.apache.usergrid.android;
+
+import android.app.Application;
+import android.test.ApplicationTestCase;
+
+import org.apache.usergrid.android.callbacks.UsergridResponseCallback;
+
+import org.apache.usergrid.java.client.Usergrid;
+import org.apache.usergrid.java.client.model.UsergridEntity;
+import org.apache.usergrid.java.client.response.UsergridResponse;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.concurrent.CountDownLatch;
+
+/**
+ * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
+ */
+public class ApplicationTest extends ApplicationTestCase<Application> {
+
+ Book finishedBook;
+ String newBookTitle = "A new title again at time: " + System.currentTimeMillis();
+
+ public ApplicationTest() {
+ super(Application.class);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ Usergrid.initSharedInstance("rwalsh","sandbox");
+ UsergridEntity.mapCustomSubclassToType("book",Book.class);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ Usergrid.reset();
+ }
+
+ public void testGET() throws InterruptedException {
+ final CountDownLatch signal = new CountDownLatch(1);
+
+ Usergrid.initSharedInstance("rwalsh","sandbox");
+ UsergridAsync.GET("books", new UsergridResponseCallback() {
+ @Override
+ public void onResponse(@NotNull UsergridResponse response) {
+ if (response.ok()) {
+ final Book book = (Book) response.first();
+ assertNotNull(book);
+ assertNotNull(book.getUuid());
+ book.setTitle(newBookTitle);
+ UsergridEntityAsync.save(book, new UsergridResponseCallback() {
+ @Override
+ public void onResponse(@NotNull UsergridResponse response) {
+ final Book book = (Book) response.first();
+ assertNotNull(book);
+ assertNotNull(book.getUuid());
+ assertEquals(book.getTitle(),newBookTitle);
+ UsergridAsync.GET("book", book.getUuid(), new UsergridResponseCallback() {
+ @Override
+ public void onResponse(@NotNull UsergridResponse response) {
+ assertNotNull(response.getEntities());
+ assertNotNull(response.first());
+ finishedBook = (Book) response.first();
+ signal.countDown();
+ }
+ });
+ }
+ });
+ }
+ }
+ });
+ signal.await();
+ assertNotNull(finishedBook);
+ assertEquals(finishedBook.getTitle(),newBookTitle);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/UsergridAndroidSDK/src/androidTest/java/org/apache/usergrid/android/Book.java
----------------------------------------------------------------------
diff --git a/sdks/android/UsergridAndroidSDK/src/androidTest/java/org/apache/usergrid/android/Book.java b/sdks/android/UsergridAndroidSDK/src/androidTest/java/org/apache/usergrid/android/Book.java
new file mode 100644
index 0000000..a27f237
--- /dev/null
+++ b/sdks/android/UsergridAndroidSDK/src/androidTest/java/org/apache/usergrid/android/Book.java
@@ -0,0 +1,26 @@
+package org.apache.usergrid.android;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import org.apache.usergrid.java.client.model.UsergridEntity;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Created by Robert Walsh on 4/12/16.
+ */
+public class Book extends UsergridEntity {
+ @Nullable private String title;
+
+ public Book(@JsonProperty("type") @NotNull String type) {
+ super(type);
+ }
+
+ public void setTitle(@NotNull final String title) {
+ this.title = title;
+ }
+ public String getTitle() {
+ return this.title;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/UsergridAndroidSDK/src/main/AndroidManifest.xml
----------------------------------------------------------------------
diff --git a/sdks/android/UsergridAndroidSDK/src/main/AndroidManifest.xml b/sdks/android/UsergridAndroidSDK/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..8d9dfe0
--- /dev/null
+++ b/sdks/android/UsergridAndroidSDK/src/main/AndroidManifest.xml
@@ -0,0 +1,17 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="org.apache.usergrid.android">
+ <uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.READ_PHONE_STATE" />
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+ <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+ <application
+ android:allowBackup="true"
+ android:label="@string/app_name"
+ android:supportsRtl="true">
+
+ </application>
+
+</manifest>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/UsergridAndroidSDK/src/main/java/org/apache/usergrid/android/UsergridAsync.java
----------------------------------------------------------------------
diff --git a/sdks/android/UsergridAndroidSDK/src/main/java/org/apache/usergrid/android/UsergridAsync.java b/sdks/android/UsergridAndroidSDK/src/main/java/org/apache/usergrid/android/UsergridAsync.java
new file mode 100644
index 0000000..e701893
--- /dev/null
+++ b/sdks/android/UsergridAndroidSDK/src/main/java/org/apache/usergrid/android/UsergridAsync.java
@@ -0,0 +1,474 @@
+/*
+ * 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;
+
+import android.content.Context;
+
+import org.apache.usergrid.android.callbacks.UsergridResponseCallback;
+import org.apache.usergrid.android.tasks.UsergridAsyncTask;
+import org.apache.usergrid.java.client.Usergrid;
+import org.apache.usergrid.java.client.UsergridClient;
+import org.apache.usergrid.java.client.UsergridEnums.UsergridDirection;
+import org.apache.usergrid.java.client.UsergridRequest;
+import org.apache.usergrid.java.client.auth.UsergridAppAuth;
+import org.apache.usergrid.java.client.auth.UsergridUserAuth;
+import org.apache.usergrid.java.client.model.UsergridEntity;
+import org.apache.usergrid.java.client.model.UsergridUser;
+import org.apache.usergrid.java.client.query.UsergridQuery;
+import org.apache.usergrid.java.client.response.UsergridResponse;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.List;
+import java.util.Map;
+
+@SuppressWarnings("unused")
+public final class UsergridAsync {
+
+ private UsergridAsync() { }
+
+ public static void applyPushToken(@NotNull final Context context, @NotNull final String pushToken, @NotNull final String notifier, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.applyPushToken(Usergrid.getInstance(),context,pushToken,notifier,responseCallback);
+ }
+
+ public static void applyPushToken(@NotNull final UsergridClient client, @NotNull final Context context, @NotNull final String pushToken, @NotNull final String notifier, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridSharedDevice.applyPushToken(client,context,notifier,pushToken,responseCallback);
+ }
+
+ public static void authenticateApp(@NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.authenticateApp(Usergrid.getInstance(),responseCallback);
+ }
+
+ public static void authenticateApp(@NotNull final UsergridClient client, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return client.authenticateApp();
+ }
+ }).execute();
+ }
+
+ public static void authenticateApp(@NotNull final UsergridAppAuth auth, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.authenticateApp(Usergrid.getInstance(),auth,responseCallback);
+ }
+
+ public static void authenticateApp(@NotNull final UsergridClient client, @NotNull final UsergridAppAuth auth, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return client.authenticateApp(auth);
+ }
+ }).execute();
+ }
+
+ public static void authenticateUser(@NotNull final UsergridUserAuth userAuth, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.authenticateUser(Usergrid.getInstance(),userAuth,true,responseCallback);
+ }
+
+ public static void authenticateUser(@NotNull final UsergridClient client, @NotNull final UsergridUserAuth userAuth, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.authenticateUser(client,userAuth,true,responseCallback);
+ }
+
+ public static void authenticateUser(@NotNull final UsergridUserAuth userAuth, final boolean setAsCurrentUser, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.authenticateUser(Usergrid.getInstance(),userAuth,setAsCurrentUser,responseCallback);
+ }
+
+ public static void authenticateUser(@NotNull final UsergridClient client, @NotNull final UsergridUserAuth userAuth, final boolean setAsCurrentUser, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return client.authenticateUser(userAuth,setAsCurrentUser);
+ }
+ }).execute();
+ }
+
+ public static void resetPassword(@NotNull final UsergridUser user, @NotNull final String oldPassword, @NotNull final String newPassword, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.resetPassword(Usergrid.getInstance(),user,oldPassword,newPassword,responseCallback);
+ }
+
+ public static void resetPassword(@NotNull final UsergridClient client, @NotNull final UsergridUser user, @NotNull final String oldPassword, @NotNull final String newPassword, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return client.resetPassword(user,oldPassword,newPassword);
+ }
+ }).execute();
+ }
+
+ public static void logoutCurrentUser(@NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.logoutCurrentUser(Usergrid.getInstance(),responseCallback);
+ }
+
+ public static void logoutCurrentUser(@NotNull final UsergridClient client, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return client.logoutCurrentUser();
+ }
+ }).execute();
+ }
+
+ public static void logoutUserAllTokens(@NotNull final String uuidOrUsername, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.logoutUser(Usergrid.getInstance(),uuidOrUsername, null, responseCallback);
+ }
+
+ public static void logoutUserAllTokens(@NotNull final UsergridClient client, @NotNull final String uuidOrUsername, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.logoutUser(client,uuidOrUsername, null, responseCallback);
+ }
+
+ public static void logoutUser(@NotNull final UsergridClient client, @NotNull final String uuidOrUsername, @Nullable final String token, @NotNull final UsergridResponseCallback responseCallback){
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return client.logoutUser(uuidOrUsername,token);
+ }
+ }).execute();
+ }
+
+ public static void sendRequest(@NotNull final UsergridRequest request, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.sendRequest(Usergrid.getInstance(),request,responseCallback);
+ }
+
+ public static void sendRequest(@NotNull final UsergridClient client, @NotNull final UsergridRequest request, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return client.sendRequest(request);
+ }
+ }).execute();
+ }
+
+ public static void GET(@NotNull final String collection, @NotNull final String uuidOrName, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.GET(Usergrid.getInstance(),collection,uuidOrName,responseCallback);
+ }
+
+ public static void GET(@NotNull final UsergridClient client, @NotNull final String collection, @NotNull final String uuidOrName, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return client.GET(collection,uuidOrName);
+ }
+ }).execute();
+ }
+
+ public static void GET(@NotNull final String type, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.GET(Usergrid.getInstance(),type,responseCallback);
+ }
+
+ public static void GET(@NotNull final UsergridClient client, @NotNull final String type, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return client.GET(type);
+ }
+ }).execute();
+ }
+
+ public static void GET(@NotNull final UsergridQuery query, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.GET(Usergrid.getInstance(),query,responseCallback);
+ }
+
+ public static void GET(@NotNull final UsergridClient client, @NotNull final UsergridQuery query, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return client.GET(query);
+ }
+ }).execute();
+ }
+
+ public static void PUT(@NotNull final String type, @NotNull final String uuidOrName, @NotNull final Map<String, Object> jsonBody, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.PUT(Usergrid.getInstance(),type,uuidOrName,jsonBody,responseCallback);
+ }
+
+ public static void PUT(@NotNull final UsergridClient client, @NotNull final String type, @NotNull final String uuidOrName, @NotNull final Map<String, Object> jsonBody, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return client.PUT(type, uuidOrName, jsonBody);
+ }
+ }).execute();
+ }
+
+ public static void PUT(@NotNull final String type, @NotNull final Map<String, Object> jsonBody, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.PUT(Usergrid.getInstance(),type,jsonBody,responseCallback);
+ }
+
+ public static void PUT(@NotNull final UsergridClient client, @NotNull final String type, @NotNull final Map<String, Object> jsonBody, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return client.PUT(type, jsonBody);
+ }
+ }).execute();
+ }
+
+ public static void PUT(@NotNull final UsergridEntity entity, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.PUT(Usergrid.getInstance(),entity,responseCallback);
+ }
+
+ public static void PUT(@NotNull final UsergridClient client, @NotNull final UsergridEntity entity, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return client.PUT(entity);
+ }
+ }).execute();
+ }
+
+ public static void PUT(@NotNull final UsergridQuery query, @NotNull final Map<String, Object> jsonBody, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.PUT(Usergrid.getInstance(),query,jsonBody,responseCallback);
+ }
+
+ public static void PUT(@NotNull final UsergridClient client, @NotNull final UsergridQuery query, @NotNull final Map<String, Object> jsonBody, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return client.PUT(query, jsonBody);
+ }
+ }).execute();
+ }
+
+ public static void POST(@NotNull final UsergridEntity entity, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.POST(Usergrid.getInstance(),entity,responseCallback);
+ }
+
+ public static void POST(@NotNull final UsergridClient client, @NotNull final UsergridEntity entity, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return client.PUT(entity);
+ }
+ }).execute();
+ }
+
+ public static void POST(@NotNull final List<UsergridEntity> entities, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.POST(Usergrid.getInstance(),entities,responseCallback);
+ }
+
+ public static void POST(@NotNull final UsergridClient client, @NotNull final List<UsergridEntity> entities, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return client.POST(entities);
+ }
+ }).execute();
+ }
+
+ public static void POST(@NotNull final String type, @NotNull final String uuidOrName, @NotNull final Map<String, ?> jsonBody, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.POST(Usergrid.getInstance(),type,uuidOrName,jsonBody,responseCallback);
+ }
+
+ public static void POST(@NotNull final UsergridClient client, @NotNull final String type, @NotNull final String uuidOrName, @NotNull final Map<String, ?> jsonBody, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return client.POST(type, uuidOrName, jsonBody);
+ }
+ }).execute();
+ }
+
+ public static void POST(@NotNull final String type, @NotNull final Map<String, ?> jsonBody, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.POST(Usergrid.getInstance(),type,jsonBody,responseCallback);
+ }
+
+ public static void POST(@NotNull final UsergridClient client, @NotNull final String type, @NotNull final Map<String, ?> jsonBody, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return client.POST(type, jsonBody);
+ }
+ }).execute();
+ }
+
+ public static void POST(@NotNull final String type, @NotNull final List<Map<String, ?>> jsonBodies, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.POST(Usergrid.getInstance(),type,jsonBodies,responseCallback);
+ }
+
+ public static void POST(@NotNull final UsergridClient client, @NotNull final String type, @NotNull final List<Map<String, ?>> jsonBodies, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return client.POST(type, jsonBodies);
+ }
+ }).execute();
+ }
+
+ public static void DELETE(@NotNull final UsergridEntity entity, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.DELETE(Usergrid.getInstance(),entity,responseCallback);
+ }
+
+ public static void DELETE(@NotNull final UsergridClient client, @NotNull final UsergridEntity entity, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return client.DELETE(entity);
+ }
+ }).execute();
+ }
+
+ public static void DELETE(@NotNull final String type, @NotNull final String uuidOrName, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.DELETE(Usergrid.getInstance(),type,uuidOrName,responseCallback);
+ }
+
+ public static void DELETE(@NotNull final UsergridClient client, @NotNull final String type, @NotNull final String uuidOrName, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return client.DELETE(type, uuidOrName);
+ }
+ }).execute();
+ }
+
+ public static void DELETE(@NotNull final UsergridQuery query, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.DELETE(Usergrid.getInstance(),query,responseCallback);
+ }
+
+ public static void DELETE(@NotNull final UsergridClient client, @NotNull final UsergridQuery query, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return client.DELETE(query);
+ }
+ }).execute();
+ }
+
+ public static void connect(@NotNull final UsergridEntity entity, @NotNull final String relationship, @NotNull final UsergridEntity to, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.connect(Usergrid.getInstance(),entity,relationship,to,responseCallback);
+ }
+
+ public static void connect(@NotNull final UsergridClient client, @NotNull final UsergridEntity entity, @NotNull final String relationship, @NotNull final UsergridEntity to, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return client.connect(entity, relationship, to);
+ }
+ }).execute();
+ }
+
+ public static void connect(@NotNull final String entityType, @NotNull final String entityId, @NotNull final String relationship, @NotNull final String toType, @NotNull final String toName, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.connect(Usergrid.getInstance(),entityType,entityId,relationship,toType,toName,responseCallback);
+ }
+
+ public static void connect(@NotNull final UsergridClient client, @NotNull final String entityType, @NotNull final String entityId, @NotNull final String relationship, @NotNull final String toType, @NotNull final String toName, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return client.connect(entityType, entityId, relationship, toType, toName);
+ }
+ }).execute();
+ }
+
+ public static void connect(@NotNull final String entityType, @NotNull final String entityId, @NotNull final String relationship, @NotNull final String toId, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.connect(Usergrid.getInstance(),entityType,entityId,relationship,toId,responseCallback);
+ }
+
+ public static void connect(@NotNull final UsergridClient client, @NotNull final String entityType, @NotNull final String entityId, @NotNull final String relationship, @NotNull final String toId, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return client.connect(entityType, entityId, relationship, toId);
+ }
+ }).execute();
+ }
+
+ public static void disconnect(@NotNull final String entityType, @NotNull final String entityId, @NotNull final String relationship, @NotNull final String fromUuid, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.disconnect(Usergrid.getInstance(),entityType,entityId,relationship,fromUuid,responseCallback);
+ }
+
+ public static void disconnect(@NotNull final UsergridClient client, @NotNull final String entityType, @NotNull final String entityId, @NotNull final String relationship, @NotNull final String fromUuid, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return client.disconnect(entityType, entityId, relationship, fromUuid);
+ }
+ }).execute();
+ }
+
+ public static void disconnect(@NotNull final String entityType, @NotNull final String entityId, @NotNull final String relationship, @NotNull final String fromType, @NotNull final String fromName, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.disconnect(Usergrid.getInstance(),entityType,entityId,relationship,fromType,fromName,responseCallback);
+ }
+
+ public static void disconnect(@NotNull final UsergridClient client, @NotNull final String entityType, @NotNull final String entityId, @NotNull final String relationship, @NotNull final String fromType, @NotNull final String fromName, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return client.disconnect(entityType, entityId, relationship, fromType, fromName);
+ }
+ }).execute();
+ }
+
+ public static void disconnect(@NotNull final UsergridEntity entity, @NotNull final String relationship, @NotNull final UsergridEntity from, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.disconnect(Usergrid.getInstance(),entity,relationship,from,responseCallback);
+ }
+
+ public static void disconnect(@NotNull final UsergridClient client, @NotNull final UsergridEntity entity, @NotNull final String relationship, @NotNull final UsergridEntity from, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return client.disconnect(entity, relationship, from);
+ }
+ }).execute();
+ }
+
+ public static void getConnections(@NotNull final UsergridDirection direction, @NotNull final UsergridEntity entity, @NotNull final String relationship, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.getConnections(Usergrid.getInstance(),direction,entity,relationship,null,responseCallback);
+ }
+
+ public static void getConnections(@NotNull final UsergridClient client, @NotNull final UsergridDirection direction, @NotNull final UsergridEntity entity, @NotNull final String relationship, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.getConnections(client,direction,entity,relationship,null,responseCallback);
+ }
+
+ public static void getConnections(@NotNull final UsergridDirection direction, @NotNull final UsergridEntity entity, @NotNull final String relationship, @Nullable final UsergridQuery query, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.getConnections(Usergrid.getInstance(),direction,entity,relationship,query,responseCallback);
+ }
+
+ public static void getConnections(@NotNull final UsergridClient client, @NotNull final UsergridDirection direction, @NotNull final UsergridEntity entity, @NotNull final String relationship, @Nullable final UsergridQuery query, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return client.getConnections(direction, entity, relationship, query);
+ }
+ }).execute();
+ }
+
+ public static void getConnections(@NotNull final UsergridDirection direction, @NotNull final String type, @NotNull final String uuidOrName, @NotNull final String relationship, @Nullable final UsergridQuery query, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.getConnections(Usergrid.getInstance(),direction,type,uuidOrName,relationship,query,responseCallback);
+ }
+
+ public static void getConnections(@NotNull final UsergridClient client, @NotNull final UsergridDirection direction, @NotNull final String type, @NotNull final String uuidOrName, @NotNull final String relationship, @Nullable final UsergridQuery query, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return client.getConnections(direction, type, uuidOrName, relationship, query);
+ }
+ }).execute();
+ }
+
+ public static void getConnections(@NotNull final UsergridDirection direction, @NotNull final String uuid, @NotNull final String relationship, @Nullable final UsergridQuery query, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridAsync.getConnections(Usergrid.getInstance(),direction,uuid,relationship,query,responseCallback);
+ }
+
+ public static void getConnections(@NotNull final UsergridClient client, @NotNull final UsergridDirection direction, @NotNull final String uuid, @NotNull final String relationship, @Nullable final UsergridQuery query, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return client.getConnections(direction, uuid, relationship, query);
+ }
+ }).execute();
+ }
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/UsergridAndroidSDK/src/main/java/org/apache/usergrid/android/UsergridEntityAsync.java
----------------------------------------------------------------------
diff --git a/sdks/android/UsergridAndroidSDK/src/main/java/org/apache/usergrid/android/UsergridEntityAsync.java b/sdks/android/UsergridAndroidSDK/src/main/java/org/apache/usergrid/android/UsergridEntityAsync.java
new file mode 100644
index 0000000..690cc0f
--- /dev/null
+++ b/sdks/android/UsergridAndroidSDK/src/main/java/org/apache/usergrid/android/UsergridEntityAsync.java
@@ -0,0 +1,110 @@
+/*
+ * 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;
+
+import org.apache.usergrid.android.callbacks.UsergridResponseCallback;
+import org.apache.usergrid.android.tasks.UsergridAsyncTask;
+import org.apache.usergrid.java.client.Usergrid;
+import org.apache.usergrid.java.client.UsergridClient;
+import org.apache.usergrid.java.client.UsergridEnums.UsergridDirection;
+import org.apache.usergrid.java.client.model.UsergridEntity;
+import org.apache.usergrid.java.client.response.UsergridResponse;
+import org.jetbrains.annotations.NotNull;
+
+@SuppressWarnings("unused")
+public final class UsergridEntityAsync {
+
+ private UsergridEntityAsync() {}
+
+ public static void reload(@NotNull final UsergridEntity entity, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridEntityAsync.reload(Usergrid.getInstance(),entity,responseCallback);
+ }
+
+ public static void reload(@NotNull final UsergridClient client, @NotNull final UsergridEntity entity, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return entity.reload(client);
+ }
+ }).execute();
+ }
+
+ public static void save(@NotNull final UsergridEntity entity, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridEntityAsync.save(Usergrid.getInstance(),entity,responseCallback);
+ }
+
+ public static void save(@NotNull final UsergridClient client, @NotNull final UsergridEntity entity, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return entity.save(client);
+ }
+ }).execute();
+ }
+
+ public static void remove(@NotNull final UsergridEntity entity, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridEntityAsync.remove(Usergrid.getInstance(),entity, responseCallback);
+ }
+
+ public static void remove(@NotNull final UsergridClient client, @NotNull final UsergridEntity entity, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return entity.remove(client);
+ }
+ }).execute();
+ }
+
+ public static void connect(@NotNull final UsergridEntity entity, @NotNull final String relationship, @NotNull final UsergridEntity toEntity, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridEntityAsync.connect(Usergrid.getInstance(), entity, relationship, toEntity, responseCallback);
+ }
+
+ public static void connect(@NotNull final UsergridClient client, @NotNull final UsergridEntity entity, @NotNull final String relationship, @NotNull final UsergridEntity toEntity, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return entity.connect(client,relationship,toEntity);
+ }
+ }).execute();
+ }
+
+ public static void disconnect(@NotNull final UsergridEntity entity, @NotNull final String relationship, @NotNull final UsergridEntity fromEntity, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridEntityAsync.disconnect(Usergrid.getInstance(), entity, relationship, fromEntity, responseCallback);
+ }
+
+ public static void disconnect(@NotNull final UsergridClient client, @NotNull final UsergridEntity entity, @NotNull final String relationship, @NotNull final UsergridEntity fromEntity, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return entity.disconnect(client,relationship,fromEntity);
+ }
+ }).execute();
+ }
+
+ public static void getConnections(@NotNull final UsergridEntity entity, @NotNull final UsergridDirection direction, @NotNull final String relationship, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridEntityAsync.getConnections(Usergrid.getInstance(),entity,direction,relationship,responseCallback);
+ }
+
+ public static void getConnections(@NotNull final UsergridClient client, @NotNull final UsergridEntity entity, @NotNull final UsergridDirection direction, @NotNull final String relationship, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return entity.getConnections(client,direction,relationship);
+ }
+ }).execute();
+ }
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/UsergridAndroidSDK/src/main/java/org/apache/usergrid/android/UsergridResponseAsync.java
----------------------------------------------------------------------
diff --git a/sdks/android/UsergridAndroidSDK/src/main/java/org/apache/usergrid/android/UsergridResponseAsync.java b/sdks/android/UsergridAndroidSDK/src/main/java/org/apache/usergrid/android/UsergridResponseAsync.java
new file mode 100644
index 0000000..51c14c4
--- /dev/null
+++ b/sdks/android/UsergridAndroidSDK/src/main/java/org/apache/usergrid/android/UsergridResponseAsync.java
@@ -0,0 +1,38 @@
+/*
+ * 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;
+
+import org.apache.usergrid.android.callbacks.UsergridResponseCallback;
+import org.apache.usergrid.android.tasks.UsergridAsyncTask;
+
+import org.apache.usergrid.java.client.response.UsergridResponse;
+import org.jetbrains.annotations.NotNull;
+
+@SuppressWarnings("unused")
+public final class UsergridResponseAsync {
+
+ private UsergridResponseAsync() {}
+
+ public static void loadNextPage(@NotNull final UsergridResponse response, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return response.loadNextPage();
+ }
+ }).execute();
+ }
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/UsergridAndroidSDK/src/main/java/org/apache/usergrid/android/UsergridSharedDevice.java
----------------------------------------------------------------------
diff --git a/sdks/android/UsergridAndroidSDK/src/main/java/org/apache/usergrid/android/UsergridSharedDevice.java b/sdks/android/UsergridAndroidSDK/src/main/java/org/apache/usergrid/android/UsergridSharedDevice.java
new file mode 100644
index 0000000..ee23d2a
--- /dev/null
+++ b/sdks/android/UsergridAndroidSDK/src/main/java/org/apache/usergrid/android/UsergridSharedDevice.java
@@ -0,0 +1,175 @@
+package org.apache.usergrid.android;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.net.wifi.WifiManager;
+import android.os.Build;
+import android.provider.Settings;
+import android.telephony.TelephonyManager;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.TextNode;
+
+import org.apache.usergrid.android.callbacks.UsergridResponseCallback;
+import org.apache.usergrid.java.client.Usergrid;
+import org.apache.usergrid.java.client.UsergridClient;
+import org.apache.usergrid.java.client.UsergridEnums.UsergridHttpMethod;
+import org.apache.usergrid.java.client.UsergridRequest;
+import org.apache.usergrid.java.client.model.UsergridDevice;
+import org.apache.usergrid.java.client.model.UsergridEntity;
+import org.apache.usergrid.java.client.response.UsergridResponse;
+import org.apache.usergrid.java.client.utils.JsonUtils;
+import org.apache.usergrid.java.client.utils.ObjectUtils;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.UUID;
+
+@SuppressWarnings("unused")
+public final class UsergridSharedDevice {
+ @Nullable
+ private static UsergridDevice sharedDevice;
+
+ @NotNull
+ private static final String USERGRID_PREFS_FILE_NAME = "usergrid_prefs.xml";
+ @NotNull
+ private static final String USERGRID_SHARED_DEVICE_KEY = "usergridSharedDevice";
+
+ @NotNull
+ public static UsergridDevice getSharedDevice(@NotNull final Context context) {
+ if (sharedDevice == null) {
+ sharedDevice = UsergridSharedDevice.getStoredSharedDevice(context);
+ if (sharedDevice == null) {
+ String sharedDeviceId = UsergridSharedDevice.getSharedDeviceUUID(context);
+ HashMap<String, JsonNode> map = new HashMap<String, JsonNode>();
+ map.put("uuid", new TextNode(sharedDeviceId));
+ sharedDevice = new UsergridDevice(map);
+ sharedDevice.setModel(Build.MODEL);
+ sharedDevice.setPlatform("android");
+ sharedDevice.setOsVersion(Build.VERSION.RELEASE);
+ }
+ }
+ return sharedDevice;
+ }
+
+ public static void applyPushToken(@NotNull final Context context, @NotNull final String notifier, @NotNull final String token, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridSharedDevice.applyPushToken(Usergrid.getInstance(), context, notifier, token, responseCallback);
+ }
+
+ public static void applyPushToken(@NotNull final UsergridClient client, @NotNull final Context context, @NotNull final String notifier, @NotNull final String token, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridSharedDevice.getSharedDevice(context).putProperty(notifier + ".notifier.id", token);
+ UsergridSharedDevice.saveSharedDeviceRemotelyAndToDisk(client, context, responseCallback);
+ }
+
+ public static void save(@NotNull final Context context, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridSharedDevice.saveSharedDevice(Usergrid.getInstance(), context, responseCallback);
+ }
+
+ public static void save(@NotNull final UsergridClient client, @NotNull final Context context, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridSharedDevice.saveSharedDevice(client, context, responseCallback);
+ }
+
+ public static void saveSharedDevice(@NotNull final Context context, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridSharedDevice.saveSharedDeviceRemotelyAndToDisk(Usergrid.getInstance(), context, responseCallback);
+ }
+
+ public static void saveSharedDevice(@NotNull final UsergridClient client, @NotNull final Context context, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridSharedDevice.saveSharedDeviceRemotelyAndToDisk(client, context, responseCallback);
+ }
+
+ @Nullable
+ private static UsergridDevice getStoredSharedDevice(@NotNull final Context context) {
+ SharedPreferences prefs = context.getSharedPreferences(USERGRID_PREFS_FILE_NAME, Context.MODE_PRIVATE);
+ String deviceString = prefs.getString(USERGRID_SHARED_DEVICE_KEY, null);
+ UsergridDevice storedSharedDevice = null;
+ if (deviceString != null) {
+ try {
+ storedSharedDevice = JsonUtils.mapper.readValue(deviceString, UsergridDevice.class);
+ } catch (IOException ignored) {
+ prefs.edit().remove(USERGRID_SHARED_DEVICE_KEY).commit();
+ }
+ }
+ return storedSharedDevice;
+ }
+
+ private static void saveSharedDeviceToDisk(@NotNull final Context context) {
+ String deviceAsString = UsergridSharedDevice.getSharedDevice(context).toString();
+ SharedPreferences prefs = context.getSharedPreferences(USERGRID_PREFS_FILE_NAME, Context.MODE_PRIVATE);
+ prefs.edit().putString(USERGRID_SHARED_DEVICE_KEY, deviceAsString).commit();
+ }
+
+ private static void saveSharedDeviceRemotelyAndToDisk(@NotNull final UsergridClient client, @NotNull final Context context, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridDevice sharedDevice = UsergridSharedDevice.getSharedDevice(context);
+ String sharedDeviceUUID = sharedDevice.getUuid() != null ? sharedDevice.getUuid() : sharedDevice.getStringProperty("uuid");
+ UsergridRequest request = new UsergridRequest(UsergridHttpMethod.PUT, UsergridRequest.APPLICATION_JSON_MEDIA_TYPE, client.clientAppUrl(), null, sharedDevice, client.authForRequests(), "devices", sharedDeviceUUID);
+ UsergridAsync.sendRequest(client, request, new UsergridResponseCallback() {
+ @Override
+ public void onResponse(@NotNull UsergridResponse response) {
+ UsergridEntity responseEntity = response.entity();
+ if (response.ok() && responseEntity != null && responseEntity instanceof UsergridDevice) {
+ UsergridSharedDevice.sharedDevice = (UsergridDevice) responseEntity;
+ UsergridSharedDevice.saveSharedDeviceToDisk(context);
+ }
+ responseCallback.onResponse(response);
+ }
+ });
+ }
+
+ @NotNull
+ public static String getSharedDeviceUUID(@NotNull final Context context) {
+ if( sharedDevice != null && sharedDevice.getUuid() != null ) {
+ return sharedDevice.getUuid();
+ }
+
+ String androidId = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
+ UUID uuid;
+ 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 (Exception ignored) {
+ uuid = UUID.randomUUID();
+ }
+ return uuid.toString();
+ }
+
+ private static 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 = Settings.Secure.getString(context.getContentResolver(),
+ Settings.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 (ObjectUtils.isEmpty(imei) && ObjectUtils.isEmpty(androidId) && ObjectUtils.isEmpty(mac)) {
+ return UUID.randomUUID();
+ }
+
+ // concatenate the string
+ String fullHash = buildParams + imei + androidId + mac;
+ return UUID.nameUUIDFromBytes(fullHash.getBytes());
+ }
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/UsergridAndroidSDK/src/main/java/org/apache/usergrid/android/UsergridUserAsync.java
----------------------------------------------------------------------
diff --git a/sdks/android/UsergridAndroidSDK/src/main/java/org/apache/usergrid/android/UsergridUserAsync.java b/sdks/android/UsergridAndroidSDK/src/main/java/org/apache/usergrid/android/UsergridUserAsync.java
new file mode 100644
index 0000000..af0b791
--- /dev/null
+++ b/sdks/android/UsergridAndroidSDK/src/main/java/org/apache/usergrid/android/UsergridUserAsync.java
@@ -0,0 +1,125 @@
+/*
+ * 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;
+
+import org.apache.usergrid.android.callbacks.UsergridCheckAvailabilityCallback;
+import org.apache.usergrid.android.callbacks.UsergridResponseCallback;
+import org.apache.usergrid.android.tasks.UsergridAsyncTask;
+
+import org.apache.usergrid.java.client.Usergrid;
+import org.apache.usergrid.java.client.UsergridClient;
+import org.apache.usergrid.java.client.UsergridEnums.*;
+import org.apache.usergrid.java.client.model.UsergridUser;
+import org.apache.usergrid.java.client.query.UsergridQuery;
+import org.apache.usergrid.java.client.response.UsergridResponse;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+@SuppressWarnings("unused")
+public final class UsergridUserAsync {
+
+ private UsergridUserAsync() {}
+
+ public static void checkAvailable(@Nullable final String email, @Nullable final String username, @NotNull final UsergridCheckAvailabilityCallback checkAvailabilityCallback) {
+ UsergridUserAsync.checkAvailable(Usergrid.getInstance(), email, username, checkAvailabilityCallback);
+ }
+
+ public static void checkAvailable(@NotNull final UsergridClient client, @Nullable final String email, @Nullable final String username, @NotNull final UsergridCheckAvailabilityCallback checkAvailabilityCallback) {
+ if (email == null && username == null) {
+ checkAvailabilityCallback.onResponse(false);
+ return;
+ }
+ UsergridQuery query = new UsergridQuery(UsergridUser.USER_ENTITY_TYPE);
+ if (username != null) {
+ query.eq(UsergridUserProperties.USERNAME.toString(), username);
+ }
+ if (email != null) {
+ query.or().eq(UsergridUserProperties.EMAIL.toString(), email);
+ }
+ UsergridAsync.GET(client, query, new UsergridResponseCallback() {
+ @Override
+ public void onResponse(@NotNull UsergridResponse response) {
+ checkAvailabilityCallback.onResponse((response.ok() && response.first() != null));
+ }
+ });
+ }
+
+ public static void create(@NotNull final UsergridUser user, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridUserAsync.create(Usergrid.getInstance(),user,responseCallback);
+ }
+
+ public static void create(@NotNull final UsergridClient client, @NotNull final UsergridUser user, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return user.create(client);
+ }
+ }).execute();
+ }
+
+ public static void login(@NotNull final UsergridUser user, @NotNull final String username, @NotNull final String password, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridUserAsync.login(Usergrid.getInstance(),user,username,password,responseCallback);
+ }
+
+ public static void login(@NotNull final UsergridClient client, @NotNull final UsergridUser user, @NotNull final String username, @NotNull final String password, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return user.login(client,username,password);
+ }
+ }).execute();
+ }
+
+ public static void resetPassword(@NotNull final UsergridUser user, @NotNull final String oldPassword, @NotNull final String newPassword, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridUserAsync.resetPassword(Usergrid.getInstance(),user,oldPassword,newPassword,responseCallback);
+ }
+
+ public static void resetPassword(@NotNull final UsergridClient client, @NotNull final UsergridUser user, @NotNull final String oldPassword, @NotNull final String newPassword, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return user.resetPassword(client,oldPassword,newPassword);
+ }
+ }).execute();
+ }
+
+ public static void reauthenticate(@NotNull final UsergridUser user, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridUserAsync.reauthenticate(Usergrid.getInstance(),user,responseCallback);
+ }
+
+ public static void reauthenticate(@NotNull final UsergridClient client, @NotNull final UsergridUser user, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return user.reauthenticate(client);
+ }
+ }).execute();
+ }
+
+ public static void logout(@NotNull final UsergridUser user, @NotNull final UsergridResponseCallback responseCallback) {
+ UsergridUserAsync.logout(Usergrid.getInstance(),user,responseCallback);
+ }
+
+ public static void logout(@NotNull final UsergridClient client, @NotNull final UsergridUser user, @NotNull final UsergridResponseCallback responseCallback) {
+ (new UsergridAsyncTask(responseCallback) {
+ @Override
+ public UsergridResponse doTask() {
+ return user.logout(client);
+ }
+ }).execute();
+ }
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/UsergridAndroidSDK/src/main/java/org/apache/usergrid/android/callbacks/UsergridCheckAvailabilityCallback.java
----------------------------------------------------------------------
diff --git a/sdks/android/UsergridAndroidSDK/src/main/java/org/apache/usergrid/android/callbacks/UsergridCheckAvailabilityCallback.java b/sdks/android/UsergridAndroidSDK/src/main/java/org/apache/usergrid/android/callbacks/UsergridCheckAvailabilityCallback.java
new file mode 100644
index 0000000..3c3916e
--- /dev/null
+++ b/sdks/android/UsergridAndroidSDK/src/main/java/org/apache/usergrid/android/callbacks/UsergridCheckAvailabilityCallback.java
@@ -0,0 +1,21 @@
+/*
+ * 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.callbacks;
+
+public interface UsergridCheckAvailabilityCallback {
+ void onResponse(final boolean available);
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/UsergridAndroidSDK/src/main/java/org/apache/usergrid/android/callbacks/UsergridResponseCallback.java
----------------------------------------------------------------------
diff --git a/sdks/android/UsergridAndroidSDK/src/main/java/org/apache/usergrid/android/callbacks/UsergridResponseCallback.java b/sdks/android/UsergridAndroidSDK/src/main/java/org/apache/usergrid/android/callbacks/UsergridResponseCallback.java
new file mode 100644
index 0000000..fce1e67
--- /dev/null
+++ b/sdks/android/UsergridAndroidSDK/src/main/java/org/apache/usergrid/android/callbacks/UsergridResponseCallback.java
@@ -0,0 +1,24 @@
+/*
+ * 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.callbacks;
+
+import org.apache.usergrid.java.client.response.UsergridResponse;
+import org.jetbrains.annotations.NotNull;
+
+public interface UsergridResponseCallback {
+ void onResponse(@NotNull final UsergridResponse response);
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/UsergridAndroidSDK/src/main/java/org/apache/usergrid/android/tasks/UsergridAsyncTask.java
----------------------------------------------------------------------
diff --git a/sdks/android/UsergridAndroidSDK/src/main/java/org/apache/usergrid/android/tasks/UsergridAsyncTask.java b/sdks/android/UsergridAndroidSDK/src/main/java/org/apache/usergrid/android/tasks/UsergridAsyncTask.java
new file mode 100644
index 0000000..b9dd2c6
--- /dev/null
+++ b/sdks/android/UsergridAndroidSDK/src/main/java/org/apache/usergrid/android/tasks/UsergridAsyncTask.java
@@ -0,0 +1,45 @@
+/*
+ * 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.tasks;
+
+import android.os.AsyncTask;
+
+import org.apache.usergrid.android.callbacks.UsergridResponseCallback;
+
+import org.apache.usergrid.java.client.response.UsergridResponse;
+import org.jetbrains.annotations.NotNull;
+
+public abstract class UsergridAsyncTask extends AsyncTask<Void, Void, UsergridResponse> {
+
+ @NotNull private final UsergridResponseCallback responseCallback;
+
+ public UsergridAsyncTask(@NotNull final UsergridResponseCallback responseCallback) {
+ this.responseCallback = responseCallback;
+ }
+
+ @Override @NotNull
+ protected UsergridResponse doInBackground(final Void... v) {
+ return doTask();
+ }
+
+ public abstract UsergridResponse doTask();
+
+ @Override
+ protected void onPostExecute(@NotNull final UsergridResponse response) {
+ this.responseCallback.onResponse(response);
+ }
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/UsergridAndroidSDK/src/main/res/values/strings.xml
----------------------------------------------------------------------
diff --git a/sdks/android/UsergridAndroidSDK/src/main/res/values/strings.xml b/sdks/android/UsergridAndroidSDK/src/main/res/values/strings.xml
new file mode 100644
index 0000000..2bb6e0e
--- /dev/null
+++ b/sdks/android/UsergridAndroidSDK/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+<resources>
+ <string name="app_name">UsergridAndroidSDK</string>
+</resources>
[02/12] usergrid git commit: Removing old android SDK.
Posted by mr...@apache.org.
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7e0ffbc0/sdks/android/src/main/java/org/apache/usergrid/android/sdk/URLConnectionFactory.java
----------------------------------------------------------------------
diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/URLConnectionFactory.java b/sdks/android/src/main/java/org/apache/usergrid/android/sdk/URLConnectionFactory.java
deleted file mode 100755
index f19aa64..0000000
--- a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/URLConnectionFactory.java
+++ /dev/null
@@ -1,30 +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.sdk;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URLConnection;
-
-/**
- * @y.exclude
- */
-public interface URLConnectionFactory {
- public URLConnection openConnection(String urlAsString) throws MalformedURLException, IOException;
-}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7e0ffbc0/sdks/android/src/main/java/org/apache/usergrid/android/sdk/callbacks/ApiResponseCallback.java
----------------------------------------------------------------------
diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/callbacks/ApiResponseCallback.java b/sdks/android/src/main/java/org/apache/usergrid/android/sdk/callbacks/ApiResponseCallback.java
deleted file mode 100755
index bbc846f..0000000
--- a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/callbacks/ApiResponseCallback.java
+++ /dev/null
@@ -1,31 +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.sdk.callbacks;
-
-import org.apache.usergrid.android.sdk.response.ApiResponse;
-
-/**
- * Default callback for async requests that return an ApiResponse object
- */
-public interface ApiResponseCallback extends ClientCallback<ApiResponse> {
-
- public void onResponse(ApiResponse response);
-
-}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7e0ffbc0/sdks/android/src/main/java/org/apache/usergrid/android/sdk/callbacks/ClientAsyncTask.java
----------------------------------------------------------------------
diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/callbacks/ClientAsyncTask.java b/sdks/android/src/main/java/org/apache/usergrid/android/sdk/callbacks/ClientAsyncTask.java
deleted file mode 100755
index 92794aa..0000000
--- a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/callbacks/ClientAsyncTask.java
+++ /dev/null
@@ -1,66 +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.sdk.callbacks;
-
-import android.os.AsyncTask;
-
-/**
- * Default async request handler
- */
-public abstract class ClientAsyncTask<T> extends AsyncTask<Void, Exception, T> {
-
- ClientCallback<T> callback;
-
- /**
- * Default constructor for starting an async request
- */
- 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;
- }
-
- /**
- * Starts the async request
- */
- 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/usergrid/blob/7e0ffbc0/sdks/android/src/main/java/org/apache/usergrid/android/sdk/callbacks/ClientCallback.java
----------------------------------------------------------------------
diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/callbacks/ClientCallback.java b/sdks/android/src/main/java/org/apache/usergrid/android/sdk/callbacks/ClientCallback.java
deleted file mode 100755
index ebf7035..0000000
--- a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/callbacks/ClientCallback.java
+++ /dev/null
@@ -1,31 +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.sdk.callbacks;
-
-/**
- * Interface for all callback methods
- */
-public interface ClientCallback<T> {
-
- public void onResponse(T response);
-
- public void onException(Exception e);
-
-}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7e0ffbc0/sdks/android/src/main/java/org/apache/usergrid/android/sdk/callbacks/GroupsRetrievedCallback.java
----------------------------------------------------------------------
diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/callbacks/GroupsRetrievedCallback.java b/sdks/android/src/main/java/org/apache/usergrid/android/sdk/callbacks/GroupsRetrievedCallback.java
deleted file mode 100755
index b2339bc..0000000
--- a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/callbacks/GroupsRetrievedCallback.java
+++ /dev/null
@@ -1,35 +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.sdk.callbacks;
-
-import java.util.Map;
-
-import org.apache.usergrid.android.sdk.entities.Group;
-
-/**
- * Callback for GET requests on groups entities
- * @see org.apache.usergrid.android.sdk.UGClient#getGroupsForUserAsync(String,GroupsRetrievedCallback)
- */
-public interface GroupsRetrievedCallback extends
- ClientCallback<Map<String, Group>> {
-
- public void onGroupsRetrieved(Map<String, Group> groups);
-
-}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7e0ffbc0/sdks/android/src/main/java/org/apache/usergrid/android/sdk/callbacks/QueryResultsCallback.java
----------------------------------------------------------------------
diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/callbacks/QueryResultsCallback.java b/sdks/android/src/main/java/org/apache/usergrid/android/sdk/callbacks/QueryResultsCallback.java
deleted file mode 100755
index 3eacf5b..0000000
--- a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/callbacks/QueryResultsCallback.java
+++ /dev/null
@@ -1,33 +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.sdk.callbacks;
-
-import org.apache.usergrid.android.sdk.UGClient.Query;
-
-/**
- * Callback for async requests using the Query interface
- * @see org.apache.usergrid.android.sdk.UGClient.Query
- * @see org.apache.usergrid.android.sdk.UGClient#queryActivityFeedForUserAsync(String, QueryResultsCallback)
- */
-public interface QueryResultsCallback extends ClientCallback<Query> {
-
- public void onQueryResults(Query query);
-
-}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7e0ffbc0/sdks/android/src/main/java/org/apache/usergrid/android/sdk/entities/Activity.java
----------------------------------------------------------------------
diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/entities/Activity.java b/sdks/android/src/main/java/org/apache/usergrid/android/sdk/entities/Activity.java
deleted file mode 100755
index 426603c..0000000
--- a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/entities/Activity.java
+++ /dev/null
@@ -1,1019 +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.sdk.entities;
-
-
-import java.util.Arrays;
-import java.util.Date;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.UUID;
-
-import org.apache.usergrid.android.sdk.UGClient;
-import com.fasterxml.jackson.annotation.JsonAnyGetter;
-import com.fasterxml.jackson.annotation.JsonAnySetter;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion;
-
-/**
- * An entity type for representing posts to an activity stream. These are similar to
- * the more generic message entity type except provide the necessary properties
- * for supporting activity stream implementations.
- *
- * @see <a href="http://activitystrea.ms/specs/json/1.0/">JSON activity stream spec</a>
- * @see <a href="http://apigee.com/docs/app-services/content/activity">Activity entity documentation</a>
- */
-public class Activity extends Entity {
-
- public static final String ENTITY_TYPE = "activity";
-
- public static final String PROP_ACTOR = "actor";
-
- public static final String VERB_ADD = "add";
- public static final String VERB_CANCEL = "cancel";
- public static final String VERB_CHECKIN = "checkin";
- public static final String VERB_DELETE = "delete";
- public static final String VERB_FAVORITE = "favorite";
- public static final String VERB_FOLLOW = "follow";
- public static final String VERB_GIVE = "give";
- public static final String VERB_IGNORE = "ignore";
- public static final String VERB_INVITE = "invite";
- public static final String VERB_JOIN = "join";
- public static final String VERB_LEAVE = "leave";
- public static final String VERB_LIKE = "like";
- public static final String VERB_MAKE_FRIEND = "make-friend";
- public static final String VERB_PLAY = "play";
- public static final String VERB_POST = "post";
- public static final String VERB_RECEIVE = "receive";
- public static final String VERB_REMOVE = "remove";
- public static final String VERB_REMOVE_FRIEND = "remove-friend";
- public static final String VERB_REQUEST_FRIEND = "request-friend";
- public static final String VERB_RSVP_MAYBE = "rsvp-maybe";
- public static final String VERB_RSVP_NO = "rsvp-no";
- public static final String VERB_RSVP_YES = "rsvp-yes";
- public static final String VERB_SAVE = "save";
- public static final String VERB_SHARE = "share";
- public static final String VERB_STOP_FOLLOWING = "stop-following";
- public static final String VERB_TAG = "tag";
- public static final String VERB_UNFAVORITE = "unfavorite";
- public static final String VERB_UNLIKE = "unlike";
- public static final String VERB_UNSAVE = "unsave";
- public static final String VERB_UPDATE = "update";
-
- public static final String OBJECT_TYPE_ARTICLE = "article";
- public static final String OBJECT_TYPE_AUDIO = "audio";
- public static final String OBJECT_TYPE_BADGE = "badge";
- public static final String OBJECT_TYPE_BOOKMARK = "bookmark";
- public static final String OBJECT_TYPE_COLLECTION = "collection";
- public static final String OBJECT_TYPE_COMMENT = "comment";
- public static final String OBJECT_TYPE_EVENT = "event";
- public static final String OBJECT_TYPE_FILE = "file";
- public static final String OBJECT_TYPE_GROUP = "group";
- public static final String OBJECT_TYPE_IMAGE = "image";
- public static final String OBJECT_TYPE_NOTE = "note";
- public static final String OBJECT_TYPE_PERSON = "person";
- public static final String OBJECT_TYPE_PLACE = "place";
- public static final String OBJECT_TYPE_PRODUCT = "product";
- public static final String OBJECT_TYPE_QUESTION = "question";
- public static final String OBJECT_TYPE_REVIEW = "review";
- public static final String OBJECT_TYPE_SERVICE = "service";
- public static final String OBJECT_TYPE_VIDEO = "video";
-
- protected ActivityObject actor;
-
- protected String content;
-
- protected ActivityObject generator;
-
- protected MediaLink icon;
-
- protected String category;
-
- protected String verb;
-
- protected Long published;
-
- protected ActivityObject object;
-
- // protected
- // String objectType;
-
- // protected
- // String objectEntityType;
-
- // protected
- // String objectName;
-
- protected String title;
-
- protected Set<String> connections;
-
- /**
- * Checks if the provided type equals 'activity'.
- *
- * @return boolean true/false
- */
- public static boolean isSameType(String type) {
- return type.equals(ENTITY_TYPE);
- }
-
- /**
- * Default constructor. Sets entity type to 'activity'.
- */
- public Activity() {
- setType("activity");
- }
-
- /**
- * Constructs the Activity with an instance of UGClient.
- *
- * @param UGClient an instance of UGClient
- */
- public Activity(UGClient client) {
- super(client);
- setType("activity");
- }
-
- /**
- * Constructs the Activity with an instance of UGClient and
- * an entity UUID.
- *
- * @param UGClient an instance of UGClient
- * @param id the UUID of the activity entity
- */
- public Activity(UGClient client, UUID id) {
- this(client);
- setUuid(id);
- }
-
- /**
- * Creates a new Activity object.
- *
- * @param UGClient an instance of UGClient
- * @param verb the 'verb' to associate with the activity, e.g. 'uploaded', 'posted', etc
- * @param title the title of the activity
- * @param content the content of the posted activity
- * @param category the category of the activity
- * @param user an Entity object that represents the 'actor', i.e. the user performing the activity.
- * If the name property is set it will be used for the display name of the actor,
- * otherwise the username will be used.
- * @param object the Entity object that is acted on, e.g. the article posted, the image uploaded, etc.
- * @param objectType the type of activity object, e.g. article, group, review, etc.
- * @param objectName optional. The name of the activity object, e.g.
- * @param objectContent optional. The content of the object, e.g. a link to a posted photo
- * @return an Activity object
- */
- public static Activity newActivity(UGClient client, String verb, String title,
- String content, String category, Entity user, Entity object,
- String objectType, String objectName, String objectContent){
-
- Activity activity = new Activity(client);
- activity.setVerb(verb);
- activity.setCategory(category);
- activity.setContent(content);
- activity.setTitle(title);
-
- ActivityObject actor = new ActivityObject();
- actor.setObjectType("person");
-
- if (user != null) {
- if(user.getStringProperty("name") != null) {
- actor.setDisplayName(user.getStringProperty("name"));
- } else {
- actor.setDisplayName(user.getStringProperty("username"));
- }
- actor.setEntityType(user.getType());
- actor.setUuid(user.getUuid());
- }
-
- activity.setActor(actor);
-
- ActivityObject obj = new ActivityObject();
- obj.setDisplayName(objectName);
- obj.setObjectType(objectType);
- if (object != null) {
- obj.setEntityType(object.getType());
- obj.setUuid(object.getUuid());
- }
- if (objectContent != null) {
- obj.setContent(objectContent);
- } else {
- obj.setContent(content);
- }
- activity.setObject(obj);
-
- return activity;
- }
-
- /**
- * Gets the 'actor' of the activity
- *
- * @return an ActivityObject that represents the actor
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public ActivityObject getActor() {
- return actor;
- }
-
- /**
- * Sets the 'actor' of the activity
- *
- * @param actor an ActivityObject that represents the actor
- */
- public void setActor(ActivityObject actor) {
- this.actor = actor;
- }
-
- /**
- * Gets the activity generator, i.e. a link to the application that
- * generated the activity object.
- *
- * @return the generator
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public ActivityObject getGenerator() {
- return generator;
- }
-
- /**
- * Sets the activity generator, i.e. a link to the application that
- * generated the activity object.
- *
- * @param generator the generator
- */
- public void setGenerator(ActivityObject generator) {
- this.generator = generator;
- }
-
- /*
- * @JsonSerialize(include = Inclusion.NON_NULL) public String getActorName()
- * { return actorName; }
- *
- * public void setActorName(String actorName) { this.actorName = actorName;
- * }
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public String getCategory() {
- return category;
- }
-
- public void setCategory(String category) {
- this.category = category;
- }
-
- /**
- * Gets the verb of the Activity.
- *
- * @return the activity verb
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public String getVerb() {
- return verb;
- }
-
- /**
- * Sets the verb of the Activity.
- *
- * @param verb the verb
- */
- public void setVerb(String verb) {
- this.verb = verb;
- }
-
- /**
- * Retrieves the UNIX timestamp of when the activity was published.
- *
- * @return a UNIX timestamp
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public Long getPublished() {
- return published;
- }
-
- /**
- * Sets the UNIX timestamp of when the activity was published.
- *
- * @param published a UNIX timestamp
- */
- public void setPublished(Long published) {
- this.published = published;
- }
-
- /**
- * Retrieves the object of the activity.
- *
- * @return an ActivityObject representing the object
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public ActivityObject getObject() {
- return object;
- }
-
- /**
- * Sets the object of the activity.
- *
- * @param object an ActivityObject representing the object
- */
- public void setObject(ActivityObject object) {
- this.object = object;
- }
-
- /*
- * @JsonSerialize(include = Inclusion.NON_NULL) public String
- * getObjectType() { return objectType; }
- *
- * public void setObjectType(String objectType) { this.objectType =
- * objectType; }
- *
- * @JsonSerialize(include = Inclusion.NON_NULL) public String
- * getObjectEntityType() { return objectEntityType; }
- *
- * public void setObjectEntityType(String objectEntityType) {
- * this.objectEntityType = objectEntityType; }
- *
- * @JsonSerialize(include = Inclusion.NON_NULL) public String
- * getObjectName() { return objectName; }
- *
- * public void setObjectName(String objectName) { this.objectName =
- * objectName; }
- */
-
- /**
- * Retrieves the title of the activity
- *
- * @return the title
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public String getTitle() {
- return title;
- }
-
- /**
- * Sets the title of the Activity
- *
- * @param title the title
- */
- public void setTitle(String title) {
- this.title = title;
- }
-
- /**
- * Gets the icon to display with the Activity.
- *
- * @return a MediaLink object that represents the icon
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public MediaLink getIcon() {
- return icon;
- }
-
- /**
- * Sets the icon to display with the Activity.
- *
- * @param icon a MediaLink object that represents the icon
- */
- public void setIcon(MediaLink icon) {
- this.icon = icon;
- }
-
- /**
- * Retrieves the content of the Activity.
- *
- * @return the activity content
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public String getContent() {
- return content;
- }
-
- /**
- * Sets the content of the Activity.
- *
- * @param content the activity content
- */
- public void setContent(String content) {
- this.content = content;
- }
-
- /**
- * Gets the entity connections for the activity.
- *
- * @return the connections as a Set object
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public Set<String> getConnections() {
- return connections;
- }
-
- /**
- * Stores the entity connections for the activity.
- *
- * @param connections the connections as a Set object
- */
- public void setConnections(Set<String> connections) {
- this.connections = connections;
- }
-
- /**
- * Models a media object, such as an image.
- */
- //@XmlRootElement
- static public class MediaLink {
-
- int duration;
-
- int height;
-
- String url;
-
- int width;
-
- protected Map<String, Object> dynamic_properties = new TreeMap<String, Object>(
- String.CASE_INSENSITIVE_ORDER);
-
- /**
- * Default constructor.
- */
- public MediaLink() {
- }
-
- /**
- * Retrieves the duration of the media, e.g. the length of a video.
- *
- * @return the duration
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public int getDuration() {
- return duration;
- }
-
- /**
- * Sets the duration of the media, e.g. the length of a video.
- *
- * @param duration the duration
- */
- public void setDuration(int duration) {
- this.duration = duration;
- }
-
- /**
- * Retrieves the height of the media, e.g. height of the image.
- *
- * @return the height
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public int getHeight() {
- return height;
- }
-
- /**
- * Sets the height of the media, e.g. height of the image.
- *
- * @param height the height
- */
- public void setHeight(int height) {
- this.height = height;
- }
-
- /**
- * Retrieves the url of the media, e.g. url a video can be streamed from.
- *
- * @return the url
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public String getUrl() {
- return url;
- }
-
- /**
- * Sets the url of the media, e.g. url a video can be streamed from.
- *
- * @param url the url
- */
- public void setUrl(String url) {
- this.url = url;
- }
-
- /**
- * Retrieves the width of the media, e.g. image width.
- *
- * @return the width
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public int getWidth() {
- return width;
- }
-
- /**
- * Sets the width of the media, e.g. image width.
- *
- * @param width the width
- */
- public void setWidth(int width) {
- this.width = width;
- }
-
- @JsonAnySetter
- public void setDynamicProperty(String key, Object value) {
- dynamic_properties.put(key, value);
- }
-
- @JsonAnyGetter
- public Map<String, Object> getDynamicProperties() {
- return dynamic_properties;
- }
-
- /**
- * Returns the properties of the MediaLink object as a string.
- *
- * @return the object properties
- */
- @Override
- public String toString() {
- return "MediaLink [duration=" + duration + ", height=" + height
- + ", url=" + url + ", width=" + width
- + ", dynamic_properties=" + dynamic_properties + "]";
- }
-
- }
-
- /**
- * Models the object of an activity. For example, for the activity
- * 'John posted a new article', the article is the activity object.
- */
- //@XmlRootElement
- static public class ActivityObject {
-
- ActivityObject[] attachments;
-
- ActivityObject author;
-
- String content;
-
- String displayName;
-
- String[] downstreamDuplicates;
-
- String id;
-
- MediaLink image;
-
- String objectType;
-
- Date published;
-
- String summary;
-
- String updated;
-
- String upstreamDuplicates;
-
- String url;
-
- UUID uuid;
-
- String entityType;
-
- protected Map<String, Object> dynamic_properties = new TreeMap<String, Object>(
- String.CASE_INSENSITIVE_ORDER);
-
- /**
- * Default constructor.
- */
- public ActivityObject() {
- }
-
- /**
- * Gets the attachments for the activity
- *
- * @return an array of ActivityObject objects that represent the attachments
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public ActivityObject[] getAttachments() {
- return attachments;
- }
-
- /**
- * Sets the attachments for the activity
- *
- * @param attachments an array of ActivityObject objects that represent the attachments
- */
- public void setAttachments(ActivityObject[] attachments) {
- this.attachments = attachments;
- }
-
- /**
- * Gets the author who posted the activity. This can be distinct from
- * the actor, who is the user that performed the activity.
- *
- * @return an ActivityObject that represents the author
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public ActivityObject getAuthor() {
- return author;
- }
-
- /**
- * Sets the author who posted the activity. This can be distinct from
- * the actor, who is the user that performed the activity.
- *
- * @param author an ActivityObject that represents the author
- */
- public void setAuthor(ActivityObject author) {
- this.author = author;
- }
-
- /**
- * Gets the content of the activity.
- *
- * @return the activity content
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public String getContent() {
- return content;
- }
-
- /**
- * Sets the content of the activity.
- *
- * @param content the activity content
- */
- public void setContent(String content) {
- this.content = content;
- }
-
- /**
- * Gets the display name of the activity.
- *
- * @return the dislay name
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public String getDisplayName() {
- return displayName;
- }
-
- /**
- * Sets the display name of the activity.
- *
- * @param displayName the dislay name
- */
- public void setDisplayName(String displayName) {
- this.displayName = displayName;
- }
-
- /**
- * Gets the IRIs identifying objects that duplicate this object's content.
- *
- * @return An array of one or more absolute IRIs
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public String[] getDownstreamDuplicates() {
- return downstreamDuplicates;
- }
-
- /**
- * Sets the IRIs identifying objects that duplicate this object's content.
- *
- * @param downstreamDuplicates An array of one or more absolute IRIs
- */
- public void setDownstreamDuplicates(String[] downstreamDuplicates) {
- this.downstreamDuplicates = downstreamDuplicates;
- }
-
- /**
- * Gets the id of this object. Should be universally unique.
- *
- * @return the id
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public String getId() {
- return id;
- }
-
- /**
- * Sets the id of this object. Should be universally unique.
- *
- * @param id the id
- */
- public void setId(String id) {
- this.id = id;
- }
-
- /**
- * Gets the image associated with this object.
- *
- * @return a MediaLink object that describes the image
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public MediaLink getImage() {
- return image;
- }
-
- /**
- * Sets the image associated with this object.
- *
- * @param image a MediaLink object that describes the image
- */
- public void setImage(MediaLink image) {
- this.image = image;
- }
-
- /**
- * Gets the object type associated with this object.
- *
- * @return the type of the object
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public String getObjectType() {
- return objectType;
- }
-
- /**
- * Sets the object type associated with this object.
- *
- * @param objectType the type of the object
- */
- public void setObjectType(String objectType) {
- this.objectType = objectType;
- }
-
- /**
- * Gets the date this object was published.
- *
- * @return the date
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public Date getPublished() {
- return published;
- }
-
- /**
- * Sets the date this object was published.
- *
- * @param published the date
- */
- public void setPublished(Date published) {
- this.published = published;
- }
-
- /**
- * Gets the summary for this object.
- *
- * @return the summary
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public String getSummary() {
- return summary;
- }
-
- /**
- * Sets the summary for this object.
- *
- * @param summary the summary
- */
- public void setSummary(String summary) {
- this.summary = summary;
- }
-
- /**
- * Gets the date this object was last updated.
- *
- * @return the updated date
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public String getUpdated() {
- return updated;
- }
-
- /**
- * Sets the date this object was last updated.
- *
- * @param updated the updated date
- */
- public void setUpdated(String updated) {
- this.updated = updated;
- }
-
- /**
- * Gets the IRIs identifying objects that this object's content duplicates.
- *
- * @return A JSON Array of one or more absolute IRIs
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public String getUpstreamDuplicates() {
- return upstreamDuplicates;
- }
-
- /**
- * Sets the IRIs identifying objects that this object's content duplicates.
- *
- * @param upstreamDuplicates A JSON Array of one or more absolute IRIs
- */
- public void setUpstreamDuplicates(String upstreamDuplicates) {
- this.upstreamDuplicates = upstreamDuplicates;
- }
-
- /**
- * Gets the url for the entity that corresponds to this object
- *
- * @return the URL
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public String getUrl() {
- return url;
- }
-
- /**
- * Sets the url for the entity that corresponds to this object
- *
- * @param url the URL
- */
- public void setUrl(String url) {
- this.url = url;
- }
-
- /**
- * Gets the UUID for the entity this object is modeling.
- *
- * @return the UUID
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public UUID getUuid() {
- return uuid;
- }
-
- /**
- * Sets the UUID for the entity this object is modeling.
- *
- * @param uuid a UUID object
- */
- public void setUuid(UUID uuid) {
- this.uuid = uuid;
- }
-
- /**
- * Gets the entity type for the entity this object is modeling.
- *
- * @return the entity type
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public String getEntityType() {
- return entityType;
- }
-
- /**
- * Sets the entity type for the entity this object is modeling.
- *
- * @param entityType the entity type
- */
- public void setEntityType(String entityType) {
- this.entityType = entityType;
- }
-
- @JsonAnySetter
- public void setDynamicProperty(String key, Object value) {
- dynamic_properties.put(key, value);
- }
-
- @JsonAnyGetter
- public Map<String, Object> getDynamicProperties() {
- return dynamic_properties;
- }
-
- /**
- * Returns the properties of the ActivityObject as a string.
- *
- * @return the object properties
- */
- @Override
- public String toString() {
- return "ActivityObject [attachments="
- + Arrays.toString(attachments) + ", author=" + author
- + ", content=" + content + ", displayName=" + displayName
- + ", downstreamDuplicates="
- + Arrays.toString(downstreamDuplicates) + ", id=" + id
- + ", image=" + image + ", objectType=" + objectType
- + ", published=" + published + ", summary=" + summary
- + ", updated=" + updated + ", upstreamDuplicates="
- + upstreamDuplicates + ", url=" + url + ", uuid=" + uuid
- + ", entityType=" + entityType + ", dynamic_properties="
- + dynamic_properties + "]";
- }
-
- }
-
- /**
- * Models the feed from an activity stream as a collection
- * of individual Activity objects.
- */
- //@XmlRootElement
- static public class ActivityCollection {
-
- int totalItems;
-
- ActivityObject[] items;
-
- String url;
-
- protected Map<String, Object> dynamic_properties = new TreeMap<String, Object>(
- String.CASE_INSENSITIVE_ORDER);
-
- /**
- * Default constructor.
- */
- public ActivityCollection() {
- }
-
- /**
- * Gets a count of the number of activities
- *
- * @return the activity count
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public int getTotalItems() {
- return totalItems;
- }
-
- /**
- * @y.exclude
- */
- public void setTotalItems(int totalItems) {
- this.totalItems = totalItems;
- }
-
- /**
- * Gets an array of the activities.
- *
- * @return an array of ActivityObject objects
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public ActivityObject[] getItems() {
- return items;
- }
-
- /**
- * @y.exclude
- */
- public void setItems(ActivityObject[] items) {
- this.items = items;
- }
-
- /**
- * Gets the url for the activity feed.
- *
- * @return the URL
- */
- @JsonSerialize(include = Inclusion.NON_NULL)
- public String getUrl() {
- return url;
- }
-
- /**
- * @y.exclude
- */
- public void setUrl(String url) {
- this.url = url;
- }
-
- @JsonAnySetter
- public void setDynamicProperty(String key, Object value) {
- dynamic_properties.put(key, value);
- }
-
- @JsonAnyGetter
- public Map<String, Object> getDynamicProperties() {
- return dynamic_properties;
- }
-
- /**
- * Returns the properties of the ActivityCollection as a string.
- *
- * @return the object properties
- */
- @Override
- public String toString() {
- return "ActivityCollection [totalItems=" + totalItems + ", items="
- + Arrays.toString(items) + ", url=" + url
- + ", dynamic_properties=" + dynamic_properties + "]";
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7e0ffbc0/sdks/android/src/main/java/org/apache/usergrid/android/sdk/entities/Collection.java
----------------------------------------------------------------------
diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/entities/Collection.java b/sdks/android/src/main/java/org/apache/usergrid/android/sdk/entities/Collection.java
deleted file mode 100755
index 67e7700..0000000
--- a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/entities/Collection.java
+++ /dev/null
@@ -1,338 +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.sdk.entities;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import org.apache.usergrid.android.sdk.UGClient;
-import org.apache.usergrid.android.sdk.UGClient.Query;
-import org.apache.usergrid.android.sdk.response.ApiResponse;
-
-/**
- * Models a collection of entities as a local object. Collections
- * are the primary way that entities are organized in Usergrid.
- *
- * @see <a href="http://apigee.com/docs/app-services/content/collections">Collections documentation</a>
- */
-public class Collection
-{
- private UGClient client;
- private String type;
- private Map<String,Object> qs;
-
- private ArrayList<Entity> list;
- private int iterator;
- private ArrayList<String> previous;
- private String next;
- private String cursor;
-
- /**
- * Default constructor for a Collection object.
- *
- * @param UGClient an instance of the UGClient class
- * @param type the entity 'type' associated with the colleciton
- * @param qs optional Map object of query parameters to apply to the collection retrieval
- */
- public Collection(UGClient client, String type, Map<String,Object> qs) {
- this.client = client;
- this.type = type;
-
- if( qs == null )
- {
- this.qs = new HashMap<String,Object>();
- }
- else
- {
- this.qs = qs;
- }
-
- this.list = new ArrayList<Entity>();
- this.iterator = -1;
-
- this.previous = new ArrayList<String>();
- this.next = null;
- this.cursor = null;
-
- this.fetch();
- }
-
- /**
- * Gets the entity 'type' associated with the collection.
- *
- * @return the collection type
- */
- public String getType(){
- return this.type;
- }
-
- /**
- * Sets the entity 'type' associated with the collection.
- *
- * @param type the collection type
- */
- public void setType(String type){
- this.type = type;
- }
-
- /**
- * Retrieves the current state of the collection from the server, and populates
- * an the Collection object with the returned set of entities. Executes synchronously.
- *
- * @return an ApiResponse object
- */
- public ApiResponse fetch() {
- if (this.cursor != null) {
- this.qs.put("cursor", this.cursor);
- }
-
- Query query = this.client.queryEntitiesRequest("GET", this.qs, null,
- this.client.getOrganizationId(), this.client.getApplicationId(), this.type);
- ApiResponse response = query.getResponse();
- if (response.getError() != null) {
- this.client.writeLog("Error getting collection.");
- } else {
- String theCursor = response.getCursor();
- int count = response.getEntityCount();
-
- UUID nextUUID = response.getNext();
- if( nextUUID != null ) {
- this.next = nextUUID.toString();
- } else {
- this.next = null;
- }
- this.cursor = theCursor;
-
- this.saveCursor(theCursor);
- if ( count > 0 ) {
- this.resetEntityPointer();
- this.list = new ArrayList<Entity>();
- List<Entity> retrievedEntities = response.getEntities();
-
- for ( Entity retrievedEntity : retrievedEntities ) {
- if( retrievedEntity.getUuid() != null ) {
- retrievedEntity.setType(this.type);
- this.list.add(retrievedEntity);
- }
- }
- }
- }
-
- return response;
- }
-
- /**
- * Adds an entity to the Collection object.
- *
- * @param entityData a Map object of entity properties to be saved in the entity
- * @return an Entity object that represents the newly added entity. Must include
- * a 'type' property. Executes synchronously.
- */
- public Entity addEntity(Map<String,Object> entityData) {
- Entity entity = null;
- ApiResponse response = this.client.createEntity(entityData);
- if( (response != null) && (response.getError() == null) && (response.getEntityCount() > 0) ) {
- entity = response.getFirstEntity();
- if (entity != null) {
- this.list.add(entity);
- }
- }
- return entity;
- }
-
- /**
- * Deletes the provided entity on the server, then updates the
- * Collection object by calling fetch(). Executes synchronously.
- *
- * @param entity an Entity object that contains a 'type' and 'uuid' property
- */
- public ApiResponse destroyEntity(Entity entity) {
- ApiResponse response = entity.destroy();
- if (response.getError() != null) {
- this.client.writeLog("Could not destroy entity.");
- } else {
- response = this.fetch();
- }
-
- return response;
- }
-
- /**
- * Retrieves an entity from the server.
- *
- * @param uuid the UUID of the entity to retrieve
- * @return an ApiResponse object
- */
- public ApiResponse getEntityByUuid(UUID uuid) {
- Entity entity = new Entity(this.client);
- entity.setType(this.type);
- entity.setUuid(uuid);
- return entity.fetch();
- }
-
- /**
- * Gets the first entity in the Collection object.
- *
- * @return an Entity object
- */
- public Entity getFirstEntity() {
- return ((this.list.size() > 0) ? this.list.get(0) : null);
- }
-
- /**
- * Gets the last entity in the Collection object.
- *
- * @return an Entity object
- */
- public Entity getLastEntity() {
- return ((this.list.size() > 0) ? this.list.get(this.list.size()-1) : null);
- }
-
- /**
- * Checks if there is another entity in the Collection after the current pointer position.
- *
- * @return Boolean true/false
- */
- public boolean hasNextEntity() {
- int next = this.iterator + 1;
- return ((next >= 0) && (next < this.list.size()));
- }
-
- /**
- * Checks if there is an entity in the Collection before the current pointer position.
- *
- * @return Boolean true/false
- */
- public boolean hasPrevEntity() {
- int prev = this.iterator - 1;
- return ((prev >= 0) && (prev < this.list.size()));
- }
-
- /**
- * Checks if there is an entity in the Collection after the current
- * pointer position, and returns it.
- *
- * @return an Entity object
- */
- public Entity getNextEntity() {
- if (this.hasNextEntity()) {
- this.iterator++;
- return this.list.get(this.iterator);
- }
- return null;
- }
-
- /**
- * Checks if there is an entity in the Collection before the current
- * pointer position, and returns it.
- *
- * @return an Entity object
- */
- public Entity getPrevEntity() {
- if (this.hasPrevEntity()) {
- this.iterator--;
- return this.list.get(this.iterator);
- }
- return null;
- }
-
- /**
- * Resets the pointer to the start of the Collection.
- */
- public void resetEntityPointer() {
- this.iterator = -1;
- }
-
- /**
- * Saves a pagination cursor.
- */
- public void saveCursor(String cursor) {
- this.next = cursor;
- }
-
- /**
- * Clears the currently saved pagination cursor from the Collection.
- */
- public void resetPaging() {
- this.previous.clear();
- this.next = null;
- this.cursor = null;
- }
-
- /**
- * Checks if a pagination cursor for the next result set is
- * present in the Collection.
- *
- * @return Boolean true/false
- */
- public boolean hasNextPage() {
- return this.next != null;
- }
-
- /**
- * Checks if a pagination cursor for the previous result set is
- * present in the Collection
- *
- * @return Boolean true/false
- */
- public boolean hasPrevPage() {
- return !this.previous.isEmpty();
- }
-
- /**
- * Checks if a pagination cursor for the next result set is
- * present in the Collection, then fetches it.
- *
- * @return an ApiResponse object if a cursor is present, otherwise null
- */
- public ApiResponse getNextPage() {
- if (this.hasNextPage()) {
- this.previous.add(this.cursor);
- this.cursor = this.next;
- this.list.clear();
- return this.fetch();
- }
-
- return null;
- }
-
- /**
- * Checks if a pagination cursor for the previous result set is
- * present in the Collection, then fetches it.
- *
- * @return an ApiResponse object if a cursor is present, otherwise null
- */
- public ApiResponse getPrevPage() {
- if (this.hasPrevPage()) {
- this.next = null;
- int indexOfLastObject = this.previous.size() - 1;
- this.cursor = this.previous.get(indexOfLastObject);
- this.previous.remove(indexOfLastObject);
- this.list.clear();
- return this.fetch();
- }
-
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7e0ffbc0/sdks/android/src/main/java/org/apache/usergrid/android/sdk/entities/Device.java
----------------------------------------------------------------------
diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/entities/Device.java b/sdks/android/src/main/java/org/apache/usergrid/android/sdk/entities/Device.java
deleted file mode 100755
index f26616a..0000000
--- a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/entities/Device.java
+++ /dev/null
@@ -1,122 +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.sdk.entities;
-
-import static org.apache.usergrid.android.sdk.utils.JsonUtils.setStringProperty;
-import static com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion.NON_NULL;
-
-import java.util.List;
-
-import org.apache.usergrid.android.sdk.UGClient;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
-/**
- * Models a 'device' entity as a local object.
- *
- */
-public class Device extends Entity {
-
- public final static String ENTITY_TYPE = "device";
-
- public final static String PROPERTY_NAME = "name";
-
- /**
- * Checks if the provided type equals 'device'.
- *
- * @return Boolean true/false
- */
- public static boolean isSameType(String type) {
- return type.equals(ENTITY_TYPE);
- }
-
- /**
- * Default constructor for the Device object. Sets 'type'
- * property to 'device'.
- */
- public Device() {
- setType(ENTITY_TYPE);
- }
-
- /**
- * Constructs the Device object with a UGClient. Sets 'type'
- * property to 'device'.
- */
- public Device(UGClient client) {
- super(client);
- setType(ENTITY_TYPE);
- }
-
- /**
- * Constructs a Device object from an Entity object. If the Entity
- * has a 'type' property with a value other than 'device', the value
- * will be overwritten.
- */
- public Device(Entity entity) {
- super(entity.getUGClient());
- properties = entity.properties;
- setType(ENTITY_TYPE);
- }
-
- /**
- * Returns the type of the Device object. Should always be 'device'.
- *
- * @return the String 'device'
- */
- @Override
- @JsonIgnore
- public String getNativeType() {
- return ENTITY_TYPE;
- }
-
- /**
- * Gets the current set of property names in the Device and adds
- * the 'name' property.
- *
- * @return a List object of all properties in the Device
- */
- @Override
- @JsonIgnore
- public List<String> getPropertyNames() {
- List<String> properties = super.getPropertyNames();
- properties.add(PROPERTY_NAME);
- return properties;
- }
-
- /**
- * Gets the value of the 'name' property of the Device.
- *
- * @return the value of the 'name' property
- */
- @JsonSerialize(include = NON_NULL)
- public String getName() {
- return getStringProperty(PROPERTY_NAME);
- }
-
- /**
- * Sets the value of the 'name' property of the Device.
- *
- * @param name the value of the 'name' property
- */
- public void setName(String name) {
- setStringProperty(properties, PROPERTY_NAME, name);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7e0ffbc0/sdks/android/src/main/java/org/apache/usergrid/android/sdk/entities/Entity.java
----------------------------------------------------------------------
diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/entities/Entity.java b/sdks/android/src/main/java/org/apache/usergrid/android/sdk/entities/Entity.java
deleted file mode 100755
index 6dc5f13..0000000
--- a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/entities/Entity.java
+++ /dev/null
@@ -1,552 +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.sdk.entities;
-
-import static org.apache.usergrid.android.sdk.utils.JsonUtils.getUUIDProperty;
-import static org.apache.usergrid.android.sdk.utils.JsonUtils.setBooleanProperty;
-import static org.apache.usergrid.android.sdk.utils.JsonUtils.setFloatProperty;
-import static org.apache.usergrid.android.sdk.utils.JsonUtils.setLongProperty;
-import static org.apache.usergrid.android.sdk.utils.JsonUtils.setStringProperty;
-import static org.apache.usergrid.android.sdk.utils.JsonUtils.setUUIDProperty;
-import static org.apache.usergrid.android.sdk.utils.JsonUtils.toJsonString;
-import static org.apache.usergrid.android.sdk.utils.MapUtils.newMapWithoutKeys;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-
-import org.apache.usergrid.android.sdk.UGClient;
-import org.apache.usergrid.android.sdk.UGClient.Query;
-import org.apache.usergrid.android.sdk.response.ApiResponse;
-import com.fasterxml.jackson.annotation.JsonAnyGetter;
-import com.fasterxml.jackson.annotation.JsonAnySetter;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.databind.JsonNode;
-
-/**
- * Models an entity of any type as a local object. Type-specific
- * classes are extended from this class.
- *
- * @see <a href="http://apigee.com/docs/app-services/content/app-services-data-model-1">Usergrid data model documentation</a>
- */
-public class Entity {
-
- public final static String PROPERTY_UUID = "uuid";
- public final static String PROPERTY_TYPE = "type";
- public final static String PROPERTY_NAME = "name";
- public final static String PROPERTY_METADATA = "metadata";
- public final static String PROPERTY_CREATED = "created";
- public final static String PROPERTY_MODIFIED = "modified";
- public final static String PROPERTY_ACTIVATED = "activated";
-
-
- protected Map<String, JsonNode> properties = new HashMap<String, JsonNode>();
- private UGClient client;
-
- public static Map<String, Class<? extends Entity>> CLASS_FOR_ENTITY_TYPE = new HashMap<String, Class<? extends Entity>>();
- static {
- CLASS_FOR_ENTITY_TYPE.put(User.ENTITY_TYPE, User.class);
- }
-
- /**
- * Default constructor for instantiating an Entity object.
- */
- public Entity() {
- }
-
- /**
- * Constructor for instantiating an Entity with a UGClient.
- * @param UGClient a UGClient object
- */
- public Entity(UGClient client) {
- this.client = client;
- }
-
- /**
- * Constructor for instantiating an Entity with a UGClient
- * and entity type. Normally this is the constructor that should
- * be used to model an entity locally.
- * @param UGClient a UGClient object
- * @param type the 'type' property of the entity
- */
- public Entity(UGClient client, String type) {
- this.client = client;
- setType(type);
- }
-
- /**
- * Gets the UGClient currently saved in the Entity object.
- * @return the UGClient instance
- */
- public UGClient getUGClient() {
- return client;
- }
-
- /**
- * Sets the UGClient in the Entity object.
- * @param UGClient the UGClient instance
- */
- public void setUGClient(UGClient client) {
- this.client = client;
- }
-
- /**
- * Gets the 'type' of the Entity object.
- * @return the 'type' of the entity
- */
- @JsonIgnore
- public String getNativeType() {
- return getType();
- }
-
- /**
- * Adds the type and UUID properties to the Entity object, then
- * returns all object properties.
- * @return a List object with the entity UUID and type
- */
- @JsonIgnore
- public List<String> getPropertyNames() {
- List<String> properties = new ArrayList<String>();
- properties.add(PROPERTY_TYPE);
- properties.add(PROPERTY_UUID);
- return properties;
- }
-
- /**
- * Gets the String value of the specified Entity property.
- * @param name the name of the property
- * @return the property value. Returns null if the property has no value
- */
- public String getStringProperty(String name) {
- JsonNode val = this.properties.get(name);
- return val != null ? val.textValue() : null;
- }
-
- /**
- * Gets the boolean value of the specified Entity property.
- * @param name the name of the property
- * @return the property value
- */
- public boolean getBoolProperty(String name) {
- return this.properties.get(name).booleanValue();
- }
-
- /**
- * Gets the Int value of the specified Entity property.
- * @param name the name of the property
- * @return the property value
- */
- public int getIntProperty(String name) {
- return this.properties.get(name).intValue();
- }
-
- /**
- * Gets the Double value of the specified Entity property.
- * @param name the name of the property
- * @return the property value
- */
- public double getDoubleProperty(String name) {
- return this.properties.get(name).doubleValue();
- }
-
- /**
- * Gets the long value of the specified Entity property.
- * @param name the name of the property
- * @return the property value
- */
- public long getLongProperty(String name) {
- return this.properties.get(name).longValue();
- }
-
- /**
- * Gets the 'type' property of the Entity object.
- * @return the Entity type
- */
- public String getType() {
- return getStringProperty(PROPERTY_TYPE);
- }
-
- /**
- * Sets the 'type' property of the Entity object.
- * @param type the entity type
- */
- public void setType(String type) {
- setStringProperty(properties, PROPERTY_TYPE, type);
- }
-
- /**
- * Gets the 'uuid' property of the Entity object.
- * @return the Entity UUID
- */
- public UUID getUuid() {
- return getUUIDProperty(properties, PROPERTY_UUID);
- }
-
- /**
- * Sets the 'uuid' property of the Entity object.
- * @param uuid the entity UUID
- */
- public void setUuid(UUID uuid) {
- setUUIDProperty(properties, PROPERTY_UUID, uuid);
- }
-
- /**
- * Returns a HashMap of the Entity properties without keys.
- *
- * @return a HashMap object with no keys and the value of the Entity properties
- */
- @JsonAnyGetter
- public Map<String, JsonNode> getProperties() {
- return newMapWithoutKeys(properties, getPropertyNames());
- }
-
- /**
- * Adds a property to the Entity object.
- *
- * @param name the name of the property to be set
- * @param value the value of the property as a JsonNode object.
- * If the value is null, the property will be removed from the object.
- * @see <a href="http://jackson.codehaus.org/1.0.1/javadoc/org/codehaus/jackson/JsonNode.html">JsonNode</a>
- */
- @JsonAnySetter
- public void setProperty(String name, JsonNode value) {
- if (value == null) {
- properties.remove(name);
- } else {
- properties.put(name, value);
- }
- }
-
- /**
- * Removes all properties from the Entity object, then adds multiple properties.
- *
- * @param newProperties a Map object that contains the
- * property names as keys and their values as values.
- * Property values must be JsonNode objects. If the value
- * is null, the property will be removed from the object.
- * @see <a href="http://jackson.codehaus.org/1.0.1/javadoc/org/codehaus/jackson/JsonNode.html">JsonNode</a>
- */
- public void setProperties(Map<String,JsonNode> newProperties) {
- properties.clear();
- Set<String> keySet = newProperties.keySet();
- Iterator<String> keySetIter = keySet.iterator();
-
- while( keySetIter.hasNext() ) {
- String key = keySetIter.next();
- setProperty(key, newProperties.get(key));
- }
- }
-
- /**
- * Adds a property to the Entity object with a String value.
- *
- * @param name the name of the property to be set
- * @param value the String value of the property
- */
- public void setProperty(String name, String value) {
- setStringProperty(properties, name, value);
- }
-
- /**
- * Adds a property to the Entity object with a boolean value.
- *
- * @param name the name of the property to be set
- * @param value the boolean value of the property
- */
- public void setProperty(String name, boolean value) {
- setBooleanProperty(properties, name, value);
- }
-
- /**
- * Adds a property to the Entity object with a long value.
- *
- * @param name the name of the property to be set
- * @param value the long value of the property
- */
- public void setProperty(String name, long value) {
- setLongProperty(properties, name, value);
- }
-
- /**
- * Adds a property to the Entity object with a int value.
- *
- * @param name the name of the property to be set
- * @param value the int value of the property
- */
- public void setProperty(String name, int value) {
- setProperty(name, (long) value);
- }
-
- /**
- * Adds a property to the Entity object with a float value.
- *
- * @param name the name of the property to be set
- * @param value the float value of the property
- */
- public void setProperty(String name, float value) {
- setFloatProperty(properties, name, value);
- }
-
- /**
- * Returns the Entity object as a JSON-formatted string
- */
- @Override
- public String toString() {
- return toJsonString(this);
- }
-
- /**
- * @y.exclude
- */
- public <T extends Entity> T toType(Class<T> t) {
- return toType(this, t);
- }
-
- /**
- * @y.exclude
- */
- public static <T extends Entity> T toType(Entity entity, Class<T> t) {
- if (entity == null) {
- return null;
- }
- T newEntity = null;
- if (entity.getClass().isAssignableFrom(t)) {
- try {
- newEntity = (t.newInstance());
- if ((newEntity.getNativeType() != null)
- && newEntity.getNativeType().equals(entity.getType())) {
- newEntity.properties = entity.properties;
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- return newEntity;
- }
-
- /**
- * @y.exclude
- */
- public static <T extends Entity> List<T> toType(List<Entity> entities,
- Class<T> t) {
- List<T> l = new ArrayList<T>(entities != null ? entities.size() : 0);
- if (entities != null) {
- for (Entity entity : entities) {
- T newEntity = entity.toType(t);
- if (newEntity != null) {
- l.add(newEntity);
- }
- }
- }
- return l;
- }
-
- /**
- * Fetches the current state of the entity from the server and saves
- * it in the Entity object. Runs synchronously.
- *
- * @return an ApiResponse object
- */
- public ApiResponse fetch() {
- ApiResponse response = new ApiResponse();
- String type = this.getType();
- UUID uuid = this.getUuid(); // may be NULL
- String entityId = null;
- if ( uuid != null ) {
- entityId = uuid.toString();
- } else {
- if (User.isSameType(type)) {
- String username = this.getStringProperty(User.PROPERTY_USERNAME);
- if ((username != null) && (username.length() > 0)) {
- entityId = username;
- } else {
- String error = "no_username_specified";
- this.client.writeLog(error);
- response.setError(error);
- //response.setErrorCode(error);
- return response;
- }
- } else {
- String name = this.getStringProperty(PROPERTY_NAME);
- if ((name != null) && (name.length() > 0)) {
- entityId = name;
- } else {
- String error = "no_name_specified";
- this.client.writeLog(error);
- response.setError(error);
- //response.setErrorCode(error);
- return response;
- }
- }
- }
-
- Query q = this.client.queryEntitiesRequest("GET", null, null,
- this.client.getOrganizationId(), this.client.getApplicationId(), type, entityId);
- response = q.getResponse();
- if (response.getError() != null) {
- this.client.writeLog("Could not get entity.");
- } else {
- if ( response.getUser() != null ) {
- this.addProperties(response.getUser().getProperties());
- } else if ( response.getEntityCount() > 0 ) {
- Entity entity = response.getFirstEntity();
- this.setProperties(entity.getProperties());
- }
- }
-
- return response;
- }
-
- /**
- * Saves the Entity object as an entity on the server. Any
- * conflicting properties on the server will be overwritten. Runs synchronously.
- *
- * @return an ApiResponse object
- */
- public ApiResponse save() {
- ApiResponse response = null;
- UUID uuid = this.getUuid();
- boolean entityAlreadyExists = false;
-
- if (client.isUuidValid(uuid)) {
- entityAlreadyExists = true;
- }
-
- // copy over all properties except some specific ones
- Map<String,Object> data = new HashMap<String,Object>();
- Set<String> keySet = this.properties.keySet();
- Iterator<String> keySetIter = keySet.iterator();
-
- while(keySetIter.hasNext()) {
- String key = keySetIter.next();
- if (!key.equals(PROPERTY_METADATA) &&
- !key.equals(PROPERTY_CREATED) &&
- !key.equals(PROPERTY_MODIFIED) &&
- !key.equals(PROPERTY_ACTIVATED) &&
- !key.equals(PROPERTY_UUID)) {
- data.put(key, this.properties.get(key));
- }
- }
-
- if (entityAlreadyExists) {
- // update it
- response = this.client.updateEntity(uuid.toString(), data);
- } else {
- // create it
- response = this.client.createEntity(data);
- }
-
- if ( response.getError() != null ) {
- this.client.writeLog("Could not save entity.");
- } else {
- if (response.getEntityCount() > 0) {
- Entity entity = response.getFirstEntity();
- this.setProperties(entity.getProperties());
- }
- }
-
- return response;
- }
-
- /**
- * Deletes the entity on the server.
- *
- * @return an ApiResponse object
- */
- public ApiResponse destroy() {
- ApiResponse response = new ApiResponse();
- String type = getType();
- String uuidAsString = null;
- UUID uuid = getUuid();
- if ( uuid != null ) {
- uuidAsString = uuid.toString();
- } else {
- String error = "Error trying to delete object: No UUID specified.";
- this.client.writeLog(error);
- response.setError(error);
- //response.setErrorCode(error);
- return response;
- }
-
- response = this.client.removeEntity(type, uuidAsString);
-
- if( (response != null) && (response.getError() != null) ) {
- this.client.writeLog("Entity could not be deleted.");
- } else {
- this.properties.clear();
- }
-
- return response;
- }
-
- /**
- * Adds multiple properties to the Entity object. Pre-existing properties will
- * be preserved, unless there is a conflict, then the pre-existing property
- * will be overwritten.
- *
- * @param properties a Map object that contains the
- * property names as keys and their values as values.
- * Property values must be JsonNode objects. If the value
- * is null, the property will be removed from the object.
- * @see <a href="http://jackson.codehaus.org/1.0.1/javadoc/org/codehaus/jackson/JsonNode.html">JsonNode</a>
- */
- public void addProperties(Map<String, JsonNode> properties) {
- Set<String> keySet = properties.keySet();
- Iterator<String> keySetIter = keySet.iterator();
-
- while( keySetIter.hasNext() ) {
- String key = keySetIter.next();
- setProperty(key, properties.get(key));
- }
- }
-
- /**
- * Creates a connection between two entities.
- *
- * @param connectType the type of connection
- * @param targetEntity the UUID of the entity to connect to
- * @return an ApiResponse object
- */
- public ApiResponse connect(String connectType, Entity targetEntity) {
- return this.client.connectEntities(this.getType(),
- this.getUuid().toString(),
- connectType,
- targetEntity.getUuid().toString());
- }
-
- /**
- * Destroys a connection between two entities.
- *
- * @param connectType the type of connection
- * @param targetEntity the UUID of the entity to disconnect from
- * @return an ApiResponse object
- */
- public ApiResponse disconnect(String connectType, Entity targetEntity) {
- return this.client.disconnectEntities(this.getType(),
- this.getUuid().toString(),
- connectType,
- targetEntity.getUuid().toString());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7e0ffbc0/sdks/android/src/main/java/org/apache/usergrid/android/sdk/entities/Group.java
----------------------------------------------------------------------
diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/entities/Group.java b/sdks/android/src/main/java/org/apache/usergrid/android/sdk/entities/Group.java
deleted file mode 100755
index f7c7b80..0000000
--- a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/entities/Group.java
+++ /dev/null
@@ -1,151 +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.sdk.entities;
-
-import static org.apache.usergrid.android.sdk.utils.JsonUtils.setStringProperty;
-import static com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion.NON_NULL;
-
-import java.util.List;
-
-import org.apache.usergrid.android.sdk.UGClient;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
-/**
- * Models the 'group' entity as a local object. The group entity is
- * primarily used as a way of grouping users, but can be used to group
- * any entity.
- *
- * @see <a href="http://apigee.com/docs/app-services/content/group">Group entity documentation</a>
- */
-public class Group extends Entity {
-
- public final static String ENTITY_TYPE = "group";
-
- public final static String PROPERTY_PATH = "path";
- public final static String PROPERTY_TITLE = "title";
-
- /**
- * Checks if the provided 'type' equals 'group'.
- *
- * @param type the type to compare
- * @return Boolean true/false
- */
- public static boolean isSameType(String type) {
- return type.equals(ENTITY_TYPE);
- }
-
- /**
- * Default constructor for the Group object. Sets the 'type'
- * property to 'group'.
- */
- public Group() {
- setType(ENTITY_TYPE);
- }
-
- /**
- * Constructs the Group object with a UGClient. Sets the 'type'
- * property to 'group'.
- *
- * @param UGClient an instance of UGClient
- */
- public Group(UGClient client) {
- super(client);
- setType(ENTITY_TYPE);
- }
-
- /**
- * Constructs the Group object from an Entity object. If the 'type'
- * property of the Entity is not 'group' it will be overwritten.
- *
- * @param entity an Entity object
- */
- public Group(Entity entity) {
- super(entity.getUGClient());
- properties = entity.properties;
- setType(ENTITY_TYPE);
- }
-
- /**
- * Returns the valye of the 'type' property of the Group object.
- * Should always be 'group'.
- *
- * @return the String 'group'
- */
- @Override
- @JsonIgnore
- public String getNativeType() {
- return ENTITY_TYPE;
- }
-
- /**
- * Gets all the current property names in the Group object and adds
- * the 'path' and 'title' properties.
- *
- * @return a List object that contains the properties list
- */
- @Override
- @JsonIgnore
- public List<String> getPropertyNames() {
- List<String> properties = super.getPropertyNames();
- properties.add(PROPERTY_PATH);
- properties.add(PROPERTY_TITLE);
- return properties;
- }
-
- /**
- * Gets the value of the 'path' property of the Group object.
- *
- * @return the value of the 'path' property
- */
- @JsonSerialize(include = NON_NULL)
- public String getPath() {
- return getStringProperty(PROPERTY_PATH);
- }
-
- /**
- * Sets the value of the 'path' property of the Group object.
- *
- * @param path the value of the 'path' property
- */
- public void setPath(String path) {
- setStringProperty(properties, PROPERTY_PATH, path);
- }
-
- /**
- * Gets the value of the 'title' property of the Group object.
- *
- * @return the value of the 'title' property
- */
- @JsonSerialize(include = NON_NULL)
- public String getTitle() {
- return getStringProperty(PROPERTY_TITLE);
- }
-
- /**
- * Sets the value of the 'title' property of the Group object.
- *
- * @param title the value of the 'title' property
- */
- public void setTitle(String title) {
- setStringProperty(properties, PROPERTY_TITLE, title);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7e0ffbc0/sdks/android/src/main/java/org/apache/usergrid/android/sdk/entities/Message.java
----------------------------------------------------------------------
diff --git a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/entities/Message.java b/sdks/android/src/main/java/org/apache/usergrid/android/sdk/entities/Message.java
deleted file mode 100755
index e4786c9..0000000
--- a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/entities/Message.java
+++ /dev/null
@@ -1,159 +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.sdk.entities;
-
-import static org.apache.usergrid.android.sdk.utils.JsonUtils.getBooleanProperty;
-import static org.apache.usergrid.android.sdk.utils.JsonUtils.getUUIDProperty;
-import static org.apache.usergrid.android.sdk.utils.JsonUtils.setBooleanProperty;
-import static org.apache.usergrid.android.sdk.utils.JsonUtils.setLongProperty;
-import static org.apache.usergrid.android.sdk.utils.JsonUtils.setStringProperty;
-import static org.apache.usergrid.android.sdk.utils.JsonUtils.setUUIDProperty;
-import static com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion.NON_NULL;
-
-import java.util.List;
-import java.util.UUID;
-
-import org.apache.usergrid.android.sdk.UGClient;
-import org.apache.usergrid.android.sdk.utils.JsonUtils;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion;
-
-public class Message extends Entity {
-
- public static final String ENTITY_TYPE = "message";
-
- public static final String PROPERTY_CORRELATION_ID = "correlation_id";
- public static final String PROPERTY_DESTINATION = "destination";
- public static final String PROPERTY_REPLY_TO = "reply_to";
- public static final String PROPERTY_TIMESTAMP = "timestamp";
- public static final String PROPERTY_TYPE = "type";
- public static final String PROPERTY_CATEGORY = "category";
- public static final String PROPERTY_INDEXED = "indexed";
- public static final String PROPERTY_PERSISTENT = "persistent";
-
- public static boolean isSameType(String type) {
- return type.equals(ENTITY_TYPE);
- }
-
- public Message() {
- setType(ENTITY_TYPE);
- }
-
- public Message(UGClient client) {
- super(client);
- setType(ENTITY_TYPE);
- }
-
- public Message(Entity entity) {
- super(entity.getUGClient());
- properties = entity.properties;
- setType(ENTITY_TYPE);
- }
-
- @Override
- @JsonIgnore
- public String getNativeType() {
- return ENTITY_TYPE;
- }
-
- @Override
- @JsonIgnore
- public List<String> getPropertyNames() {
- List<String> properties = super.getPropertyNames();
- properties.add(PROPERTY_CORRELATION_ID);
- properties.add(PROPERTY_DESTINATION);
- properties.add(PROPERTY_REPLY_TO);
- properties.add(PROPERTY_TIMESTAMP);
- properties.add(PROPERTY_CATEGORY);
- properties.add(PROPERTY_INDEXED);
- properties.add(PROPERTY_PERSISTENT);
- return properties;
- }
-
- @JsonSerialize(include = NON_NULL)
- @JsonProperty(PROPERTY_CORRELATION_ID)
- public UUID getCorrelationId() {
- return getUUIDProperty(properties, PROPERTY_CORRELATION_ID);
- }
-
- @JsonProperty(PROPERTY_CORRELATION_ID)
- public void setCorrelationId(UUID uuid) {
- setUUIDProperty(properties, PROPERTY_CORRELATION_ID, uuid);
- }
-
- @JsonSerialize(include = NON_NULL)
- public String getDestination() {
- return getStringProperty(PROPERTY_DESTINATION);
- }
-
- public void setDestination(String destination) {
- setStringProperty(properties, PROPERTY_DESTINATION, destination);
- }
-
- @JsonSerialize(include = NON_NULL)
- @JsonProperty(PROPERTY_REPLY_TO)
- public String getReplyTo() {
- return getStringProperty(PROPERTY_DESTINATION);
- }
-
- @JsonProperty(PROPERTY_REPLY_TO)
- public void setReplyTo(String replyTo) {
- setStringProperty(properties, PROPERTY_DESTINATION, replyTo);
- }
-
- @JsonSerialize(include = Inclusion.NON_NULL)
- public Long getTimestamp() {
- return JsonUtils.getLongProperty(properties, PROPERTY_TIMESTAMP);
- }
-
- public void setTimestamp(Long timestamp) {
- setLongProperty(properties, PROPERTY_TIMESTAMP, timestamp);
- }
-
- @JsonSerialize(include = NON_NULL)
- public String getCategory() {
- return getStringProperty(PROPERTY_CATEGORY);
- }
-
- public void setCategory(String category) {
- setStringProperty(properties, PROPERTY_CATEGORY, category);
- }
-
- @JsonSerialize(include = NON_NULL)
- public Boolean isIndexed() {
- return getBooleanProperty(properties, PROPERTY_INDEXED);
- }
-
- public void setIndexed(Boolean indexed) {
- setBooleanProperty(properties, PROPERTY_INDEXED, indexed);
- }
-
- @JsonSerialize(include = NON_NULL)
- public Boolean isPersistent() {
- return getBooleanProperty(properties, PROPERTY_INDEXED);
- }
-
- public void setPersistent(Boolean persistent) {
- setBooleanProperty(properties, PROPERTY_INDEXED, persistent);
- }
-
-}
[07/12] usergrid git commit: Adding new Android SDK
Posted by mr...@apache.org.
Adding new Android SDK
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/b30b60b3
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/b30b60b3
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/b30b60b3
Branch: refs/heads/master
Commit: b30b60b32c298d78abfcbf42d7932b0ebdffb98d
Parents: 7e0ffbc
Author: Robert Walsh <rj...@gmail.com>
Authored: Mon Aug 8 15:37:35 2016 -0500
Committer: Robert Walsh <rj...@gmail.com>
Committed: Mon Aug 8 15:37:35 2016 -0500
----------------------------------------------------------------------
sdks/android/Samples/ActivityFeed/.gitignore | 8 +
.../ActivityFeed/activityfeed/.gitignore | 1 +
.../ActivityFeed/activityfeed/build.gradle | 27 ++
.../ActivityFeed/activityfeed/libs/gcm.jar | Bin 0 -> 13662 bytes
.../activityfeed/proguard-rules.pro | 17 +
.../usergrid/activityfeed/ApplicationTest.java | 13 +
.../activityfeed/src/main/AndroidManifest.xml | 53 +++
.../usergrid/activityfeed/ActivityEntity.java | 86 ++++
.../usergrid/activityfeed/GCMIntentService.java | 87 ++++
.../usergrid/activityfeed/UsergridManager.java | 259 ++++++++++
.../activities/CreateAccountActivity.java | 67 +++
.../activityfeed/activities/FeedActivity.java | 142 ++++++
.../activityfeed/activities/FollowActivity.java | 59 +++
.../activityfeed/activities/MainActivity.java | 87 ++++
.../callbacks/GetFeedMessagesCallback.java | 27 ++
.../callbacks/PostFeedMessageCallback.java | 25 +
.../activityfeed/helpers/ActionBarHelpers.java | 53 +++
.../helpers/AlertDialogHelpers.java | 61 +++
.../activityfeed/helpers/FeedAdapter.java | 153 ++++++
.../src/main/res/drawable/in_message_bg.9.png | Bin 0 -> 1160 bytes
.../src/main/res/drawable/out_message_bg.9.png | Bin 0 -> 1072 bytes
.../src/main/res/drawable/usergridguy.png | Bin 0 -> 6230 bytes
.../src/main/res/layout/action_bar_layout.xml | 29 ++
.../main/res/layout/activity_create_account.xml | 101 ++++
.../src/main/res/layout/activity_feed.xml | 46 ++
.../src/main/res/layout/activity_follow.xml | 44 ++
.../src/main/res/layout/activity_main.xml | 87 ++++
.../src/main/res/layout/message_layout.xml | 43 ++
.../main/res/layout/scrollable_alert_view.xml | 35 ++
.../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 3418 bytes
.../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 2206 bytes
.../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 4842 bytes
.../src/main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 7718 bytes
.../src/main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 10486 bytes
.../src/main/res/values-w820dp/dimens.xml | 6 +
.../activityfeed/src/main/res/values/colors.xml | 8 +
.../activityfeed/src/main/res/values/dimens.xml | 5 +
.../src/main/res/values/strings.xml | 3 +
.../activityfeed/src/main/res/values/styles.xml | 19 +
.../usergrid/activityfeed/ExampleUnitTest.java | 15 +
sdks/android/Samples/ActivityFeed/build.gradle | 23 +
.../Samples/ActivityFeed/gradle.properties | 18 +
.../gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 53636 bytes
.../gradle/wrapper/gradle-wrapper.properties | 6 +
sdks/android/Samples/ActivityFeed/gradlew | 160 +++++++
sdks/android/Samples/ActivityFeed/gradlew.bat | 90 ++++
.../Samples/ActivityFeed/settings.gradle | 2 +
sdks/android/Samples/Push/.gitignore | 8 +
sdks/android/Samples/Push/build.gradle | 22 +
sdks/android/Samples/Push/gradle.properties | 18 +
.../Push/gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 53636 bytes
.../gradle/wrapper/gradle-wrapper.properties | 6 +
sdks/android/Samples/Push/gradlew | 160 +++++++
sdks/android/Samples/Push/gradlew.bat | 90 ++++
sdks/android/Samples/Push/push/.gitignore | 1 +
sdks/android/Samples/Push/push/build.gradle | 27 ++
sdks/android/Samples/Push/push/libs/gcm.jar | Bin 0 -> 13662 bytes
.../Samples/Push/push/proguard-rules.pro | 17 +
.../apache/usergrid/push/ApplicationTest.java | 13 +
.../Push/push/src/main/AndroidManifest.xml | 51 ++
.../apache/usergrid/push/GCMIntentService.java | 85 ++++
.../org/apache/usergrid/push/MainActivity.java | 162 +++++++
.../apache/usergrid/push/SettingsActivity.java | 68 +++
.../Push/push/src/main/res/drawable/info.png | Bin 0 -> 44546 bytes
.../push/src/main/res/drawable/usergridguy.png | Bin 0 -> 6230 bytes
.../push/src/main/res/layout/activity_main.xml | 69 +++
.../src/main/res/layout/activity_settings.xml | 95 ++++
.../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 3418 bytes
.../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 2206 bytes
.../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 4842 bytes
.../src/main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 7718 bytes
.../src/main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 10486 bytes
.../push/src/main/res/values-w820dp/dimens.xml | 6 +
.../Push/push/src/main/res/values/colors.xml | 6 +
.../Push/push/src/main/res/values/dimens.xml | 5 +
.../Push/push/src/main/res/values/strings.xml | 3 +
.../Push/push/src/main/res/values/styles.xml | 11 +
.../apache/usergrid/push/ExampleUnitTest.java | 15 +
sdks/android/Samples/Push/settings.gradle | 2 +
sdks/android/UsergridAndroidSDK/.gitignore | 8 +
sdks/android/UsergridAndroidSDK/build.gradle | 70 +++
.../gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 53636 bytes
.../gradle/wrapper/gradle-wrapper.properties | 6 +
sdks/android/UsergridAndroidSDK/gradlew | 160 +++++++
sdks/android/UsergridAndroidSDK/gradlew.bat | 90 ++++
.../libs/usergrid-java-client-2.1.0.jar | Bin 0 -> 1991936 bytes
.../UsergridAndroidSDK/proguard-rules.pro | 17 +
.../usergrid/android/ApplicationTest.java | 75 +++
.../java/org/apache/usergrid/android/Book.java | 26 +
.../src/main/AndroidManifest.xml | 17 +
.../apache/usergrid/android/UsergridAsync.java | 474 +++++++++++++++++++
.../usergrid/android/UsergridEntityAsync.java | 110 +++++
.../usergrid/android/UsergridResponseAsync.java | 38 ++
.../usergrid/android/UsergridSharedDevice.java | 175 +++++++
.../usergrid/android/UsergridUserAsync.java | 125 +++++
.../UsergridCheckAvailabilityCallback.java | 21 +
.../callbacks/UsergridResponseCallback.java | 24 +
.../android/tasks/UsergridAsyncTask.java | 45 ++
.../src/main/res/values/strings.xml | 3 +
99 files changed, 4389 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/.gitignore
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/.gitignore b/sdks/android/Samples/ActivityFeed/.gitignore
new file mode 100644
index 0000000..c6cbe56
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/.gitignore
@@ -0,0 +1,8 @@
+*.iml
+.gradle
+/local.properties
+/.idea/workspace.xml
+/.idea/libraries
+.DS_Store
+/build
+/captures
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/.gitignore
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/.gitignore b/sdks/android/Samples/ActivityFeed/activityfeed/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/activityfeed/.gitignore
@@ -0,0 +1 @@
+/build
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/build.gradle
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/build.gradle b/sdks/android/Samples/ActivityFeed/activityfeed/build.gradle
new file mode 100644
index 0000000..91d4c7e
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/activityfeed/build.gradle
@@ -0,0 +1,27 @@
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 23
+ buildToolsVersion "22.0.1"
+
+ defaultConfig {
+ applicationId "org.apache.usergrid.activityfeed"
+ minSdkVersion 17
+ targetSdkVersion 23
+ versionCode 1
+ versionName "1.0"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+}
+
+dependencies {
+ compile fileTree(include: ['*.jar'], dir: 'libs')
+ testCompile 'junit:junit:4.12'
+ compile 'com.android.support:appcompat-v7:23.3.0'
+ compile project(':UsergridAndroidSDK')
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/libs/gcm.jar
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/libs/gcm.jar b/sdks/android/Samples/ActivityFeed/activityfeed/libs/gcm.jar
new file mode 100755
index 0000000..ac109a8
Binary files /dev/null and b/sdks/android/Samples/ActivityFeed/activityfeed/libs/gcm.jar differ
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/proguard-rules.pro
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/proguard-rules.pro b/sdks/android/Samples/ActivityFeed/activityfeed/proguard-rules.pro
new file mode 100644
index 0000000..73ed137
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/activityfeed/proguard-rules.pro
@@ -0,0 +1,17 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in /Users/ApigeeCorporation/Developer/android_sdk_files/sdk/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/androidTest/java/org/apache/usergrid/activityfeed/ApplicationTest.java
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/androidTest/java/org/apache/usergrid/activityfeed/ApplicationTest.java b/sdks/android/Samples/ActivityFeed/activityfeed/src/androidTest/java/org/apache/usergrid/activityfeed/ApplicationTest.java
new file mode 100644
index 0000000..b376e2f
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/activityfeed/src/androidTest/java/org/apache/usergrid/activityfeed/ApplicationTest.java
@@ -0,0 +1,13 @@
+package org.apache.usergrid.activityfeed;
+
+import android.app.Application;
+import android.test.ApplicationTestCase;
+
+/**
+ * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
+ */
+public class ApplicationTest extends ApplicationTestCase<Application> {
+ public ApplicationTest() {
+ super(Application.class);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/AndroidManifest.xml
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/AndroidManifest.xml b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..ec275c8
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/AndroidManifest.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="org.apache.usergrid.activityfeed">
+
+ <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
+ <uses-permission android:name="android.permission.GET_ACCOUNTS" />
+ <uses-permission android:name="android.permission.WAKE_LOCK" />
+
+ <permission
+ android:name="org.apache.usergrid.activityfeed.gcm.permission.C2D_MESSAGE"
+ android:protectionLevel="signature" />
+
+ <uses-permission android:name="org.apache.usergrid.activityfeed.gcm.permission.C2D_MESSAGE" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@mipmap/ic_launcher"
+ android:label="@string/app_name"
+ android:supportsRtl="true"
+ android:theme="@style/AppTheme">
+
+ <receiver
+ android:name="com.google.android.gcm.GCMBroadcastReceiver"
+ android:permission="com.google.android.c2dm.permission.SEND" >
+ <intent-filter>
+ <action android:name="com.google.android.c2dm.intent.RECEIVE" />
+ <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
+
+ <category android:name="org.apache.usergrid.activityfeed" />
+ </intent-filter>
+ </receiver>
+ <service android:name=".GCMIntentService" />
+
+ <activity
+ android:name=".activities.MainActivity"
+ android:label="">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity
+ android:name=".activities.CreateAccountActivity"
+ android:label=""> </activity>
+ <activity
+ android:name=".activities.FeedActivity"
+ android:windowSoftInputMode="stateHidden"
+ android:label=""> </activity>
+ <activity android:name=".activities.FollowActivity"> </activity>
+ </application>
+
+</manifest>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/ActivityEntity.java
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/ActivityEntity.java b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/ActivityEntity.java
new file mode 100644
index 0000000..4c19085
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/ActivityEntity.java
@@ -0,0 +1,86 @@
+/*
+ * 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.activityfeed;
+
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.JsonNode;
+
+import org.apache.usergrid.java.client.model.UsergridEntity;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.HashMap;
+
+@SuppressWarnings("unused")
+public class ActivityEntity extends UsergridEntity {
+
+ public static final String ACTIVITY_ENTITY_TYPE = "activity";
+
+ private String content;
+ private JsonNode actor;
+
+ @Nullable @JsonIgnore
+ public String getDisplayName() {
+ if( actor != null ) {
+ JsonNode displayName = actor.get("displayName");
+ if( displayName != null ) {
+ return displayName.asText();
+ }
+ }
+ return null;
+ }
+
+ @Nullable public String getContent() { return this.content; }
+ public void setContent(@NonNull String content) {
+ this.content = content;
+ }
+
+ @Nullable public JsonNode getActor() { return this.actor; }
+ public void setActor(@NonNull JsonNode actor) {
+ this.actor = actor;
+ }
+
+ public ActivityEntity() {
+ super(ACTIVITY_ENTITY_TYPE);
+ }
+
+ public ActivityEntity(@JsonProperty("type") @NotNull String type) {
+ super(type);
+ }
+
+ public ActivityEntity(@NonNull final String displayName, @NonNull final String email, @Nullable final String picture, @NonNull final String content) {
+ super(ACTIVITY_ENTITY_TYPE);
+ HashMap<String,Object> actorMap = new HashMap<>();
+ actorMap.put("displayName",displayName);
+ actorMap.put("email",email);
+ if( picture != null ) {
+ HashMap<String,Object> imageMap = new HashMap<>();
+ imageMap.put("url",picture);
+ imageMap.put("height",80);
+ imageMap.put("width",80);
+ actorMap.put("image",imageMap);
+ }
+ HashMap<String,Object> activityMap = new HashMap<>();
+ activityMap.put("verb","post");
+ activityMap.put("actor",actorMap);
+ activityMap.put("content",content);
+ this.putProperties(activityMap);
+ }
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/GCMIntentService.java
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/GCMIntentService.java b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/GCMIntentService.java
new file mode 100644
index 0000000..36cb9f1
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/GCMIntentService.java
@@ -0,0 +1,87 @@
+package org.apache.usergrid.activityfeed;
+
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.Intent;
+import android.support.v4.app.NotificationCompat;
+import android.util.Log;
+
+import com.google.android.gcm.GCMBaseIntentService;
+
+import org.apache.usergrid.activityfeed.activities.MainActivity;
+
+public class GCMIntentService extends GCMBaseIntentService {
+
+ public GCMIntentService() {
+ super(UsergridManager.GCM_SENDER_ID);
+ }
+
+ @Override
+ protected void onRegistered(Context context, String registrationId) {
+ Log.i(TAG, "Device registered: " + registrationId);
+ UsergridManager.registerPush(context,registrationId);
+ }
+
+ @Override
+ protected void onUnregistered(Context context, String registrationId) {
+ Log.i(TAG, "Device unregistered");
+ }
+
+ @Override
+ protected void onMessage(Context context, Intent intent) {
+ String message = intent.getExtras().getString("data");
+ Log.i(TAG, "Received message: " + message);
+ generateNotification(context, message);
+ }
+
+ @Override
+ protected void onDeletedMessages(Context context, int total) {
+ Log.i(TAG, "Received deleted messages notification");
+ String message = "GCM server deleted " + total +" pending messages!";
+ generateNotification(context, message);
+ }
+
+ @Override
+ public void onError(Context context, String errorId) {
+ Log.i(TAG, "Received error: " + errorId);
+ }
+
+ @Override
+ protected boolean onRecoverableError(Context context, String errorId) {
+ Log.i(TAG, "Received recoverable error: " + errorId);
+ return super.onRecoverableError(context, errorId);
+ }
+
+ /**
+ * Issues a Notification to inform the user that server has sent a message.
+ */
+ private static void generateNotification(Context context, String message) {
+ long when = System.currentTimeMillis();
+ NotificationManager notificationManager = (NotificationManager)
+ context.getSystemService(Context.NOTIFICATION_SERVICE);
+
+ Intent notificationIntent = new Intent(context, MainActivity.class);
+ // set intent so it does not start a new activity
+ notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
+ PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
+
+ Notification notification = new NotificationCompat.Builder(context)
+ .setContentText(message)
+ .setContentTitle(context.getString(R.string.app_name))
+ .setWhen(when)
+ .setSmallIcon(R.drawable.usergridguy)
+ .setContentIntent(intent)
+ .build();
+
+ notification.flags |= Notification.FLAG_AUTO_CANCEL;
+
+ // Play default notification sound
+ notification.defaults |= Notification.DEFAULT_SOUND;
+
+ // Vibrate if vibrate is enabled
+ notification.defaults |= Notification.DEFAULT_VIBRATE;
+ notificationManager.notify(0, notification);
+ }
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/UsergridManager.java
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/UsergridManager.java b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/UsergridManager.java
new file mode 100644
index 0000000..b201631
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/UsergridManager.java
@@ -0,0 +1,259 @@
+/*
+ * 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.activityfeed;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.support.annotation.NonNull;
+import android.util.Log;
+
+import com.google.android.gcm.GCMRegistrar;
+
+import org.apache.usergrid.activityfeed.activities.FeedActivity;
+import org.apache.usergrid.activityfeed.callbacks.GetFeedMessagesCallback;
+import org.apache.usergrid.activityfeed.callbacks.PostFeedMessageCallback;
+import org.apache.usergrid.activityfeed.helpers.AlertDialogHelpers;
+import org.apache.usergrid.android.UsergridAsync;
+import org.apache.usergrid.android.UsergridSharedDevice;
+import org.apache.usergrid.android.UsergridUserAsync;
+import org.apache.usergrid.android.callbacks.UsergridResponseCallback;
+import org.apache.usergrid.java.client.Usergrid;
+import org.apache.usergrid.java.client.UsergridEnums;
+import org.apache.usergrid.java.client.UsergridRequest;
+import org.apache.usergrid.java.client.auth.UsergridUserAuth;
+import org.apache.usergrid.java.client.model.UsergridEntity;
+import org.apache.usergrid.java.client.model.UsergridUser;
+import org.apache.usergrid.java.client.query.UsergridQuery;
+import org.apache.usergrid.java.client.response.UsergridResponse;
+import org.apache.usergrid.java.client.response.UsergridResponseError;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+
+public final class UsergridManager {
+
+ private static final String ORG_ID = "rwalsh";
+ private static final String APP_ID = "sandbox";
+ private static final String BASE_URL = "https://api.usergrid.com";
+ private static final String ANDROID_NOTIFIER_ID = "androidPushNotifier";
+
+ public static String GCM_SENDER_ID = "186455511595";
+ public static String GCM_REGISTRATION_ID = "";
+
+ private UsergridManager() {}
+
+ public static void initializeSharedInstance(@NonNull final Context context) {
+ Usergrid.initSharedInstance(ORG_ID,APP_ID,BASE_URL);
+ Usergrid.setAuthMode(UsergridEnums.UsergridAuthMode.USER);
+ UsergridEntity.mapCustomSubclassToType(ActivityEntity.ACTIVITY_ENTITY_TYPE,ActivityEntity.class);
+ UsergridSharedDevice.saveSharedDevice(context, new UsergridResponseCallback() {
+ @Override
+ public void onResponse(@NotNull UsergridResponse response) { }
+ });
+ registerPush(context);
+ }
+
+ public static void registerPush(Context context) {
+ final String regId = GCMRegistrar.getRegistrationId(context);
+ if ("".equals(regId)) {
+ GCMRegistrar.register(context, GCM_SENDER_ID);
+ } else {
+ if (GCMRegistrar.isRegisteredOnServer(context)) {
+ Log.i("", "Already registered with GCM");
+ } else {
+ registerPush(context, regId);
+ }
+ }
+ }
+
+ public static void registerPush(@NonNull final Context context, @NonNull final String registrationId) {
+ GCM_REGISTRATION_ID = registrationId;
+ UsergridAsync.applyPushToken(context, registrationId, ANDROID_NOTIFIER_ID, new UsergridResponseCallback() {
+ @Override
+ public void onResponse(@NonNull UsergridResponse response) {
+ if( !response.ok() && response.getResponseError() != null ) {
+ System.out.print("Error Description :" + response.getResponseError().toString());
+ }
+ }
+ });
+ }
+
+ public static void loginUser(@NonNull final Activity activity, @NonNull final String username, @NonNull final String password) {
+ UsergridAsync.authenticateUser(new UsergridUserAuth(username,password), new UsergridResponseCallback() {
+ @Override
+ public void onResponse(@NotNull final UsergridResponse response) {
+ final UsergridUser currentUser = Usergrid.getCurrentUser();
+ if( response.ok() && currentUser != null ) {
+ UsergridAsync.connect("users", "me", "devices", UsergridSharedDevice.getSharedDeviceUUID(activity), new UsergridResponseCallback() {
+ @Override
+ public void onResponse(@NotNull UsergridResponse response) {
+ AlertDialogHelpers.showScrollableAlert(activity,"Authenticate User Successful","User Description: \n\n " + currentUser.toPrettyString(), new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ activity.startActivity(new Intent(activity,FeedActivity.class));
+ }
+ });
+ }
+ });
+ } else {
+ AlertDialogHelpers.showAlert(activity,"Error Authenticating User","Invalid username or password.");
+ }
+ }
+ });
+ }
+
+ public static void logoutCurrentUser(@NonNull final Activity activity) {
+ UsergridAsync.disconnect("users", "me", "devices", UsergridSharedDevice.getSharedDevice(activity).getUuid(), new UsergridResponseCallback() {
+ @Override
+ public void onResponse(@NotNull UsergridResponse response) {
+ UsergridAsync.logoutCurrentUser(new UsergridResponseCallback() {
+ @Override
+ public void onResponse(@NotNull UsergridResponse response) {
+ System.out.print(response.toString());
+ }
+ });
+ }
+ });
+ }
+
+ public static void createUserAccount(@NonNull final Activity activity, @NonNull final String name, @NonNull final String username, @NonNull final String email, @NonNull final String password) {
+ final UsergridUser user = new UsergridUser(name,username,email,password);
+ UsergridUserAsync.create(user, new UsergridResponseCallback() {
+ @Override
+ public void onResponse(@NotNull UsergridResponse response) {
+ final UsergridUser responseUser = response.user();
+ if( response.ok() && responseUser != null ) {
+ AlertDialogHelpers.showScrollableAlert(activity, "Creating Account Successful", "User Description: \n\n " + responseUser.toPrettyString(), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ activity.finish();
+ }
+ });
+ } else {
+ String errorMessage = "Unknown Error";
+ UsergridResponseError responseError = response.getResponseError();
+ if( responseError != null ) {
+ errorMessage = responseError.getErrorDescription();
+ }
+ AlertDialogHelpers.showAlert(activity,"Error Creating Account",errorMessage);
+ }
+ }
+ });
+ }
+
+ @SuppressWarnings("unchecked")
+ public static void getFeedMessages(@NonNull final GetFeedMessagesCallback callback) {
+ final UsergridQuery feedMessagesQuery = new UsergridQuery("users/me/feed").desc(UsergridEnums.UsergridEntityProperties.CREATED.toString());
+ UsergridAsync.GET(feedMessagesQuery, new UsergridResponseCallback() {
+ @Override
+ public void onResponse(@NotNull UsergridResponse response) {
+ ArrayList<ActivityEntity> feedMessages = new ArrayList<>();
+ if( response.ok() ) {
+ List feedEntities = response.getEntities();
+ if( feedEntities != null ) {
+ Collections.reverse(feedEntities);
+ feedMessages.addAll((List<ActivityEntity>)feedEntities);
+ }
+ }
+ callback.onResponse(feedMessages);
+ }
+ });
+ }
+
+ public static void postFeedMessage(@NonNull final String messageText, @NonNull final PostFeedMessageCallback callback) {
+ final UsergridUser currentUser = Usergrid.getCurrentUser();
+ if( currentUser != null ) {
+ String usernameOrEmail = currentUser.usernameOrEmail();
+ if( usernameOrEmail == null ) {
+ usernameOrEmail = "";
+ }
+ String email = currentUser.getEmail();
+ if( email == null ) {
+ email = "";
+ }
+ String picture = currentUser.getPicture();
+ final ActivityEntity activityEntity = new ActivityEntity(usernameOrEmail,email,picture,messageText);
+ UsergridAsync.POST("users/me/activities",activityEntity.toMapValue(), new UsergridResponseCallback() {
+ @Override
+ public void onResponse(@NotNull UsergridResponse response) {
+ final UsergridEntity responseEntity = response.entity();
+ if( response.ok() && responseEntity != null && responseEntity instanceof ActivityEntity ) {
+ callback.onSuccess((ActivityEntity)responseEntity);
+ UsergridManager.sendPushToFollowers(messageText);
+ }
+ }
+ });
+ }
+ }
+
+ public static void followUser(@NonNull final Activity activity, @NonNull final String username) {
+ UsergridAsync.connect("users", "me", "following", "users", username, new UsergridResponseCallback() {
+ @Override
+ public void onResponse(@NotNull UsergridResponse response) {
+ if( response.ok() ) {
+ activity.finish();
+ } else {
+ String errorMessage = "Unknown Error";
+ UsergridResponseError responseError = response.getResponseError();
+ if( responseError != null ) {
+ String errorDescription = responseError.getErrorDescription();
+ if( errorDescription != null ) {
+ errorMessage = errorDescription;
+ }
+ }
+ AlertDialogHelpers.showAlert(activity,"Error Following User",errorMessage);
+ }
+ }
+ });
+ }
+
+ public static void sendPushToFollowers(@NonNull final String message) {
+ HashMap<String,String> notificationMap = new HashMap<>();
+ notificationMap.put(ANDROID_NOTIFIER_ID,message);
+ final HashMap<String,HashMap<String,String>> payloadMap = new HashMap<>();
+ payloadMap.put("payloads",notificationMap);
+
+ UsergridAsync.GET("users/me/followers", new UsergridResponseCallback() {
+ @Override
+ public void onResponse(@NotNull UsergridResponse response) {
+ if( response.ok() ) {
+ String followerUserNames = "";
+ final List<UsergridUser> users = response.users();
+ if( users != null && !users.isEmpty() ) {
+ for( UsergridUser user : users ) {
+ String username = user.getUsername();
+ if( username != null && !username.isEmpty() ) {
+ followerUserNames += username + ";";
+ }
+ }
+ if( !followerUserNames.isEmpty() ) {
+ final UsergridRequest notificationRequest = new UsergridRequest(UsergridEnums.UsergridHttpMethod.POST,UsergridRequest.APPLICATION_JSON_MEDIA_TYPE,Usergrid.clientAppUrl(),null,payloadMap,Usergrid.authForRequests(),"users", followerUserNames, "notifications");
+ UsergridAsync.sendRequest(notificationRequest, new UsergridResponseCallback() {
+ @Override
+ public void onResponse(@NonNull UsergridResponse response) {}
+ });
+ }
+ }
+ }
+ }
+ });
+ }
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/activities/CreateAccountActivity.java
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/activities/CreateAccountActivity.java b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/activities/CreateAccountActivity.java
new file mode 100644
index 0000000..0f72fbb
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/activities/CreateAccountActivity.java
@@ -0,0 +1,67 @@
+/*
+ * 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.activityfeed.activities;
+
+import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
+import android.view.View;
+import android.widget.EditText;
+import android.widget.TextView;
+
+import org.apache.usergrid.activityfeed.R;
+import org.apache.usergrid.activityfeed.UsergridManager;
+import org.apache.usergrid.activityfeed.helpers.ActionBarHelpers;
+import org.apache.usergrid.activityfeed.helpers.AlertDialogHelpers;
+
+public class CreateAccountActivity extends AppCompatActivity {
+
+ private static final String actionBarTitle = "Create Account";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_create_account);
+
+ ActionBarHelpers.setCustomViewForActionBarWithTitle(this,actionBarTitle);
+
+ final EditText nameText = (EditText) findViewById(R.id.nameText);
+ final EditText usernameEditText = (EditText) findViewById(R.id.usernameText);
+ final EditText emailText = (EditText) findViewById(R.id.emailText);
+ final EditText passwordEditText = (EditText) findViewById(R.id.passwordEditText);
+
+ final TextView createAccountTextView = (TextView) findViewById(R.id.createAccountText);
+ if( createAccountTextView != null ) {
+ createAccountTextView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if( nameText != null && usernameEditText != null && emailText != null && passwordEditText != null ) {
+ String name = nameText.getText().toString();
+ String username = usernameEditText.getText().toString();
+ String email = emailText.getText().toString();
+ String password = passwordEditText.getText().toString();
+ if(!name.isEmpty() && !username.isEmpty() && !email.isEmpty() && !password.isEmpty()) {
+ UsergridManager.createUserAccount(CreateAccountActivity.this,name,username,email,password);
+ } else {
+ AlertDialogHelpers.showAlert(CreateAccountActivity.this,"Error Creating Account","All fields must not be empty.");
+ }
+ }
+
+ }
+ });
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/activities/FeedActivity.java
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/activities/FeedActivity.java b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/activities/FeedActivity.java
new file mode 100644
index 0000000..4f347f8
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/activities/FeedActivity.java
@@ -0,0 +1,142 @@
+/*
+ * 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.activityfeed.activities;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.v7.app.AppCompatActivity;
+import android.text.TextUtils;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ListView;
+
+import org.apache.usergrid.activityfeed.ActivityEntity;
+import org.apache.usergrid.activityfeed.R;
+import org.apache.usergrid.activityfeed.UsergridManager;
+import org.apache.usergrid.activityfeed.callbacks.GetFeedMessagesCallback;
+import org.apache.usergrid.activityfeed.callbacks.PostFeedMessageCallback;
+import org.apache.usergrid.activityfeed.helpers.ActionBarHelpers;
+import org.apache.usergrid.activityfeed.helpers.FeedAdapter;
+import org.apache.usergrid.java.client.Usergrid;
+import org.apache.usergrid.java.client.model.UsergridUser;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class FeedActivity extends AppCompatActivity {
+
+ private EditText messageET;
+ private ListView messagesContainer;
+ private FeedAdapter adapter;
+ private ArrayList<ActivityEntity> feedMessages;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_feed);
+
+ final UsergridUser currentUser = Usergrid.getCurrentUser();
+ String username = "Unknown";
+ if( currentUser != null ) {
+ String currentUsername = currentUser.getUsername();
+ if( currentUsername != null ) {
+ username = currentUser.getUsername();
+ }
+ }
+ final Intent followActivityIntent = new Intent(this,FollowActivity.class);
+ ActionBarHelpers.setCustomViewForActionBarWithTitle(this, username + "'s feed", "Follow", new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ FeedActivity.this.startActivity(followActivityIntent);
+ }
+ });
+
+ initControls();
+ }
+
+ private void initControls() {
+ messagesContainer = (ListView) findViewById(R.id.messagesContainer);
+ messageET = (EditText) findViewById(R.id.messageEdit);
+ if(messageET != null) {
+ messageET.setMaxWidth(messageET.getWidth());
+ }
+ final Button sendBtn = (Button) findViewById(R.id.chatSendButton);
+ if( sendBtn != null ) {
+ sendBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ String messageText = messageET.getText().toString();
+ if (TextUtils.isEmpty(messageText)) {
+ return;
+ }
+
+ UsergridManager.postFeedMessage(messageText, new PostFeedMessageCallback() {
+ @Override
+ public void onSuccess(@NonNull ActivityEntity activityEntity) {
+ displayMessage(activityEntity);
+ }
+ });
+ messageET.setText("");
+ }
+ });
+ }
+ }
+
+ private void displayMessage(ActivityEntity message) {
+ adapter.add(message);
+ adapter.notifyDataSetChanged();
+ scroll();
+ }
+
+ private void scroll() {
+ messagesContainer.setSelection(messagesContainer.getCount() - 1);
+ }
+
+ @SuppressWarnings("unchecked")
+ private void loadMessages(){
+
+ feedMessages = new ArrayList<>();
+ adapter = new FeedAdapter(FeedActivity.this, new ArrayList<ActivityEntity>());
+ messagesContainer.setAdapter(adapter);
+
+ UsergridManager.getFeedMessages(new GetFeedMessagesCallback() {
+ @Override
+ public void onResponse(@NonNull List<ActivityEntity> feedMessages) {
+ FeedActivity.this.feedMessages.addAll(feedMessages);
+ for( ActivityEntity activityEntity : FeedActivity.this.feedMessages ) {
+ displayMessage(activityEntity);
+ }
+ }
+ });
+ }
+
+ @Override
+ protected void onResume() {
+ this.loadMessages();
+ super.onResume();
+ }
+
+ @Override
+ protected void onDestroy() {
+ if( Usergrid.getCurrentUser() != null ) {
+ UsergridManager.logoutCurrentUser(this);
+ }
+ super.onDestroy();
+ }
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/activities/FollowActivity.java
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/activities/FollowActivity.java b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/activities/FollowActivity.java
new file mode 100644
index 0000000..c4aac27
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/activities/FollowActivity.java
@@ -0,0 +1,59 @@
+/*
+ * 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.activityfeed.activities;
+
+import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+import org.apache.usergrid.activityfeed.R;
+import org.apache.usergrid.activityfeed.UsergridManager;
+import org.apache.usergrid.activityfeed.helpers.ActionBarHelpers;
+import org.apache.usergrid.activityfeed.helpers.AlertDialogHelpers;
+
+public class FollowActivity extends AppCompatActivity {
+
+ private static final String actionBarTitle = "Follow";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_follow);
+
+ ActionBarHelpers.setCustomViewForActionBarWithTitle(this,actionBarTitle);
+
+ final EditText usernameEditText = (EditText) findViewById(R.id.followUsernameText);
+ final Button addFollowerButton = (Button) findViewById(R.id.addFollowerButton);
+ if( addFollowerButton != null ) {
+ addFollowerButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if( usernameEditText != null ) {
+ final String username = usernameEditText.getText().toString();
+ if( !username.isEmpty() ) {
+ UsergridManager.followUser(FollowActivity.this,username);
+ } else {
+ AlertDialogHelpers.showAlert(FollowActivity.this,"Error Following User","Please enter a valid username.");
+ }
+ }
+ }
+ });
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/activities/MainActivity.java
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/activities/MainActivity.java b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/activities/MainActivity.java
new file mode 100644
index 0000000..338f829
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/activities/MainActivity.java
@@ -0,0 +1,87 @@
+/*
+ * 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.activityfeed.activities;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.TextView;
+
+import org.apache.usergrid.activityfeed.R;
+import org.apache.usergrid.activityfeed.UsergridManager;
+import org.apache.usergrid.activityfeed.helpers.AlertDialogHelpers;
+import org.apache.usergrid.java.client.Usergrid;
+
+public class MainActivity extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ UsergridManager.initializeSharedInstance(this);
+
+ final EditText usernameEditText = (EditText) findViewById(R.id.usernameText);
+ if( usernameEditText != null ) {
+ usernameEditText.setSelection(usernameEditText.getText().length());
+ }
+ final EditText passwordEditText = (EditText) findViewById(R.id.passwordEditText);
+ if( passwordEditText != null ) {
+ passwordEditText.setSelection(passwordEditText.getText().length());
+ }
+
+ final Button signInButton = (Button) findViewById(R.id.signInButton);
+ if( signInButton != null ) {
+ signInButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if( usernameEditText != null && passwordEditText != null ) {
+ final String username = usernameEditText.getText().toString();
+ final String password = passwordEditText.getText().toString();
+ if( !username.isEmpty() && !password.isEmpty() ) {
+ UsergridManager.loginUser(MainActivity.this,username,password);
+ } else {
+ AlertDialogHelpers.showAlert(MainActivity.this,"Error Authenticating User","Username and password must not be empty.");
+ }
+ }
+ }
+ });
+ }
+
+ final TextView createAccountTextView = (TextView) findViewById(R.id.createAccountTextView);
+ if( createAccountTextView != null ) {
+ final Intent createAccountIntent = new Intent(this,CreateAccountActivity.class);
+ createAccountTextView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ MainActivity.this.startActivity(createAccountIntent);
+ }
+ });
+ }
+ }
+
+ @Override
+ protected void onResume() {
+ if(Usergrid.getCurrentUser() != null) {
+ this.startActivity(new Intent(this,FeedActivity.class));
+ }
+ super.onResume();
+ }
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/callbacks/GetFeedMessagesCallback.java
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/callbacks/GetFeedMessagesCallback.java b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/callbacks/GetFeedMessagesCallback.java
new file mode 100644
index 0000000..ae7b999
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/callbacks/GetFeedMessagesCallback.java
@@ -0,0 +1,27 @@
+/*
+ * 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.activityfeed.callbacks;
+
+import android.support.annotation.NonNull;
+
+import org.apache.usergrid.activityfeed.ActivityEntity;
+
+import java.util.List;
+
+public interface GetFeedMessagesCallback {
+ void onResponse(@NonNull final List<ActivityEntity> feedMessages);
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/callbacks/PostFeedMessageCallback.java
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/callbacks/PostFeedMessageCallback.java b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/callbacks/PostFeedMessageCallback.java
new file mode 100644
index 0000000..14f5117
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/callbacks/PostFeedMessageCallback.java
@@ -0,0 +1,25 @@
+/*
+ * 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.activityfeed.callbacks;
+
+import android.support.annotation.NonNull;
+
+import org.apache.usergrid.activityfeed.ActivityEntity;
+
+public interface PostFeedMessageCallback {
+ void onSuccess(@NonNull final ActivityEntity activityEntity);
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/helpers/ActionBarHelpers.java
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/helpers/ActionBarHelpers.java b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/helpers/ActionBarHelpers.java
new file mode 100644
index 0000000..46c2560
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/helpers/ActionBarHelpers.java
@@ -0,0 +1,53 @@
+/*
+ * 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.activityfeed.helpers;
+
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.AppCompatActivity;
+import android.view.Gravity;
+import android.view.View;
+import android.widget.TextView;
+
+import org.apache.usergrid.activityfeed.R;
+
+public final class ActionBarHelpers {
+ private ActionBarHelpers() {}
+
+ public static void setCustomViewForActionBarWithTitle(@NonNull final AppCompatActivity activity, @Nullable final String title) {
+ ActionBarHelpers.setCustomViewForActionBarWithTitle(activity,title,null,null);
+ }
+
+ public static void setCustomViewForActionBarWithTitle(@NonNull final AppCompatActivity activity, @Nullable final String title, @Nullable final String rightButtonTitle, @Nullable final View.OnClickListener rightButtonOnClick) {
+ ActionBar actionBar = activity.getSupportActionBar();
+ if( actionBar != null ) {
+ actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
+ View actionBarView = View.inflate(activity, R.layout.action_bar_layout,null);
+ TextView actionBarTitleText = (TextView) actionBarView.findViewById(R.id.actionBarTitle);
+ actionBarTitleText.setText(title);
+ if( rightButtonTitle != null ) {
+ TextView rightTextView = (TextView) actionBarView.findViewById(R.id.buttonTitle);
+ rightTextView.setText(rightButtonTitle);
+ rightTextView.setOnClickListener(rightButtonOnClick);
+ }
+ final ActionBar.LayoutParams params = new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.MATCH_PARENT, Gravity.CENTER);
+ actionBar.setCustomView(actionBarView,params);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/helpers/AlertDialogHelpers.java
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/helpers/AlertDialogHelpers.java b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/helpers/AlertDialogHelpers.java
new file mode 100644
index 0000000..e871271
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/helpers/AlertDialogHelpers.java
@@ -0,0 +1,61 @@
+/*
+ * 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.activityfeed.helpers;
+
+import android.app.Activity;
+import android.content.DialogInterface;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AlertDialog;
+import android.view.View;
+import android.widget.TextView;
+
+import org.apache.usergrid.activityfeed.R;
+
+@SuppressWarnings("unused")
+public final class AlertDialogHelpers {
+
+ private AlertDialogHelpers() {}
+
+ public static void showAlert(@NonNull final Activity activity, @Nullable final String title, @Nullable final String message) {
+ AlertDialogHelpers.showAlert(activity,title,message,null);
+ }
+
+ public static void showAlert(@NonNull final Activity activity, @Nullable final String title, @Nullable final String message, @Nullable final DialogInterface.OnClickListener onClickListener) {
+ new AlertDialog.Builder(activity)
+ .setTitle(title)
+ .setMessage(message)
+ .setPositiveButton(android.R.string.ok, onClickListener)
+ .show();
+ }
+
+ public static void showScrollableAlert(@NonNull final Activity activity, @Nullable final String title, @Nullable final String message) {
+ AlertDialogHelpers.showScrollableAlert(activity, title, message,null);
+ }
+
+ public static void showScrollableAlert(@NonNull final Activity activity, @Nullable final String title, @Nullable final String message, @Nullable final DialogInterface.OnClickListener onClickListener) {
+ final View scrollableAlertView = View.inflate(activity, R.layout.scrollable_alert_view, null);
+ final TextView titleTextView = (TextView) scrollableAlertView.findViewById(R.id.scrollableAlertTitle);
+ titleTextView.setText(title);
+ final TextView messageTextView = (TextView) scrollableAlertView.findViewById(R.id.scrollableAlertMessage);
+ messageTextView.setText(message);
+ new AlertDialog.Builder(activity)
+ .setView(scrollableAlertView)
+ .setPositiveButton(android.R.string.ok, onClickListener)
+ .show();
+ }
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/helpers/FeedAdapter.java
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/helpers/FeedAdapter.java b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/helpers/FeedAdapter.java
new file mode 100644
index 0000000..53494dd
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/java/org/apache/usergrid/activityfeed/helpers/FeedAdapter.java
@@ -0,0 +1,153 @@
+/*
+ * 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.activityfeed.helpers;
+
+import android.app.Activity;
+import android.view.Gravity;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import org.apache.usergrid.activityfeed.ActivityEntity;
+import org.apache.usergrid.activityfeed.R;
+import org.apache.usergrid.java.client.Usergrid;
+import org.apache.usergrid.java.client.model.UsergridUser;
+
+import java.util.List;
+
+public class FeedAdapter extends BaseAdapter {
+ private final List<ActivityEntity> feedMessages;
+ private final Activity context;
+
+ public FeedAdapter(Activity context, List<ActivityEntity> feedMessages) {
+ this.context = context;
+ this.feedMessages = feedMessages;
+ }
+
+ @Override
+ public int getCount() {
+ if (feedMessages != null) {
+ return feedMessages.size();
+ } else {
+ return 0;
+ }
+ }
+
+ @Override
+ public ActivityEntity getItem(int position) {
+ if (feedMessages != null) {
+ return feedMessages.get(position);
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return position;
+ }
+
+ @Override
+ public View getView(final int position, View convertView, ViewGroup parent) {
+ ViewHolder holder;
+ ActivityEntity messageEntity = getItem(position);
+ if (convertView == null) {
+ convertView = View.inflate(context,R.layout.message_layout,null);
+ holder = createViewHolder(convertView);
+ convertView.setTag(holder);
+ } else {
+ holder = (ViewHolder) convertView.getTag();
+ }
+
+ holder.txtMessage.setText(messageEntity.getContent());
+
+ boolean isMe = false;
+ String displayName = messageEntity.getDisplayName();
+ if( displayName != null ) {
+ final UsergridUser currentUser = Usergrid.getCurrentUser();
+ if( currentUser != null ) {
+ final String currentUserUsername = currentUser.getUsername();
+ if( currentUserUsername != null && displayName.equalsIgnoreCase(currentUserUsername) ) {
+ isMe = true;
+ }
+ }
+ holder.txtInfo.setText(displayName);
+ }
+ setAlignment(holder,isMe);
+ return convertView;
+ }
+
+ public void add(ActivityEntity message) {
+ feedMessages.add(message);
+ }
+
+ private void setAlignment(ViewHolder holder, boolean isMe) {
+ int gravity;
+ int drawableResourceId;
+ if( !isMe ) {
+ gravity = Gravity.END;
+ drawableResourceId = R.drawable.in_message_bg;
+ } else {
+ gravity = Gravity.START;
+ drawableResourceId = R.drawable.out_message_bg;
+ }
+
+ holder.contentWithBG.setBackgroundResource(drawableResourceId);
+
+ LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) holder.contentWithBG.getLayoutParams();
+ layoutParams.gravity = gravity;
+ holder.contentWithBG.setLayoutParams(layoutParams);
+
+ RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) holder.content.getLayoutParams();
+ if( !isMe ) {
+ lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 0);
+ lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
+ } else {
+ lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0);
+ lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
+ }
+
+ holder.content.setLayoutParams(lp);
+ layoutParams = (LinearLayout.LayoutParams) holder.txtMessage.getLayoutParams();
+ layoutParams.gravity = gravity;
+ holder.txtMessage.setLayoutParams(layoutParams);
+
+ layoutParams = (LinearLayout.LayoutParams) holder.txtInfo.getLayoutParams();
+ layoutParams.gravity = gravity;
+ holder.txtInfo.setLayoutParams(layoutParams);
+ }
+
+ private ViewHolder createViewHolder(View v) {
+ ViewHolder holder = new ViewHolder();
+ holder.txtMessage = (TextView) v.findViewById(R.id.txtMessage);
+ holder.content = (LinearLayout) v.findViewById(R.id.content);
+ holder.contentWithBG = (LinearLayout) v.findViewById(R.id.contentWithBackground);
+ holder.txtInfo = (TextView) v.findViewById(R.id.txtInfo);
+ return holder;
+ }
+
+
+ private static class ViewHolder {
+ public TextView txtMessage;
+ public TextView txtInfo;
+ public LinearLayout content;
+ public LinearLayout contentWithBG;
+ }
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/drawable/in_message_bg.9.png
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/drawable/in_message_bg.9.png b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/drawable/in_message_bg.9.png
new file mode 100644
index 0000000..08c6f09
Binary files /dev/null and b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/drawable/in_message_bg.9.png differ
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/drawable/out_message_bg.9.png
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/drawable/out_message_bg.9.png b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/drawable/out_message_bg.9.png
new file mode 100644
index 0000000..3d511e7
Binary files /dev/null and b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/drawable/out_message_bg.9.png differ
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/drawable/usergridguy.png
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/drawable/usergridguy.png b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/drawable/usergridguy.png
new file mode 100644
index 0000000..b8a6844
Binary files /dev/null and b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/drawable/usergridguy.png differ
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/action_bar_layout.xml
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/action_bar_layout.xml b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/action_bar_layout.xml
new file mode 100644
index 0000000..f20a1f0
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/action_bar_layout.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:gravity="center">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:textColor="@android:color/white"
+ android:id="@+id/actionBarTitle"
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ android:textSize="20sp"
+ android:gravity="center"
+ android:layout_centerInParent="true" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textColor="@android:color/white"
+ android:id="@+id/buttonTitle"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textSize="17sp"
+ android:layout_alignParentEnd="true"
+ android:layout_centerVertical="true" />
+
+</RelativeLayout>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/activity_create_account.xml
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/activity_create_account.xml b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/activity_create_account.xml
new file mode 100644
index 0000000..1fba8ed
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/activity_create_account.xml
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingBottom="@dimen/activity_vertical_margin"
+ android:paddingLeft="@dimen/activity_horizontal_margin"
+ android:paddingRight="@dimen/activity_horizontal_margin"
+ android:paddingTop="@dimen/activity_vertical_margin"
+ tools:context=".activities.CreateAccountActivity"
+ android:background="@color/lightBlue">
+
+ <EditText
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/nameText"
+ android:minWidth="250dp"
+ android:background="@android:color/white"
+ android:height="40dp"
+ android:layout_marginTop="32dp"
+ android:hint="Name"
+ android:paddingStart="10dp"
+ android:singleLine="true"
+ android:minLines="1"
+ android:maxLines="1"
+ android:minHeight="30dp"
+ android:layout_centerHorizontal="true"
+ android:inputType="textPersonName"
+ android:maxWidth="250dp"
+ android:paddingEnd="10dp" />
+
+ <EditText
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/usernameText"
+ android:minWidth="250dp"
+ android:background="@android:color/white"
+ android:height="40dp"
+ android:layout_marginTop="15dp"
+ android:hint="Username"
+ android:paddingStart="10dp"
+ android:singleLine="true"
+ android:minLines="1"
+ android:maxLines="1"
+ android:minHeight="30dp"
+ android:layout_below="@+id/nameText"
+ android:layout_centerHorizontal="true"
+ android:paddingEnd="10dp"
+ android:maxWidth="250dp" />
+
+ <EditText
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/emailText"
+ android:minWidth="250dp"
+ android:background="@android:color/white"
+ android:height="40dp"
+ android:layout_marginTop="15dp"
+ android:hint="Email"
+ android:paddingStart="10dp"
+ android:singleLine="true"
+ android:minLines="1"
+ android:maxLines="1"
+ android:minHeight="30dp"
+ android:layout_below="@+id/usernameText"
+ android:layout_centerHorizontal="true"
+ android:inputType="textEmailAddress"
+ android:paddingEnd="10dp"
+ android:maxWidth="250dp" />
+
+ <EditText
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/passwordEditText"
+ android:minWidth="250dp"
+ android:background="@android:color/white"
+ android:height="40dp"
+ android:layout_marginTop="15dp"
+ android:hint="Password"
+ android:paddingStart="10dp"
+ android:singleLine="true"
+ android:minLines="1"
+ android:maxLines="1"
+ android:minHeight="30dp"
+ android:layout_below="@+id/emailText"
+ android:layout_centerHorizontal="true"
+ android:inputType="textPassword"
+ android:paddingEnd="10dp"
+ android:maxWidth="250dp" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Create Account"
+ android:id="@+id/createAccountText"
+ android:textColor="@color/colorPrimary"
+ android:clickable="true"
+ android:layout_centerVertical="true"
+ android:layout_centerHorizontal="true"
+ android:textSize="20sp" />
+</RelativeLayout>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/activity_feed.xml
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/activity_feed.xml b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/activity_feed.xml
new file mode 100644
index 0000000..7e0789a
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/activity_feed.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:background="@color/white">
+
+ <EditText
+ android:id="@+id/messageEdit"
+ android:layout_width="match_parent"
+ android:layout_height="50dp"
+ android:layout_alignParentBottom="true"
+ android:hint="Message"
+ android:layout_alignBottom="@+id/chatSendButton"
+ android:layout_toStartOf="@+id/chatSendButton"
+ android:paddingEnd="10dp"
+ android:paddingStart="10dp" />
+
+ <Button
+ android:id="@+id/chatSendButton"
+ android:layout_width="wrap_content"
+ android:layout_height="50dp"
+ android:layout_alignParentBottom="true"
+ android:layout_alignParentEnd="true"
+ android:background="@color/colorPrimary"
+ android:text="Send"
+ android:textColor="@color/background_material_light"
+ android:layout_alignParentTop="false"
+ android:layout_alignParentStart="false" />
+
+ <ListView
+ android:id="@+id/messagesContainer"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_alignParentStart="false"
+ android:layout_alignParentTop="false"
+ android:layout_marginBottom="50dp"
+ android:listSelector="@android:color/transparent"
+ android:transcriptMode="alwaysScroll"
+ android:divider="@null"
+ android:background="@color/switch_thumb_normal_material_light"
+ android:paddingBottom="10dp"
+ android:stackFromBottom="true" />
+
+</RelativeLayout>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/activity_follow.xml
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/activity_follow.xml b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/activity_follow.xml
new file mode 100644
index 0000000..c70da17
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/activity_follow.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingBottom="@dimen/activity_vertical_margin"
+ android:paddingLeft="@dimen/activity_horizontal_margin"
+ android:paddingRight="@dimen/activity_horizontal_margin"
+ android:paddingTop="@dimen/activity_vertical_margin"
+ tools:context=".activities.FollowActivity"
+ android:background="@color/lightBlue">
+
+ <EditText
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/followUsernameText"
+ android:minWidth="250dp"
+ android:background="@android:color/white"
+ android:height="40dp"
+ android:layout_marginTop="70dp"
+ android:hint="Username"
+ android:paddingStart="10dp"
+ android:singleLine="true"
+ android:minLines="1"
+ android:maxLines="1"
+ android:minHeight="30dp"
+ android:inputType="textPersonName"
+ android:layout_alignParentTop="true"
+ android:layout_centerHorizontal="true"
+ android:paddingEnd="10dp"
+ android:maxWidth="250dp" />
+
+ <Button
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Add Follower"
+ android:id="@+id/addFollowerButton"
+ android:minWidth="250dp"
+ android:background="@color/colorPrimary"
+ android:textColor="@android:color/white"
+ android:layout_below="@+id/followUsernameText"
+ android:layout_alignStart="@+id/followUsernameText"
+ android:layout_marginTop="30dp" />
+</RelativeLayout>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/activity_main.xml
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/activity_main.xml b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..db63ae4
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/activity_main.xml
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingBottom="@dimen/activity_vertical_margin"
+ android:paddingLeft="@dimen/activity_horizontal_margin"
+ android:paddingRight="@dimen/activity_horizontal_margin"
+ android:paddingTop="@dimen/activity_vertical_margin"
+ tools:context=".activities.MainActivity"
+ android:background="@color/lightBlue">
+
+ <ImageView
+ android:layout_width="125dp"
+ android:layout_height="125dp"
+ android:id="@+id/imageView"
+ android:layout_alignParentTop="true"
+ android:layout_centerHorizontal="true"
+ android:src="@drawable/usergridguy"
+ android:layout_marginTop="20dp"
+ android:adjustViewBounds="true" />
+
+ <EditText
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/usernameText"
+ android:minWidth="250dp"
+ android:background="@android:color/white"
+ android:height="40dp"
+ android:layout_below="@+id/imageView"
+ android:layout_centerHorizontal="true"
+ android:layout_marginTop="30dp"
+ android:hint="Username"
+ android:paddingStart="10dp"
+ android:singleLine="true"
+ android:minLines="1"
+ android:maxLines="1"
+ android:minHeight="30dp"
+ android:paddingEnd="10dp"
+ android:maxWidth="250dp"
+ android:text="fc" />
+
+ <EditText
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/passwordEditText"
+ android:minWidth="250dp"
+ android:background="@android:color/white"
+ android:height="40dp"
+ android:layout_marginTop="15dp"
+ android:layout_below="@+id/usernameText"
+ android:layout_alignStart="@+id/usernameText"
+ android:hint="Password"
+ android:paddingStart="10dp"
+ android:singleLine="true"
+ android:maxLines="1"
+ android:minLines="1"
+ android:minHeight="30dp"
+ android:maxWidth="250dp"
+ android:paddingEnd="10dp"
+ android:inputType="textPassword"
+ android:text="fc" />
+
+ <Button
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Sign In"
+ android:id="@+id/signInButton"
+ android:layout_below="@+id/passwordEditText"
+ android:layout_alignEnd="@+id/passwordEditText"
+ android:layout_marginTop="25dp"
+ android:minWidth="250dp"
+ android:background="@color/colorPrimary"
+ android:textColor="@android:color/white" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Create Account"
+ android:id="@+id/createAccountTextView"
+ android:layout_below="@+id/signInButton"
+ android:layout_centerHorizontal="true"
+ android:layout_marginTop="30dp"
+ android:textColor="@color/colorPrimary"
+ android:clickable="true" />
+
+</RelativeLayout>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b30b60b3/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/message_layout.xml
----------------------------------------------------------------------
diff --git a/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/message_layout.xml b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/message_layout.xml
new file mode 100644
index 0000000..da355b9
--- /dev/null
+++ b/sdks/android/Samples/ActivityFeed/activityfeed/src/main/res/layout/message_layout.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content">
+ <LinearLayout
+ android:id="@+id/content"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentRight="true"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/txtInfo"
+ android:layout_width="wrap_content"
+ android:layout_height="40sp"
+ android:layout_gravity="left"
+ android:textSize="25sp"
+ android:textColor="@android:color/darker_gray"
+ android:layout_marginTop="10dp"
+ android:layout_marginLeft="10dp"
+ android:layout_marginRight="10dp" />
+
+ <LinearLayout
+ android:id="@+id/contentWithBackground"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="left"
+ android:background="@drawable/in_message_bg"
+ android:paddingLeft="10dp"
+ android:paddingBottom="10dp"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/txtMessage"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textColor="@android:color/black"
+ android:maxWidth="240dp" />
+
+ </LinearLayout>
+
+ </LinearLayout>
+</RelativeLayout>
\ No newline at end of file
[10/12] usergrid git commit: Updating ReadMe.
Posted by mr...@apache.org.
Updating ReadMe.
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/22110ae3
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/22110ae3
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/22110ae3
Branch: refs/heads/master
Commit: 22110ae3c00c09dcfbcf64ce2587da540f498f82
Parents: 8ddc90d
Author: Robert Walsh <rj...@gmail.com>
Authored: Mon Aug 8 17:22:48 2016 -0500
Committer: Robert Walsh <rj...@gmail.com>
Committed: Mon Aug 8 17:22:48 2016 -0500
----------------------------------------------------------------------
sdks/android/README.md | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/22110ae3/sdks/android/README.md
----------------------------------------------------------------------
diff --git a/sdks/android/README.md b/sdks/android/README.md
index a1cbf41..a45b8d7 100644
--- a/sdks/android/README.md
+++ b/sdks/android/README.md
@@ -1,6 +1,8 @@
# Usergrid Android SDK
-Usergrid SDK written for Android
+Usergrid SDK written for Android.
+
+The Android SDK is an extension upon the the Usergrid Java SDK with added functionality including asynchronous HTTP handling and push notifications.
## Initialization
@@ -20,6 +22,14 @@ UsergridClient client = new UsergridClient("orgId","appId");
_Note: Examples in this readme assume you are using the `Usergrid` shared instance. If you've implemented the instance pattern instead, simply replace `Usergrid` with your client instance variable._
+## ASYNCHRONOUS operations
+
+The examples in this readme utilize the synchronous method calls provided by the Usergrid Java SDK.
+
+Each RESTful operation has a matching asynchrous method within to use within the SDK for convience of use within Android applications.
+
+For examples of asynchronous calls, look over the sample Android applications located within the `Samples` folder.
+
## RESTful operations
When making any RESTful call, a `type` parameter (or `path`) is always required. Whether you specify this as an argument or in an object as a parameter is up to you.
[04/12] usergrid git commit: Removing old android SDK.
Posted by mr...@apache.org.
Removing old android SDK.
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/7e0ffbc0
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/7e0ffbc0
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/7e0ffbc0
Branch: refs/heads/master
Commit: 7e0ffbc0f919b8030a0e65333f8b2ee7b0c170c1
Parents: c0dd93e
Author: Robert Walsh <rj...@gmail.com>
Authored: Mon Aug 8 15:36:17 2016 -0500
Committer: Robert Walsh <rj...@gmail.com>
Committed: Mon Aug 8 15:36:17 2016 -0500
----------------------------------------------------------------------
sdks/android/.gitignore | 20 -
sdks/android/LICENSE | 202 --
sdks/android/NOTICE | 12 -
sdks/android/README.md | 32 -
sdks/android/README.txt | 13 -
sdks/android/assembly.xml | 55 -
sdks/android/build_release_zip.sh | 10 -
sdks/android/pom.xml | 106 -
.../usergrid/android/sdk/CounterIncrement.java | 72 -
.../sdk/DefaultURLConnectionFactory.java | 36 -
.../apache/usergrid/android/sdk/UGClient.java | 3181 ------------------
.../android/sdk/URLConnectionFactory.java | 30 -
.../sdk/callbacks/ApiResponseCallback.java | 31 -
.../android/sdk/callbacks/ClientAsyncTask.java | 66 -
.../android/sdk/callbacks/ClientCallback.java | 31 -
.../sdk/callbacks/GroupsRetrievedCallback.java | 35 -
.../sdk/callbacks/QueryResultsCallback.java | 33 -
.../usergrid/android/sdk/entities/Activity.java | 1019 ------
.../android/sdk/entities/Collection.java | 338 --
.../usergrid/android/sdk/entities/Device.java | 122 -
.../usergrid/android/sdk/entities/Entity.java | 552 ---
.../usergrid/android/sdk/entities/Group.java | 151 -
.../usergrid/android/sdk/entities/Message.java | 159 -
.../usergrid/android/sdk/entities/User.java | 315 --
.../android/sdk/exception/ClientException.java | 43 -
.../android/sdk/response/AggregateCounter.java | 58 -
.../sdk/response/AggregateCounterSet.java | 117 -
.../android/sdk/response/ApiResponse.java | 774 -----
.../sdk/response/ClientCredentialsInfo.java | 64 -
.../android/sdk/response/QueueInfo.java | 47 -
.../android/sdk/utils/DeviceUuidFactory.java | 173 -
.../usergrid/android/sdk/utils/JsonUtils.java | 185 -
.../usergrid/android/sdk/utils/MapUtils.java | 42 -
.../usergrid/android/sdk/utils/ObjectUtils.java | 39 -
.../usergrid/android/sdk/utils/UrlUtils.java | 127 -
35 files changed, 8290 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7e0ffbc0/sdks/android/.gitignore
----------------------------------------------------------------------
diff --git a/sdks/android/.gitignore b/sdks/android/.gitignore
deleted file mode 100644
index 3dfc800..0000000
--- a/sdks/android/.gitignore
+++ /dev/null
@@ -1,20 +0,0 @@
-.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/usergrid/blob/7e0ffbc0/sdks/android/LICENSE
----------------------------------------------------------------------
diff --git a/sdks/android/LICENSE b/sdks/android/LICENSE
deleted file mode 100644
index e06d208..0000000
--- a/sdks/android/LICENSE
+++ /dev/null
@@ -1,202 +0,0 @@
-Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "{}"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright {yyyy} {name of copyright owner}
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7e0ffbc0/sdks/android/NOTICE
----------------------------------------------------------------------
diff --git a/sdks/android/NOTICE b/sdks/android/NOTICE
deleted file mode 100644
index b5db9bf..0000000
--- a/sdks/android/NOTICE
+++ /dev/null
@@ -1,12 +0,0 @@
-Apache Usergrid
-Copyright 2014 The Apache Software Foundation.
-
-This product bundles SSToolkit Copyright (c) 2009-2011 Sam Soffes. All rights reserved.
-These files can be located within the /sdks/ios package.
-
-This product uses Intro.js (MIT licensed)
-Copyright (C) 2013 usabli.ca - A weekend project by Afshin Mehrabani (@afshinmeh)
-
-This prodcut uses NPM MD5 (BSD-3 licensed)
-Copyright (C) 2011-2012, Paul Vorbach and Copyright (C) 2009, Jeff Mott.
-
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7e0ffbc0/sdks/android/README.md
----------------------------------------------------------------------
diff --git a/sdks/android/README.md b/sdks/android/README.md
deleted file mode 100755
index 0218763..0000000
--- a/sdks/android/README.md
+++ /dev/null
@@ -1,32 +0,0 @@
-# Android SDK
-
-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/usergrid/blob/7e0ffbc0/sdks/android/README.txt
----------------------------------------------------------------------
diff --git a/sdks/android/README.txt b/sdks/android/README.txt
deleted file mode 100644
index 5540ba4..0000000
--- a/sdks/android/README.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-
-Usergrid Android Client
-
-Experimental Android client for Usergrid. Basically uses Spring Android and
-Jackson to wrap calls to Usergrid REST API. Loosely based on the Usergrid
-Javascript client.
-
-Requires the following permissions:
-
- <uses-permission android:name="android.permission.INTERNET" />
- <uses-permission android:name="android.permission.READ_PHONE_STATE" />
- <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
-
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7e0ffbc0/sdks/android/assembly.xml
----------------------------------------------------------------------
diff --git a/sdks/android/assembly.xml b/sdks/android/assembly.xml
deleted file mode 100644
index 9a0d818..0000000
--- a/sdks/android/assembly.xml
+++ /dev/null
@@ -1,55 +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.
- -->
-
-<assembly
- xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
- <id>dist</id>
- <formats>
- <format>zip</format>
- <format>tar.gz</format>
- </formats>
- <baseDirectory>..</baseDirectory>
- <includeBaseDirectory>true</includeBaseDirectory>
- <fileSets>
- <fileSet>
- <directory>src/main/java/</directory>
- <outputDirectory>/src/</outputDirectory>
- </fileSet>
- <fileSet>
- <directory>.</directory>
- <outputDirectory>.</outputDirectory>
- <includes>
- <include>LICENSE</include>
- <include>README*</include>
- <include>NOTICE</include>
- </includes>
- </fileSet>
- </fileSets>
- <dependencySets>
- <dependencySet>
- <useProjectArtifact>true</useProjectArtifact>
- <includes>
- <include>*:*</include>
- </includes>
- <outputDirectory>bin</outputDirectory>
- </dependencySet>
- </dependencySets>
-</assembly>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7e0ffbc0/sdks/android/build_release_zip.sh
----------------------------------------------------------------------
diff --git a/sdks/android/build_release_zip.sh b/sdks/android/build_release_zip.sh
deleted file mode 100755
index c6ee926..0000000
--- a/sdks/android/build_release_zip.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/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
-#******************************************************************************
-
-mvn clean install
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7e0ffbc0/sdks/android/pom.xml
----------------------------------------------------------------------
diff --git a/sdks/android/pom.xml b/sdks/android/pom.xml
deleted file mode 100644
index 1ef5cfa..0000000
--- a/sdks/android/pom.xml
+++ /dev/null
@@ -1,106 +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.
- -->
-
-<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.apache.usergrid</bundle.symbolicName>
- <bundle.namespace>org.apache.usergrid</bundle.namespace>
- </properties>
-
- <parent>
- <groupId>org.apache.usergrid</groupId>
- <artifactId>usergrid</artifactId>
- <version>1.0.0</version>
- <relativePath>../../stack</relativePath>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <artifactId>usergrid-android</artifactId>
- <version>0.0.8</version>
-
- <packaging>jar</packaging>
- <description>A simple java client for usergrid</description>
- <url>http://usergrid.apache.org</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>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.9.1</version>
- <configuration>
- <doclet>com.sun.tools.doclets.standard.Standard</doclet>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>2.4</version>
- <configuration>
- <descriptor>assembly.xml</descriptor>
- </configuration>
- <executions>
- <execution>
- <id>assembly</id>
- <goals>
- <goal>single</goal>
- </goals>
- <phase>package</phase>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.usergrid</groupId>
- <artifactId>usergrid-java-client</artifactId>
- <version>0.0.6</version>
- </dependency>
- <dependency>
- <groupId>com.google.android</groupId>
- <artifactId>android</artifactId>
- <version>2.2.1</version>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7e0ffbc0/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
deleted file mode 100755
index e4796fd..0000000
--- a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/CounterIncrement.java
+++ /dev/null
@@ -1,72 +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.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/usergrid/blob/7e0ffbc0/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
deleted file mode 100755
index 44166e1..0000000
--- a/sdks/android/src/main/java/org/apache/usergrid/android/sdk/DefaultURLConnectionFactory.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.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();
- }
-
-}