org.openanzo.server.repository.structures
Class User

java.lang.Object
  extended by org.openanzo.server.repository.structures.User

public class User
extends java.lang.Object

Provides read and write access to users stored in the local repository. Unlike many of the data access objects in anzo, users are not batched and changes are persisted to the database immediately.

Author:
Joe Betz

Method Summary
static User createUser(java.lang.Long id, java.lang.Long roleId, java.lang.Long aclId, java.lang.String userId, java.lang.String password, RepositoryConnection repositoryConnection, java.lang.Long modified)
          Creates a new user and adds the user to the database.
 void flattenRoles(java.lang.Long modified)
          Updates the 'implicit' entries in the UsersRoles table for this user.
 java.lang.Long getDefaultAclTemplateId()
          Get the ID for the default Acl template associated with this user.
 java.lang.Long getDefaultRoleId()
          Gets the ID for the default role associated with this user.
 java.lang.Long getId()
          Gets the unique id for the user.
 java.lang.Long getModified()
          Get timestamp when User was last modified
 java.util.Set<Role> getRoles()
          Gets the roles the user belongs to.
static User getUser(org.openrdf.model.URI uri, RepositoryConnection repositoryConnection)
          Load a User from user's URI
 java.lang.String getUserId()
           
static User loadUser(java.lang.Long userId, RepositoryConnection repositoryConnection)
          Load a User based on the user's Id.
 void remove(java.lang.Long modified)
          Remove the User from the database
 void setDefaultAclTemplateId(java.lang.Long defaultAclId)
          Set the Default Acl Template ID
 void setDefaultRoleId(java.lang.Long defaultRoleId)
          Set the Default Role Id
 void setModified(java.lang.Long modified)
          Set timestamp when User was last modified
 void setPassword(java.lang.String password)
          Set the User password
 void setUserId(java.lang.String userId)
           
 boolean update(java.lang.Long modified)
          Update the User data in the database
 boolean verifyPassword(java.lang.String password)
          Checks if the user's password matches the password parameter.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

loadUser

public static User loadUser(java.lang.Long userId,
                            RepositoryConnection repositoryConnection)
Load a User based on the user's Id.

Parameters:
userId - The id for the user.
repositoryConnection - Repository connection to run queries against
Returns:
User instance for ID, or null if ID not stored

getUser

public static User getUser(org.openrdf.model.URI uri,
                           RepositoryConnection repositoryConnection)
Load a User from user's URI

Parameters:
uri - URI for User
repositoryConnection - Repository connection to run queries against
Returns:
User instance for URI, or null if URI does not exist

createUser

public static User createUser(java.lang.Long id,
                              java.lang.Long roleId,
                              java.lang.Long aclId,
                              java.lang.String userId,
                              java.lang.String password,
                              RepositoryConnection repositoryConnection,
                              java.lang.Long modified)
                       throws AnzoException
Creates a new user and adds the user to the database.

Parameters:
id - Unique id for the User
roleId - The ID for the user's role. It must not be a pre-existing role.
aclId - The ID for the user's default ACL template
userId - The login id for the user
password - The user's password.
repositoryConnection - connection to the database
modified - timestamp when user was modified
Returns:
The new user object.
Throws:
AnzoException

verifyPassword

public boolean verifyPassword(java.lang.String password)
                       throws AnzoException
Checks if the user's password matches the password parameter.

Parameters:
password -
Returns:
True if the user's password matches the password parameter.
Throws:
AnzoException

getModified

public java.lang.Long getModified()
Get timestamp when User was last modified

Returns:
Timestamp when User was last modified

setModified

public void setModified(java.lang.Long modified)
Set timestamp when User was last modified

Parameters:
modified - Timestamp when User was last modified

getRoles

public java.util.Set<Role> getRoles()
                             throws AnzoException
Gets the roles the user belongs to.

Returns:
A iterator of Roles.
Throws:
AnzoException

getDefaultRoleId

public java.lang.Long getDefaultRoleId()
                                throws AnzoException
Gets the ID for the default role associated with this user. The default role is created when the user is created, and has only this user in it when it is created. Also, the default role is given full privileges to all stored NamedGraphs created by this user.

Returns:
The default role ID for this user.
Throws:
AnzoException

getDefaultAclTemplateId

public java.lang.Long getDefaultAclTemplateId()
                                       throws AnzoException
Get the ID for the default Acl template associated with this user. All new NamedGraphs that don't specify an ACL when created by the user will use the default ACL template to create a new ACL.

Returns:
The default ACL ID for this user.
Throws:
AnzoException

getId

public java.lang.Long getId()
Gets the unique id for the user.

Returns:
Unique id for this user.

flattenRoles

public void flattenRoles(java.lang.Long modified)
                  throws AnzoException
Updates the 'implicit' entries in the UsersRoles table for this user. These entries are required for roles the user is indirectly a member of via the subRoleOf relations. Must be called on each user effected by a change to the SubRoleOf permissions.

Parameters:
modified - Timestamp when updates to User were made
Throws:
AnzoException

update

public boolean update(java.lang.Long modified)
               throws AnzoException
Update the User data in the database

Parameters:
modified - Timestamp when update was made to user
Returns:
true if update was needed and successful, return false otherwise
Throws:
AnzoException

remove

public void remove(java.lang.Long modified)
            throws AnzoException
Remove the User from the database

Parameters:
modified - Timestamp when User was removed from the database
Throws:
AnzoException

setDefaultAclTemplateId

public void setDefaultAclTemplateId(java.lang.Long defaultAclId)
Set the Default Acl Template ID

Parameters:
defaultAclId - ID for Default ACL Template

setDefaultRoleId

public void setDefaultRoleId(java.lang.Long defaultRoleId)
Set the Default Role Id

Parameters:
defaultRoleId - ID for Default Role

setPassword

public void setPassword(java.lang.String password)
                 throws AnzoException
Set the User password

Parameters:
password - clear text version of password
Throws:
AnzoException

getUserId

public java.lang.String getUserId()
Returns:
the userId

setUserId

public void setUserId(java.lang.String userId)
Parameters:
userId - the userId to set


Copyright © 2007 Cambridge Semantics Inc.. All Rights Reserved.