public class App extends Object implements ParaObject
ParaObject belongs to an app.
| Modifier and Type | Class and Description |
|---|---|
static class |
App.AllowedMethods
Represents HTTP methods allowed to be executed on a specific resource/type.
|
Votable.VoteValue| Modifier and Type | Field and Description |
|---|---|
static String |
ALLOW_ALL |
static String |
APP_ROLE |
| Constructor and Description |
|---|
App()
No-args constructor
|
App(String id)
Default constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
addDatatype(String pluralDatatype,
String datatype)
Adds a user-defined data type to the types map.
|
void |
addDatatypes(ParaObject... objects)
Adds unknown types to this app's list of data types.
|
boolean |
addValidationConstraint(String type,
String field,
Constraint c)
Adds a new constraint to the list of constraints for a given field and type.
|
Long |
countChildren(String type)
Count the total number of child objects for this object.
|
Long |
countLinks(String type2)
Count the total number of links between this object and another type of object.
|
String |
create()
Stores this object in the data store.
|
void |
delete()
Deletes the object permanently by removing it from the data store.
|
void |
deleteChildren(String type)
Deletes all child objects permanently.
|
boolean |
equals(Object obj) |
boolean |
exists()
Checks if an object is stored in the data store.
|
Boolean |
getActive()
Returns true if this application is active (enabled)
|
Map<String,Map<String,List<String>>> |
getAllResourcePermissions(String... subjectids)
Returns all resource permission for a list of subjects ids.
|
Map<String,Map<String,Map<String,Map<String,?>>>> |
getAllValidationConstraints(String... types)
Returns all validation constraints for a list of types.
|
String |
getAppid()
The application name.
|
String |
getAppIdentifier()
The App identifier (the id but without the prefix)
|
Boolean |
getCached()
Boolean flat which controls whether this object is cached.
|
<P extends ParaObject> |
getChildren(String type,
Pager... pager)
Returns all child objects linked to this object.
|
<P extends ParaObject> |
getChildren(String type,
String field,
String term,
Pager... pager)
Returns all child objects linked to this object.
|
String |
getCreatorid()
The id of the user who created this.
|
Map<String,String> |
getCredentials()
Returns the map containing the app's access key and secret key.
|
Map<String,String> |
getDatatypes()
Returns a set of custom data types for this app.
|
Long |
getDeleteOn()
The timestamp for when this app must be deleted.
|
String |
getId()
The id of an object.
|
Boolean |
getIndexed()
Boolean flat which controls whether this object is indexed
by the search engine.
|
<P extends ParaObject> |
getLinkedObjects(String type,
Pager... pager)
Similar to
Linkable.getChildren(java.lang.String, com.erudika.para.utils.Pager...)
but for many-to-many relationships. |
List<Linker> |
getLinks(String type2,
Pager... pager)
Returns all links between this type object and another type of object.
|
String |
getName()
The name of the object.
|
String |
getObjectURI()
The URI of this object.
|
String |
getParentid()
The id of the parent object.
|
String |
getPlural()
The plural name of the object.
|
Boolean |
getReadOnly()
Gets read-only mode.
|
Map<String,Map<String,List<String>>> |
getResourcePermissions()
Returns a map of resource permissions.
|
String |
getSecret()
Returns the app's secret key
|
Boolean |
getStored()
Boolean flag which controls whether this object is stored
in the database or not.
|
List<String> |
getTags()
The tags associated with this object.
|
Long |
getTimestamp()
The time when the object was created, in milliseconds.
|
Long |
getTokenValiditySec()
The validity period for access tokens in seconds.
|
String |
getType()
The name of the object's class.
|
Long |
getUpdated()
The last time this object was updated.
|
Map<String,Map<String,Map<String,Map<String,?>>>> |
getValidationConstraints()
Returns a map of user-defined data types and their validation annotations.
|
Integer |
getVotes()
Returns the total sum of all votes for this object.
|
boolean |
grantResourcePermission(String subjectid,
String resourcePath,
EnumSet<App.AllowedMethods> permission)
Grants a new permission for a given subject and resource.
|
boolean |
grantResourcePermission(String subjectid,
String resourcePath,
EnumSet<App.AllowedMethods> permission,
boolean allowGuestAccess)
Grants a new permission for a given subject and resource.
|
int |
hashCode() |
static String |
id(String id) |
boolean |
isAllowedTo(String subjectid,
String resourcePath,
String httpMethod)
Checks if a subject is allowed to call method X on resource Y.
|
boolean |
isDeniedExplicitly(String subjectid,
String resourcePath,
String httpMethod)
Check if a subject is explicitly denied access to a resource.
|
boolean |
isLinked(ParaObject toObj)
Checks if a given object is linked to this one.
|
boolean |
isLinked(String type2,
String id2)
Checks if this object is linked to another.
|
boolean |
isShared()
Is this a shared app (shared db, index, etc.)
|
String |
link(String id2)
Links an object to this one in a many-to-many relationship.
|
void |
removeDatatype(String pluralDatatype)
Removes a datatype from the types map.
|
boolean |
removeValidationConstraint(String type,
String field,
String constraintName)
Removes a constraint from the map.
|
void |
resetSecret()
Resets the secret key by generating a new one.
|
boolean |
revokeAllResourcePermissions(String subjectid)
Revokes all permissions for a subject id.
|
boolean |
revokeResourcePermission(String subjectid,
String resourcePath)
Revokes a permission for given subject.
|
void |
setActive(Boolean active)
Sets the active flag.
|
void |
setAppid(String appid)
Sets a new app name.
|
void |
setCached(Boolean cached)
Sets the "isCached" flag.
|
void |
setCreatorid(String creatorid)
Sets a new creator id.
|
void |
setDatatypes(Map<String,String> datatypes)
Sets the data types for this app
|
void |
setDeleteOn(Long deleteOn)
Sets the time for deletion
|
void |
setId(String id)
Sets a new id.
|
void |
setIndexed(Boolean indexed)
Sets the "isIndexed" flag.
|
void |
setName(String name)
Sets a new name.
|
void |
setParentid(String parentid)
Sets a new parent id.
|
void |
setReadOnly(Boolean readOnly)
Sets read-only mode
|
void |
setResourcePermissions(Map<String,Map<String,List<String>>> resourcePermissions)
Sets the permissions map
|
void |
setSecret(String secret)
Sets the secret key
|
void |
setShared(boolean shared)
Sets the shared flag
|
void |
setStored(Boolean stored)
Sets the "isStored" flag.
|
void |
setTags(List<String> tags)
Merges the given tags with existing tags.
|
void |
setTimestamp(Long timestamp)
Sets the timestamp.
|
void |
setTokenValiditySec(Long tokenValiditySec)
Sets the access token validity period in seconds.
|
void |
setType(String type)
Sets a new object type.
|
void |
setUpdated(Long updated)
Sets the last updated timestamp.
|
void |
setValidationConstraints(Map<String,Map<String,Map<String,Map<String,?>>>> validationConstraints)
Sets the validation constraints map.
|
void |
setVotes(Integer votes)
Sets the total votes for this object.
|
String |
toString() |
void |
unlink(String type,
String id2)
Unlinks an object from this one.
|
void |
unlinkAll()
Unlinks all objects that are linked to this one.
|
void |
update()
Updates the object permanently.
|
boolean |
voteDown(String userid)
Downvotes the object.
|
boolean |
voteUp(String userid)
Upvotes the object.
|
public static final String APP_ROLE
public static final String ALLOW_ALL
public App()
public App(String id)
id - the name of the apppublic final void setId(String id)
ParaObjectsetId in interface ParaObjectid - the new idpublic Map<String,Map<String,Map<String,Map<String,?>>>> getValidationConstraints()
public void setValidationConstraints(Map<String,Map<String,Map<String,Map<String,?>>>> validationConstraints)
validationConstraints - the constraints mappublic Map<String,Map<String,List<String>>> getResourcePermissions()
public void setResourcePermissions(Map<String,Map<String,List<String>>> resourcePermissions)
resourcePermissions - permissions mappublic String getAppIdentifier()
public Boolean getActive()
public void setActive(Boolean active)
active - true if activepublic Long getDeleteOn()
public void setDeleteOn(Long deleteOn)
deleteOn - a timestamppublic Long getTokenValiditySec()
public void setTokenValiditySec(Long tokenValiditySec)
tokenValiditySec - secondspublic String getSecret()
public void setSecret(String secret)
secret - a secret keypublic Boolean getReadOnly()
public void setReadOnly(Boolean readOnly)
readOnly - true if app is in read-only modepublic Map<String,String> getDatatypes()
public void setDatatypes(Map<String,String> datatypes)
datatypes - a map of type names (plural form to singular)public boolean isShared()
public void setShared(boolean shared)
shared - true if sharedpublic Map<String,Map<String,Map<String,Map<String,?>>>> getAllValidationConstraints(String... types)
types - a list of valid Para data typespublic boolean addValidationConstraint(String type, String field, Constraint c)
type - the typefield - the fieldc - the constraintpublic boolean removeValidationConstraint(String type, String field, String constraintName)
type - the typefield - the fieldconstraintName - the constraint namepublic Map<String,Map<String,List<String>>> getAllResourcePermissions(String... subjectids)
subjectids - subject ids (user ids)public boolean grantResourcePermission(String subjectid, String resourcePath, EnumSet<App.AllowedMethods> permission)
subjectid - the subject to give permissions toresourcePath - the resource name/typepermission - the set or HTTP methods allowedpublic boolean grantResourcePermission(String subjectid, String resourcePath, EnumSet<App.AllowedMethods> permission, boolean allowGuestAccess)
subjectid - the subject to give permissions toresourcePath - the resource name/typepermission - the set or HTTP methods allowedallowGuestAccess - if true - all unauthenticated requests will go through, 'false' by default.public boolean revokeResourcePermission(String subjectid, String resourcePath)
subjectid - subject idresourcePath - resource path or object typepublic boolean revokeAllResourcePermissions(String subjectid)
subjectid - subject idpublic boolean isAllowedTo(String subjectid, String resourcePath, String httpMethod)
subjectid - subject idresourcePath - resource path or object typehttpMethod - HTTP method namepublic boolean isDeniedExplicitly(String subjectid, String resourcePath, String httpMethod)
subjectid - subject idresourcePath - resource path or object typehttpMethod - HTTP method namepublic void addDatatype(String pluralDatatype, String datatype)
pluralDatatype - the plural form of the typedatatype - a datatype, must not be null or emptypublic void addDatatypes(ParaObject... objects)
objects - a list of new objectspublic void removeDatatype(String pluralDatatype)
pluralDatatype - a datatype, must not be null or emptypublic void resetSecret()
public Map<String,String> getCredentials()
public String create()
ParaObjectcreate in interface ParaObjectStored,
DAO.create(com.erudika.para.core.ParaObject)public void delete()
ParaObjectdelete in interface ParaObjectDAO.delete(com.erudika.para.core.ParaObject)public final String getId()
ParaObjectgetId in interface ParaObjectpublic final String getType()
ParaObjectClass.getSimpleName().toLowerCase()getType in interface ParaObjectpublic final void setType(String type)
ParaObjectsetType in interface ParaObjecttype - a new typepublic String getAppid()
ParaObjectgetAppid in interface ParaObjectpublic void setAppid(String appid)
ParaObjectsetAppid in interface ParaObjectappid - the new app id (name)public String getObjectURI()
ParaObjectgetObjectURI in interface ParaObjectUtils.getObjectURI(com.erudika.para.core.ParaObject, boolean, boolean)public List<String> getTags()
ParaObjectgetTags in interface ParaObjectTagpublic void setTags(List<String> tags)
ParaObjectsetTags in interface ParaObjecttags - the additional tags, or clears all tags if set to nullpublic Boolean getStored()
ParaObjectgetStored in interface ParaObjectpublic void setStored(Boolean stored)
ParaObjectsetStored in interface ParaObjectstored - when set to true, object is stored in DB.public Boolean getIndexed()
ParaObjectgetIndexed in interface ParaObjectpublic void setIndexed(Boolean indexed)
ParaObjectsetIndexed in interface ParaObjectindexed - when set to true, object is indexed.public Boolean getCached()
ParaObjectgetCached in interface ParaObjectpublic void setCached(Boolean cached)
ParaObjectsetCached in interface ParaObjectcached - when set to true, object is cached.public Long getTimestamp()
ParaObjectgetTimestamp in interface ParaObjectpublic void setTimestamp(Long timestamp)
ParaObjectsetTimestamp in interface ParaObjecttimestamp - a new timestamp in milliseconds.public String getCreatorid()
ParaObjectUser id.getCreatorid in interface ParaObjectpublic void setCreatorid(String creatorid)
ParaObjectsetCreatorid in interface ParaObjectcreatorid - a new idpublic final String getName()
ParaObjectgetName in interface ParaObjectpublic final void setName(String name)
ParaObjectsetName in interface ParaObjectname - the new namepublic String getPlural()
ParaObjectgetPlural in interface ParaObjectpublic String getParentid()
ParaObjectgetParentid in interface ParaObjectpublic void setParentid(String parentid)
ParaObjectsetParentid in interface ParaObjectparentid - a new idpublic Long getUpdated()
ParaObjectgetUpdated in interface ParaObjectpublic void setUpdated(Long updated)
ParaObjectsetUpdated in interface ParaObjectupdated - a new timestamppublic void update()
ParaObjectLocked fields are ignored.update in interface ParaObjectLocked,
DAO.update(com.erudika.para.core.ParaObject)public boolean exists()
ParaObjectexists in interface ParaObjectDAO.read(java.lang.String)public boolean voteUp(String userid)
Votablepublic boolean voteDown(String userid)
Votablepublic Integer getVotes()
Votablepublic void setVotes(Integer votes)
Votablepublic Long countLinks(String type2)
LinkablecountLinks in interface Linkabletype2 - the other type of objectpublic List<Linker> getLinks(String type2, Pager... pager)
Linkablepublic <P extends ParaObject> List<P> getLinkedObjects(String type, Pager... pager)
LinkableLinkable.getChildren(java.lang.String, com.erudika.para.utils.Pager...)
but for many-to-many relationships.getLinkedObjects in interface LinkableP - type of linked objectstype - type of linked objectspager - a Pagerpublic boolean isLinked(String type2, String id2)
Linkablepublic boolean isLinked(ParaObject toObj)
Linkablepublic String link(String id2)
Linkablepublic void unlink(String type, String id2)
Linkablepublic void unlinkAll()
LinkableLinker objects. Only the links are deleted. Objects are left untouched.public Long countChildren(String type)
LinkablecountChildren in interface Linkabletype - the other type of objectpublic <P extends ParaObject> List<P> getChildren(String type, Pager... pager)
LinkablegetChildren in interface LinkableP - the type of childrentype - the type of children to look forpager - a PagerParaObject in a one-to-many relationship with this objectpublic <P extends ParaObject> List<P> getChildren(String type, String field, String term, Pager... pager)
LinkablegetChildren in interface LinkableP - the type of childrentype - the type of children to look forfield - the field name to use as filterterm - the field value to use as filterpager - a PagerParaObject in a one-to-many relationship with this objectpublic void deleteChildren(String type)
LinkabledeleteChildren in interface Linkabletype - the children's type.Copyright © 2016 Erudika. All rights reserved.