magoffin.matt.ma2.biz
Interface UserBiz

All Known Implementing Classes:
UserBizImpl

public interface UserBiz

Business interface for users.

Version:
$Revision: 43 $ $Date: 2007-10-21 11:10:01 +1300 (Sun, 21 Oct 2007) $
Author:
Matt Magoffin (spamsqr@msqr.us)

Field Summary
static int ACCESS_ADMIN
          Bit flag for Admin user access level.
static java.lang.String DO_NOT_CHANGE_VALUE
          Flag for a String value that should not change.
static java.lang.String WATERMARK_META_KEY
          The metadata key for the user watermark path.
 
Method Summary
 User confirmForgotPassword(java.lang.String login, java.lang.String confirmationCode, java.lang.String newPassword, BizContext context)
          Confirm a forgotten password.
 User confirmRegisteredUser(java.lang.String login, java.lang.String confirmationCode, BizContext context)
          Confirm a registered user.
 java.lang.String forgotPassword(java.lang.String login, BizContext context)
          Call to email a user a link with a one-time password.
 java.util.List<Album> getAlbumFeedForUser(AlbumFeedCommand command)
          Get a List of Albums for a user's album feed.
 java.util.List<Album> getAlbumsForUser(User user, BizContext context)
          Get all albums for a given user.
 User getAnonymousUser()
          Get an anonymous user object.
 Collection getCollection(java.lang.Long collectionId, BizContext context)
          Get a single collection.
 java.io.File getCollectionDirectory(Collection collection, BizContext context)
          Get the directory for a given collection.
 java.util.List<Collection> getCollectionsForUser(User user, BizContext context)
          Get all collections for a given user.
 java.util.List<Album> getSharedAlbumsForUser(BrowseAlbumsCommand command)
          Get a List of Albums for a browse command.
 User getUserByAnonymousKey(java.lang.String key)
          Get a User by its anonymous key.
 User getUserById(java.lang.Long userId, BizContext context)
          Get a User by its ID.
 java.util.Locale getUserLocale(User user, BizContext context)
          Get the Locale for a User.
 java.util.List<User> getUsersWithAccess(int level)
          Get a list of User objects that have a specific access level.
 org.springframework.core.io.Resource getUserWatermark(java.lang.Long userId)
          Get a Resource for a user's watermark.
 boolean hasAccessLevel(User user, int level)
          Return true if the supplied user has the specified access level.
 boolean isAnonymousUser(User user)
          Test if a User is an anonoymous user.
 User logonUser(java.lang.String login, java.lang.String password)
          Authenticate a user by their username and password.
 Collection newCollectionForUser(Collection collection, User user, BizContext context)
          Create a new Collection for a given user.
 java.lang.String registerUser(User user, BizContext context)
          Register a new user.
 void removeUser(java.lang.Long userId, BizContext context)
          Remove a User from the back end.
 java.lang.Long storeCollection(Collection collection, BizContext context)
          Store a collection in the back end.
 java.lang.Long storeUser(User user, BizContext context)
          Store a User in the back end.
 void storeUserPreferences(PreferencesCommand command, BizContext context)
          Store user preferences in the back end.
 

Field Detail

ACCESS_ADMIN

static final int ACCESS_ADMIN
Bit flag for Admin user access level.

See Also:
Constant Field Values

WATERMARK_META_KEY

static final java.lang.String WATERMARK_META_KEY
The metadata key for the user watermark path.

See Also:
Constant Field Values

DO_NOT_CHANGE_VALUE

static final java.lang.String DO_NOT_CHANGE_VALUE
Flag for a String value that should not change.

For example, when updating a User, the password field can be left unchagned when set to this value.

See Also:
Constant Field Values
Method Detail

registerUser

java.lang.String registerUser(User user,
                              BizContext context)
                              throws AuthorizationException
Register a new user.

