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:21:43 UTC
[33/96] [abbrv] [partial] Change package namespace to
org.apache.usergrid
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Application.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Application.java b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Application.java
new file mode 100644
index 0000000..9ead59c
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Application.java
@@ -0,0 +1,609 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * 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.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.entities;
+
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.usergrid.persistence.TypedEntity;
+import org.apache.usergrid.persistence.annotations.EntityCollection;
+import org.apache.usergrid.persistence.annotations.EntityDictionary;
+import org.apache.usergrid.persistence.annotations.EntityProperty;
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+
+
+/** Applications represent the topmost container for all entities. */
+@XmlRootElement
+public class Application extends TypedEntity {
+
+ public static final String ENTITY_TYPE = "application";
+
+ public static final String COLLECTION_USERS = "users";
+
+ public static final String COLLECTION_GROUPS = "groups";
+
+ public static final String COLLECTION_ASSETS = "assets";
+
+ public static final String COLLECTION_ACTIVITIES = "activities";
+
+ @EntityProperty(indexed = true, fulltextIndexed = false, required = true, mutable = false, aliasProperty = true,
+ basic = true)
+ protected String name;
+
+ @EntityProperty(basic = true, indexed = false)
+ protected String title;
+
+ @EntityProperty(basic = true, indexed = false)
+ protected Long accesstokenttl;
+
+ @EntityProperty(indexed = false)
+ protected String description;
+
+ @EntityDictionary(keyType = java.lang.String.class)
+ protected Set<String> collections;
+
+ @EntityDictionary(keyType = java.lang.String.class, valueType = java.lang.String.class)
+ protected Map<String, String> rolenames;
+
+ @EntityDictionary(keyType = java.lang.String.class)
+ protected Set<String> counters;
+
+ @EntityProperty(indexed = false)
+ protected Boolean activated;
+
+ @EntityProperty(indexed = false)
+ protected Boolean disabled;
+
+ @EntityProperty(name = "allow_open_registration", indexed = false)
+ protected Boolean allowOpenRegistration;
+
+ @EntityProperty(name = "registration_requires_email_confirmation", indexed = false)
+ protected Boolean registrationRequiresEmailConfirmation;
+
+ @EntityProperty(name = "registration_requires_admin_approval", indexed = false)
+ protected Boolean registrationRequiresAdminApproval;
+
+ @EntityProperty(name = "notify_admin_of_new_users", indexed = false)
+ protected Boolean notifyAdminOfNewUsers;
+
+ @EntityDictionary(keyType = java.lang.String.class, valueType = OAuthProvider.class)
+ protected Map<String, OAuthProvider> oauthproviders;
+
+ @EntityDictionary(keyType = java.lang.String.class, valueType = java.lang.String.class)
+ protected Map<String, String> credentials;
+
+ @EntityDictionary(keyType = java.lang.String.class, valueType = WebHook.class)
+ protected Map<String, WebHook> webhooks;
+
+ @EntityCollection(type = "activity", reversed = true, sort = "published desc", indexingDynamicDictionaries = true)
+ protected List<UUID> activities;
+
+ @EntityCollection(type = "asset", indexingDynamicDictionaries = true)
+ protected List<UUID> assets;
+
+ @EntityCollection(type = "event", indexingDynamicDictionaries = true)
+ protected List<UUID> events;
+
+ @EntityCollection(type = "folder", indexingDynamicDictionaries = true)
+ protected List<UUID> folders;
+
+ @EntityCollection(type = "group")
+ protected List<UUID> groups;
+
+ @EntityCollection(type = "user", dictionariesIndexed = { "aliases" })
+ protected List<UUID> users;
+
+ @EntityCollection(type = "device")
+ protected List<UUID> devices;
+
+ @EntityCollection(type = "notification")
+ protected List<UUID> notifications;
+
+
+ public Application() {
+ // id = UUIDUtils.newTimeUUID();
+ }
+
+
+ public Application( UUID id ) {
+ uuid = id;
+ }
+
+
+ @Override
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public String getName() {
+ return name;
+ }
+
+
+ public void setName( String name ) {
+ this.name = name;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public String getTitle() {
+ return title;
+ }
+
+
+ public void setTitle( String title ) {
+ this.title = title;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public String getDescription() {
+ return description;
+ }
+
+
+ public void setDescription( String description ) {
+ this.description = description;
+ }
+
+
+ public boolean activated() {
+ return ( activated != null ) && activated;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public Boolean getActivated() {
+ return activated;
+ }
+
+
+ public void setActivated( Boolean activated ) {
+ this.activated = activated;
+ }
+
+
+ public boolean disabled() {
+ return ( disabled != null ) && disabled;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public Boolean getDisabled() {
+ return disabled;
+ }
+
+
+ public void setDisabled( Boolean disabled ) {
+ this.disabled = disabled;
+ }
+
+
+ public boolean allowOpenRegistration() {
+ return ( allowOpenRegistration != null ) && allowOpenRegistration;
+ }
+
+
+ @JsonProperty("allow_open_registration")
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public Boolean getAllowOpenRegistration() {
+ return allowOpenRegistration;
+ }
+
+
+ @JsonProperty("allow_open_registration")
+ public void setAllowOpenRegistration( Boolean allowOpenRegistration ) {
+ this.allowOpenRegistration = allowOpenRegistration;
+ }
+
+
+ public boolean registrationRequiresEmailConfirmation() {
+ return ( registrationRequiresEmailConfirmation != null ) && registrationRequiresEmailConfirmation;
+ }
+
+
+ @JsonProperty("registration_requires_email_confirmation")
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public Boolean getRegistrationRequiresEmailConfirmation() {
+ return registrationRequiresEmailConfirmation;
+ }
+
+
+ @JsonProperty("registration_requires_email_confirmation")
+ public void setRegistrationRequiresEmailConfirmation( Boolean registrationRequiresEmailConfirmation ) {
+ this.registrationRequiresEmailConfirmation = registrationRequiresEmailConfirmation;
+ }
+
+
+ public boolean registrationRequiresAdminApproval() {
+ return ( registrationRequiresAdminApproval != null ) && registrationRequiresAdminApproval;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ @JsonProperty("registration_requires_admin_approval")
+ public Boolean getRegistrationRequiresAdminApproval() {
+ return registrationRequiresAdminApproval;
+ }
+
+
+ @JsonProperty("registration_requires_admin_approval")
+ public void setRegistrationRequiresAdminApproval( Boolean registrationRequiresAdminApproval ) {
+ this.registrationRequiresAdminApproval = registrationRequiresAdminApproval;
+ }
+
+
+ public boolean notifyAdminOfNewUsers() {
+ return ( notifyAdminOfNewUsers != null ) && notifyAdminOfNewUsers;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ @JsonProperty("notify_admin_of_new_users")
+ public Boolean getNotifyAdminOfNewUsers() {
+ return notifyAdminOfNewUsers;
+ }
+
+
+ @JsonProperty("notify_admin_of_new_users")
+ public void setNotifyAdminOfNewUsers( Boolean notifyAdminOfNewUsers ) {
+ this.notifyAdminOfNewUsers = notifyAdminOfNewUsers;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public List<UUID> getUsers() {
+ return users;
+ }
+
+
+ public void setUsers( List<UUID> users ) {
+ this.users = users;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public List<UUID> getGroups() {
+ return groups;
+ }
+
+
+ public void setGroups( List<UUID> groups ) {
+ this.groups = groups;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public Set<String> getCollections() {
+ return collections;
+ }
+
+
+ public void setCollections( Set<String> collections ) {
+ this.collections = collections;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public Map<String, String> getRolenames() {
+ return rolenames;
+ }
+
+
+ public void setRolenames( Map<String, String> rolenames ) {
+ this.rolenames = rolenames;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public Set<String> getCounters() {
+ return counters;
+ }
+
+
+ public void setCounters( Set<String> counters ) {
+ this.counters = counters;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public List<UUID> getAssets() {
+ return assets;
+ }
+
+
+ public void setAssets( List<UUID> assets ) {
+ this.assets = assets;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public Map<String, String> getCredentials() {
+ return credentials;
+ }
+
+
+ public void setCredentials( Map<String, String> credentials ) {
+ this.credentials = credentials;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public List<UUID> getActivities() {
+ return activities;
+ }
+
+
+ public void setActivities( List<UUID> activities ) {
+ this.activities = activities;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public List<UUID> getFolders() {
+ return folders;
+ }
+
+
+ public void setFolders( List<UUID> folders ) {
+ this.folders = folders;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public List<UUID> getEvents() {
+ return events;
+ }
+
+
+ public void setEvents( List<UUID> events ) {
+ this.events = events;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public List<UUID> getDevices() {
+ return devices;
+ }
+
+
+ public void setDevices( List<UUID> devices ) {
+ this.devices = devices;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public Map<String, OAuthProvider> getOauthproviders() {
+ return oauthproviders;
+ }
+
+
+ public void setOauthproviders( Map<String, OAuthProvider> oauthproviders ) {
+ this.oauthproviders = oauthproviders;
+ }
+
+
+ /** Get the organization name of this app */
+ public String getOrganizationName() {
+ String[] names = name.split( "/" );
+
+ if ( names.length == 2 ) {
+ return names[0];
+ }
+
+ return null;
+ }
+
+
+ /** Get the application name of this app */
+ public String getApplicationName() {
+ String[] names = name.split( "/" );
+
+ if ( names.length == 2 ) {
+ return names[1];
+ }
+
+ return null;
+ }
+
+
+ /** @return the accesstokenttl */
+ public Long getAccesstokenttl() {
+ return accesstokenttl;
+ }
+
+
+ /** @param accesstokenttl the accesstokenttl to set */
+ public void setAccesstokenttl( Long accesstokenttl ) {
+ this.accesstokenttl = accesstokenttl;
+ }
+
+
+ @XmlRootElement
+ public static class OAuthProvider {
+ String clientId;
+ String clientSecret;
+ String redirectUris;
+ String javaScriptOrigins;
+ String authorizationEndpointUrl;
+ String accessTokenEndpointUrl;
+ String requestTokenEndpointUrl;
+ String version = "1.0a";
+
+
+ public OAuthProvider() {
+ }
+
+
+ public OAuthProvider( String clientId, String clientSecret ) {
+ this.clientId = clientId;
+ this.clientSecret = clientSecret;
+ }
+
+
+ public OAuthProvider( String clientId, String clientSecret, String redirectUris, String javaScriptOrigins ) {
+ this.clientId = clientId;
+ this.clientSecret = clientSecret;
+ this.redirectUris = redirectUris;
+ this.javaScriptOrigins = javaScriptOrigins;
+ }
+
+
+ public OAuthProvider( String clientId, String clientSecret, String redirectUris, String javaScriptOrigins,
+ String authorizationEndpointUrl, String accessTokenEndpointUrl,
+ String requestTokenEndpointUrl ) {
+ this.clientId = clientId;
+ this.clientSecret = clientSecret;
+ this.redirectUris = redirectUris;
+ this.javaScriptOrigins = javaScriptOrigins;
+ this.authorizationEndpointUrl = authorizationEndpointUrl;
+ this.accessTokenEndpointUrl = accessTokenEndpointUrl;
+ this.requestTokenEndpointUrl = requestTokenEndpointUrl;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public String getVersion() {
+ return version;
+ }
+
+
+ public void setVersion( String version ) {
+ this.version = version;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public String getClientId() {
+ return clientId;
+ }
+
+
+ public void setClientId( String clientId ) {
+ this.clientId = clientId;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public String getClientSecret() {
+ return clientSecret;
+ }
+
+
+ public void setClientSecret( String clientSecret ) {
+ this.clientSecret = clientSecret;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public String getRedirectUris() {
+ return redirectUris;
+ }
+
+
+ public void setRedirectUris( String redirectUris ) {
+ this.redirectUris = redirectUris;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public String getJavaScriptOrigins() {
+ return javaScriptOrigins;
+ }
+
+
+ public void setJavaScriptOrigins( String javaScriptOrigins ) {
+ this.javaScriptOrigins = javaScriptOrigins;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public String getAuthorizationEndpointUrl() {
+ return authorizationEndpointUrl;
+ }
+
+
+ public void setAuthorizationEndpointUrl( String authorizationEndpointUrl ) {
+ this.authorizationEndpointUrl = authorizationEndpointUrl;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public String getAccessTokenEndpointUrl() {
+ return accessTokenEndpointUrl;
+ }
+
+
+ public void setAccessTokenEndpointUrl( String accessTokenEndpointUrl ) {
+ this.accessTokenEndpointUrl = accessTokenEndpointUrl;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public String getRequestTokenEndpointUrl() {
+ return requestTokenEndpointUrl;
+ }
+
+
+ public void setRequestTokenEndpointUrl( String requestTokenEndpointUrl ) {
+ this.requestTokenEndpointUrl = requestTokenEndpointUrl;
+ }
+
+
+ @Override
+ public String toString() {
+ return "OAuthProvider [clientId=" + clientId + ", clientSecret=" + clientSecret + ", redirectUris="
+ + redirectUris + ", javaScriptOrigins=" + javaScriptOrigins + ", authorizationEndpointUrl="
+ + authorizationEndpointUrl + ", accessTokenEndpointUrl=" + accessTokenEndpointUrl
+ + ", requestTokenEndpointUrl=" + requestTokenEndpointUrl + ", version=" + version + "]";
+ }
+ }
+
+
+ @XmlRootElement
+ public static class WebHook {
+ String type;
+ String uri;
+
+
+ public WebHook() {
+ }
+
+
+ public String getType() {
+ return type;
+ }
+
+
+ public void setType( String type ) {
+ this.type = type;
+ }
+
+
+ public String getUri() {
+ return uri;
+ }
+
+
+ public void setUri( String uri ) {
+ this.uri = uri;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Asset.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Asset.java b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Asset.java
new file mode 100644
index 0000000..fcaf6ce
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Asset.java
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * 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.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.entities;
+
+
+import java.util.Set;
+import java.util.UUID;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.usergrid.persistence.TypedEntity;
+import org.apache.usergrid.persistence.annotations.EntityDictionary;
+import org.apache.usergrid.persistence.annotations.EntityProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+
+
+/**
+ * Asset entity for representing file-like objects.
+ *
+ * @deprecated
+ */
+@XmlRootElement
+public class Asset extends TypedEntity {
+
+ public static final String ENTITY_TYPE = "asset";
+
+ @EntityProperty(required = true, indexed = true, mutable = false)
+ UUID owner;
+
+ @EntityProperty(indexed = true, fulltextIndexed = false, required = true, aliasProperty = true,
+ pathBasedName = true, mutable = false, unique = true)
+ protected String path;
+
+ @EntityDictionary(keyType = java.lang.String.class)
+ protected Set<String> connections;
+
+
+ public Asset() {
+ // id = UUIDUtils.newTimeUUID();
+ }
+
+
+ public Asset( UUID id ) {
+ this.uuid = id;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public String getPath() {
+ return path;
+ }
+
+
+ public void setPath( String name ) {
+ path = name;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public UUID getOwner() {
+ return owner;
+ }
+
+
+ public void setOwner( UUID owner ) {
+ this.owner = owner;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public Set<String> getConnections() {
+ return connections;
+ }
+
+
+ public void setConnections( Set<String> connections ) {
+ this.connections = connections;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Device.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Device.java b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Device.java
new file mode 100644
index 0000000..01a4a36
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Device.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * 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.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.entities;
+
+
+import java.util.List;
+import java.util.UUID;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.usergrid.persistence.TypedEntity;
+import org.apache.usergrid.persistence.annotations.EntityCollection;
+import org.apache.usergrid.persistence.annotations.EntityProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+
+
+/** The Device entity class for representing devices in the service. */
+@XmlRootElement
+public class Device extends TypedEntity {
+
+ public static final String ENTITY_TYPE = "device";
+ public static final String RECEIPTS_COLLECTION = "receipts";
+
+ @EntityProperty(indexed = true, fulltextIndexed = false, required = false, aliasProperty = true, unique = true,
+ basic = true)
+ protected String name;
+
+ @EntityCollection(type = "user", linkedCollection = "devices")
+ protected List<UUID> users;
+
+ @EntityCollection(type = "receipt")
+ protected List<UUID> receipts;
+
+ @EntityProperty
+ protected Integer badge;
+
+
+ public Device() {
+ // id = UUIDUtils.newTimeUUID();
+ }
+
+
+ public Device( UUID id ) {
+ uuid = id;
+ }
+
+
+ @Override
+ @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<UUID> getUsers() {
+ return users;
+ }
+
+
+ public void setUsers( List<UUID> users ) {
+ this.users = users;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public List<UUID> getReceipts() {
+ return receipts;
+ }
+
+
+ public void setReceipts( List<UUID> receipts ) {
+ this.receipts = receipts;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public Integer getBadge() {
+ return badge;
+ }
+
+
+ public void setBadge( Integer badge ) {
+ this.badge = badge;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Event.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Event.java b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Event.java
new file mode 100644
index 0000000..2ab2882
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Event.java
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * 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.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.entities;
+
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.usergrid.persistence.TypedEntity;
+import org.apache.usergrid.persistence.annotations.EntityDictionary;
+import org.apache.usergrid.persistence.annotations.EntityProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+
+
+/** An event type posted by the application. */
+@XmlRootElement
+public class Event extends TypedEntity {
+
+ public static final String ENTITY_TYPE = "event";
+
+ @EntityProperty(required = true, indexed = true, mutable = false)
+ long timestamp = System.currentTimeMillis();
+
+ @EntityProperty(required = false, indexed = true, mutable = false)
+ UUID user;
+
+ @EntityProperty(required = false, indexed = true, mutable = false)
+ UUID group;
+
+ @EntityProperty(fulltextIndexed = false, required = false, mutable = false, indexed = true)
+ String category;
+
+ @EntityProperty(indexed = false, required = false, mutable = false)
+ Map<String, Integer> counters;
+
+ @EntityProperty(indexed = true, required = false, mutable = false)
+ String message;
+
+ @EntityDictionary(keyType = java.lang.String.class)
+ protected Set<String> connections;
+
+
+ public Event() {
+ // id = UUIDUtils.newTimeUUID();
+ }
+
+
+ public Event( UUID id ) {
+ uuid = id;
+ }
+
+
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+
+ public void setTimestamp( long timestamp ) {
+ if ( timestamp == 0 ) {
+ timestamp = System.currentTimeMillis();
+ }
+ this.timestamp = timestamp;
+ }
+
+
+ @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 Map<String, Integer> getCounters() {
+ return counters;
+ }
+
+
+ public void setCounters( Map<String, Integer> counters ) {
+ this.counters = counters;
+ }
+
+
+ public void addCounter( String name, int value ) {
+ if ( counters == null ) {
+ counters = new HashMap<String, Integer>();
+ }
+ counters.put( name, value );
+ }
+
+
+ public String getMessage() {
+ return message;
+ }
+
+
+ public void setMessage( String message ) {
+ this.message = message;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public Set<String> getConnections() {
+ return connections;
+ }
+
+
+ public void setConnections( Set<String> connections ) {
+ this.connections = connections;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Folder.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Folder.java b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Folder.java
new file mode 100644
index 0000000..6ae91e0
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Folder.java
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * 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.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.entities;
+
+
+import java.util.Set;
+import java.util.UUID;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.usergrid.persistence.TypedEntity;
+import org.apache.usergrid.persistence.annotations.EntityDictionary;
+import org.apache.usergrid.persistence.annotations.EntityProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+
+
+/**
+ * Asset entity for representing folder-like objects.
+ *
+ * @deprecated
+ */
+@XmlRootElement
+public class Folder extends TypedEntity {
+
+ public static final String ENTITY_TYPE = "asset";
+
+ @EntityProperty(required = true, indexed = true, mutable = false)
+ UUID owner;
+
+ @EntityProperty(indexed = true, fulltextIndexed = false, required = true, aliasProperty = true,
+ pathBasedName = true, mutable = false, unique = true)
+ protected String path;
+
+ @EntityDictionary(keyType = java.lang.String.class)
+ protected Set<String> connections;
+
+
+ public Folder() {
+ // id = UUIDUtils.newTimeUUID();
+ }
+
+
+ public Folder( UUID id ) {
+ this.uuid = id;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public String getPath() {
+ return path;
+ }
+
+
+ public void setPath( String name ) {
+ path = name;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public UUID getOwner() {
+ return owner;
+ }
+
+
+ public void setOwner( UUID owner ) {
+ this.owner = owner;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public Set<String> getConnections() {
+ return connections;
+ }
+
+
+ public void setConnections( Set<String> connections ) {
+ this.connections = connections;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Group.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Group.java b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Group.java
new file mode 100644
index 0000000..8993d46
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Group.java
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * 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.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.entities;
+
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.usergrid.persistence.CredentialsInfo;
+import org.apache.usergrid.persistence.TypedEntity;
+import org.apache.usergrid.persistence.annotations.EntityCollection;
+import org.apache.usergrid.persistence.annotations.EntityDictionary;
+import org.apache.usergrid.persistence.annotations.EntityProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+
+
+/** Groups are used to organize users. */
+@XmlRootElement
+public class Group extends TypedEntity {
+
+ public static final String ENTITY_TYPE = "group";
+
+ public static final String CONNECTION_MEMBERSHIP = "membership";
+
+ @EntityProperty(indexed = true, fulltextIndexed = false, required = true, aliasProperty = true,
+ pathBasedName = true, mutable = true, unique = true, basic = true)
+ protected String path;
+
+ @EntityDictionary(keyType = java.lang.String.class)
+ protected Set<String> connections;
+
+ @EntityDictionary(keyType = java.lang.String.class, valueType = java.lang.String.class)
+ protected Map<String, String> rolenames;
+
+ @EntityDictionary(keyType = java.lang.String.class)
+ protected Set<String> permissions;
+
+ @EntityDictionary(keyType = java.lang.String.class, valueType = CredentialsInfo.class)
+ protected Map<String, CredentialsInfo> credentials;
+
+ @EntityCollection(type = "user", linkedCollection = "groups")
+ protected List<UUID> users;
+
+ @EntityCollection(type = "activity", reversed = true, sort = "published desc", indexingDynamicDictionaries = true)
+ protected List<UUID> activities;
+
+ @EntityCollection(type = "activity", reversed = true, sort = "published desc", indexingDynamicDictionaries = true)
+ protected List<UUID> feed;
+
+ @EntityCollection(type = "role", linkedCollection = "groups", indexingDynamicDictionaries = true)
+ protected List<UUID> roles;
+
+
+ public Group() {
+ // id = UUIDUtils.newTimeUUID();
+ }
+
+
+ public Group( UUID id ) {
+ uuid = id;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public String getPath() {
+ return path;
+ }
+
+
+ public void setPath( String path ) {
+ this.path = path;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public List<UUID> getUsers() {
+ return users;
+ }
+
+
+ public void setUsers( List<UUID> users ) {
+ this.users = users;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public Set<String> getConnections() {
+ return connections;
+ }
+
+
+ public void setConnections( Set<String> connections ) {
+ this.connections = connections;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public Map<String, String> getRolenames() {
+ return rolenames;
+ }
+
+
+ public void setRolenames( Map<String, String> rolenames ) {
+ this.rolenames = rolenames;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public List<UUID> getActivities() {
+ return activities;
+ }
+
+
+ public void setActivities( List<UUID> activities ) {
+ this.activities = activities;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public List<UUID> getFeed() {
+ return feed;
+ }
+
+
+ public void setFeed( List<UUID> feed ) {
+ this.feed = feed;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public Map<String, CredentialsInfo> getCredentials() {
+ return credentials;
+ }
+
+
+ public void setCredentials( Map<String, CredentialsInfo> credentials ) {
+ this.credentials = credentials;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public List<UUID> getRoles() {
+ return roles;
+ }
+
+
+ public void setRoles( List<UUID> roles ) {
+ this.roles = roles;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/apache/usergrid/persistence/entities/JobData.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/JobData.java b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/JobData.java
new file mode 100644
index 0000000..e9cbc9e
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/JobData.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * 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.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.entities;
+
+
+import org.apache.usergrid.persistence.TypedEntity;
+import org.apache.usergrid.persistence.annotations.EntityProperty;
+
+
+/**
+ * All job data should be contained in this entity
+ *
+ * @author tnine
+ */
+public class JobData extends TypedEntity {
+
+
+ @EntityProperty(required = true, basic = true, indexed = true)
+ private String jobName;
+
+
+ /**
+ * @param jobName
+ * @param startTime
+ */
+ public JobData() {
+ super();
+ }
+
+
+ /** @return the jobName */
+ public String getJobName() {
+ return jobName;
+ }
+
+
+ /** @param jobName the jobName to set */
+ public void setJobName( String jobName ) {
+ this.jobName = jobName;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/apache/usergrid/persistence/entities/JobStat.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/JobStat.java b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/JobStat.java
new file mode 100644
index 0000000..7ed306f
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/JobStat.java
@@ -0,0 +1,175 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * 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.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.entities;
+
+
+import java.util.UUID;
+
+import org.apache.usergrid.persistence.TypedEntity;
+import org.apache.usergrid.persistence.annotations.EntityProperty;
+
+
+/**
+ * All job execution info should be in this entity
+ *
+ * @author tnine
+ */
+public class JobStat extends TypedEntity {
+
+
+ @EntityProperty(required = true, basic = true, indexed = true)
+ private String jobName;
+
+ @EntityProperty(required = true, basic = true, indexed = true)
+ private UUID jobId;
+
+ @EntityProperty(required = true, basic = true, indexed = true)
+ private long startTime;
+
+ @EntityProperty(required = true, basic = true, indexed = true)
+ private int runCount;
+
+ @EntityProperty(required = true, basic = true, indexed = true)
+ private int delayCount;
+
+ @EntityProperty(required = true, basic = true, indexed = true)
+ private long duration;
+
+
+ /**
+ * @param jobName
+ * @param startTime
+ */
+ public JobStat() {
+ }
+
+
+ /**
+ * @param jobName
+ * @param jobId
+ */
+ public JobStat( String jobName, UUID jobId ) {
+ super();
+ this.jobName = jobName;
+ this.jobId = jobId;
+ }
+
+
+ /** @return the jobName */
+ public String getJobName() {
+ return jobName;
+ }
+
+
+ /** @param jobName the jobName to set */
+ public void setJobName( String jobName ) {
+ this.jobName = jobName;
+ }
+
+
+ /** @return the fireTime */
+ public long getStartTime() {
+ return startTime;
+ }
+
+
+ /**
+ * Don't set this, it won't accomplish anything. This is overwritten by the job as an audit record
+ *
+ * @param startTime the fireTime to set
+ */
+ public void setStartTime( long startTime ) {
+ this.startTime = startTime;
+ }
+
+
+ /** Increment the run count */
+ public void incrementRuns() {
+ runCount++;
+ }
+
+
+ /** Increment the run count */
+ public void incrementDelays() {
+ delayCount++;
+ }
+
+
+ /** Get the number of times this job has failed */
+ public int getRunCount() {
+ return runCount;
+ }
+
+
+ /**
+ * DON'T CALL THIS, USE THE INRECMENT METHOD!
+ *
+ * @param failCount the failCount to set
+ */
+ public void setRunCount( int runCount ) {
+ this.runCount = runCount;
+ }
+
+
+ /**
+ * Return the total number of attempts that have resulted in an error and not an explicit delay
+ * <p/>
+ * runCount - delayCount
+ */
+ public int getTotalAttempts() {
+ return runCount - delayCount;
+ }
+
+
+ /** @return the delayCount */
+ public int getDelayCount() {
+ return delayCount;
+ }
+
+
+ /**
+ * DON'T CALL THIS, USE THE INRECMENT METHOD!
+ *
+ * @param delayCount the delayCount to set
+ */
+ public void setDelayCount( int delayCount ) {
+ this.delayCount = delayCount;
+ }
+
+
+ /** @return the duration */
+ public long getDuration() {
+ return duration;
+ }
+
+
+ /** @param duration the duration to set */
+ public void setDuration( long duration ) {
+ this.duration = duration;
+ }
+
+
+ /** @return the jobId */
+ public UUID getJobId() {
+ return jobId;
+ }
+
+
+ /** @param jobId the jobId to set */
+ public void setJobId( UUID jobId ) {
+ this.jobId = jobId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Message.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Message.java b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Message.java
new file mode 100644
index 0000000..c540447
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Message.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * 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.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.entities;
+
+
+import java.util.Set;
+import java.util.UUID;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.usergrid.persistence.TypedEntity;
+import org.apache.usergrid.persistence.annotations.EntityDictionary;
+import org.apache.usergrid.persistence.annotations.EntityProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+
+
+/**
+ * A generic Message type for message queue type operations. For status updates and other social actions, use Activity
+ * instead.
+ */
+@XmlRootElement
+public class Message extends TypedEntity {
+
+ public static final String ENTITY_TYPE = "message";
+
+ @EntityProperty(fulltextIndexed = false, required = true, mutable = false, indexed = true)
+ String category;
+
+ @EntityDictionary(keyType = java.lang.String.class)
+ protected Set<String> connections;
+
+
+ public Message() {
+ // id = UUIDUtils.newTimeUUID();
+ }
+
+
+ public Message( UUID id ) {
+ this.uuid = id;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public String getCategory() {
+ return category;
+ }
+
+
+ public void setCategory( String category ) {
+ this.category = category;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public Set<String> getConnections() {
+ return connections;
+ }
+
+
+ public void setConnections( Set<String> connections ) {
+ this.connections = connections;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Role.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Role.java b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Role.java
new file mode 100644
index 0000000..2f96e75
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Role.java
@@ -0,0 +1,153 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * 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.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.entities;
+
+
+import java.util.List;
+import java.util.Set;
+import java.util.UUID;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.usergrid.persistence.TypedEntity;
+import org.apache.usergrid.persistence.annotations.EntityCollection;
+import org.apache.usergrid.persistence.annotations.EntityDictionary;
+import org.apache.usergrid.persistence.annotations.EntityProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+
+
+/** Groups are used to organize users. */
+@XmlRootElement
+public class Role extends TypedEntity {
+
+ public static final String ENTITY_TYPE = "role";
+
+ @EntityProperty(indexed = true, fulltextIndexed = false, required = true, aliasProperty = true, mutable = false,
+ unique = true)
+ protected String name;
+
+ @EntityProperty(mutable = true, indexed = true)
+ protected String roleName;
+
+ @EntityProperty(mutable = true, indexed = true)
+ protected String title;
+
+ @EntityProperty(mutable = true, indexed = true)
+ protected Long inactivity;
+
+ @EntityDictionary(keyType = java.lang.String.class)
+ protected Set<String> permissions;
+
+ @EntityCollection(type = "user", linkedCollection = "roles", indexingDynamicDictionaries = true)
+ protected List<UUID> users;
+
+ @EntityCollection(type = "group", linkedCollection = "roles", indexingDynamicDictionaries = true)
+ protected List<UUID> groups;
+
+
+ public Role() {
+ // id = UUIDUtils.newTimeUUID();
+ }
+
+
+ public Role( String roleName ) {
+ this.roleName = roleName;
+ }
+
+
+ public Role( UUID id ) {
+ this.uuid = id;
+ }
+
+
+ @Override
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public String getName() {
+ return name;
+ }
+
+
+ public void setName( String name ) {
+ this.name = name;
+ }
+
+
+ public String getRoleName() {
+ return roleName;
+ }
+
+
+ public void setRoleName( String roleName ) {
+ this.roleName = roleName;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public String getTitle() {
+ return title;
+ }
+
+
+ public void setTitle( String title ) {
+ this.title = title;
+ }
+
+
+ /** @return the inactivity */
+ public Long getInactivity() {
+ return inactivity;
+ }
+
+
+ /** @param inactivity the inactivity to set */
+ public void setInactivity( Long inactivity ) {
+ this.inactivity = inactivity;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public List<UUID> getUsers() {
+ return users;
+ }
+
+
+ public void setUsers( List<UUID> users ) {
+ this.users = users;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public Set<String> getPermissions() {
+ return permissions;
+ }
+
+
+ public void setPermissions( Set<String> permissions ) {
+ this.permissions = permissions;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public List<UUID> getGroups() {
+ return groups;
+ }
+
+
+ public void setGroups( List<UUID> groups ) {
+ this.groups = groups;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/apache/usergrid/persistence/entities/User.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/User.java b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/User.java
new file mode 100644
index 0000000..13df1ad
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/User.java
@@ -0,0 +1,348 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * 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.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.entities;
+
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.usergrid.persistence.CredentialsInfo;
+import org.apache.usergrid.persistence.TypedEntity;
+import org.apache.usergrid.persistence.annotations.EntityCollection;
+import org.apache.usergrid.persistence.annotations.EntityDictionary;
+import org.apache.usergrid.persistence.annotations.EntityProperty;
+import org.codehaus.jackson.annotate.JsonIgnore;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+
+import static org.apache.commons.lang.StringUtils.isNotBlank;
+
+
+/** The User entity class for representing users in the service. */
+@XmlRootElement
+public class User extends TypedEntity {
+
+ public static final String ENTITY_TYPE = "user";
+
+ public static final String CONNECTION_FOLLOW = "follow";
+
+ public static final String PROPERTY_UUID = "uuid";
+
+ public static final String PROPERTY_EMAIL = "email";
+
+ public static final String PROPERTY_HASHTYPE = "hashtype";
+
+ public static final String HASHTYPE_MD5 = "md5";
+
+ @EntityProperty(indexed = true, fulltextIndexed = false, required = true, aliasProperty = true, unique = true,
+ basic = true)
+ protected String username;
+
+ @EntityProperty(indexed = true, unique = true, basic = true)
+ protected String email;
+
+ @EntityProperty(indexed = true, fulltextIndexed = true)
+ protected String name;
+
+ @EntityProperty(indexed = true)
+ protected Boolean activated;
+
+ @EntityProperty(indexed = true)
+ protected Boolean confirmed;
+
+ @EntityProperty(indexed = true)
+ protected Boolean disabled;
+
+ @EntityProperty(indexed = false)
+ protected String picture;
+
+ /** The time this user was deactivated */
+ @EntityProperty(indexed = true)
+ protected Long deactivated;
+
+ @EntityDictionary(keyType = java.lang.String.class)
+ protected Set<String> connections;
+
+ @EntityDictionary(keyType = java.lang.String.class, valueType = java.lang.String.class)
+ protected Map<String, String> rolenames;
+
+ @EntityDictionary(keyType = java.lang.String.class)
+ protected Set<String> permissions;
+
+ @EntityDictionary(keyType = java.lang.String.class, valueType = CredentialsInfo.class)
+ protected Map<String, CredentialsInfo> credentials;
+
+ @EntityCollection(type = "group", linkedCollection = "users")
+ protected List<UUID> groups;
+
+ @EntityCollection(type = "device", linkedCollection = "users")
+ protected List<UUID> devices;
+
+ @EntityCollection(type = "activity", reversed = true, sort = "published desc", indexingDynamicDictionaries = true)
+ protected List<UUID> activities;
+
+ @EntityCollection(type = "activity", reversed = true, sort = "published desc", indexingDynamicDictionaries = true)
+ protected List<UUID> feed;
+
+ @EntityCollection(type = "role", linkedCollection = "users", indexingDynamicDictionaries = true)
+ protected List<UUID> roles;
+
+ @JsonIgnore
+ @EntityDictionary(keyType = String.class, valueType = CredentialsInfo.class)
+ protected Map<String, CredentialsInfo> credentialsHistory;
+
+
+ public Map<String, CredentialsInfo> getCredentialsHistory() {
+ return credentialsHistory;
+ }
+
+
+ public void setCredentialsHistory( Map<String, CredentialsInfo> credentialsHistory ) {
+ this.credentialsHistory = credentialsHistory;
+ }
+
+
+ public User() {
+ // id = UUIDUtils.newTimeUUID();
+ }
+
+
+ public User( UUID id ) {
+ uuid = id;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public String getUsername() {
+ return username;
+ }
+
+
+ public void setUsername( String username ) {
+ this.username = username;
+ }
+
+
+ @Override
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public String getName() {
+ return name;
+ }
+
+
+ public void setName( String name ) {
+ this.name = name;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public String getEmail() {
+ return email;
+ }
+
+
+ @JsonIgnore
+ public String getDisplayEmailAddress() {
+ if ( isNotBlank( name ) ) {
+ return name + " <" + email + ">";
+ }
+ return email;
+ }
+
+
+ public void setEmail( String email ) {
+ this.email = email;
+ }
+
+
+ public boolean activated() {
+ return ( activated != null ) && activated;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public Boolean getActivated() {
+ return activated;
+ }
+
+
+ public void setActivated( Boolean activated ) {
+ this.activated = activated;
+
+ if ( activated ) {
+ deactivated = null;
+ }
+ }
+
+
+ /** @return the deactivated */
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public Long getDeactivated() {
+ return deactivated;
+ }
+
+
+ /** @param deactivated the deactivated to set */
+ public void setDeactivated( Long deactivated ) {
+ this.deactivated = deactivated;
+ }
+
+
+ public boolean confirmed() {
+ return ( confirmed != null ) && confirmed;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public Boolean getConfirmed() {
+ return confirmed;
+ }
+
+
+ public void setConfirmed( Boolean confirmed ) {
+ this.confirmed = confirmed;
+ }
+
+
+ public boolean disabled() {
+ return ( disabled != null ) && disabled;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public Boolean getDisabled() {
+ return disabled;
+ }
+
+
+ public void setDisabled( Boolean disabled ) {
+ this.disabled = disabled;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public String getPicture() {
+ return picture;
+ }
+
+
+ public void setPicture( String picture ) {
+ this.picture = picture;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public List<UUID> getGroups() {
+ return groups;
+ }
+
+
+ public void setGroups( List<UUID> groups ) {
+ this.groups = groups;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public List<UUID> getDevices() {
+ return devices;
+ }
+
+
+ public void setDevices( List<UUID> devices ) {
+ this.devices = devices;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public Set<String> getConnections() {
+ return connections;
+ }
+
+
+ public void setConnections( Set<String> connections ) {
+ this.connections = connections;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public Map<String, String> getRolenames() {
+ return rolenames;
+ }
+
+
+ public void setRolenames( Map<String, String> rolenames ) {
+ this.rolenames = rolenames;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public Set<String> getPermissions() {
+ return permissions;
+ }
+
+
+ public void setPermissions( Set<String> permissions ) {
+ this.permissions = permissions;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public Map<String, CredentialsInfo> getCredentials() {
+ return credentials;
+ }
+
+
+ public void setCredentials( Map<String, CredentialsInfo> credentials ) {
+ this.credentials = credentials;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public List<UUID> getActivities() {
+ return activities;
+ }
+
+
+ public void setActivities( List<UUID> activities ) {
+ this.activities = activities;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public List<UUID> getFeed() {
+ return feed;
+ }
+
+
+ public void setFeed( List<UUID> feed ) {
+ this.feed = feed;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public List<UUID> getRoles() {
+ return roles;
+ }
+
+
+ public void setRoles( List<UUID> roles ) {
+ this.roles = roles;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/ApplicationAlreadyExistsException.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/ApplicationAlreadyExistsException.java b/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/ApplicationAlreadyExistsException.java
new file mode 100644
index 0000000..788f9a2
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/ApplicationAlreadyExistsException.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * 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.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.exceptions;
+
+
+public class ApplicationAlreadyExistsException extends PersistenceException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ final String applicationName;
+
+
+ public ApplicationAlreadyExistsException( String applicationName ) {
+ super( "Application " + applicationName + " already exists" );
+ this.applicationName = applicationName;
+ }
+
+
+ public String getApplicationName() {
+ return applicationName;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/DuplicateUniquePropertyExistsException.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/DuplicateUniquePropertyExistsException.java b/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/DuplicateUniquePropertyExistsException.java
new file mode 100644
index 0000000..7687dea
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/DuplicateUniquePropertyExistsException.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * 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.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.exceptions;
+
+
+public class DuplicateUniquePropertyExistsException extends PersistenceException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ final String entityType;
+ final String propertyName;
+ final Object propertyValue;
+
+
+ public DuplicateUniquePropertyExistsException( String entityType, String propertyName, Object propertyValue ) {
+ super( "Entity " + entityType + " requires that property named " + propertyName + " be unique, value of "
+ + propertyValue + " exists" );
+ this.entityType = entityType;
+ this.propertyName = propertyName;
+ this.propertyValue = propertyValue;
+ }
+
+
+ public String getEntityType() {
+ return entityType;
+ }
+
+
+ public String getPropertyName() {
+ return propertyName;
+ }
+
+
+ public Object getPropertyValue() {
+ return propertyValue;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/EntityNotFoundException.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/EntityNotFoundException.java b/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/EntityNotFoundException.java
new file mode 100644
index 0000000..385f69b
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/EntityNotFoundException.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * 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.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.exceptions;
+
+
+public class EntityNotFoundException extends PersistenceException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3579346096812510039L;
+
+
+ public EntityNotFoundException() {
+ super();
+ }
+
+
+ public EntityNotFoundException( String message, Throwable cause ) {
+ super( message, cause );
+ }
+
+
+ public EntityNotFoundException( String message ) {
+ super( message );
+ }
+
+
+ public EntityNotFoundException( Throwable cause ) {
+ super( cause );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/LockingException.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/LockingException.java b/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/LockingException.java
new file mode 100644
index 0000000..7d01114
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/LockingException.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * 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.
+ ******************************************************************************/
+/**
+ *
+ */
+package org.apache.usergrid.persistence.exceptions;
+
+
+/** General Exception for locking related operations. */
+public class LockingException extends Exception {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1630572186589575754L;
+
+
+ /**
+ *
+ */
+ public LockingException() {
+ // TODO Auto-generated constructor stub
+ }
+
+
+ /**
+ * @param arg0
+ */
+ public LockingException( String arg0 ) {
+ super( arg0 );
+ // TODO Auto-generated constructor stub
+ }
+
+
+ /**
+ * @param arg0
+ */
+ public LockingException( Throwable arg0 ) {
+ super( arg0 );
+ // TODO Auto-generated constructor stub
+ }
+
+
+ /**
+ * @param arg0
+ * @param arg1
+ */
+ public LockingException( String arg0, Throwable arg1 ) {
+ super( arg0, arg1 );
+ // TODO Auto-generated constructor stub
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/NoFullTextIndexException.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/NoFullTextIndexException.java b/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/NoFullTextIndexException.java
new file mode 100644
index 0000000..793f623
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/NoFullTextIndexException.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * 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.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.exceptions;
+
+
+/**
+ * Thrown when the user attempts to perform a "contains" operation on a field that isn't full text indexed
+ *
+ * @author tnine
+ */
+public class NoFullTextIndexException extends PersistenceException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ final String entityType;
+ final String propertyName;
+
+
+ public NoFullTextIndexException( String entityType, String propertyName ) {
+ super( "Entity '" + entityType + "' with property named '" + propertyName
+ + "' is not full text indexed. You cannot use the 'contains' operand on this field" );
+ this.entityType = entityType;
+ this.propertyName = propertyName;
+ }
+
+
+ public String getEntityType() {
+ return entityType;
+ }
+
+
+ public String getPropertyName() {
+ return propertyName;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/NoIndexException.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/NoIndexException.java b/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/NoIndexException.java
new file mode 100644
index 0000000..2ee5107
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/NoIndexException.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * 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.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.exceptions;
+
+
+/**
+ * Thrown when the user attempts to perform a "contains" operation on a field that isn't full text indexed
+ *
+ * @author tnine
+ */
+public class NoIndexException extends PersistenceException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ final String entityType;
+ final String propertyName;
+
+
+ public NoIndexException( String entityType, String propertyName ) {
+ super( "Entity '" + entityType + "' with property named '" + propertyName
+ + "' is not indexed. You cannot use the this field in queries." );
+ this.entityType = entityType;
+ this.propertyName = propertyName;
+ }
+
+
+ public String getEntityType() {
+ return entityType;
+ }
+
+
+ public String getPropertyName() {
+ return propertyName;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/PersistenceException.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/PersistenceException.java b/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/PersistenceException.java
new file mode 100644
index 0000000..dff5c8a
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/PersistenceException.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * 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.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.exceptions;
+
+
+public class PersistenceException extends Exception {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+
+ public PersistenceException() {
+ super();
+ }
+
+
+ public PersistenceException( String message, Throwable cause ) {
+ super( message, cause );
+ }
+
+
+ public PersistenceException( String message ) {
+ super( message );
+ }
+
+
+ public PersistenceException( Throwable cause ) {
+ super( cause );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/PropertyTypeConversionException.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/PropertyTypeConversionException.java b/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/PropertyTypeConversionException.java
new file mode 100644
index 0000000..90234e5
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/PropertyTypeConversionException.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * 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.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.exceptions;
+
+
+public class PropertyTypeConversionException extends PersistenceException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ final String entityType;
+ final String propertyName;
+ final Object propertyValue;
+ final Class<?> propertyType;
+
+
+ public PropertyTypeConversionException( String entityType, String propertyName, Object propertyValue,
+ Class<?> propertyType ) {
+ super( "Unable to convert property \"" + propertyName + "\" of entity \"" + entityType
+ + "\" from value of type " + propertyValue.getClass() + " to value of type " + propertyType );
+ this.entityType = entityType;
+ this.propertyName = propertyName;
+ this.propertyValue = propertyValue;
+ this.propertyType = propertyType;
+ }
+
+
+ public PropertyTypeConversionException( String entityType, String propertyName, Object propertyValue,
+ Class<?> propertyType, Throwable cause ) {
+ super( "Unable to convert property \"" + propertyName + "\" of entity \"" + entityType
+ + "\" from value of type " + propertyValue.getClass() + " to value of type " + propertyType, cause );
+ this.entityType = entityType;
+ this.propertyName = propertyName;
+ this.propertyValue = propertyValue;
+ this.propertyType = propertyType;
+ }
+
+
+ public String getEntityType() {
+ return entityType;
+ }
+
+
+ public String getPropertyName() {
+ return propertyName;
+ }
+
+
+ public Object getPropertyValue() {
+ return propertyValue;
+ }
+
+
+ public Class<?> getPropertyType() {
+ return propertyType;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/QueryIterationException.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/QueryIterationException.java b/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/QueryIterationException.java
new file mode 100644
index 0000000..1acc76a
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/QueryIterationException.java
@@ -0,0 +1,13 @@
+package org.apache.usergrid.persistence.exceptions;
+
+
+/**
+ * Thrown when an error occurs during query iteration
+ *
+ * @author tnine
+ */
+public class QueryIterationException extends RuntimeException {
+ public QueryIterationException( final String message ) {
+ super( message );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/QueryParseException.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/QueryParseException.java b/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/QueryParseException.java
new file mode 100644
index 0000000..d53144f
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/QueryParseException.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * 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.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.exceptions;
+
+
+/**
+ * An exception thrown when a query cannot be parsed
+ *
+ * @author tnine
+ */
+public class QueryParseException extends RuntimeException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+
+ /**
+ *
+ */
+ public QueryParseException() {
+ super();
+ }
+
+
+ /**
+ * @param arg0
+ * @param arg1
+ */
+ public QueryParseException( String arg0, Throwable arg1 ) {
+ super( arg0, arg1 );
+ }
+
+
+ /**
+ * @param arg0
+ */
+ public QueryParseException( String arg0 ) {
+ super( arg0 );
+ }
+
+
+ /**
+ * @param arg0
+ */
+ public QueryParseException( Throwable arg0 ) {
+ super( arg0 );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/QueryTokenException.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/QueryTokenException.java b/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/QueryTokenException.java
new file mode 100644
index 0000000..72f158a
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/QueryTokenException.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * 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.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.exceptions;
+
+
+/**
+ * An exception thrown when a query encounters a token it doesn't recognize
+ * @author tnine
+ */
+public class QueryTokenException extends RuntimeException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+
+
+
+ /**
+ * @param arg0
+ */
+ public QueryTokenException( Throwable arg0 ) {
+ super( arg0 );
+ }
+
+
+ @Override
+ public String getMessage() {
+ //antlr errors or strange. We have to do this, there's no message
+ return getCause().toString();
+ }
+
+
+ @Override
+ public String getLocalizedMessage() {
+ return getMessage();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/QueueException.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/QueueException.java b/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/QueueException.java
new file mode 100644
index 0000000..07889a6
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/QueueException.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * 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.
+ ******************************************************************************/
+/**
+ *
+ */
+package org.apache.usergrid.persistence.exceptions;
+
+
+/** General Exception for queue related operations. */
+public class QueueException extends RuntimeException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1630572186589575754L;
+
+
+ /**
+ *
+ */
+ public QueueException() {
+ }
+
+
+ /**
+ * @param arg0
+ */
+ public QueueException( String arg0 ) {
+ super( arg0 );
+ }
+
+
+ /**
+ * @param arg0
+ */
+ public QueueException( Throwable arg0 ) {
+ super( arg0 );
+ }
+
+
+ /**
+ * @param arg0
+ * @param arg1
+ */
+ public QueueException( String arg0, Throwable arg1 ) {
+ super( arg0, arg1 );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/RequiredPropertyNotFoundException.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/RequiredPropertyNotFoundException.java b/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/RequiredPropertyNotFoundException.java
new file mode 100644
index 0000000..850c925
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/exceptions/RequiredPropertyNotFoundException.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * 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.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.exceptions;
+
+
+public class RequiredPropertyNotFoundException extends PersistenceException {
+
+ private static final long serialVersionUID = 1L;
+ final String entityType;
+ final String propertyName;
+
+
+ public RequiredPropertyNotFoundException( String entityType, String propertyName ) {
+ super( "Entity " + entityType + " requires a property named " + propertyName );
+ this.entityType = entityType;
+ this.propertyName = propertyName;
+ }
+
+
+ public String getEntityType() {
+ return entityType;
+ }
+
+
+ public String getPropertyName() {
+ return propertyName;
+ }
+}