You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2014/01/28 23:22:04 UTC

[54/96] [abbrv] USERGRID-2 package namespace to org.apache.usergrid

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3ccbfd8a/sdks/java/src/main/java/org/usergrid/java/client/response/ApiResponse.java
----------------------------------------------------------------------
diff --git a/sdks/java/src/main/java/org/usergrid/java/client/response/ApiResponse.java b/sdks/java/src/main/java/org/usergrid/java/client/response/ApiResponse.java
deleted file mode 100644
index 4ee3cf3..0000000
--- a/sdks/java/src/main/java/org/usergrid/java/client/response/ApiResponse.java
+++ /dev/null
@@ -1,405 +0,0 @@
-package org.usergrid.java.client.response;
-
-import static org.usergrid.java.client.utils.JsonUtils.toJsonString;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import com.fasterxml.jackson.databind.JsonNode;
-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.annotation.JsonSerialize;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion;
-import org.usergrid.java.client.entities.Entity;
-import org.usergrid.java.client.entities.Message;
-import org.usergrid.java.client.entities.User;
-
-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 final Map<String, JsonNode> properties = new HashMap<String, JsonNode>();
-
-	public ApiResponse() {
-	}
-
-	@JsonAnyGetter
-	public Map<String, JsonNode> getProperties() {
-		return properties;
-	}
-
-	@JsonAnySetter
-	public void setProperty(String key, JsonNode value) {
-		properties.put(key, value);
-	}
-
-	@JsonProperty("access_token")
-	@JsonSerialize(include = Inclusion.NON_NULL)
-	public String getAccessToken() {
-		return accessToken;
-	}
-
-	@JsonProperty("access_token")
-	public void setAccessToken(String accessToken) {
-		this.accessToken = accessToken;
-	}
-
-	@JsonSerialize(include = Inclusion.NON_NULL)
-	public String getError() {
-		return error;
-	}
-
-	public void setError(String error) {
-		this.error = error;
-	}
-
-	@JsonSerialize(include = Inclusion.NON_NULL)
-	@JsonProperty("error_description")
-	public String getErrorDescription() {
-		return errorDescription;
-	}
-
-	@JsonProperty("error_description")
-	public void setErrorDescription(String errorDescription) {
-		this.errorDescription = errorDescription;
-	}
-
-	@JsonSerialize(include = Inclusion.NON_NULL)
-	@JsonProperty("error_uri")
-	public String getErrorUri() {
-		return errorUri;
-	}
-
-	@JsonProperty("error_uri")
-	public void setErrorUri(String errorUri) {
-		this.errorUri = errorUri;
-	}
-
-	@JsonSerialize(include = Inclusion.NON_NULL)
-	public String getException() {
-		return exception;
-	}
-
-	public void setException(String exception) {
-		this.exception = exception;
-	}
-
-	@JsonSerialize(include = Inclusion.NON_NULL)
-	public String getPath() {
-		return path;
-	}
-
-	public void setPath(String path) {
-		this.path = path;
-	}
-
-	@JsonSerialize(include = Inclusion.NON_NULL)
-	public String getUri() {
-		return uri;
-	}
-
-	public void setUri(String uri) {
-		this.uri = uri;
-	}
-
-	@JsonSerialize(include = Inclusion.NON_NULL)
-	public String getStatus() {
-		return status;
-	}
-
-	public void setStatus(String status) {
-		this.status = status;
-	}
-
-	public long getTimestamp() {
-		return timestamp;
-	}
-
-	public void setTimestamp(long timestamp) {
-		this.timestamp = timestamp;
-	}
-
-	@JsonSerialize(include = Inclusion.NON_NULL)
-	public UUID getApplication() {
-		return application;
-	}
-
-	public void setApplication(UUID application) {
-		this.application = application;
-	}
-
-	@JsonSerialize(include = Inclusion.NON_NULL)
-	public List<Entity> getEntities() {
-		return entities;
-	}
-
-	public void setEntities(List<Entity> entities) {
-		this.entities = entities;
-	}
-
-	public int getEntityCount() {
-		if (entities == null) {
-			return 0;
-		}
-		return entities.size();
-	}
-
-	public Entity getFirstEntity() {
-		if ((entities != null) && (entities.size() > 0)) {
-			return entities.get(0);
-		}
-		return null;
-	}
-
-	public <T extends Entity> T getFirstEntity(Class<T> t) {
-		return Entity.toType(getFirstEntity(), t);
-	}
-
-	public Entity getLastEntity() {
-		if ((entities != null) && (entities.size() > 0)) {
-			return entities.get(entities.size() - 1);
-		}
-		return null;
-	}
-
-	public <T extends Entity> T getLastEntity(Class<T> t) {
-		return Entity.toType(getLastEntity(), t);
-	}
-
-	public <T extends Entity> List<T> getEntities(Class<T> t) {
-		return Entity.toType(entities, t);
-	}
-
-	@JsonSerialize(include = Inclusion.NON_NULL)
-	public UUID getNext() {
-		return next;
-	}
-
-	public void setNext(UUID next) {
-		this.next = next;
-	}
-
-	@JsonSerialize(include = Inclusion.NON_NULL)
-	public String getCursor() {
-		return cursor;
-	}
-
-	public void setCursor(String cursor) {
-		this.cursor = cursor;
-	}
-
-	@JsonSerialize(include = Inclusion.NON_NULL)
-	public String getAction() {
-		return action;
-	}
-
-	public void setAction(String action) {
-		this.action = action;
-	}
-
-	@JsonSerialize(include = Inclusion.NON_NULL)
-	public List<Object> getList() {
-		return list;
-	}
-
-	public void setList(List<Object> list) {
-		this.list = list;
-	}
-
-	@JsonSerialize(include = Inclusion.NON_NULL)
-	public Object getData() {
-		return data;
-	}
-
-	public void setData(Object data) {
-		this.data = data;
-	}
-
-	@JsonSerialize(include = Inclusion.NON_NULL)
-	public Map<String, UUID> getApplications() {
-		return applications;
-	}
-
-	public void setApplications(Map<String, UUID> applications) {
-		this.applications = applications;
-	}
-
-	@JsonSerialize(include = Inclusion.NON_NULL)
-	public Map<String, JsonNode> getMetadata() {
-		return metadata;
-	}
-
-	public void setMetadata(Map<String, JsonNode> metadata) {
-		this.metadata = metadata;
-	}
-
-	@JsonSerialize(include = Inclusion.NON_NULL)
-	public Map<String, List<String>> getParams() {
-		return params;
-	}
-
-	public void setParams(Map<String, List<String>> params) {
-		this.params = params;
-	}
-
-	@JsonSerialize(include = Inclusion.NON_NULL)
-	public List<AggregateCounterSet> getCounters() {
-		return counters;
-	}
-
-	public void setCounters(List<AggregateCounterSet> counters) {
-		this.counters = counters;
-	}
-
-	@JsonSerialize(include = Inclusion.NON_NULL)
-	public ClientCredentialsInfo getCredentials() {
-		return credentials;
-	}
-
-	public void setCredentials(ClientCredentialsInfo credentials) {
-		this.credentials = credentials;
-	}
-
-	@JsonSerialize(include = Inclusion.NON_NULL)
-	public User getUser() {
-		return user;
-	}
-
-	public void setUser(User user) {
-		this.user = user;
-	}
-
-	@Override
-	public String toString() {
-		return toJsonString(this);
-	}
-
-	@JsonSerialize(include = Inclusion.NON_NULL)
-	public List<Message> getMessages() {
-		return messages;
-	}
-
-	public void setMessages(List<Message> messages) {
-		this.messages = messages;
-	}
-
-	@JsonIgnore
-	public int getMessageCount() {
-		if (messages == null) {
-			return 0;
-		}
-		return messages.size();
-	}
-
-	@JsonIgnore
-	public Message getFirstMessage() {
-		if ((messages != null) && (messages.size() > 0)) {
-			return messages.get(0);
-		}
-		return null;
-	}
-
-	@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;
-	}
-
-	public void setLast(UUID last) {
-		this.last = last;
-	}
-
-	@JsonSerialize(include = Inclusion.NON_NULL)
-	public List<QueueInfo> getQueues() {
-		return queues;
-	}
-
-	public void setQueues(List<QueueInfo> queues) {
-		this.queues = queues;
-	}
-
-	@JsonIgnore
-	public QueueInfo getFirstQueue() {
-		if ((queues != null) && (queues.size() > 0)) {
-			return queues.get(0);
-		}
-		return null;
-	}
-
-	@JsonIgnore
-	public QueueInfo getLastQueue() {
-		if ((queues != null) && (queues.size() > 0)) {
-			return queues.get(queues.size() - 1);
-		}
-		return null;
-	}
-
-	@JsonIgnore
-	public UUID getLastQueueId() {
-		QueueInfo q = getLastQueue();
-		if (q != null) {
-			return q.getQueue();
-		}
-		return null;
-	}
-
-	@JsonSerialize(include = Inclusion.NON_NULL)
-	public UUID getQueue() {
-		return queue;
-	}
-
-	public void setQueue(UUID queue) {
-		this.queue = queue;
-	}
-
-	@JsonSerialize(include = Inclusion.NON_NULL)
-	public UUID getConsumer() {
-		return consumer;
-	}
-
-	public void setConsumer(UUID consumer) {
-		this.consumer = consumer;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3ccbfd8a/sdks/java/src/main/java/org/usergrid/java/client/response/ClientCredentialsInfo.java
----------------------------------------------------------------------
diff --git a/sdks/java/src/main/java/org/usergrid/java/client/response/ClientCredentialsInfo.java b/sdks/java/src/main/java/org/usergrid/java/client/response/ClientCredentialsInfo.java
deleted file mode 100644
index 2724977..0000000
--- a/sdks/java/src/main/java/org/usergrid/java/client/response/ClientCredentialsInfo.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.usergrid.java.client.response;
-
-import static org.usergrid.java.client.utils.JsonUtils.toJsonString;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-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/incubator-usergrid/blob/3ccbfd8a/sdks/java/src/main/java/org/usergrid/java/client/response/QueueInfo.java
----------------------------------------------------------------------
diff --git a/sdks/java/src/main/java/org/usergrid/java/client/response/QueueInfo.java b/sdks/java/src/main/java/org/usergrid/java/client/response/QueueInfo.java
deleted file mode 100644
index d4963c2..0000000
--- a/sdks/java/src/main/java/org/usergrid/java/client/response/QueueInfo.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.usergrid.java.client.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/incubator-usergrid/blob/3ccbfd8a/sdks/java/src/main/java/org/usergrid/java/client/utils/JsonUtils.java
----------------------------------------------------------------------
diff --git a/sdks/java/src/main/java/org/usergrid/java/client/utils/JsonUtils.java b/sdks/java/src/main/java/org/usergrid/java/client/utils/JsonUtils.java
deleted file mode 100644
index 00b95f3..0000000
--- a/sdks/java/src/main/java/org/usergrid/java/client/utils/JsonUtils.java
+++ /dev/null
@@ -1,166 +0,0 @@
-package org.usergrid.java.client.utils;
-
-import java.io.IOException;
-import java.util.Map;
-import java.util.UUID;
-
-import com.fasterxml.jackson.core.JsonGenerationException;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;
-import org.usergrid.java.client.exception.ClientException;
-
-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/incubator-usergrid/blob/3ccbfd8a/sdks/java/src/main/java/org/usergrid/java/client/utils/MapUtils.java
----------------------------------------------------------------------
diff --git a/sdks/java/src/main/java/org/usergrid/java/client/utils/MapUtils.java b/sdks/java/src/main/java/org/usergrid/java/client/utils/MapUtils.java
deleted file mode 100644
index af04a6c..0000000
--- a/sdks/java/src/main/java/org/usergrid/java/client/utils/MapUtils.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.usergrid.java.client.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/incubator-usergrid/blob/3ccbfd8a/sdks/java/src/main/java/org/usergrid/java/client/utils/ObjectUtils.java
----------------------------------------------------------------------
diff --git a/sdks/java/src/main/java/org/usergrid/java/client/utils/ObjectUtils.java b/sdks/java/src/main/java/org/usergrid/java/client/utils/ObjectUtils.java
deleted file mode 100644
index 8ef65b1..0000000
--- a/sdks/java/src/main/java/org/usergrid/java/client/utils/ObjectUtils.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.usergrid.java.client.utils;
-
-import java.util.Map;
-
-public class ObjectUtils {
-
-	public static boolean isEmpty(Object s) {
-		if (s == null) {
-			return true;
-		}
-		if ((s instanceof String) && (((String) s).trim().length() == 0)) {
-			return true;
-		}
-		if (s instanceof Map) {
-			return ((Map<?, ?>) s).isEmpty();
-		}
-		return false;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3ccbfd8a/sdks/java/src/main/java/org/usergrid/java/client/utils/UrlUtils.java
----------------------------------------------------------------------
diff --git a/sdks/java/src/main/java/org/usergrid/java/client/utils/UrlUtils.java b/sdks/java/src/main/java/org/usergrid/java/client/utils/UrlUtils.java
deleted file mode 100644
index a64fb96..0000000
--- a/sdks/java/src/main/java/org/usergrid/java/client/utils/UrlUtils.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package org.usergrid.java.client.utils;
-
-import static java.net.URLEncoder.encode;
-import static org.usergrid.java.client.utils.ObjectUtils.isEmpty;
-
-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.usergrid.java.client.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;
-    }
-
-}