Class CachedPubSubRepository<T>

java.lang.Object
tigase.pubsub.repository.cached.CachedPubSubRepository<T>
All Implemented Interfaces:
tigase.kernel.beans.Initializable, IItems.IListnener, IPubSubRepository, tigase.stats.StatisticHolder, tigase.xmpp.mam.MAMRepository<PubSubQuery,tigase.xmpp.mam.MAMRepository.Item>

@Bean(name="repository", parent=PubSubComponent.class, active=true) public class CachedPubSubRepository<T> extends Object implements IPubSubRepository, tigase.stats.StatisticHolder, tigase.kernel.beans.Initializable, IItems.IListnener
Implementation of IPubSubRepository interface providing access to the database for data storage with caching.
Version:
5.0.0, 2010.03.27 at 05:20:46 GMT
Author:
Artur Hefczyc
  • Field Details

  • Constructor Details

    • CachedPubSubRepository

      public CachedPubSubRepository()
  • Method Details

    • isServiceAutoCreated

      protected boolean isServiceAutoCreated()
    • addToRootCollection

      public void addToRootCollection(tigase.xmpp.jid.BareJID serviceJid, String nodeName) throws tigase.component.exceptions.RepositoryException
      Specified by:
      addToRootCollection in interface IPubSubRepository
      Throws:
      tigase.component.exceptions.RepositoryException
    • createNode

      public void createNode(tigase.xmpp.jid.BareJID serviceJid, String nodeName, tigase.xmpp.jid.BareJID ownerJid, AbstractNodeConfig nodeConfig, NodeType nodeType, String collection) throws tigase.component.exceptions.RepositoryException, PubSubException
      Specified by:
      createNode in interface IPubSubRepository
      Throws:
      tigase.component.exceptions.RepositoryException
      PubSubException
    • createService

      public void createService(tigase.xmpp.jid.BareJID serviceJID, boolean isPublic) throws tigase.component.exceptions.RepositoryException
      Specified by:
      createService in interface IPubSubRepository
      Throws:
      tigase.component.exceptions.RepositoryException
    • getServices

      public List<tigase.xmpp.jid.BareJID> getServices(tigase.xmpp.jid.BareJID domain, Boolean isPublic) throws tigase.component.exceptions.RepositoryException
      Specified by:
      getServices in interface IPubSubRepository
      Throws:
      tigase.component.exceptions.RepositoryException
    • deleteNode

      public void deleteNode(tigase.xmpp.jid.BareJID serviceJid, String nodeName) throws tigase.component.exceptions.RepositoryException
      Specified by:
      deleteNode in interface IPubSubRepository
      Throws:
      tigase.component.exceptions.RepositoryException
    • destroy

      public void destroy()
      Specified by:
      destroy in interface IPubSubRepository
    • everyHour

      public void everyHour()
      Specified by:
      everyHour in interface tigase.stats.StatisticHolder
    • everyMinute

      public void everyMinute()
      Specified by:
      everyMinute in interface tigase.stats.StatisticHolder
    • everySecond

      public void everySecond()
      Specified by:
      everySecond in interface tigase.stats.StatisticHolder
    • updateNodeConfiguration

      protected void updateNodeConfiguration(tigase.xmpp.jid.BareJID serviceJID, String nodeName, tigase.form.Form config)
    • getChildNodes

      public String[] getChildNodes(tigase.xmpp.jid.BareJID serviceJid, String nodeName) throws tigase.component.exceptions.RepositoryException
      Specified by:
      getChildNodes in interface IPubSubRepository
      Throws:
      tigase.component.exceptions.RepositoryException
    • getNodeAffiliations

      public IAffiliations getNodeAffiliations(tigase.xmpp.jid.BareJID serviceJid, String nodeName) throws tigase.component.exceptions.RepositoryException
      Specified by:
      getNodeAffiliations in interface IPubSubRepository
      Throws:
      tigase.component.exceptions.RepositoryException
    • getNodeConfig

      public AbstractNodeConfig getNodeConfig(tigase.xmpp.jid.BareJID serviceJid, String nodeName) throws tigase.component.exceptions.RepositoryException
      Specified by:
      getNodeConfig in interface IPubSubRepository
      Throws:
      tigase.component.exceptions.RepositoryException
    • getNodeMeta

      public INodeMeta getNodeMeta(tigase.xmpp.jid.BareJID serviceJid, String nodeName) throws tigase.component.exceptions.RepositoryException
      Specified by:
      getNodeMeta in interface IPubSubRepository
      Throws:
      tigase.component.exceptions.RepositoryException
    • getNodeItems

      public IItems getNodeItems(tigase.xmpp.jid.BareJID serviceJid, String nodeName) throws tigase.component.exceptions.RepositoryException
      Specified by:
      getNodeItems in interface IPubSubRepository
      Throws:
      tigase.component.exceptions.RepositoryException
    • getNodeItems

      public List<IItems.IItem> getNodeItems(tigase.xmpp.jid.BareJID serviceJid, String nodeName, tigase.xmpp.jid.JID requester, Date after, Date before, tigase.xmpp.rsm.RSM rsm) throws tigase.component.exceptions.ComponentException, tigase.component.exceptions.RepositoryException
      Specified by:
      getNodeItems in interface IPubSubRepository
      Throws:
      tigase.component.exceptions.ComponentException
      tigase.component.exceptions.RepositoryException
    • getNodeSubscriptions

      public ISubscriptions getNodeSubscriptions(tigase.xmpp.jid.BareJID serviceJid, String nodeName) throws tigase.component.exceptions.RepositoryException
      Specified by:
      getNodeSubscriptions in interface IPubSubRepository
      Throws:
      tigase.component.exceptions.RepositoryException
    • getNodesCount

      public long getNodesCount(tigase.xmpp.jid.BareJID serviceJID) throws tigase.component.exceptions.RepositoryException
      Specified by:
      getNodesCount in interface IPubSubRepository
      Throws:
      tigase.component.exceptions.RepositoryException
    • getPubSubDAO

      public IPubSubDAO getPubSubDAO()
      Specified by:
      getPubSubDAO in interface IPubSubRepository
    • setDao

      public void setDao(IPubSubDAO<T,tigase.db.DataSource,PubSubQuery> dao)
    • getRootCollection

      public String[] getRootCollection(tigase.xmpp.jid.BareJID serviceJid) throws tigase.component.exceptions.RepositoryException
      Specified by:
      getRootCollection in interface IPubSubRepository
      Throws:
      tigase.component.exceptions.RepositoryException
    • getStatistics

      public void getStatistics(String name, tigase.stats.StatisticsList stats)
      Specified by:
      getStatistics in interface tigase.stats.StatisticHolder
    • getUserAffiliations

      public Map<String,UsersAffiliation> getUserAffiliations(tigase.xmpp.jid.BareJID serviceJid, tigase.xmpp.jid.BareJID jid) throws tigase.component.exceptions.RepositoryException
      Specified by:
      getUserAffiliations in interface IPubSubRepository
      Throws:
      tigase.component.exceptions.RepositoryException
    • getUserRoster

      public Map<tigase.xmpp.jid.BareJID,tigase.xmpp.impl.roster.RosterElement> getUserRoster(tigase.xmpp.jid.BareJID owner) throws tigase.component.exceptions.RepositoryException
      Specified by:
      getUserRoster in interface IPubSubRepository
      Throws:
      tigase.component.exceptions.RepositoryException
    • getUserSubscriptions

      public Map<String,UsersSubscription> getUserSubscriptions(tigase.xmpp.jid.BareJID serviceJid, tigase.xmpp.jid.BareJID userJid) throws tigase.component.exceptions.RepositoryException
      Specified by:
      getUserSubscriptions in interface IPubSubRepository
      Throws:
      tigase.component.exceptions.RepositoryException
    • init

      public void init()
      Specified by:
      init in interface IPubSubRepository
    • initialize

      public void initialize()
      Specified by:
      initialize in interface tigase.kernel.beans.Initializable
    • queryItems

      public void queryItems(PubSubQuery query, tigase.xmpp.mam.MAMRepository.ItemHandler<PubSubQuery,tigase.xmpp.mam.MAMRepository.Item> itemHandler) throws tigase.component.exceptions.RepositoryException, tigase.component.exceptions.ComponentException
      Specified by:
      queryItems in interface tigase.xmpp.mam.MAMRepository<PubSubQuery,tigase.xmpp.mam.MAMRepository.Item>
      Throws:
      tigase.component.exceptions.RepositoryException
      tigase.component.exceptions.ComponentException
    • newQuery

      public PubSubQuery newQuery()
      Specified by:
      newQuery in interface tigase.xmpp.mam.MAMRepository<PubSubQuery,tigase.xmpp.mam.MAMRepository.Item>
    • newQuery

      public PubSubQuery newQuery(tigase.xmpp.jid.BareJID jid)
      Specified by:
      newQuery in interface tigase.xmpp.mam.MAMRepository<PubSubQuery,tigase.xmpp.mam.MAMRepository.Item>
    • removeFromRootCollection

      public void removeFromRootCollection(tigase.xmpp.jid.BareJID serviceJid, String nodeName) throws tigase.component.exceptions.RepositoryException
      Specified by:
      removeFromRootCollection in interface IPubSubRepository
      Throws:
      tigase.component.exceptions.RepositoryException
    • setStatisticsPrefix

      public void setStatisticsPrefix(String prefix)
      Specified by:
      setStatisticsPrefix in interface tigase.stats.StatisticHolder
    • statisticExecutedIn

      public void statisticExecutedIn(long executionTime)
      Specified by:
      statisticExecutedIn in interface tigase.stats.StatisticHolder
    • update

      public void update(tigase.xmpp.jid.BareJID serviceJid, String nodeName, AbstractNodeConfig nodeConfig) throws tigase.component.exceptions.RepositoryException, PubSubException
      Specified by:
      update in interface IPubSubRepository
      Throws:
      tigase.component.exceptions.RepositoryException
      PubSubException
    • update

      public void update(tigase.xmpp.jid.BareJID serviceJid, String nodeName, IAffiliations nodeAffiliations) throws tigase.component.exceptions.RepositoryException
      Specified by:
      update in interface IPubSubRepository
      Throws:
      tigase.component.exceptions.RepositoryException
    • update

      public void update(tigase.xmpp.jid.BareJID serviceJid, String nodeName, ISubscriptions nodeSubscriptions) throws tigase.component.exceptions.RepositoryException
      Specified by:
      update in interface IPubSubRepository
      Throws:
      tigase.component.exceptions.RepositoryException
    • deleteService

      public void deleteService(tigase.xmpp.jid.BareJID userJid) throws tigase.component.exceptions.RepositoryException
      Specified by:
      deleteService in interface IPubSubRepository
      Throws:
      tigase.component.exceptions.RepositoryException
    • addMAMItem

      public void addMAMItem(tigase.xmpp.jid.BareJID serviceJid, String nodeName, String uuid, tigase.xml.Element message, String itemId) throws tigase.component.exceptions.RepositoryException
      Specified by:
      addMAMItem in interface IPubSubRepository
      Throws:
      tigase.component.exceptions.RepositoryException
    • validateItem

      public boolean validateItem(tigase.xmpp.jid.BareJID serviceJID, String node, String id, String publisher, tigase.xml.Element item) throws PubSubException
      Specified by:
      validateItem in interface IItems.IListnener
      Throws:
      PubSubException
    • itemWritten

      public void itemWritten(tigase.xmpp.jid.BareJID serviceJID, String node, String id, String publisher, tigase.xml.Element item, String uuid)
      Specified by:
      itemWritten in interface IItems.IListnener
    • itemDeleted

      public void itemDeleted(tigase.xmpp.jid.BareJID serviceJID, String node, String id)
      Specified by:
      itemDeleted in interface IItems.IListnener
    • createKey

      protected CachedPubSubRepository.NodeKey createKey(tigase.xmpp.jid.BareJID serviceJid, String nodeName)
    • getNode

      protected Node getNode(tigase.xmpp.jid.BareJID serviceJid, String nodeName) throws tigase.component.exceptions.RepositoryException
      Throws:
      tigase.component.exceptions.RepositoryException
    • loadNode

      protected Node loadNode(tigase.xmpp.jid.BareJID serviceJid, String nodeName) throws tigase.component.exceptions.RepositoryException
      Throws:
      tigase.component.exceptions.RepositoryException
    • newNodeAffiliations

      protected IAffiliationsCached newNodeAffiliations(tigase.xmpp.jid.BareJID serviceJid, String nodeName, T nodeId, IPubSubRepository.RepositorySupplier<Map<tigase.xmpp.jid.BareJID,UsersAffiliation>> affiliationSupplier) throws tigase.component.exceptions.RepositoryException
      Throws:
      tigase.component.exceptions.RepositoryException
    • newNodeSubscriptions

      protected ISubscriptionsCached newNodeSubscriptions(tigase.xmpp.jid.BareJID serviceJid, String nodeName, T nodeId, IPubSubRepository.RepositorySupplier<Map<tigase.xmpp.jid.BareJID,UsersSubscription>> subscriptionsSupplier) throws tigase.component.exceptions.RepositoryException
      Throws:
      tigase.component.exceptions.RepositoryException
    • getNodeFromCache

      protected Node getNodeFromCache(tigase.xmpp.jid.BareJID serviceJid, String nodeName)
    • getRootCollectionSet

      protected IPubSubRepository.RootCollectionSetIfc getRootCollectionSet(tigase.xmpp.jid.BareJID serviceJid) throws tigase.component.exceptions.RepositoryException
      Throws:
      tigase.component.exceptions.RepositoryException
    • loadRootCollections

      protected void loadRootCollections(CachedPubSubRepository.RootCollectionSet rootCollection) throws tigase.component.exceptions.RepositoryException
      Throws:
      tigase.component.exceptions.RepositoryException
    • getNodeAndSubnodes

      protected List<Node<T>> getNodeAndSubnodes(tigase.xmpp.jid.BareJID serviceJid, String nodeName, Predicate<Node<T>> filterWithSubnodes, Predicate<Node<T>> filter) throws tigase.component.exceptions.RepositoryException, tigase.component.exceptions.ComponentException
      Throws:
      tigase.component.exceptions.RepositoryException
      tigase.component.exceptions.ComponentException
    • hasAccessPermission

      protected boolean hasAccessPermission(Node node, tigase.xmpp.jid.JID requester, PubSubLogic.Action action)
    • serviceRemoved

      protected void serviceRemoved(tigase.xmpp.jid.BareJID userJid)
    • nodeCollectionChanged

      protected void nodeCollectionChanged(tigase.xmpp.jid.BareJID serviceJid, String nodeName, String oldCollection, String newCollection)
    • saveNode

      protected void saveNode(Node<T> node, int iteration) throws tigase.component.exceptions.RepositoryException
      Throws:
      tigase.component.exceptions.RepositoryException