org.nuiton.wikitty
Class WikittyServiceNotifier

java.lang.Object
  extended by org.nuiton.wikitty.WikittyServiceNotifier
All Implemented Interfaces:
WikittyService

public class WikittyServiceNotifier
extends Object
implements WikittyService

Wikitty service notifier. Currently based on jgroups.

Version:
$Revision: 161 $ Last update : $Date: 2010-06-28 17:56:28 +0200 (lun., 28 juin 2010) $ By : $Author: echatellier $
Author:
chatellier

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.nuiton.wikitty.WikittyService
WikittyService.ServiceListenerType
 
Field Summary
protected  org.nuiton.util.ListenerSet<WikittyServiceListener> allWikittyServiceListeners
          Wikitty service listener (all event).
protected  org.nuiton.util.ListenerSet<WikittyServiceListener> localWikittyServiceListeners
          Wikitty service listener (only for local event).
protected  WikittyServiceListener notifier
          JGroup notifier.
protected  boolean propagateCache
          Indique si les evenement sont propagés aux autres listener.
protected  org.nuiton.util.ListenerSet<WikittyServiceListener> remoteWikittyServiceListeners
          Wikitty service listener (only for remote event).
static String WIKITTY_EVENT_JGROUPCHANNELNAME_OPTION
          Utilisation du canal de communication basé sur jgroups avec comme identifiant d'application le nom de canal en option.
static String WIKITTY_EVENT_PROPAGATE_OPTION
          Indique si les objects sont propages (true) vers les autres caches ou simplement supprimes des autres caches (false).
protected  WikittyService ws
          Service to delegate.
 
Constructor Summary
WikittyServiceNotifier(WikittyService ws)
          Default constructor.
WikittyServiceNotifier(WikittyService ws, Properties props)
          Constructor with configuration.
 
Method Summary
protected  void addJGroupNotifier(Properties props)
          Add jgroup listener if enabled by configuration.
 void addLabel(String securityToken, String wikittyId, String label)
          add new lable to the wikitty object
 void addWikittyServiceListener(WikittyServiceListener listener, WikittyService.ServiceListenerType type)
          Add new wikitty service listener.
 boolean canDelete(String securityToken, String wikittyId)
          Verifie que l'utilisateur associe au securityToken peut supprimer le wikitty dont on passe l'identifiant.
 boolean canRead(String securityToken, String wikittyId)
          Un utilisateur peu lire un objet, s'il est Reader ou a defaut: - owner - AppAdmin - Admin - Writer
 boolean canWrite(String securityToken, Wikitty wikitty)
          Verifie si l'utilisateur lie au securityToken a le droit d'ecrire le Wikitty passe en argument
 void clear(String securityToken)
          Use with caution : It will delete ALL indexes from search engine !
 void delete(String securityToken, Collection<String> ids)
          delete all object if id exists
 void delete(String securityToken, String id)
          delete object if id exists
 Set<String> findAllAppliedLabels(String securityToken, String wikittyId)
          retrieve all labels applied on a wikitty object
 PagedResult<String> findAllByCriteria(String securityToken, Criteria criteria)
           
 PagedResult<String> findAllByCriteria(String securityToken, WikittyTransaction transaction, Criteria criteria)
           
 PagedResult<String> findAllByLabel(String securityToken, String label, int firstIndex, int endIndex)
           
 Wikitty findByCriteria(String securityToken, Criteria criteria)
          Fist lonely (or first one) wikitty object that match criteria, if no wikitty found or first retrived is not authorized for the user return null
 Wikitty findByLabel(String securityToken, String label)
           
protected  void fireClearExtension()
          Build event to fire and call fireClearExtension(WikittyServiceEvent).
protected  void fireClearExtension(WikittyServiceEvent event)
          Fire event to all registred listener.
protected  void fireClearWikitty()
          Build event to fire and call fireClearWikitty(WikittyServiceEvent).
protected  void fireClearWikitty(WikittyServiceEvent event)
          Fire event to all registred listener.