Use this method to register a new user. After registration the user will be stored in the back end, but the user will require confirmation before they can officially log into the application (see confirmRegisteredUser(String, String, BizContext)).

Parameters:
user - the new user to register
context - the BizContext
Returns:
a confirmation string suitable to pass to confirmRegisteredUser(String, String, BizContext)
Throws:
AuthorizationException - if the desired login is taken already, this exception will be thrown with the reason code AuthorizationException.Reason#DUPLICATE_LOGIN

confirmRegisteredUser

User confirmRegisteredUser(java.lang.String login,
                           java.lang.String confirmationCode,
                           BizContext context)
                           throws AuthorizationException
Confirm a registered user.

After a user has registered (see registerUser(User, BizContext)) they must confirm the registration via this method. After confirmation the user can login via logonUser(String, String) as a normal user.

Parameters:
login - the login to confirm
confirmationCode - the confirmation code
context - the BizContext
Returns:
the confirmed user
Throws:
AuthorizationException - if the confirmationCode does not match then the reason code will be set to AuthorizationException.Reason#REGISTRATION_NOT_CONFIRMED, if the login is not found then AuthorizationException.Reason#UNKNOWN_LOGIN, if the account has already been confirmed then AuthorizationException.Reason#REGISTRATION_ALREADY_CONFIRMED

storeUser

java.lang.Long storeUser(User user,
                         BizContext context)
                         throws AuthorizationException
Store a User in the back end.

This method will accept new users as well as updates to existing users.

When updating an existing user, if the User's password field is set to DO_NOT_CHANGE_VALUE then the User's password will not be updated in the back end.

Parameters:
user - the user to store
context - the current context
Returns:
the stored user's primary key
Throws:
AuthorizationException - if the current user is not authorized to update this user

storeUserPreferences

void storeUserPreferences(PreferencesCommand command,
                          BizContext context)
                          throws AuthorizationException
Store user preferences in the back end.

Parameters:
command - the preferences to store
context - the current context
Throws:
AuthorizationException - if the current user is not authorized to update this user

getUserWatermark

org.springframework.core.io.Resource getUserWatermark(java.lang.Long userId)
Get a Resource for a user's watermark.

Parameters:
userId - the ID of the user to get the watermark resource for
Returns:
a Resource, or null if none available

removeUser

void removeUser(java.lang.Long userId,
                BizContext context)
Remove a User from the back end.

Parameters:
userId - the ID of the User to remove
context - the current context

logonUser

User logonUser(java.lang.String login,
               java.lang.String password)
               throws AuthorizationException
Authenticate a user by their username and password.

Parameters:
login - the login name of the user to logon
password - the attempted password
Returns:
the User if found and password matches
Throws:
AuthorizationException - if user not found or password does not match

getUserById

User getUserById(java.lang.Long userId,
                 BizContext context)
Get a User by its ID.

Parameters:
userId - the ID of the user to get
context - the current context
Returns:
User

getUserByAnonymousKey

User getUserByAnonymousKey(java.lang.String key)
Get a User by its anonymous key.

Parameters:
key - the key of the user to get
Returns:
the user, or null if not found

getUserLocale

java.util.Locale getUserLocale(User user,
                               BizContext context)
Get the Locale for a User.

Parameters:
user - the user to get the Locale for
context - the current context
Returns:
Locale

getCollectionDirectory

java.io.File getCollectionDirectory(Collection collection,
                                    BizContext context)
Get the directory for a given collection.

Parameters:
collection - the collection to get the root directory for
context - the current context
Returns:
the directory

getCollection

Collection getCollection(java.lang.Long collectionId,
                         BizContext context)
Get a single collection.

The collection items need not be populated here. See the MediaBiz.getCollectionWithItems(Long, BizContext) method for that.

Parameters:
collectionId - the ID of the collection to get
context - the current context
Returns:
the collection, or null if not available

storeCollection

java.lang.Long storeCollection(Collection collection,
                               BizContext context)
                               throws AuthorizationException
