org.apache.lucene.gdata.data
Class GDataAccount

java.lang.Object
  extended by org.apache.lucene.gdata.data.GDataAccount

public class GDataAccount
extends Object

The GData-Server system provides acccount to be associated with registered feed. Every feed has an owner account. The account holder is automaticaly in role to modify his feeds. One account can own n feeds having m entries.

Additionally an account can be in role to modify other feeds, create accounts or feeds. See GDataAccount.AccountRole for detailed infomation about roles. One account can also have more than one role. All roles in GDataAccount.AccountRole can be combined

For each account values for author name, author email and author link can be set at creation time or during an update. These values will be used as the corresponding values for the feed ServerBaseFeed.addAuthor(Person) if no value for the feed has be specified.

Author:
Simon Willnauer

Nested Class Summary
static class GDataAccount.AccountRole
          This enum respesents all account roles an account can have.
 
Constructor Summary
GDataAccount()
          Creates a new GDataAccount.
 
Method Summary
static GDataAccount createAdminAccount()
           
 boolean equals(Object o)
           
 URL getAuthorLink()
           
 String getAuthorMail()
           
 String getAuthorname()
           
 String getName()
           
 String getPassword()
           
 Set<GDataAccount.AccountRole> getRoles()
           
 int getRolesAsInt()
           
 int hashCode()
           
static boolean isInRole(int intRole, GDataAccount.AccountRole role)
          checks whether the given integer matches the account role.
 boolean isUserInRole(GDataAccount.AccountRole role)
           
 boolean requiredValuesSet()
          Checks the requiered values for creating an account are set.
 void setAuthorLink(URL authorLink)
           
 void setAuthorMail(String authorMail)
           
 void setAuthorname(String authorname)
           
 void setName(String name)
           
 void setPassword(String password)
           
 void setRole(GDataAccount.AccountRole role)
          Adds the given role to the role list
 void setRolesAsInt(int i)
          Sets the roles from a int representation.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GDataAccount

public GDataAccount()
Creates a new GDataAccount. The default role GDataAccount.AccountRole.USER will be set.

Method Detail

getPassword

public String getPassword()
Returns:
- the password

setPassword

public void setPassword(String password)
Parameters:
password - - the account Password

getName

public String getName()
Returns:
- the account name

setName

public void setName(String name)
Parameters:
name - The name to set.

getAuthorLink

public URL getAuthorLink()
Returns:
- the http link specified for the author

setAuthorLink

public void setAuthorLink(URL authorLink)
Parameters:
authorLink - - the http link specified for the author

getAuthorMail

public String getAuthorMail()
Returns:
- the authors mail address

setAuthorMail

public void setAuthorMail(String authorMail)
Parameters:
authorMail - - the authors mail address

getAuthorname

public String getAuthorname()
Returns:
- the name specified as being the author name

setAuthorname

public void setAuthorname(String authorname)
Parameters:
authorname - - the name specified as being the author name

setRole

public void setRole(GDataAccount.AccountRole role)
Adds the given role to the role list

Parameters:
role - - the role to add to the role list

getRoles

public Set<GDataAccount.AccountRole> getRoles()
Returns:
- the set containing all roles

isUserInRole

public boolean isUserInRole(GDataAccount.AccountRole role)
Parameters:
role - - the role to check
Returns:
true if the role list contains the given role

getRolesAsInt

public int getRolesAsInt()
Returns:
- the integer representation for the user roles
See Also:
setRolesAsInt(int)

setRolesAsInt

public void setRolesAsInt(int i)
Sets the roles from a int representation.
  1. The fist bit set indicates a GDataAccount.AccountRole.USER - int value 1
  2. The second bit set indicates a GDataAccount.AccountRole.ENTRYAMINISTRATOR - int value 2
  3. The third bit set indicates a GDataAccount.AccountRole.FEEDAMINISTRATOR - int value 4
  4. The forth bit set indicates a GDataAccount.AccountRole.USERADMINISTRATOR - int value 8
    1. This method will only set roles, will not remove roles! A combination of roles is also possible e.g. the int value 6 combines GDataAccount.AccountRole.ENTRYAMINISTRATOR and GDataAccount.AccountRole.FEEDAMINISTRATOR.

      Parameters:
      i - - the integer used to set the roles

equals

public boolean equals(Object o)
Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Overrides:
hashCode in class Object
See Also:
Object.hashCode()

requiredValuesSet

public boolean requiredValuesSet()
Checks the requiered values for creating an account are set. Required values are name and password the minimum length of these values is 6.

Returns:
true if an only if password and name are not null and the length is > 5

toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()

isInRole

public static boolean isInRole(int intRole,
                               GDataAccount.AccountRole role)
checks whether the given integer matches the account role.

Parameters:
intRole - - integer representation of a role
role - - the account role to match
Returns:
true if and only if the given roles match, otherwise false

createAdminAccount

public static final GDataAccount createAdminAccount()
Returns:
- a new Administrator account


Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.