protected  void firePutExtension(WikittyExtension... exts)
          Build event to fire and call firePutExtension(WikittyServiceEvent).
protected  void firePutExtension(WikittyServiceEvent event)
          Fire event to all registred listener.
protected  void firePutWikitty(Wikitty... ws)
          Build event to fire and call firePutWikitty(WikittyServiceEvent).
protected  void firePutWikitty(WikittyServiceEvent event)
          Fire event to all registred listener.
protected  void fireRemoveExtension(WikittyExtension... exts)
          Build event to fire and call fireRemoveExtension(WikittyServiceEvent).
protected  void fireRemoveExtension(WikittyServiceEvent event)
          Fire event to all registred listener.
protected  void fireRemoveWikitty(String... wikittyIds)
          Build event to fire and call fireRemoveWikitty(WikittyServiceEvent).
protected  void fireRemoveWikitty(WikittyServiceEvent event)
          Fire event to all registred listener.
 List<String> getAllExtensionIds(String securityToken)
          Return all extension id (ex: "extName[version])")
 List<String> getAllExtensionsRequires(String securityToken, String extensionName)
          Return all extension id (ex: "extName[version])") where extensionName is required.
 String login(String login, String password)
          Authenticate someone on WikittyService. securityToken returned must be used to call others methods
 void logout(String securityToken)
          Unanthenticate someone by disabled securityToken
 void removeWikittyServiceListener(WikittyServiceListener listener, WikittyService.ServiceListenerType type)
          Remove wikitty service listener.
 List<Wikitty> restore(String securityToken, List<String> ids)
           
 Wikitty restore(String securityToken, String id)
           
 List<Wikitty> restore(String securityToken, WikittyTransaction transaction, List<String> ids)
          Restore wikitty using opened transaction.
 Map<TreeNode,Integer> restoreChildren(String securityToken, String wikittyId, Criteria filter)
          Retrieve all wikitties children with count (no recursively) of an other one Wikitty reference by wikittyId MUST include the 'Node' extension
 WikittyExtension restoreExtension(String securityToken, String id)
           
 WikittyExtension restoreExtension(String securityToken, WikittyTransaction transaction, String id)
          action is done in transaction passed in argument
 WikittyExtension restoreExtensionLastVersion(String securityToken, String name)
          Search extension with name in last version.
 WikittyExtension restoreExtensionLastVersion(String securityToken, WikittyTransaction transaction, String name)
          Search extension with name in last version.
 Map.Entry<TreeNode,Integer> restoreNode(String securityToken, String wikittyId, Criteria filter)
          Retrieve wikitty node with count.
 Tree restoreTree(String securityToken, String wikittyId)
          Retrieve all wikitties children (recursively) of an other one Wikitty reference by wikittyId MUST include the 'Node' extension
 Wikitty restoreVersion(String securityToken, String wikittyId, String version)
          Restore wikitty in specifique version.
 UpdateResponse store(String securityToken, Collection<Wikitty> wikitties)
          Manage Update and creation.
 UpdateResponse store(String securityToken, Collection<Wikitty> wikitties, boolean disableAutoVersionIncrement)
          Manage Update and creation.
 UpdateResponse store(String securityToken, Wikitty wikitty)
          Manage Update and creation.
 UpdateResponse store(String securityToken, WikittyTransaction transaction, Collection<Wikitty> wikitties, boolean disableAutoVersionIncrement)
          Manage Update and creation, action is done in transaction passed in argument
 UpdateResponse storeExtension(String securityToken, Collection<WikittyExtension> exts)
          Manage Update and creation.
 UpdateResponse storeExtension(String securityToken, WikittyExtension ext)
          Manage Update and creation.
 UpdateResponse storeExtension(String securityToken, WikittyTransaction transaction, Collection<WikittyExtension> exts)
          Manage Update and creation, action is done in transaction passed in argument
 UpdateResponse syncEngin(String securityToken)
          Synchronise search engine with wikitty strorage engine, i.e. clear and reindex all wikitties.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WIKITTY_EVENT_JGROUPCHANNELNAME_OPTION