Store a collection in the back end.

This method will accept new collections as well as updates to existing collections.

Parameters:
collection - the collection to store
context - the current context
Returns:
the stored collection's primary key
Throws:
AuthorizationException - if the current user is not authorized to update this collection

getCollectionsForUser

java.util.List<Collection> getCollectionsForUser(User user,
                                                 BizContext context)
Get all collections for a given user.

Note this method is not presumed to return Collection instances populated with the MediaItem instances associated with each Collection. That is assumed to be a very expensive operation, so the implementation need not bother returning "complete" Collection instanes.

Parameters:
user - the user to get collections for
context - the current context
Returns:
non-null List of users's collections

newCollectionForUser

Collection newCollectionForUser(Collection collection,
                                User user,
                                BizContext context)
Create a new Collection for a given user.

Parameters:
collection - the collection object to associate with the user
user - the user
context - the current context
Returns:
the saved Collection

getAlbumsForUser

java.util.List<Album> getAlbumsForUser(User user,
                                       BizContext context)
Get all albums for a given user.

Note this method is not presumed to return Album instances populated with the MediaItem instances associated with each Album. That is assumed to be a very expensive operation, so the implementation need not bother returning "complete" Album instanes.

Parameters:
user - the user to get albums for
context - the current context
Returns:
non-null List of users's albums

getAlbumFeedForUser

java.util.List<Album> getAlbumFeedForUser(AlbumFeedCommand command)
Get a List of Albums for a user's album feed.

Parameters:
command - the command
Returns:
the albums

getSharedAlbumsForUser

java.util.List<Album> getSharedAlbumsForUser(BrowseAlbumsCommand command)
Get a List of Albums for a browse command.

Parameters:
command - the browse command
Returns:
the albums

hasAccessLevel

boolean hasAccessLevel(User user,
                       int level)
Return true if the supplied user has the specified access level.

Parameters:
user - the user to test
level - the level (use the ACCESS_* constants)
Returns:
true if the supplied user has the specified access level

forgotPassword

java.lang.String forgotPassword(java.lang.String login,
                                BizContext context)
                                throws AuthorizationException
Call to email a user a link with a one-time password.

Calling this method will do the following:

  1. Generate a random password for the user
  2. Update the user with the new password
  3. Generate a confirmation code for the user to pass later to confirmForgotPassword(String, String, String, BizContext)

Parameters:
login - the login of the user that forgot their password
context - the current context
Returns:
a confirmation string suitable to pass to confirmForgotPassword(String, String, String, BizContext)
Throws:
AuthorizationException - if the login is not found the reason code will be set to AuthorizationException.Reason#UNKNOWN_LOGIN

confirmForgotPassword

User confirmForgotPassword(java.lang.String login,
                           java.lang.String confirmationCode,
                           java.lang.String newPassword,
                           BizContext context)
                           throws AuthorizationException
Confirm a forgotten password.

Parameters:
login - the login of the user being confirmed
confirmationCode - the confirmation code issued by a previous call to forgotPassword(String, BizContext)
newPassword - the new password to set
context - the current context
Returns:
the confirmed user
Throws:
AuthorizationException - if the login is not found the reason code will be set to AuthorizationException.Reason#UNKNOWN_LOGIN, if the confirmationCode does not match then the reason code will be set to AuthorizationException.Reason#FORGOTTEN_PASSWORD_NOT_CONFIRMED

getUsersWithAccess

java.util.List<User> getUsersWithAccess(int level)
Get a list of User objects that have a specific access level.

Parameters:
level - the access level
Returns:
list of users

getAnonymousUser

User getAnonymousUser()
Get an anonymous user object.

Returns:
user instance

isAnonymousUser

boolean isAnonymousUser(User user)
Test if a User is an anonoymous user.

Parameters:
user - the user to test
Returns:
true if the user is an anonymous user