org.nuiton.topia.history
Class TopiaHistoryServiceImpl

java.lang.Object
  extended by org.nuiton.topia.history.TopiaHistoryServiceImpl
All Implemented Interfaces:
java.lang.Runnable, java.util.EventListener, TopiaTransactionVetoable, TopiaService, TopiaHistoryService

public class TopiaHistoryServiceImpl
extends java.lang.Object
implements TopiaHistoryService, java.lang.Runnable, TopiaTransactionVetoable

Pour active l'historisation des actions utilisateur il faut mettre dans le fichier de propriete la cle suivante:

  • topia.history=org.nuiton.topia.history.TopiaHistoryServiceImpl

    puis par defaut toutes les actions sont historis�es, mais on peut choisir dans desactiver certaines:

  • topia.history.create=[true|false]
  • topia.history.delete=[true|false]
  • topia.history.update=[true|false]
  • topia.history.load=[true|false]

    On peut demander a ce que l'historique soit nettoyer automatiquement avec:

  • topia.history.clean.frequency=1
  • topia.history.clean.date=3
  • topia.history.clean.number=1000
  • topia.history.store.file=/path/to/file/history Si seul frequency est specifier alors l'history est nettoyer a cette frequence et pour le nombre de jour indiqu�. Par exemple si on indique 1d alors tous les jours l'history est nettoy� pour ne garder qu'un jour.

    Si on souhaite garder plus d'un jour, mais nettoyer tout de meme tous les jours, il faut utiliser l'option topia.history.clean.date qui donne le nombre de jour a conserver.

    Si on ne veut pas conserver un nombre de jour, mais un nombre d'enregistrement il faut utiliser a la place topia.history.clean.number

    Si l'on souhaite sauver l'history avant de le nettoyer il faut utiliser l'option topia.history.store.file. Le fichier indiqu� est utilis� pour ajouter l'history. Si le fichier existe, les nouveaux history lui sont ajouter, sinon le fichier est cr��. Sous Linux on peut utiliser logrotate sur ce fichier.

    Author:
    poussin

    Field Summary
    protected  int cleanDate
              nombre de jour a garder
    protected  float cleanFrequency
              en jour
    protected  int cleanNumber
              nombre d'history a garder
    protected  TopiaContextImplementor context
               
    protected  TopiaHistoryListener historyListener
               
    protected  java.io.File storeFile
              fichier on conserver les histories
    protected  java.util.concurrent.ScheduledThreadPoolExecutor task
              Scheduler de nettoyage
     
    Fields inherited from interface org.nuiton.topia.history.TopiaHistoryService
    SERVICE_NAME
     
    Constructor Summary
    TopiaHistoryServiceImpl()
               
     
    Method Summary
     void beginTransaction(TopiaTransactionEvent event)
              Permet de propager le l'historisation sur l'ensemble des contextes
     void clear(java.util.Date toDate)
              Supprime tout l'historique jusqu'a la date passé en parametre
     java.util.List<java.lang.String> findLastAction(int limit, java.lang.String user, java.lang.String type, java.lang.Integer... actions)
              Search TopiaId targeted by action and user.
     java.lang.Class<?>[] getPersistenceClasses()
               
     java.lang.String getServiceName()
               
     void keep(int number)
              Ne garde dans l'historique que les number dernier elements
     boolean postInit(TopiaContextImplementor context)
               
     boolean preInit(TopiaContextImplementor context)
               
     void run()
              Fait le menage de l'history
     void store(java.util.Date toDate, java.io.Writer out)
              Permet de stocker l'historique dans un writer (par exemple un fichier)
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    historyListener

    protected TopiaHistoryListener historyListener

    context

    protected TopiaContextImplementor context

    cleanFrequency

    protected float cleanFrequency
    en jour


    cleanDate

    protected int cleanDate
    nombre de jour a garder


    cleanNumber

    protected int cleanNumber
    nombre d'history a garder


    storeFile

    protected java.io.File storeFile
    fichier on conserver les histories


    task

    protected java.util.concurrent.ScheduledThreadPoolExecutor task
    Scheduler de nettoyage

    Constructor Detail

    TopiaHistoryServiceImpl

    public TopiaHistoryServiceImpl()
    Method Detail

    getServiceName

    public java.lang.String getServiceName()
    Specified by:
    getServiceName in interface TopiaService

    getPersistenceClasses

    public java.lang.Class<?>[] getPersistenceClasses()
    Specified by:
    getPersistenceClasses in interface TopiaService

    preInit

    public boolean preInit(TopiaContextImplementor context)
    Specified by:
    preInit in interface TopiaService

    postInit

    public boolean postInit(TopiaContextImplementor context)
    Specified by:
    postInit in interface TopiaService

    beginTransaction

    public void beginTransaction(TopiaTransactionEvent event)
    Permet de propager le l'historisation sur l'ensemble des contextes

    Specified by:
    beginTransaction in interface TopiaTransactionVetoable
    Parameters:
    event -

    clear

    public void clear(java.util.Date toDate)
               throws java.lang.Exception
    Description copied from interface: TopiaHistoryService
    Supprime tout l'historique jusqu'a la date passé en parametre

    Specified by:
    clear in interface TopiaHistoryService
    Parameters:
    toDate - la derniere date effacé inclue
    Throws:
    java.lang.Exception - if any pb

    keep

    public void keep(int number)
              throws java.lang.Exception
    Description copied from interface: TopiaHistoryService
    Ne garde dans l'historique que les number dernier elements

    Specified by:
    keep in interface TopiaHistoryService
    Parameters:
    number - le nombre d'element a conserver dans l'historique
    Throws:
    java.lang.Exception - if any pb

    store

    public void store(java.util.Date toDate,
                      java.io.Writer out)
               throws java.lang.Exception
    Description copied from interface: TopiaHistoryService
    Permet de stocker l'historique dans un writer (par exemple un fichier)

    Specified by:
    store in interface TopiaHistoryService
    Parameters:
    toDate - l'historique est sauve jusqu'a cette date incluse
    out - le flux sur lequel il faut ecrire l'historique
    Throws:
    java.lang.Exception - if any pb

    findLastAction

    public java.util.List<java.lang.String> findLastAction(int limit,
                                                           java.lang.String user,
                                                           java.lang.String type,
                                                           java.lang.Integer... actions)
                                                    throws java.lang.Exception
    Description copied from interface: TopiaHistoryService
    Search TopiaId targeted by action and user. Results are ordered by date last is oldest

    Specified by:
    findLastAction in interface TopiaHistoryService
    Parameters:
    limit - maximum number of result, -1 for all
    user - TopiaId of user, can be null for all user
    type - type of target search (fqn class) can be null for all object
    actions - action as int that we want to search, can be an sum of action wanted LOAD + UPDATE + DELETE + CREATE for all action
    Returns:
    TopiaId of target object
    Throws:
    java.lang.Exception - if any pb

    run

    public void run()
    Fait le menage de l'history

    Specified by:
    run in interface java.lang.Runnable
    See Also:
    Runnable.run()


    Copyright © 2004-2009 CodeLutin. All Rights Reserved.