org.eaglei.repository
Class User

java.lang.Object
  extended by org.eaglei.repository.User

public class User
extends java.lang.Object

User object model, reflects the user's properties in the both RDBMS and RDF database. Also manages the RDF descriptions of users. Named Graph Usage: 1. Almost all statements about a repo User are in the graph named "repo:NG_Users". 2. Ony the :hasPrincipalName statement is on the NG_Internal graph sicne it should not be exposed; there is no reason to let login names leak and it's good security practice to keep them hidden, since that just makes dictionary attacks so much easier.

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

Method Summary
 void addRole(javax.servlet.http.HttpServletRequest request, Role r)
          addRole - add a role
 void addRole(javax.servlet.http.HttpServletRequest request, Role r, boolean skipAccessCheck)
          addRole - add a role
 void addRole(javax.servlet.http.HttpServletRequest request, org.openrdf.model.URI ru)
          addRole - add a role
static User create(javax.servlet.http.HttpServletRequest request, java.lang.String username)
          alternate create with access check off
static User create(javax.servlet.http.HttpServletRequest request, java.lang.String username, boolean skipAccessCheck)
           Create new user instance for given username.
 boolean equals(java.lang.Object o)
          
protected  void finalize()
          finalize - flag error if GC'ing a dirty instance, its changes are lost.
static java.lang.Iterable<User> findAll(javax.servlet.http.HttpServletRequest request)
          Get all known Users from RDF DB - may not match auth'n DB.
static User findUsername(javax.servlet.http.HttpServletRequest request, java.lang.String pname)
          find a record by username, i.e.
 java.lang.String getFirstName()
          Getter for the field firstName.
 java.lang.String getLastName()
          Getter for the field lastName.
 java.lang.String getMbox()
          Getter for the field mbox.
 java.lang.String getPersonalName()
          Get personal name, if available, as "firstname lastname".
 Role[] getRoles()
          Get Roles.
 java.lang.String getTitle()
          Computes the most informative "label" for a user, to present in UI.
 org.openrdf.model.URI getURI()
          Getter for the field uri.
static org.openrdf.query.Dataset getUserDataset()
           
 java.lang.String getUsername()
          Getter for the field username.
 boolean hasRoleP(Role r)
          has role predicate - the P suffix is a Lisp thing
 boolean hasRoleP(org.openrdf.model.URI ru)
          hasRoleP
 void removeRole(javax.servlet.http.HttpServletRequest request, Role r)
          removeRole
 void removeRole(javax.servlet.http.HttpServletRequest request, org.openrdf.model.URI ru)
          removeRole
 void setFirstName(javax.servlet.http.HttpServletRequest request, java.lang.String name)
          Change value of first name.
 void setLastName(javax.servlet.http.HttpServletRequest request, java.lang.String name)
          Setter for the field lastName.
 void setMbox(javax.servlet.http.HttpServletRequest request, java.lang.String mbox)
          Setter for the field mbox.
 boolean setRoles(javax.servlet.http.HttpServletRequest request, Role[] newRoles)
          setRoles
 java.lang.String toString()
          toString
 void update(javax.servlet.http.HttpServletRequest request)
          update - push any changes into repository - needs superuser also recomputes rdfs:label Does not need access checks because the only operatiosn taht set "dirty" are access-protected..
 
Methods inherited from class java.lang.Object
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getUserDataset

public static org.openrdf.query.Dataset getUserDataset()
Returns:
dataset of graphs needed to query for all repo users' data

findUsername

public static User findUsername(javax.servlet.http.HttpServletRequest request,
                                java.lang.String pname)
                         throws javax.servlet.ServletException
find a record by username, i.e. login principal name Returns null if NOT found.. NOTE that user instance gets auto-created for a "new" principal upon login, so this CAN be called (by that code) when checking first before creating a new Person instance.

Parameters:
request - a HttpServletRequest object.
pname - principal name (from user account RDBMS).
Returns:
the User object, or null if none found.
Throws:
javax.servlet.ServletException - if any.

findAll

public static java.lang.Iterable<User> findAll(javax.servlet.http.HttpServletRequest request)
                                        throws javax.servlet.ServletException

Get all known Users from RDF DB - may not match auth'n DB.
XXX TODO should add start and count for pagination

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

getURI

public org.openrdf.model.URI getURI()

Getter for the field uri.

Returns:
a URI object.

getUsername

public java.lang.String getUsername()

Getter for the field username.

Returns:
a String object.

getFirstName

public java.lang.String getFirstName()

Getter for the field firstName.

Returns:
a String object or null if not set.

getLastName

public java.lang.String getLastName()

Getter for the field lastName.