public static final String WIKITTY_EVENT_JGROUPCHANNELNAME_OPTION
Utilisation du canal de communication basé sur jgroups avec comme identifiant d'application le nom de canal en option. Si ce nom est vide, jgroups n'est pas utilisé. Si WIKITTY_EVENT_PROPAGATE_OPTION est a true et que cette options est vide, une exception est levée.

See Also:
Constant Field Values

WIKITTY_EVENT_PROPAGATE_OPTION

public static final String WIKITTY_EVENT_PROPAGATE_OPTION
Indique si les objects sont propages (true) vers les autres caches ou simplement supprimes des autres caches (false). Default to false.

See Also:
Constant Field Values

propagateCache

protected boolean propagateCache
Indique si les evenement sont propagés aux autres listener. Sinon on est juste listener des evenements recus. C'est pourquoi le listener notifier doit toujours être ajouté.

See Also:
WIKITTY_EVENT_PROPAGATE_OPTION

ws

protected WikittyService ws
Service to delegate.


allWikittyServiceListeners

protected org.nuiton.util.ListenerSet<WikittyServiceListener> allWikittyServiceListeners
Wikitty service listener (all event).


localWikittyServiceListeners

protected org.nuiton.util.ListenerSet<WikittyServiceListener> localWikittyServiceListeners
Wikitty service listener (only for local event).


remoteWikittyServiceListeners

protected org.nuiton.util.ListenerSet<WikittyServiceListener> remoteWikittyServiceListeners
Wikitty service listener (only for remote event).


notifier

protected WikittyServiceListener notifier
JGroup notifier.

Constructor Detail

WikittyServiceNotifier

public WikittyServiceNotifier(WikittyService ws)
Default constructor.

Parameters:
ws - delegate service

WikittyServiceNotifier

public WikittyServiceNotifier(WikittyService ws,
                              Properties props)
Constructor with configuration.

Parameters:
ws - delegate service
props - properties (can be null)
Method Detail

addJGroupNotifier

protected void addJGroupNotifier(Properties props)
Add jgroup listener if enabled by configuration.

Parameters:
props - properties (can be null)

addWikittyServiceListener

public void addWikittyServiceListener(WikittyServiceListener listener,
                                      WikittyService.ServiceListenerType type)
Description copied from interface: WikittyService
Add new wikitty service listener. Warning, listener is referenced as WeakReference, but sure to another reference to work.

Specified by:
addWikittyServiceListener in interface WikittyService
Parameters:
listener - listener to add
type - type of event to listen
See Also:
WikittyService.ServiceListenerType

removeWikittyServiceListener

public void removeWikittyServiceListener(WikittyServiceListener listener,
                                         WikittyService.ServiceListenerType type)
Description copied from interface: WikittyService
Remove wikitty service listener. Warning, listener is referenced as WeakReference, but sure to another reference to work.

Specified by:
removeWikittyServiceListener in interface WikittyService
Parameters:
listener - listener to remove
type - type of event to listen
See Also:
WikittyService.ServiceListenerType

login

public String login(String login,
                    String password)
Description copied from interface: WikittyService
Authenticate someone on WikittyService. securityToken returned must be used to call others methods

Specified by:
login in interface WikittyService
Parameters:
login - can be application specifique login, but best practice is to use email user
Returns:
return token securityToken

logout

public void logout(String securityToken)
Description copied from interface: WikittyService
Unanthenticate someone by disabled securityToken

Specified by:
logout in interface WikittyService
Parameters:
securityToken - security token previously returned by login. If securityToken is not valid, this method do nothing

canWrite

public boolean canWrite(String securityToken,
                        Wikitty wikitty)
Description copied from interface: WikittyService
Verifie si l'utilisateur lie au securityToken a le droit d'ecrire le Wikitty passe en argument

Specified by:
canWrite in interface WikittyService
Parameters:
securityToken - le token de securite qui permet de retrouver l'utilisateur et ainsi verifier les droits
wikitty - le wikitty a sauver
Returns:
vrai si l'utilisateur peut sauver l'objet

