com.opensymphony.user.provider.ofbiz
Class OFBizAbstractProvider

java.lang.Object
  extended bycom.opensymphony.user.provider.ofbiz.OFBizAbstractProvider
All Implemented Interfaces:
java.io.Serializable, UserProvider
Direct Known Subclasses:
OFBizAccessProvider, OFBizCredentialsProvider, OFBizProfileProvider

public abstract class OFBizAbstractProvider
extends java.lang.Object
implements UserProvider

An abstract provider which handles most of the init and life cycle tasks of the provider.

Here's a sample of the entitymodel.xml fragment required for the OFBiz OSUser providers:

         <!-- OSUser implementation -->
         <entity entity-name="OSUser" table-name="userBase">
                 <field name="id" type="numeric"/>
                 <field name="name" type="string"/>
                 <field name="passwordHash" type="string"/>
                 <prim-key field="id"/>
         </entity>

         <entity entity-name="OSMembership" table-name="membershipBase">
                 <field name="id" type="numeric"/>
                 <field name="userName" type="string"/>
                 <field name="groupName" type="string"/>
                 <prim-key field="id"/>
         </entity>

  <entity entity-name="OSGroup" table-name="groupBase">
                 <field name="id" type="numeric"/>
                 <field name="name" type="string"/>
                 <prim-key field="id"/>
         </entity>
 

Settable properties (these must be set in all providers if changed from the default!):

delegator - the name of the OFBiz delegator (default: "default") userEntity - the name of the OFBiz group entity (default: "OSUser") exclusiveAccess - Whether or not the provider has exclusive access to the database (ie can take advantage of in memory caches) (default: "false")

Author:
Victor Salaman, Mike Cannon-Brookes
See Also:
Serialized Form

Field Summary
protected  java.lang.String delegator
           
protected  boolean exclusiveAccess
           
protected  org.apache.log4j.Category LOG
           
protected  java.util.Map nameCache
           
protected  java.lang.String userEntity
           
 
Constructor Summary
OFBizAbstractProvider()
           
 
Method Summary
protected  void clearAllCache()
          If using exclusive access, this will clear the cache of all users
protected  void clearUserCache(java.lang.String name)
          If using exclusive access, this will clear the cache of a particular user
 boolean create(java.lang.String s)
          Create new Entity with given name.
protected  org.ofbiz.core.entity.GenericValue findUser(java.lang.String name)
           
 void flushCaches()
          Flush the providers caches - if it is caching.
protected  org.ofbiz.core.entity.GenericDelegator getDelegator()
           
 boolean init(java.util.Properties properties)
          Called by UserManager before any other method.
 java.util.List list()
          Returns List of names (Strings) of all Entities that can be accessed by this UserProvider If this UserProvider cannot retrieve a list of names, null is to be returned.
 boolean load(java.lang.String s, Entity.Accessor accessor)
          Load Entity.
 boolean remove(java.lang.String s)
          Remove Entity with given name.
 boolean store(java.lang.String s, Entity.Accessor accessor)
          Stores changes to Entity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.opensymphony.user.provider.UserProvider
handles
 

Field Detail

LOG

protected final org.apache.log4j.Category LOG

nameCache

protected java.util.Map nameCache

delegator

protected java.lang.String delegator

userEntity

protected java.lang.String userEntity

exclusiveAccess

protected boolean exclusiveAccess
Constructor Detail

OFBizAbstractProvider

public OFBizAbstractProvider()
Method Detail

create

public boolean create(java.lang.String s)
Description copied from interface: UserProvider
Create new Entity with given name.

Specified by:
create in interface UserProvider
Returns:
Whether entity was successfully created.

flushCaches

public void flushCaches()
Description copied from interface: UserProvider
Flush the providers caches - if it is caching. Providers may implement their own caching strategies. This method merely indicates to the provider that it should flush it's caches now.

Specified by:
flushCaches in interface UserProvider

init

public boolean init(java.util.Properties properties)
Description copied from interface: UserProvider
Called by UserManager before any other method. Allows for UserProvider specific initialization.

Specified by:
init in interface UserProvider
Parameters:
properties - Extra properties passed across by UserManager.

list

public java.util.List list()
Description copied from interface: UserProvider
Returns List of names (Strings) of all Entities that can be accessed by this UserProvider If this UserProvider cannot retrieve a list of names, null is to be returned. If there are no current Entities stored by this provider, an empty List is to be returned. The order of names returned can be determined by the UserProvider (it may or may not be relevant). This List should be immutable.

Specified by:
list in interface UserProvider

load

public boolean load(java.lang.String s,
                    Entity.Accessor accessor)
Description copied from interface: UserProvider
Load Entity.

Specified by:
load in interface UserProvider
Returns:
Whether entity was successfully loaded.

remove

public boolean remove(java.lang.String s)
Description copied from interface: UserProvider
Remove Entity with given name.

Specified by:
remove in interface UserProvider
Returns:
Whether entity was successfully removed.

store

public boolean store(java.lang.String s,
                     Entity.Accessor accessor)
Description copied from interface: UserProvider
Stores changes to Entity.

Specified by:
store in interface UserProvider
Returns:
Whether changes to entity were successfully stored.

getDelegator

protected org.ofbiz.core.entity.GenericDelegator getDelegator()

clearAllCache

protected void clearAllCache()
If using exclusive access, this will clear the cache of all users


clearUserCache

protected void clearUserCache(java.lang.String name)
If using exclusive access, this will clear the cache of a particular user

Parameters:
name -

findUser

protected org.ofbiz.core.entity.GenericValue findUser(java.lang.String name)
                                               throws org.ofbiz.core.entity.GenericEntityException
Throws:
org.ofbiz.core.entity.GenericEntityException

See www.opensymphony.com for more information.