org.eaglei.repository
Class Role

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

@HasContentCache
public class Role
extends java.lang.Object
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.

Version:
$Id: $
Author:
Larry Stone Started April 26, 2010

Method Summary
 void commit(javax.servlet.http.HttpServletRequest request)
          commit - commit any changes made to this object (and any others)
 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)
          Make a new Role
static void decache()
          Invalidate the role cache, called when RDF has changed.
 void delete(javax.servlet.http.HttpServletRequest request)
           
static void doExportRoles(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.openrdf.rio.RDFFormat format, java.util.Set<java.lang.String> includes, java.util.Set<java.lang.String> excludes)
          Export roles to serialized quad format.
static void doImportRoles(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.openrdf.repository.RepositoryConnection content, java.util.Set<java.lang.String> includes, java.util.Set<java.lang.String> excludes, ImportExport.DuplicateArg duplicate, boolean transform)
          Import description of roles from serialized RDF quads.
 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()
           
 boolean isImplicit()
           
 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 java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

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 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.


getURI

public org.openrdf.model.URI getURI()

getURI

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.

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()

isImplicit

public boolean isImplicit()

create

public static Role create(javax.servlet.http.HttpServletRequest request,
                          org.openrdf.model.URI asubject,
                          java.lang.String label,
                          java.lang.String comment)
                   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
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

commit

public void commit(javax.servlet.http.HttpServletRequest request)
            throws javax.servlet.ServletException

commit - commit any changes made to this object (and any others)

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

doExportRoles

public static void doExportRoles(javax.servlet.http.HttpServletRequest request,
                                 javax.servlet.http.HttpServletResponse response,
                                 org.openrdf.rio.RDFFormat format,
                                 java.util.Set<java.lang.String> includes,
                                 java.util.Set<java.lang.String> excludes)
                          throws javax.servlet.ServletException,
                                 java.io.IOException
Export roles to serialized quad format. Write a stylized representation of essential data, since the actual statements implementing a Role are bound to chagne soon. The export contains these statements for each role: {All statements in :NG_Internal graph} a :Role . rdfs:label "label" . {optional} rdfs:comment "comment" .

Throws:
javax.servlet.ServletException
java.io.IOException

doImportRoles

public static void doImportRoles(javax.servlet.http.HttpServletRequest request,
                                 javax.servlet.http.HttpServletResponse response,
                                 org.openrdf.repository.RepositoryConnection content,
                                 java.util.Set<java.lang.String> includes,
                                 java.util.Set<java.lang.String> excludes,
                                 ImportExport.DuplicateArg duplicate,
                                 boolean transform)
                          throws javax.servlet.ServletException,
                                 java.io.IOException
Import description of roles from serialized RDF quads.

Throws:
javax.servlet.ServletException
java.io.IOException


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