canDelete

public boolean canDelete(String securityToken,
                         String wikittyId)
Description copied from interface: WikittyService
Verifie que l'utilisateur associe au securityToken peut supprimer le wikitty dont on passe l'identifiant. Seul le propriétaire de l'objet ou un admin peut supprimer un objet. Si l'id de l'objet est invalide, la methode retourne true, car la suppression d'un id invalide ne fait rien

Specified by:
canDelete in interface WikittyService
Returns:
vrai le la suppression ne posera pas de probleme.

canRead

public boolean canRead(String securityToken,
                       String wikittyId)
Description copied from interface: WikittyService
Un utilisateur peu lire un objet, s'il est Reader ou a defaut: - owner - AppAdmin - Admin - Writer

Specified by:
canRead in interface WikittyService
Returns:
vrai si l'utilisateur peut lire l'obbjet

clear

public void clear(String securityToken)
Description copied from interface: WikittyService
Use with caution : It will delete ALL indexes from search engine ! This operation should be disabled in production environment.

Specified by:
clear in interface WikittyService

store

public UpdateResponse store(String securityToken,
                            Wikitty wikitty)
Description copied from interface: WikittyService
Manage Update and creation.

Specified by:
store in interface WikittyService
wikitty - contains an id all the time.

store

public UpdateResponse store(String securityToken,
                            Collection<Wikitty> wikitties)
Description copied from interface: WikittyService
Manage Update and creation.

Specified by:
store in interface WikittyService
wikitties - list of wikitty to be persisted

store

public UpdateResponse store(String securityToken,
                            Collection<Wikitty> wikitties,
                            boolean disableAutoVersionIncrement)
Description copied from interface: WikittyService
Manage Update and creation.

Specified by:
store in interface WikittyService
wikitties - list of wikitty to be persisted
disableAutoVersionIncrement - boolean to disable version increment on saved wikitty

store

public UpdateResponse store(String securityToken,
                            WikittyTransaction transaction,
                            Collection<Wikitty> wikitties,
                            boolean disableAutoVersionIncrement)
Description copied from interface: WikittyService
Manage Update and creation, action is done in transaction passed in argument

Specified by:
store in interface WikittyService
transaction - transaction used to do the action (must not be null)
wikitties - list of wikitty to be persisted
disableAutoVersionIncrement - boolean to disable version increment on saved wikitty

getAllExtensionIds

public List<String> getAllExtensionIds(String securityToken)
Description copied from interface: WikittyService
Return all extension id (ex: "extName[version])")

Specified by:
getAllExtensionIds in interface WikittyService
Returns:

getAllExtensionsRequires

public List<String> getAllExtensionsRequires(String securityToken,
                                             String extensionName)
Description copied from interface: WikittyService
Return all extension id (ex: "extName[version])") where extensionName is required.

Specified by:
getAllExtensionsRequires in interface WikittyService
Returns:

storeExtension

public UpdateResponse storeExtension(String securityToken,
                                     WikittyExtension ext)
Description copied from interface: WikittyService
Manage Update and creation.

Specified by:
storeExtension in interface WikittyService

storeExtension

public UpdateResponse storeExtension(String securityToken,
                                     Collection<WikittyExtension> exts)
Description copied from interface: WikittyService
Manage Update and creation.

Specified by:
storeExtension in interface WikittyService
exts - list of wikitty extension to be persisted

storeExtension

public UpdateResponse storeExtension(String securityToken,
                                     WikittyTransaction transaction,
                                     Collection<WikittyExtension> exts)
Description copied from interface: WikittyService
Manage Update and creation, action is done in transaction passed in argument

Specified by:
storeExtension in interface WikittyService
transaction - transaction used to do the action (must not be null)
exts - list of wikitty extension to be persisted

restoreExtension

public WikittyExtension restoreExtension(String securityToken,
                                         String id)
Specified by:
restoreExtension in interface WikittyService
Returns:
the corresponding object, exception if no such object found.

restoreExtension

