Repository: usergrid Updated Branches: refs/heads/master fdc10b784 -> 9943e4bcb
http://git-wip-us.apache.org/repos/asf/usergrid/blob/9943e4bc/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/entities/User.java ---------------------------------------------------------------------- diff --git a/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/entities/User.java b/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/entities/User.java deleted file mode 100644 index b6cd22b..0000000 --- a/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/entities/User.java +++ /dev/null @@ -1,158 +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.usergrid.java.client.entities; - -import static com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion.NON_NULL; -import static org.usergrid.java.client.utils.JsonUtils.getBooleanProperty; -import static org.usergrid.java.client.utils.JsonUtils.getStringProperty; -import static org.usergrid.java.client.utils.JsonUtils.setBooleanProperty; -import static org.usergrid.java.client.utils.JsonUtils.setStringProperty; - -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -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 User() { - super(); - setType(ENTITY_TYPE); - } - - public User(Entity entity) { - super(); - 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_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; - } - - @JsonSerialize(include = NON_NULL) - public String getUsername() { - return getStringProperty(properties, PROPERTY_USERNAME); - } - - public void setUsername(String username) { - setStringProperty(properties, PROPERTY_USERNAME, username); - } - - @JsonSerialize(include = NON_NULL) - public String getName() { - return getStringProperty(properties, PROPERTY_NAME); - } - - public void setName(String name) { - setStringProperty(properties, PROPERTY_NAME, name); - } - - @JsonSerialize(include = NON_NULL) - public String getEmail() { - return getStringProperty(properties, PROPERTY_EMAIL); - } - - public void setEmail(String email) { - setStringProperty(properties, PROPERTY_EMAIL, email); - } - - @JsonSerialize(include = NON_NULL) - public Boolean isActivated() { - return getBooleanProperty(properties, PROPERTY_ACTIVATED); - } - - public void setActivated(Boolean activated) { - setBooleanProperty(properties, PROPERTY_ACTIVATED, activated); - } - - @JsonSerialize(include = NON_NULL) - public Boolean isDisabled() { - return getBooleanProperty(properties, PROPERTY_DISABLED); - } - - public void setDisabled(Boolean disabled) { - setBooleanProperty(properties, PROPERTY_DISABLED, disabled); - } - - @JsonSerialize(include = NON_NULL) - public String getFirstname() { - return getStringProperty(properties, PROPERTY_FIRSTNAME); - } - - public void setFirstname(String firstname) { - setStringProperty(properties, PROPERTY_FIRSTNAME, firstname); - } - - @JsonSerialize(include = NON_NULL) - public String getMiddlename() { - return getStringProperty(properties, PROPERTY_MIDDLENAME); - } - - public void setMiddlename(String middlename) { - setStringProperty(properties, PROPERTY_MIDDLENAME, middlename); - } - - @JsonSerialize(include = NON_NULL) - public String getLastname() { - return getStringProperty(properties, PROPERTY_LASTNAME); - } - - public void setLastname(String lastname) { - setStringProperty(properties, PROPERTY_LASTNAME, lastname); - } - - @JsonSerialize(include = NON_NULL) - public String getPicture() { - return getStringProperty(properties, PROPERTY_PICTURE); - } - - public void setPicture(String picture) { - setStringProperty(properties, PROPERTY_PICTURE, picture); - } - -} http://git-wip-us.apache.org/repos/asf/usergrid/blob/9943e4bc/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/exception/ClientException.java ---------------------------------------------------------------------- diff --git a/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/exception/ClientException.java b/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/exception/ClientException.java deleted file mode 100644 index 834f11a..0000000 --- a/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/exception/ClientException.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.usergrid.java.client.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/9943e4bc/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/response/AggregateCounter.java ---------------------------------------------------------------------- diff --git a/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/response/AggregateCounter.java b/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/response/AggregateCounter.java deleted file mode 100644 index 4453e72..0000000 --- a/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/response/AggregateCounter.java +++ /dev/null @@ -1,52 +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.usergrid.java.client.response; - -import static org.usergrid.java.client.utils.JsonUtils.toJsonString; - -public class AggregateCounter { - - private long timestamp; - private long value; - - 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/9943e4bc/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/response/AggregateCounterSet.java ---------------------------------------------------------------------- diff --git a/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/response/AggregateCounterSet.java b/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/response/AggregateCounterSet.java deleted file mode 100644 index 6dd0596..0000000 --- a/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/response/AggregateCounterSet.java +++ /dev/null @@ -1,111 +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.usergrid.java.client.response; - -import static org.usergrid.java.client.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(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/9943e4bc/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/response/ApiResponse.java ---------------------------------------------------------------------- diff --git a/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/response/ApiResponse.java b/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/response/ApiResponse.java deleted file mode 100644 index 33247d1..0000000 --- a/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/response/ApiResponse.java +++ /dev/null @@ -1,421 +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.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/usergrid/blob/9943e4bc/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/response/ClientCredentialsInfo.java ---------------------------------------------------------------------- diff --git a/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/response/ClientCredentialsInfo.java b/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/response/ClientCredentialsInfo.java deleted file mode 100644 index 475f653..0000000 --- a/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/response/ClientCredentialsInfo.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.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/usergrid/blob/9943e4bc/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/response/QueueInfo.java ---------------------------------------------------------------------- diff --git a/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/response/QueueInfo.java b/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/response/QueueInfo.java deleted file mode 100644 index 572cff9..0000000 --- a/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/response/QueueInfo.java +++ /dev/null @@ -1,44 +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.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/usergrid/blob/9943e4bc/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/utils/JsonUtils.java ---------------------------------------------------------------------- diff --git a/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/utils/JsonUtils.java b/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/utils/JsonUtils.java deleted file mode 100644 index dc14251..0000000 --- a/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/utils/JsonUtils.java +++ /dev/null @@ -1,182 +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.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/usergrid/blob/9943e4bc/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/utils/MapUtils.java ---------------------------------------------------------------------- diff --git a/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/utils/MapUtils.java b/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/utils/MapUtils.java deleted file mode 100644 index 3b647e5..0000000 --- a/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/utils/MapUtils.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.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/usergrid/blob/9943e4bc/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/utils/ObjectUtils.java ---------------------------------------------------------------------- diff --git a/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/utils/ObjectUtils.java b/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/utils/ObjectUtils.java deleted file mode 100644 index e011f8c..0000000 --- a/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/utils/ObjectUtils.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.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/usergrid/blob/9943e4bc/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/utils/UrlUtils.java ---------------------------------------------------------------------- diff --git a/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/utils/UrlUtils.java b/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/utils/UrlUtils.java deleted file mode 100644 index 0b2fd62..0000000 --- a/sdks/usergrid-java-sdk-0.0.6/src/main/java/org/usergrid/java/client/utils/UrlUtils.java +++ /dev/null @@ -1,124 +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.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; - } - -}