Returns:
a String object or null if not set.

getMbox

public java.lang.String getMbox()

Getter for the field mbox.

Returns:
a String object or null if not set.

getTitle

public java.lang.String getTitle()
Computes the most informative "label" for a user, to present in UI. Format is, ideally, "username (firstname lastname)" But it reverts to bare username or even URI if none is available.

Returns:
label as a String object.

getPersonalName

public java.lang.String getPersonalName()

Get personal name, if available, as "firstname lastname".

Returns:
name in String or else empty string if there is none; never null.

getRoles

public Role[] getRoles()

Get Roles.

Returns:
all known Roles as an array of Role objects.

hasRoleP

public boolean hasRoleP(Role r)
has role predicate - the P suffix is a Lisp thing

Parameters:
r - role as a Role object.
Returns:
a boolean, true if this User has indicated role.

hasRoleP

public boolean hasRoleP(org.openrdf.model.URI ru)

hasRoleP

Parameters:
ru - role as a URI object.
Returns:
a boolean, true if this User has indicated role.

create

public static User create(javax.servlet.http.HttpServletRequest request,
                          java.lang.String username)
                   throws javax.servlet.ServletException

alternate create with access check off

Parameters:
request - a HttpServletRequest object.
username - principal name, a String object.
Returns:
the new User object.
Throws:
javax.servlet.ServletException - if any.

create

public static User create(javax.servlet.http.HttpServletRequest request,
                          java.lang.String username,
                          boolean skipAccessCheck)
                   throws javax.servlet.ServletException

Create new user instance for given username. Returns User object with URI and username set; nothing else. Fails if there is an existing user with the same principal. Skip access test if skipAccessCheck bit is set -- dangerous, only for bootstrapping the authentication.

Parameters:
request - a HttpServletRequest object.
username - principal name, a String object.
skipAccessCheck - a boolean.
Returns:
the new User object.
Throws:
javax.servlet.ServletException - if any.

setFirstName

public void setFirstName(javax.servlet.http.HttpServletRequest request,
                         java.lang.String name)
                  throws javax.servlet.ServletException
Change value of first name. Setting it to null clears it.

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

setLastName

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

Setter for the field lastName.

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

setMbox

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

Setter for the field mbox.

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

addRole

public void addRole(javax.servlet.http.HttpServletRequest request,
                    org.openrdf.model.URI ru)
             throws javax.servlet.ServletException

addRole - add a role

Parameters:
request - a HttpServletRequest object.
ru - Role to add, as a URI object.
Throws:
javax.servlet.ServletException - if any.

addRole

public void addRole(javax.servlet.http.HttpServletRequest request,
                    Role r)
             throws javax.servlet.ServletException

addRole - add a role

Parameters:
request - a HttpServletRequest object.
r - role to add as a Role object.
Throws:
javax.servlet.ServletException - if any.

addRole

public void addRole(javax.servlet.http.HttpServletRequest request,
                    Role r,
                    boolean skipAccessCheck)
             throws javax.servlet.ServletException

addRole - add a role

Parameters:
request - a HttpServletRequest object.
r - role to add as a Role object.
skipAccessCheck - a boolean, true to skip access control check.
Throws:
javax.servlet.ServletException - if any.

removeRole

public void removeRole(javax.servlet.http.HttpServletRequest request,
                       org.openrdf.model.URI ru)
                throws javax.servlet.ServletException

removeRole

Parameters:
request - a HttpServletRequest object.
ru - role to remove as a URI object.
Throws:
javax.servlet.ServletException - if any.

removeRole

public void removeRole(javax.servlet.http.HttpServletRequest request,
                       Role r)
                throws javax.servlet.ServletException

removeRole

Parameters:
request - a HttpServletRequest object.
r - role to remove as a Role object.
Throws:
javax.servlet.ServletException - if any.

setRoles

public boolean setRoles(javax.servlet.http.HttpServletRequest request,
                        Role[] newRoles)
                 throws javax.servlet.ServletException

setRoles

make the user's set of roles equal to contents of this array

Parameters:
request - a HttpServletRequest object.
role - array of Role objects which should be the new role set
Returns:
true if any roles were actually changed.
Throws:
javax.servlet.ServletException - if any.

update

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

update - push any changes into repository - needs superuser also recomputes rdfs:label Does not need access checks because the only operatiosn taht set "dirty" are access-protected..

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

finalize

protected void finalize()
                 throws java.lang.Throwable

finalize - flag error if GC'ing a dirty instance, its changes are lost.

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

toString

public java.lang.String toString()

toString

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

equals

public boolean equals(java.lang.Object o)

Overrides:
equals in class java.lang.Object


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