org.eaglei.repository.model
Class Role

java.lang.Object
  extended by org.eaglei.repository.model.ImmutableObjectModel
      extended by org.eaglei.repository.model.WritableObjectModel
          extended by org.eaglei.repository.model.Role
All Implemented Interfaces:
java.lang.Comparable

@HasContentCache
public class Role
extends WritableObjectModel
implements java.lang.Comparable

Role object model, reflects the :Role object in RDF database. A role represents an entity that can be granted privileges in the access control system. Users who are members of a Role get all its grants. Roles are "flat" objects, i.e. there is NO hierarchy of Roles -- although it would be convenient, it is too difficult to implement given the current inferencing support available in the RDF database. Named Graph usage: Role looks for statements in ALL graphs, although they should really only be found in the :NG_Internal graph.

Author:
Larry Stone Started April 26, 2010

Field Summary
static java.lang.String ROLE_QUERY
          SPARQL query to get role descriptions, works on both internal repo graph and exports.
 
Fields inherited from class org.eaglei.repository.model.WritableObjectModel
dirty
 
Method Summary
 int compareTo(java.lang.Object o)
          
static Role create(javax.servlet.http.HttpServletRequest request, org.openrdf.model.URI asubject, java.lang.String label, java.lang.String comment, boolean aimplicit)
          Make a new Role
static void decache()
          Invalidate the role cache, called when RDF has changed.
 void decacheInstance()
          any decache of an instance should decache global map too.
 void delete(javax.servlet.http.HttpServletRequest request)
          destroy a role
 boolean equals(java.lang.Object other)
          
static Role find(javax.servlet.http.HttpServletRequest request, org.openrdf.model.URI uri)
          Get the Role for given URI, lookup label.
static java.util.List<Role> findAll(javax.servlet.http.HttpServletRequest request)
          Get all known Roles - includes pseudo-Roles Anonymous and Authenticated that should NOT be directly assigned to Users.
static java.util.List<Role> findAllGrantable(javax.servlet.http.HttpServletRequest request)
          Get all Roles that can be granted in a :has___Access statement.
static java.util.List<Role> findAllUserRoles(javax.servlet.http.HttpServletRequest request)
          Get all Roles that ought to be assigned to users - EXCLUDES "implicit" pseudo-Roles Anonymous and Authenticated.
 java.lang.String getComment()
          Getter for the field comment.
 java.lang.String getLabel()
          Getter for the field label.
 org.openrdf.model.URI getURI()
          getURI
 int hashCode()
          
 boolean isBuiltin()
          predicate - is this one of the permanent builtin roles?
 boolean isImplicit()
          predicate - value of implicit
 boolean isSuperuser()
          isSuperuser
 void setComment(javax.servlet.http.HttpServletRequest request, java.lang.String newVal)
           
 void setLabel(javax.servlet.http.HttpServletRequest request, java.lang.String label)
          Setter for the field label.
 java.lang.String toString()
          toString
 
Methods inherited from class org.eaglei.repository.model.WritableObjectModel
commit, setDirty, update
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ROLE_QUERY

public static final java.lang.String ROLE_QUERY
SPARQL query to get role descriptions, works on both internal repo graph and exports.

Method Detail

find

public static Role find(javax.servlet.http.HttpServletRequest request,
                        org.openrdf.model.URI uri)
                 throws javax.servlet.ServletException
Get the Role for given URI, lookup label.

Parameters:
request - a HttpServletRequest object.
uri - URI of the role
Returns:
a org.eaglei.repository.Role object representing role.
Throws:
javax.servlet.ServletException - if any.

findAll

public static java.util.List<Role> findAll(javax.servlet.http.HttpServletRequest request)
                                    throws javax.servlet.ServletException
Get all known Roles - includes pseudo-Roles Anonymous and Authenticated that should NOT be directly assigned to Users. Make the query each time instead of relying on cache since some sneaky admin may *add* new roles by uploading statements to NG_Internal graph.

Parameters:
request - a HttpServletRequest object.
Returns:
all roles in a Iterable object.
Throws:
javax.servlet.ServletException - if any.

findAllGrantable

public static java.util.List<Role> findAllGrantable(javax.servlet.http.HttpServletRequest request)
                                             throws javax.servlet.ServletException
Get all Roles that can be granted in a :has___Access statement. This works out to all roles *except* SuperUser.

Parameters:
request - a HttpServletRequest object.
Returns:
all roles in a Iterable object.
Throws:
javax.servlet.ServletException - if any.

findAllUserRoles

public static java.util.List<Role> findAllUserRoles(javax.servlet.http.HttpServletRequest request)
                                             throws javax.servlet.ServletException
Get all Roles that ought to be assigned to users - EXCLUDES "implicit" pseudo-Roles Anonymous and Authenticated. Make the query each time instead of relying on cache since some sneaky admin may *add* new roles by uploading statements to NG_Internal graph.

Parameters:
request - a HttpServletRequest object.
Returns:
all roles in a Iterable object.
Throws:
javax.servlet.ServletException - if any.

decache

public static void decache()
Invalidate the role cache, called when RDF has changed.


decacheInstance

public void decacheInstance()
any decache of an instance should decache global map too.

Overrides:
decacheInstance in class WritableObjectModel

getURI

public org.openrdf.model.URI getURI()

getURI

Specified by:
getURI in class ImmutableObjectModel
Returns:
URI subject of the role, a URI object.

isSuperuser

public boolean isSuperuser()

isSuperuser

predicate that answers whether this role confers Administrator privileges, an attempt at preserving modularity.

Returns:
true if this role determins superuser (admin) privileges

getLabel

public java.lang.String getLabel()

Getter for the field label.

Specified by:
getLabel in class ImmutableObjectModel
Returns:
label of the role, a String object.

getComment

public java.lang.String getComment()

Getter for the field comment.

Returns:
comment of the role, a String object, MIGHT be null.

equals

public boolean equals(java.lang.Object other)

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()

toString

Overrides:
toString in class java.lang.Object
Returns:
a String object.

compareTo

public int compareTo(java.lang.Object o)

Specified by:
compareTo in interface java.lang.Comparable

isBuiltin

public boolean isBuiltin()
predicate - is this one of the permanent builtin roles?


isImplicit

public boolean isImplicit()
predicate - value of implicit


create

public static Role create(javax.servlet.http.HttpServletRequest request,
                          org.openrdf.model.URI asubject,
                          java.lang.String label,
                          java.lang.String comment,
                          boolean aimplicit)
                   throws javax.servlet.ServletException

Make a new Role

at a specific URI (assumes it is not already the subject of any existing statements). If uri == null, a new URI is allocated.

Parameters:
request - a HttpServletRequest object.
label - short name for role, SHOULD be non-null
comment - longer description of role, may be null
Throws:
javax.servlet.ServletException - if any.

delete

public void delete(javax.servlet.http.HttpServletRequest request)
            throws javax.servlet.ServletException
destroy a role

Throws:
javax.servlet.ServletException

setLabel

public void setLabel(javax.servlet.http.HttpServletRequest request,
                     java.lang.String label)
              throws javax.servlet.ServletException

Setter for the field label.

Parameters:
request - a HttpServletRequest object.
label - a new label value
Throws:
javax.servlet.ServletException - if any.

setComment

public void setComment(javax.servlet.http.HttpServletRequest request,
                       java.lang.String newVal)
                throws javax.servlet.ServletException
Throws:
javax.servlet.ServletException


Copyright © 2009-2011 Eagle-I. All Rights Reserved.