public WikittyExtension restoreExtension(String securityToken,
                                         WikittyTransaction transaction,
                                         String id)
Description copied from interface: WikittyService
action is done in transaction passed in argument

Specified by:
restoreExtension in interface WikittyService
transaction - transaction used to do the action (must not be null)
Returns:
the corresponding object, exception if no such object found.

restoreExtensionLastVersion

public WikittyExtension restoreExtensionLastVersion(String securityToken,
                                                    String name)
Description copied from interface: WikittyService
Search extension with name in last version.

Specified by:
restoreExtensionLastVersion in interface WikittyService
name - extension name
Returns:
the corresponding object, exception if no such object found.

restoreExtensionLastVersion

public WikittyExtension restoreExtensionLastVersion(String securityToken,
                                                    WikittyTransaction transaction,
                                                    String name)
Description copied from interface: WikittyService
Search extension with name in last version.

Specified by:
restoreExtensionLastVersion in interface WikittyService
transaction - transaction used to do the action (must not be null)
name - extension name
Returns:
the corresponding object, exception if no such object found.

restore

public Wikitty restore(String securityToken,
                       String id)
Specified by:
restore in interface WikittyService
id - object id to restore
Returns:
the corresponding object, or null if object doesn't exist, is deleted or you don't have authorisation (you can check authorisation before call restore with WikittyService.canRead(java.lang.String, java.lang.String)

restore

public List<Wikitty> restore(String securityToken,
                             List<String> ids)
Specified by:
restore in interface WikittyService
ids - list of wikitty ids to restore
Returns:
list of corresponding wikitty, if one id is not valid (no object or deleted or no authorisation) this id is skip and result list have less elements than collection argument

restore

public List<Wikitty> restore(String securityToken,
                             WikittyTransaction transaction,
                             List<String> ids)
Description copied from interface: WikittyService
Restore wikitty using opened transaction.

Specified by:
restore in interface WikittyService
Parameters:
securityToken - security token
transaction - transaction to use
ids - list of wikitty ids to restore
Returns:
list of corresponding wikitty, if one id is not valid (no object or deleted or no authorisation) this id is skip and result list have less elements than collection argument

delete

public void delete(String securityToken,
                   String id)
Description copied from interface: WikittyService
delete object if id exists

Specified by:
delete in interface WikittyService
id - object's id to remove

delete

public void delete(String securityToken,
                   Collection<String> ids)
Description copied from interface: WikittyService
delete all object if id exists

Specified by:
delete in interface WikittyService
ids - object's ids to remove

findAllByCriteria

public PagedResult<String> findAllByCriteria(String securityToken,
                                             Criteria criteria)
Specified by:
findAllByCriteria in interface WikittyService
Returns:

findAllByCriteria

public PagedResult<String> findAllByCriteria(String securityToken,
                                             WikittyTransaction transaction,
                                             Criteria criteria)
Specified by:
findAllByCriteria in interface WikittyService
Returns:

findByCriteria

public Wikitty findByCriteria(String securityToken,
                              Criteria criteria)
Description copied from interface: WikittyService
Fist lonely (or first one) wikitty object that match criteria, if no wikitty found or first retrived is not authorized for the user return null

Specified by:
findByCriteria in interface WikittyService
Returns:
wikitty object or null

addLabel

public void addLabel(String securityToken,
                     String wikittyId,
                     String label)
Description copied from interface: WikittyService
add new lable to the wikitty object

Specified by:
addLabel in interface WikittyService
wikittyId - id of wikitty object to add label
label - label to add

findAllByLabel

public PagedResult<String> findAllByLabel(String securityToken,
                                          String label,
                                          int firstIndex,
                                          int endIndex)
Specified by:
findAllByLabel in interface WikittyService
Returns:

findByLabel

public Wikitty findByLabel(String securityToken,
                           String label)
Specified by:
findByLabel in interface WikittyService
Returns:

findAllAppliedLabels

public Set<String> findAllAppliedLabels(String securityToken,
                                        String wikittyId)
Description copied from interface: WikittyService
retrieve all labels applied on a wikitty object

Specified by:
findAllAppliedLabels in interface WikittyService
Returns:

restoreTree

public Tree restoreTree(String securityToken,
                        String wikittyId)
Description copied from interface: WikittyService
Retrieve all wikitties children (recursively) of an other one Wikitty reference by wikittyId MUST include the 'Node' extension

Specified by:
restoreTree in interface WikittyService
Returns:

restoreNode

public Map.Entry<TreeNode,Integer> restoreNode(String securityToken,
                                               String wikittyId,
                                               Criteria filter)
Description copied from interface: WikittyService
Retrieve wikitty node with count. Wikitty reference by wikittyId MUST include the 'Node' extension

Specified by:
restoreNode in interface WikittyService
Returns:

restoreChildren

public Map<TreeNode,Integer> restoreChildren(String securityToken,
                                             String wikittyId,
                                             Criteria filter)
Description copied from interface: WikittyService
Retrieve all wikitties children with count (no recursively) of an other one Wikitty reference by wikittyId MUST include the 'Node' extension

Specified by:
restoreChildren in interface WikittyService
Returns:

restoreVersion

public Wikitty restoreVersion(String securityToken,
                              String wikittyId,
                              String version)
Description copied from interface: WikittyService
Restore wikitty in specifique version. Authorisation is checked on last version even for previous wikitty version

Specified by:
restoreVersion in interface WikittyService

syncEngin

public UpdateResponse syncEngin(String securityToken)
Description copied from interface: WikittyService
Synchronise search engine with wikitty strorage engine, i.e. clear and reindex all wikitties.

Specified by:
syncEngin in interface WikittyService
Returns:

firePutWikitty

protected void firePutWikitty(Wikitty... ws)
Build event to fire and call firePutWikitty(WikittyServiceEvent).

Parameters:
ws - data

fireRemoveWikitty

protected void fireRemoveWikitty(String... wikittyIds)
Build event to fire and call fireRemoveWikitty(WikittyServiceEvent).

Parameters:
wikittyIds - wikitty ids

fireClearWikitty

protected void fireClearWikitty()
Build event to fire and call fireClearWikitty(WikittyServiceEvent).


firePutExtension

protected void firePutExtension(WikittyExtension... exts)
Build event to fire and call firePutExtension(WikittyServiceEvent).

Parameters:
ws - data

fireRemoveExtension

protected void fireRemoveExtension(WikittyExtension... exts)
Build event to fire and call fireRemoveExtension(WikittyServiceEvent).

Parameters:
ws - data

fireClearExtension

protected void fireClearExtension()
Build event to fire and call fireClearExtension(WikittyServiceEvent).

Parameters:
ws - data

firePutWikitty

protected void firePutWikitty(WikittyServiceEvent event)
Fire event to all registred listener. Take care about WikittyServiceEvent.isRemote() for fire.

Parameters:
event - event to fire

fireRemoveWikitty

protected void fireRemoveWikitty(WikittyServiceEvent event)
Fire event to all registred listener. Take care about WikittyServiceEvent.isRemote() for fire.

Parameters:
event - event to fire

fireClearWikitty

protected void fireClearWikitty(WikittyServiceEvent event)
Fire event to all registred listener. Take care about WikittyServiceEvent.isRemote() for fire.

Parameters:
event - event to fire

firePutExtension

protected void firePutExtension(WikittyServiceEvent event)
Fire event to all registred listener. Take care about WikittyServiceEvent.isRemote() for fire.

Parameters:
event - event to fire

fireRemoveExtension

protected void fireRemoveExtension(WikittyServiceEvent event)
Fire event to all registred listener. Take care about WikittyServiceEvent.isRemote() for fire.

Parameters:
event - event to fire

fireClearExtension

protected void fireClearExtension(WikittyServiceEvent event)
Fire event to all registred listener. Take care about WikittyServiceEvent.isRemote() for fire.

Parameters:
event - event to fire


Copyright © 2009-2010 CodeLutin. All Rights Reserved.