org.usergrid.persistence.entities.Application Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of usergrid-core Show documentation
Show all versions of usergrid-core Show documentation
Core services for Usergrid system.
/*******************************************************************************
* 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.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.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
import org.usergrid.persistence.TypedEntity;
import org.usergrid.persistence.annotations.EntityCollection;
import org.usergrid.persistence.annotations.EntityDictionary;
import org.usergrid.persistence.annotations.EntityProperty;
/**
* 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 collections;
@EntityDictionary(keyType = java.lang.String.class, valueType = java.lang.String.class)
protected Map rolenames;
@EntityDictionary(keyType = java.lang.String.class)
protected Set 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 oauthproviders;
@EntityDictionary(keyType = java.lang.String.class, valueType = java.lang.String.class)
protected Map credentials;
@EntityDictionary(keyType = java.lang.String.class, valueType = WebHook.class)
protected Map webhooks;
@EntityCollection(type = "activity", reversed = true, sort = "published desc", indexingDynamicDictionaries = true)
protected List activities;
@EntityCollection(type = "asset", indexingDynamicDictionaries = true)
protected List assets;
@EntityCollection(type = "event", indexingDynamicDictionaries = true)
protected List events;
@EntityCollection(type = "folder", indexingDynamicDictionaries = true)
protected List folders;
@EntityCollection(type = "group")
protected List groups;
@EntityCollection(type = "user", dictionariesIndexed = { "aliases" })
protected List users;
@EntityCollection(type = "device")
protected List devices;
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 getUsers() {
return users;
}
public void setUsers(List users) {
this.users = users;
}
@JsonSerialize(include = Inclusion.NON_NULL)
public List getGroups() {
return groups;
}
public void setGroups(List groups) {
this.groups = groups;
}
@JsonSerialize(include = Inclusion.NON_NULL)
public Set getCollections() {
return collections;
}
public void setCollections(Set collections) {
this.collections = collections;
}
@JsonSerialize(include = Inclusion.NON_NULL)
public Map getRolenames() {
return rolenames;
}
public void setRolenames(Map rolenames) {
this.rolenames = rolenames;
}
@JsonSerialize(include = Inclusion.NON_NULL)
public Set getCounters() {
return counters;
}
public void setCounters(Set counters) {
this.counters = counters;
}
@JsonSerialize(include = Inclusion.NON_NULL)
public List getAssets() {
return assets;
}
public void setAssets(List assets) {
this.assets = assets;
}
@JsonSerialize(include = Inclusion.NON_NULL)
public Map getCredentials() {
return credentials;
}
public void setCredentials(Map credentials) {
this.credentials = credentials;
}
@JsonSerialize(include = Inclusion.NON_NULL)
public List getActivities() {
return activities;
}
public void setActivities(List activities) {
this.activities = activities;
}
@JsonSerialize(include = Inclusion.NON_NULL)
public List getFolders() {
return folders;
}
public void setFolders(List folders) {
this.folders = folders;
}
@JsonSerialize(include = Inclusion.NON_NULL)
public List getEvents() {
return events;
}
public void setEvents(List events) {
this.events = events;
}
@JsonSerialize(include = Inclusion.NON_NULL)
public List getDevices() {
return devices;
}
public void setDevices(List devices) {
this.devices = devices;
}
@JsonSerialize(include = Inclusion.NON_NULL)
public Map getOauthproviders() {
return oauthproviders;
}
public void setOauthproviders(Map oauthproviders) {
this.oauthproviders = oauthproviders;
}
/**
* Get the organization name of this app
* @return
*/
public String getOrganizationName(){
String[] names = name.split("/");
if(names.length == 2){
return names[0];
}
return null;
}
/**
* Get the application name of this app
* @return
*/
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;
}
}
}