Class AbstractNodeDAOImpl

java.lang.Object
org.alfresco.repo.domain.node.AbstractNodeDAOImpl
All Implemented Interfaces:
BatchingDAO, NodeDAO, NodeBulkLoader
Direct Known Subclasses:
NodeDAOImpl

public abstract class AbstractNodeDAOImpl extends Object implements NodeDAO, BatchingDAO
Abstract implementation for Node DAO.

This provides basic services such as caching, but defers to the underlying implementation for CRUD operations.

Since:
3.4
Author:
Derek Hulley
  • Field Details

    • CACHE_REGION_NODES

      public static final String CACHE_REGION_NODES
      See Also:
    • logger

      protected org.apache.commons.logging.Log logger
    • isDebugEnabled

      protected final boolean isDebugEnabled
    • LONG_ZERO

      public static final Long LONG_ZERO
  • Constructor Details

    • AbstractNodeDAOImpl

      public AbstractNodeDAOImpl()
      Constructor. Set up various instance-specific members such as caches and locks.
  • Method Details

    • setTransactionService

      public void setTransactionService(TransactionService transactionService)
      Parameters:
      transactionService - the service to start post-txn processes
    • setDictionaryService

      public void setDictionaryService(DictionaryService dictionaryService)
      Parameters:
      dictionaryService - the service help determine cm:auditable characteristics
    • setCachingThreshold

      public void setCachingThreshold(int cachingThreshold)
    • setPolicyBehaviourFilter

      public void setPolicyBehaviourFilter(BehaviourFilter policyBehaviourFilter)
      Parameters:
      policyBehaviourFilter - the service to determine the behaviour for cm:auditable and other inherent capabilities.
    • setAclDAO

      public void setAclDAO(AclDAO aclDAO)
      Parameters:
      aclDAO - used to update permissions during certain operations
    • setAccessControlListDAO

      public void setAccessControlListDAO(AccessControlListDAO accessControlListDAO)
      Parameters:
      accessControlListDAO - used to update ACL inheritance during node moves
    • setControlDAO

      public void setControlDAO(ControlDAO controlDAO)
      Parameters:
      controlDAO - create Savepoints
    • setQnameDAO

      public void setQnameDAO(QNameDAO qnameDAO)
      Parameters:
      qnameDAO - translates QName IDs into QName instances and vice-versa
    • setContentDataDAO

      public void setContentDataDAO(ContentDataDAO contentDataDAO)
      Parameters:
      contentDataDAO - used to create and delete content references
    • setLocaleDAO

      public void setLocaleDAO(LocaleDAO localeDAO)
      Parameters:
      localeDAO - used to handle MLText properties
    • setUsageDAO

      public void setUsageDAO(UsageDAO usageDAO)
      Parameters:
      usageDAO - used to keep content usage calculations in line
    • setRootNodesCache

      public void setRootNodesCache(SimpleCache<Serializable,Serializable> cache)
      Set the cache that maintains the Store root node data
      Parameters:
      cache - the cache
    • setAllRootNodesCache

      public void setAllRootNodesCache(SimpleCache<StoreRef,Set<NodeRef>> allRootNodesCache)
      Set the cache that maintains the extended Store root node data
      Parameters:
      allRootNodesCache - the cache
    • setNodesCache

      public void setNodesCache(SimpleCache<Serializable,Serializable> cache)
      Set the cache that maintains node ID-NodeRef cross referencing data
      Parameters:
      cache - the cache
    • setAspectsCache

      public void setAspectsCache(SimpleCache<NodeVersionKey,Set<QName>> aspectsCache)
      Set the cache that maintains the Node QName IDs
      Parameters:
      aspectsCache - the cache
    • setPropertiesCache

      public void setPropertiesCache(SimpleCache<NodeVersionKey,Map<QName,Serializable>> propertiesCache)
      Set the cache that maintains the Node property values
      Parameters:
      propertiesCache - the cache
    • setParentAssocsCacheSize

      public void setParentAssocsCacheSize(int parentAssocsCacheSize)
      Sets the maximum capacity of the parent assocs cache
      Parameters:
      parentAssocsCacheSize - the cache size
    • setParentAssocsCacheLimitFactor

      public void setParentAssocsCacheLimitFactor(int parentAssocsCacheLimitFactor)
      Sets the average number of parents expected per cache entry. This parameter is multiplied by the setParentAssocsCacheSize(int) parameter to compute a limit on the total number of cached parents, which will be proportional to the cache's memory usage. The cache will be pruned when this limit is exceeded to avoid excessive memory usage.
      Parameters:
      parentAssocsCacheLimitFactor - the parentAssocsCacheLimitFactor to set
    • setChildByNameCache

      public void setChildByNameCache(SimpleCache<org.alfresco.repo.domain.node.ChildByNameKey,ChildAssocEntity> childByNameCache)
      Set the cache that maintains lookups by child cm:name
      Parameters:
      childByNameCache - the cache
    • init

      public void init()
    • getCurrentTransactionCommitTime

      public Long getCurrentTransactionCommitTime()
      Specified by:
      getCurrentTransactionCommitTime in interface NodeDAO
      Returns:
      the commit time of the current transaction entry or null if there have not been any modifications to nodes registered in the transaction.
    • getCurrentTransactionId

      public Long getCurrentTransactionId(boolean ensureNew)
      Specified by:
      getCurrentTransactionId in interface NodeDAO
      Parameters:
      ensureNew - true to ensure that a new transaction entry is created if the current transaction does not have one.
      Returns:
      Returns the ID of the current transaction entry or null if there have not been any modifications to nodes registered in the transaction and forceNew is false
    • getStore

      public Pair<Long,StoreRef> getStore(StoreRef storeRef)
      Description copied from interface: NodeDAO
      Get the ID-ref pair for a store
      Specified by:
      getStore in interface NodeDAO
      Returns:
      Returns the ID-reference pair for the store or null if it doesn't exist
    • getStores

      public List<Pair<Long,StoreRef>> getStores()
      Description copied from interface: NodeDAO
      Fetch a list of all stores in the repository
      Specified by:
      getStores in interface NodeDAO
      Returns:
      Returns a list of stores
    • exists

      public boolean exists(StoreRef storeRef)
      Description copied from interface: NodeDAO
      Find out if a store exists or not
      Specified by:
      exists in interface NodeDAO
      Parameters:
      storeRef - the store
      Returns:
      Returns true if the store exists otherwise false
    • getRootNode

      public Pair<Long,NodeRef> getRootNode(StoreRef storeRef)
      Specified by:
      getRootNode in interface NodeDAO
    • getAllRootNodes

      public Set<NodeRef> getAllRootNodes(StoreRef storeRef)
      Specified by:
      getAllRootNodes in interface NodeDAO
    • newStore

      public Pair<Long,NodeRef> newStore(StoreRef storeRef)
      Description copied from interface: NodeDAO
      Creates a unique store for the given protocol and identifier combination. The root node is created with the "root" aspect.
      Specified by:
      newStore in interface NodeDAO
      Returns:
      Returns the root node, which is added automatically.
    • moveStore

      public void moveStore(StoreRef oldStoreRef, StoreRef newStoreRef)
      Description copied from interface: NodeDAO
      Changes the old store reference to the new store reference.
      Specified by:
      moveStore in interface NodeDAO
      Parameters:
      oldStoreRef - the existing store
      newStoreRef - the new store
    • exists

      public boolean exists(Long nodeId)
      Description copied from interface: NodeDAO
      Find out if a node exists. Unpurged deleted nodes do not count as they are the DAO's concern only.
      Specified by:
      exists in interface NodeDAO
      Parameters:
      nodeId - the potentially valid node ID
      Returns:
      Returns true if the node is present and undeleted
    • exists

      public boolean exists(NodeRef nodeRef)
      Description copied from interface: NodeDAO
      Find out if a node exists. Unpurged deleted nodes do not count as they are the DAO's concern only.
      Specified by:
      exists in interface NodeDAO
      Parameters:
      nodeRef - the potentially valid node reference
      Returns:
      Returns true if the node is present and undeleted
    • isInCurrentTxn

      public boolean isInCurrentTxn(Long nodeId)
      Specified by:
      isInCurrentTxn in interface NodeDAO
      Returns:
      Returns true if the node was last modified in the current transaction, otherwise false.
    • getNodeRefStatus

      public NodeRef.Status getNodeRefStatus(NodeRef nodeRef)
      Description copied from interface: NodeDAO
      Get the current status of the node, including deleted nodes.
      Specified by:
      getNodeRefStatus in interface NodeDAO
      Parameters:
      nodeRef - the node reference
      Returns:
      Returns the current status of the reference. This will only be null if the node never existed or has been purged following deletion.
    • getNodeIdStatus

      public NodeRef.Status getNodeIdStatus(Long nodeId)
      Description copied from interface: NodeDAO
      Get the current status of the node, including deleted nodes.
      Specified by:
      getNodeIdStatus in interface NodeDAO
      Parameters:
      nodeId - the node id
      Returns:
      Returns the current status of the reference. This will only be null if the node never existed or has been purged following deletion.
    • getNodePair

      public Pair<Long,NodeRef> getNodePair(NodeRef nodeRef)
      Specified by:
      getNodePair in interface NodeDAO
    • getNodePair

      public Pair<Long,NodeRef> getNodePair(Long nodeId)
      Specified by:
      getNodePair in interface NodeDAO
    • getNodeType

      public QName getNodeType(Long nodeId)
      Specified by:
      getNodeType in interface NodeDAO
    • getNodeAclId

      public Long getNodeAclId(Long nodeId)
      Specified by:
      getNodeAclId in interface NodeDAO
    • newNode

      public ChildAssocEntity newNode(Long parentNodeId, QName assocTypeQName, QName assocQName, StoreRef storeRef, String uuid, QName nodeTypeQName, Locale nodeLocale, String childNodeName, Map<QName,Serializable> auditableProperties) throws InvalidTypeException
      Description copied from interface: NodeDAO
      Create a new node. Note that allowing the uuid to be assigned by passing in a null is more efficient.
      Specified by:
      newNode in interface NodeDAO
      Parameters:
      parentNodeId - the ID of the parent node (may not be null)
      assocTypeQName - the primary association (may not be null)
      assocQName - the association path (may not be null)
      storeRef - the store to which the node must belong
      uuid - the node store-unique identifier, or null to assign a GUID
      nodeTypeQName - the type of the node
      nodeLocale - the locale of the node
      childNodeName - the cm:name of the child node or null to use the node's UUID
      auditableProperties - a map containing any cm:auditable properties for the node
      Returns:
      Returns the details of the child association created
      Throws:
      InvalidTypeException - if the node type is invalid or if the node type is not a valid real node
    • newNodeImplInsert

      protected Long newNodeImplInsert(NodeEntity node)
    • moveNode

      public Pair<Pair<Long,ChildAssociationRef>,Pair<Long,NodeRef>> moveNode(Long childNodeId, Long newParentNodeId, QName assocTypeQName, QName assocQName)
      Description copied from interface: NodeDAO
      Update a node's primary association, giving it a new parent and new association parameters.

      **NEW**: If the parent node's store differs from the child node's store, then a new child node's is created.

      Specified by:
      moveNode in interface NodeDAO
      Parameters:
      childNodeId - the child node that is moving
      newParentNodeId - the new parent node (may not be null)
      assocTypeQName - the new association type or null to keep the existing type
      assocQName - the new association qname or null to keep the existing name
      Returns:
      Returns the (first) new association reference and new child reference (second)
    • updatePrimaryParentAssocs

      protected void updatePrimaryParentAssocs(ChildAssocEntity primaryParentAssoc, Node newParentNode, Node childNode, Long newChildNodeId, String childNodeName, Long oldParentNodeId, QName assocTypeQName, QName assocQName)
    • updatePrimaryParentAssocsImpl

      protected int updatePrimaryParentAssocsImpl(ChildAssocEntity primaryParentAssoc, Node newParentNode, Node childNode, Long newChildNodeId, String childNodeName, Long oldParentNodeId, QName assocTypeQName, QName assocQName)
    • updateNode

      public boolean updateNode(Long nodeId, QName nodeTypeQName, Locale nodeLocale)
      Specified by:
      updateNode in interface NodeDAO
      nodeTypeQName - the new type QName for the node or null to keep the existing one
      nodeLocale - the new locale for the node or null to keep the existing one
      Returns:
      true if any changes were made
    • touchNodes

      public int touchNodes(Long txnId, List<Long> nodeIds)
      Description copied from interface: NodeDAO
      Update the transaction associated with a lust of nodes
      Specified by:
      touchNodes in interface NodeDAO
      Parameters:
      txnId - - the tx id to set
      nodeIds - - the nodes to update
      Returns:
      the number of nodes touched
    • setNodeAclId

      public void setNodeAclId(Long nodeId, Long aclId)
      Specified by:
      setNodeAclId in interface NodeDAO
    • setPrimaryChildrenSharedAclId

      public void setPrimaryChildrenSharedAclId(Long primaryParentNodeId, Long optionalOldSharedAlcIdInAdditionToNull, Long newSharedAclId)
      Specified by:
      setPrimaryChildrenSharedAclId in interface NodeDAO
    • deleteNode

      public void deleteNode(Long nodeId)
      Description copied from interface: NodeDAO
      Deletes the node and all entities. Note that the node entry will still exist and be associated with a live transaction.
      Specified by:
      deleteNode in interface NodeDAO
    • purgeNodes

      public int purgeNodes(long fromTxnCommitTimeMs, long toTxnCommitTimeMs)
      Description copied from interface: NodeDAO
      Purge deleted nodes where their participating transactions are in-between the given time interval.
      Specified by:
      purgeNodes in interface NodeDAO
      Parameters:
      fromTxnCommitTimeMs - from commit time
      toTxnCommitTimeMs - to commit time
      Returns:
      Returns the number of deleted nodes purged
    • getNodeProperties

      public Map<QName,Serializable> getNodeProperties(Long nodeId)
      Specified by:
      getNodeProperties in interface NodeDAO
    • getNodeProperty

      public Serializable getNodeProperty(Long nodeId, QName propertyQName)
      Specified by:
      getNodeProperty in interface NodeDAO
    • setNodeProperties

      public boolean setNodeProperties(Long nodeId, Map<QName,Serializable> properties)
      Specified by:
      setNodeProperties in interface NodeDAO
    • addNodeProperty

      public boolean addNodeProperty(Long nodeId, QName qname, Serializable value)
      Specified by:
      addNodeProperty in interface NodeDAO
    • addNodeProperties

      public boolean addNodeProperties(Long nodeId, Map<QName,Serializable> properties)
      Specified by:
      addNodeProperties in interface NodeDAO
    • removeNodeProperties

      public boolean removeNodeProperties(Long nodeId, Set<QName> propertyQNames)
      Specified by:
      removeNodeProperties in interface NodeDAO
    • setModifiedDate

      public boolean setModifiedDate(Long nodeId, Date modifiedDate)
      Description copied from interface: NodeDAO
      Pull the cm:modified up to the current time without changing any other cm:auditable properties. The change may be done in the current transaction or in a later transaction.
      Specified by:
      setModifiedDate in interface NodeDAO
      Parameters:
      nodeId - the node to change
      modifiedDate - the date to set for cm:modified
      Returns:
      Returns true if the cm:modified property was actually set
    • setModifiedProperties

      public boolean setModifiedProperties(Long nodeId, Date modifiedDate, String modifiedBy)
      Description copied from interface: NodeDAO
      Pull the cm:modified up to the current time without changing any other cm:auditable properties. The change may be done in the current transaction or in a later transaction.
      Specified by:
      setModifiedProperties in interface NodeDAO
      Parameters:
      nodeId - the node to change
      modifiedDate - the date to set for cm:modified
      modifiedBy - the name to set for cm:modifier
      Returns:
      Returns true if the cm:modified and cm:modifier properties were actually set
    • getNodeAspects

      public Set<QName> getNodeAspects(Long nodeId)
      Specified by:
      getNodeAspects in interface NodeDAO
    • hasNodeAspect

      public boolean hasNodeAspect(Long nodeId, QName aspectQName)
      Specified by:
      hasNodeAspect in interface NodeDAO
    • addNodeAspects

      public boolean addNodeAspects(Long nodeId, Set<QName> aspectQNames)
      Specified by:
      addNodeAspects in interface NodeDAO
    • removeNodeAspects

      public boolean removeNodeAspects(Long nodeId)
      Specified by:
      removeNodeAspects in interface NodeDAO
    • removeNodeAspects

      public boolean removeNodeAspects(Long nodeId, Set<QName> aspectQNames)
      Specified by:
      removeNodeAspects in interface NodeDAO
    • getNodesWithAspects

      public void getNodesWithAspects(Set<QName> aspectQNames, Long minNodeId, Long maxNodeId, NodeDAO.NodeRefQueryCallback resultsCallback)
      Description copied from interface: NodeDAO
      Get nodes with aspects between the given ranges
      Specified by:
      getNodesWithAspects in interface NodeDAO
      Parameters:
      aspectQNames - the aspects that must be on the nodes
      minNodeId - the minimum node ID (inclusive)
      maxNodeId - the maximum node ID (exclusive)
      resultsCallback - callback to process results
    • getNodesWithAspects

      public void getNodesWithAspects(Set<QName> aspectQNames, Long minNodeId, Long maxNodeId, boolean ordered, NodeDAO.NodeRefQueryCallback resultsCallback)
      Description copied from interface: NodeDAO
      Get nodes with aspects between the given ranges, ordering the results optionally
      Specified by:
      getNodesWithAspects in interface NodeDAO
      Parameters:
      aspectQNames - the aspects that must be on the nodes
      minNodeId - the minimum node ID (inclusive)
      maxNodeId - the maximum node ID (exclusive)
      ordered - if the results are to be ordered by nodeID
      resultsCallback - callback to process results
    • getNodesWithAspects

      public void getNodesWithAspects(Set<QName> aspectQNames, Long minNodeId, Long maxNodeId, boolean ordered, int maxResults, NodeDAO.NodeRefQueryCallback resultsCallback)
      Description copied from interface: NodeDAO
      Get nodes with aspects between the given ranges, ordering the results optionally and limit the result set
      Specified by:
      getNodesWithAspects in interface NodeDAO
      Parameters:
      aspectQNames - the aspects that must be on the nodes
      minNodeId - the minimum node ID (inclusive)
      maxNodeId - the maximum node ID (exclusive)
      ordered - if the results are to be ordered by nodeID
      maxResults - limit query to maxResults
      resultsCallback - callback to process results
    • newNodeAssoc

      public Long newNodeAssoc(Long sourceNodeId, Long targetNodeId, QName assocTypeQName, int assocIndex)
      Description copied from interface: NodeDAO
      Create a new association
      Specified by:
      newNodeAssoc in interface NodeDAO
      Parameters:
      sourceNodeId - the association source
      targetNodeId - the association target
      assocTypeQName - the type of the association (will be resolved to an ID)
      assocIndex - the index of the new association (-1 indicates next value)
    • setNodeAssocIndex

      public void setNodeAssocIndex(Long id, int assocIndex)
      Description copied from interface: NodeDAO
      Update an existing assoc's index.
      Specified by:
      setNodeAssocIndex in interface NodeDAO
      Parameters:
      id - the association ID
      assocIndex - the new index (greater than 0)
    • removeNodeAssoc

      public int removeNodeAssoc(Long sourceNodeId, Long targetNodeId, QName assocTypeQName)
      Description copied from interface: NodeDAO
      Remove a specific node association
      Specified by:
      removeNodeAssoc in interface NodeDAO
      Parameters:
      sourceNodeId - the source node ID
      targetNodeId - the target node id
      assocTypeQName - the node association QName
      Returns:
      Returns the number of associations removed
    • removeNodeAssocs

      public int removeNodeAssocs(List<Long> ids)
      Description copied from interface: NodeDAO
      Remove all node associations of given IDs
      Specified by:
      removeNodeAssocs in interface NodeDAO
      Parameters:
      ids - the IDs of the associations to remove
      Returns:
      Returns the number of associations removed
    • getNodeAssocsToAndFrom

      public Collection<Pair<Long,AssociationRef>> getNodeAssocsToAndFrom(Long nodeId)
      Specified by:
      getNodeAssocsToAndFrom in interface NodeDAO
      Parameters:
      nodeId - the source or target of the associations
      Returns:
      Returns all the node associations where the node is the source or target
    • getSourceNodeAssocs

      public Collection<Pair<Long,AssociationRef>> getSourceNodeAssocs(Long targetNodeId, QName typeQName)
      Specified by:
      getSourceNodeAssocs in interface NodeDAO
      Parameters:
      targetNodeId - the target of the association
      typeQName - the type of the association (optional)
      Returns:
      Returns all the node associations where the node is the target
    • getTargetNodeAssocs

      public Collection<Pair<Long,AssociationRef>> getTargetNodeAssocs(Long sourceNodeId, QName typeQName)
      Specified by:
      getTargetNodeAssocs in interface NodeDAO
      Parameters:
      sourceNodeId - the source of the association
      typeQName - the type of the association (optional)
      Returns:
      Returns all the node associations where the node is the source
    • getTargetAssocsByPropertyValue

      public Collection<Pair<Long,AssociationRef>> getTargetAssocsByPropertyValue(Long sourceNodeId, QName typeQName, QName propertyQName, Serializable propertyValue)
      Description copied from interface: NodeDAO
      Get target associations by type of the association, property name and value.
      Specified by:
      getTargetAssocsByPropertyValue in interface NodeDAO
      Parameters:
      sourceNodeId - the source of the association
      typeQName - the type of the association (null allowed)
      propertyQName - property QName (null allowed)
      propertyValue - property value (null allowed only if the propertyQName is null)
      Returns:
      Returns all the node associations where the node is the source.
    • getNodeAssocOrNull

      public Pair<Long,AssociationRef> getNodeAssocOrNull(Long assocId)
      Specified by:
      getNodeAssocOrNull in interface NodeDAO
      Returns:
      Returns a specific node association with the given ID or null if it doesn't exist
    • getNodeAssoc

      public Pair<Long,AssociationRef> getNodeAssoc(Long assocId)
      Specified by:
      getNodeAssoc in interface NodeDAO
      Returns:
      Returns a specific node association with the given ID
    • newChildAssocInsert

      protected Long newChildAssocInsert(ChildAssocEntity assoc, QName assocTypeQName, String childNodeName)
    • newChildAssocInsertImpl

      protected Long newChildAssocInsertImpl(ChildAssocEntity assoc, QName assocTypeQName, String childNodeName)
    • newChildAssoc

      public Pair<Long,ChildAssociationRef> newChildAssoc(Long parentNodeId, Long childNodeId, QName assocTypeQName, QName assocQName, String childNodeName)
      Description copied from interface: NodeDAO
      Create a new child association. The unique enforcement for cm:name will be done as part of the association creation i.e. there is no need to update it after the fact.
      Specified by:
      newChildAssoc in interface NodeDAO
      childNodeName - the cm:name to apply to the association
      Returns:
      Returns the persisted and filled association's ID
    • deleteChildAssoc

      public void deleteChildAssoc(Long assocId)
      Specified by:
      deleteChildAssoc in interface NodeDAO
      Parameters:
      assocId - the ID of the child association to delete
    • setChildAssocIndex

      public int setChildAssocIndex(Long parentNodeId, Long childNodeId, QName assocTypeQName, QName assocQName, int index)
      Description copied from interface: NodeDAO
      Sets the association index ordering.
      Specified by:
      setChildAssocIndex in interface NodeDAO
      Parameters:
      parentNodeId - the parent node ID
      childNodeId - the child node ID
      assocTypeQName - the association type
      assocQName - the association path qualified name
      index - the new index
      Returns:
      Returns the number of associations modified
    • setChildAssocsUniqueName

      public void setChildAssocsUniqueName(Long childNodeId, String childName)
      TODO: See about pulling automatic cm:name update logic into this DAO
      Specified by:
      setChildAssocsUniqueName in interface NodeDAO
      Parameters:
      childNodeId - the child node who's name is changing
      childName - the new cm:name value
    • setChildAssocsUniqueNameImpl

      protected int setChildAssocsUniqueNameImpl(Long childNodeId, String childName)
    • updateChildAssocUniqueNameImpl

      protected int updateChildAssocUniqueNameImpl(Long childNodeId, String childName)
    • getChildAssoc

      public Pair<Long,ChildAssociationRef> getChildAssoc(Long assocId)
      Description copied from interface: NodeDAO
      Get a specific association
      Specified by:
      getChildAssoc in interface NodeDAO
      Parameters:
      assocId - the ID of the association
      Returns:
      Returns the association reference or null if it doesn't exist
    • getPrimaryChildrenAcls

      public List<NodeIdAndAclId> getPrimaryChildrenAcls(Long nodeId)
      Description copied from interface: NodeDAO
      Fetch all primary child node IDs and corresponding ACL IDs.
      Specified by:
      getPrimaryChildrenAcls in interface NodeDAO
      Parameters:
      nodeId - the parent node ID
      Returns:
      Returns a list of Node ID - ACL ID pairs
    • getChildAssoc

      public Pair<Long,ChildAssociationRef> getChildAssoc(Long parentNodeId, Long childNodeId, QName assocTypeQName, QName assocQName)
      Description copied from interface: NodeDAO
      Get a specific child association given all the determining data.

      The implementation may find multiple entries (there is no constraint to prevent it) although the cm:name constraint will normally prevent the association from being created twice. The lowest ID association will always be returned and the others will be cleaned up if the transaction is read-write.

      Specified by:
      getChildAssoc in interface NodeDAO
      Returns:
      Returns a matching association or null if one was not found.
    • getChildAssocs

      public void getChildAssocs(Long parentNodeId, Long childNodeId, QName assocTypeQName, QName assocQName, Boolean isPrimary, Boolean sameStore, NodeDAO.ChildAssocRefQueryCallback resultsCallback)
      Description copied from interface: NodeDAO
      Get the child associations of a given parent node, optionally filtering on association QName and association type QName.

      This is an efficient query for node paths.

      Specified by:
      getChildAssocs in interface NodeDAO
      Parameters:
      parentNodeId - the parent node ID
      childNodeId - the child node ID to filter on; null for no filtering
      assocTypeQName - the association type qname to filter on; null for no filtering
      assocQName - the association qname to filter on; null for no filtering
      isPrimary - filter for primary (true) or secondary associations; null for no filtering.
      sameStore - null to ignore, true to only get children that are in the same store as the parent, or false to only get children that are in a different store from the parent.
      resultsCallback - the callback that will be called with the results
    • getChildAssocs

      public void getChildAssocs(Long parentNodeId, QName assocTypeQName, QName assocQName, int maxResults, NodeDAO.ChildAssocRefQueryCallback resultsCallback)
      Description copied from interface: NodeDAO
      Gets the first n child associations of a given parent node, optionally filtering on association QName and association type QName.

      This is an efficient query for node paths.

      Specified by:
      getChildAssocs in interface NodeDAO
      Parameters:
      parentNodeId - the parent node ID
      assocTypeQName - the association type qname to filter on; null for no filtering
      assocQName - the association qname to filter on; null for no filtering
      maxResults - the maximum number of results to return. The query will be terminated efficiently after that number of results
      resultsCallback - the callback that will be called with the results
    • getChildAssocs

      public void getChildAssocs(Long parentNodeId, Set<QName> assocTypeQNames, NodeDAO.ChildAssocRefQueryCallback resultsCallback)
      Description copied from interface: NodeDAO
      Get the child associations of a given parent node, optionally filtering on type QName.
      Specified by:
      getChildAssocs in interface NodeDAO
      Parameters:
      parentNodeId - the parent node ID
      assocTypeQNames - the association type qnames to filter on; null for no filtering
      resultsCallback - the callback that will be called with the results
    • getChildAssoc

      public Pair<Long,ChildAssociationRef> getChildAssoc(Long parentNodeId, QName assocTypeQName, String childName)
      Checks a cache and then queries.

      Note: If we were to cach misses, then we would have to ensure that the cache is kept up to date whenever any affection association is changed. This is actually not possible without forcing the cache to be fully clustered. So to avoid clustering the cache, we instead watch the node child version, which relies on a cache that is already clustered.

      Specified by:
      getChildAssoc in interface NodeDAO
      Parameters:
      parentNodeId - the parent Node ID
      assocTypeQName - the association type to filter on
      childName - the cm:name value to filter on
      Returns:
      Returns an association matching the given parent, type and child name (cm:name) - or null if not found
    • getChildAssocs

      public void getChildAssocs(Long parentNodeId, QName assocTypeQName, Collection<String> childNames, NodeDAO.ChildAssocRefQueryCallback resultsCallback)
      Description copied from interface: NodeDAO
      Get the child associations of a given parent node, filtering on type QName and the cm:name of the child nodes.

      NOTE: This method only works if the association type fundamentally supports unique-name enforcement.

      Specified by:
      getChildAssocs in interface NodeDAO
      Parameters:
      parentNodeId - the parent node
      assocTypeQName - the type of the association to check; or null for no filtering. If the association type is not specified, then the same child node may be included several times.
      childNames - the names of the child nodes (cm:name). These will be matched exactly.
      resultsCallback - the callback that will be called with the results
    • getChildAssocsByPropertyValue

      public void getChildAssocsByPropertyValue(Long parentNodeId, QName propertyQName, Serializable value, NodeDAO.ChildAssocRefQueryCallback resultsCallback)
      Description copied from interface: NodeDAO
      Select children by property values
      Specified by:
      getChildAssocsByPropertyValue in interface NodeDAO
    • getChildAssocsByChildTypes

      public void getChildAssocsByChildTypes(Long parentNodeId, Set<QName> childNodeTypeQNames, NodeDAO.ChildAssocRefQueryCallback resultsCallback)
      Specified by:
      getChildAssocsByChildTypes in interface NodeDAO
    • getChildAssocsWithoutParentAssocsOfType

      public void getChildAssocsWithoutParentAssocsOfType(Long parentNodeId, QName assocTypeQName, NodeDAO.ChildAssocRefQueryCallback resultsCallback)
      Description copied from interface: NodeDAO
      Gets the set of child associations of a certain parent node without parent associations of a certain type to other nodes with the same parent! In effect the 'orphans' with respect to a certain association type.
      Specified by:
      getChildAssocsWithoutParentAssocsOfType in interface NodeDAO
      Parameters:
      parentNodeId - the parent node ID
      assocTypeQName - the association type QName
      resultsCallback - the callback that will be called with the results
    • getPrimaryParentAssoc

      public Pair<Long,ChildAssociationRef> getPrimaryParentAssoc(Long childNodeId)
      Description copied from interface: NodeDAO
      Finds the association between the node's primary parent and the node itself
      Specified by:
      getPrimaryParentAssoc in interface NodeDAO
      Returns:
      Returns the primary (defining) association or null if it is a root node
    • getParentAssocs

      public void getParentAssocs(Long childNodeId, QName assocTypeQName, QName assocQName, Boolean isPrimary, NodeDAO.ChildAssocRefQueryCallback resultsCallback)
      Description copied from interface: NodeDAO
      Get the parent association of a given parent node, optionally filtering on association QName and association type QName.

      This is an efficient query for node paths.

      Specified by:
      getParentAssocs in interface NodeDAO
      Parameters:
      childNodeId - the child node ID
      assocTypeQName - the association type qname to filter on; null for no filtering
      assocQName - the association qname to filter on; null for no filtering
      isPrimary - filter for primary (true) or secondary associations; null for no filtering.
      resultsCallback - the callback that will be called with the results
    • cycleCheck

      public void cycleCheck(Long nodeId)
      Potentially cheaper than evaluating all of a node's paths to check for child association cycles

      TODO: When is it cheaper to go up and when is it cheaper to go down? Look at using direct queries to pass through layers both up and down.

      Specified by:
      cycleCheck in interface NodeDAO
      Parameters:
      nodeId - the node to start with
    • getPaths

      public List<Path> getPaths(Pair<Long,NodeRef> nodePair, boolean primaryOnly) throws InvalidNodeRefException
      Description copied from interface: NodeDAO
      Build the paths for a node. When searching for primaryOnly == true, checks that there is exactly one path.
      Specified by:
      getPaths in interface NodeDAO
      Parameters:
      nodePair - the leave or child node to start with
      primaryOnly - true to follow only primary parent associations
      Throws:
      InvalidNodeRefException
    • setCheckNodeConsistency

      public void setCheckNodeConsistency()
      Description copied from interface: NodeBulkLoader
      Transaction-scope setting to make the Node loader to guarantee the validity of all caches: some cache data will be reloaded; some cache data will be considered safe.
      Specified by:
      setCheckNodeConsistency in interface NodeBulkLoader
    • getCachedAncestors

      public Set<Long> getCachedAncestors(List<Long> nodeIds)
      Description copied from interface: NodeBulkLoader
      Gets the current set of cached ancestors of the given list of nodes.
      Specified by:
      getCachedAncestors in interface NodeBulkLoader
      Parameters:
      nodeIds - a list of node IDs to visit
      Returns:
      the current set of cached ancestors of the given list of nodes, including the nodes themselves.
    • cacheNodesById

      public void cacheNodesById(List<Long> nodeIds)
      Description copied from interface: NodeBulkLoader
      Pre-cache data relevant to the given nodes. There is no need to split the collection up before calling this method; it is up to the implementations to ensure that batching is done where necessary.
      Specified by:
      cacheNodesById in interface NodeBulkLoader
      Parameters:
      nodeIds - the nodes that will be cached.
    • cacheNodes

      public void cacheNodes(List<NodeRef> nodeRefs)
      Pre-cache data relevant to the given nodes. There is no need to split the collection up before calling this method; it is up to the implementations to ensure that batching is done where necessary.

      Loads properties, aspects, parent associations and the ID-noderef cache.

      Specified by:
      cacheNodes in interface NodeBulkLoader
      Parameters:
      nodeRefs - the nodes that will be cached.
    • clear

      public void clear()
      FOR TESTING ONLY: Clears out node cache data

      Simply clears out all the node-related caches.

      Specified by:
      clear in interface NodeBulkLoader
    • getMaxTxnIdByCommitTime

      public Long getMaxTxnIdByCommitTime(long maxCommitTime)
      Description copied from interface: NodeDAO
      Retrieves the maximum transaction ID for which the commit time is less than the given time.
      Specified by:
      getMaxTxnIdByCommitTime in interface NodeDAO
      Parameters:
      maxCommitTime - the max commit time (ms)
      Returns:
      the last transaction on or before the given time
    • getTransactionCount

      public int getTransactionCount()
      Specified by:
      getTransactionCount in interface NodeDAO
    • getTxnById

      public Transaction getTxnById(Long txnId)
      Description copied from interface: NodeDAO
      Retrieves a specific transaction.
      Specified by:
      getTxnById in interface NodeDAO
      Parameters:
      txnId - the unique transaction ID.
      Returns:
      the requested transaction or null
    • getTxnChanges

      public List<NodeRef.Status> getTxnChanges(Long txnId)
      Specified by:
      getTxnChanges in interface NodeDAO
      Returns:
      Returns the node statuses for a transaction, regardless of store
    • getTxnChangesForStore

      public List<NodeRef.Status> getTxnChangesForStore(StoreRef storeRef, Long txnId)
      Specified by:
      getTxnChangesForStore in interface NodeDAO
      Returns:
      Returns the node statuses for a transaction, limited to the store
    • getTxnsUnused

      public List<Long> getTxnsUnused(Long minTxnId, long maxCommitTime, int count)
      Specified by:
      getTxnsUnused in interface NodeDAO
    • purgeTxn

      public void purgeTxn(Long txnId)
      Specified by:
      purgeTxn in interface NodeDAO
    • getMinTxnCommitTime

      public Long getMinTxnCommitTime()
      Specified by:
      getMinTxnCommitTime in interface NodeDAO
      Returns:
      Returns the minimum commit time or null if there are no transactions
    • getMaxTxnCommitTime

      public Long getMaxTxnCommitTime()
      Specified by:
      getMaxTxnCommitTime in interface NodeDAO
      Returns:
      Returns the maximum commit time or null if there are no transactions
    • getMinTxnCommitTimeForDeletedNodes

      public Long getMinTxnCommitTimeForDeletedNodes()
      Specified by:
      getMinTxnCommitTimeForDeletedNodes in interface NodeDAO
      Returns:
      Returns the minimum commit time for deleted nodes or null if there are no transactions
    • getMinTxnId

      public Long getMinTxnId()
      Specified by:
      getMinTxnId in interface NodeDAO
      Returns:
      Returns the minimum id or 0 if there are no transactions
    • getMinUnusedTxnCommitTime

      public Long getMinUnusedTxnCommitTime()
      Specified by:
      getMinUnusedTxnCommitTime in interface NodeDAO
      Returns:
      the commit time of the oldest unused transaction
    • getMaxTxnId

      public Long getMaxTxnId()
      Specified by:
      getMaxTxnId in interface NodeDAO
      Returns:
      Returns the maximum id or 0 if there are no transactions
    • getMinTxInNodeIdRange

      public Long getMinTxInNodeIdRange(Long fromNodeId, Long toNodeId)
      Description copied from interface: NodeDAO
      Gets the minimum commit time from transactions including a node id in the range [fromNodeId:toNodeId]
      Specified by:
      getMinTxInNodeIdRange in interface NodeDAO
      Parameters:
      fromNodeId - Initial node id
      toNodeId - Final node id
      Returns:
      minimum commit time
    • getMaxTxInNodeIdRange

      public Long getMaxTxInNodeIdRange(Long fromNodeId, Long toNodeId)
      Description copied from interface: NodeDAO
      Gets the maximum commit time from transactions including a node id in the range [fromNodeId:toNodeId]
      Specified by:
      getMaxTxInNodeIdRange in interface NodeDAO
      Parameters:
      fromNodeId - Initial node id
      toNodeId - Final node id
      Returns:
      maximum commit time
    • getNextTxCommitTime

      public Long getNextTxCommitTime(Long fromCommitTime)
      Description copied from interface: NodeDAO
      Gets the next commit time from [fromCommitTime]
      Specified by:
      getNextTxCommitTime in interface NodeDAO
      Parameters:
      fromCommitTime - Initial commit time
      Returns:
      next commit time
    • insertTransaction

      protected abstract Long insertTransaction(String changeTxnId, Long commit_time_ms)
    • updateTransaction

      protected abstract int updateTransaction(Long txnId, Long commit_time_ms)
    • deleteTransaction

      protected abstract int deleteTransaction(Long txnId)
    • selectAllStores

      protected abstract List<StoreEntity> selectAllStores()
    • selectStore

      protected abstract StoreEntity selectStore(StoreRef storeRef)
    • selectStoreRootNode

      protected abstract NodeEntity selectStoreRootNode(StoreRef storeRef)
    • insertStore

      protected abstract Long insertStore(StoreEntity store)
    • updateStoreRoot

      protected abstract int updateStoreRoot(StoreEntity store)
    • updateStore

      protected abstract int updateStore(StoreEntity store)
    • updateNodesInStore

      protected abstract int updateNodesInStore(Long txnId, Long storeId)
    • insertNode

      protected abstract Long insertNode(NodeEntity node)
    • updateNode

      protected abstract int updateNode(NodeUpdateEntity nodeUpdate)
    • updateNodes

      protected abstract int updateNodes(Long txnId, List<Long> nodeIds)
    • updatePrimaryChildrenSharedAclId

      protected abstract void updatePrimaryChildrenSharedAclId(Long txnId, Long primaryParentNodeId, Long optionalOldSharedAlcIdInAdditionToNull, Long newSharedAlcId)
    • deleteNodeById

      protected abstract int deleteNodeById(Long nodeId)
    • deleteNodesByCommitTime

      protected abstract int deleteNodesByCommitTime(long fromTxnCommitTimeMs, long toTxnCommitTimeMs)
    • selectNodeById

      protected abstract NodeEntity selectNodeById(Long id)
    • selectNodeByNodeRef

      protected abstract NodeEntity selectNodeByNodeRef(NodeRef nodeRef)
    • selectNodesByUuids

      protected abstract List<Node> selectNodesByUuids(Long storeId, SortedSet<String> uuids)
    • selectNodesByIds

      protected abstract List<Node> selectNodesByIds(SortedSet<Long> ids)
    • selectNodeProperties

      protected abstract Map<NodeVersionKey,Map<NodePropertyKey,NodePropertyValue>> selectNodeProperties(Set<Long> nodeIds)
    • selectNodeProperties

      protected abstract Map<NodeVersionKey,Map<NodePropertyKey,NodePropertyValue>> selectNodeProperties(Long nodeId)
    • selectNodeProperties

      protected abstract Map<NodeVersionKey,Map<NodePropertyKey,NodePropertyValue>> selectNodeProperties(Long nodeId, Set<Long> qnameIds)
    • deleteNodeProperties

      protected abstract int deleteNodeProperties(Long nodeId, Set<Long> qnameIds)
    • deleteNodeProperties

      protected abstract int deleteNodeProperties(Long nodeId, List<NodePropertyKey> propKeys)
    • insertNodeProperties

      protected abstract void insertNodeProperties(Long nodeId, Map<NodePropertyKey,NodePropertyValue> persistableProps)
    • selectNodeAspects

      protected abstract Map<NodeVersionKey,Set<QName>> selectNodeAspects(Set<Long> nodeIds)
    • insertNodeAspect

      protected abstract void insertNodeAspect(Long nodeId, Long qnameId)
    • deleteNodeAspects

      protected abstract int deleteNodeAspects(Long nodeId, Set<Long> qnameIds)
    • selectNodesWithAspects

      protected abstract void selectNodesWithAspects(List<Long> qnameIds, Long minNodeId, Long maxNodeId, NodeDAO.NodeRefQueryCallback resultsCallback)
    • selectNodesWithAspects

      protected abstract void selectNodesWithAspects(List<Long> qnameIds, Long minNodeId, Long maxNodeId, boolean ordered, NodeDAO.NodeRefQueryCallback resultsCallback)
    • selectNodesWithAspects

      protected abstract void selectNodesWithAspects(List<Long> qnameIds, Long minNodeId, Long maxNodeId, boolean ordered, int maxResults, NodeDAO.NodeRefQueryCallback resultsCallback)
    • insertNodeAssoc

      protected abstract Long insertNodeAssoc(Long sourceNodeId, Long targetNodeId, Long assocTypeQNameId, int assocIndex)
    • updateNodeAssoc

      protected abstract int updateNodeAssoc(Long id, int assocIndex)
    • deleteNodeAssoc

      protected abstract int deleteNodeAssoc(Long sourceNodeId, Long targetNodeId, Long assocTypeQNameId)
    • deleteNodeAssocs

      protected abstract int deleteNodeAssocs(List<Long> ids)
    • selectNodeAssocs

      protected abstract List<NodeAssocEntity> selectNodeAssocs(Long nodeId)
    • selectNodeAssocsBySource

      protected abstract List<NodeAssocEntity> selectNodeAssocsBySource(Long sourceNodeId, Long typeQNameId)
    • selectNodeAssocsBySourceAndPropertyValue

      protected abstract List<NodeAssocEntity> selectNodeAssocsBySourceAndPropertyValue(Long sourceNodeId, Long typeQNameId, Long propertyQNameId, NodePropertyValue nodeValue)
    • selectNodeAssocsByTarget

      protected abstract List<NodeAssocEntity> selectNodeAssocsByTarget(Long targetNodeId, Long typeQNameId)
    • selectNodeAssocById

      protected abstract NodeAssocEntity selectNodeAssocById(Long assocId)
    • selectNodeAssocMaxIndex

      protected abstract int selectNodeAssocMaxIndex(Long sourceNodeId, Long assocTypeQNameId)
    • insertChildAssoc

      protected abstract Long insertChildAssoc(ChildAssocEntity assoc)
    • deleteChildAssocs

      protected abstract int deleteChildAssocs(List<Long> ids)
    • updateChildAssocIndex

      protected abstract int updateChildAssocIndex(Long parentNodeId, Long childNodeId, QName assocTypeQName, QName assocQName, int index)
    • updateChildAssocUniqueName

      protected abstract int updateChildAssocUniqueName(Long assocId, String name)
    • selectChildAssoc

      protected abstract ChildAssocEntity selectChildAssoc(Long assocId)
    • selectChildNodeIds

      protected abstract List<ChildAssocEntity> selectChildNodeIds(Long nodeId, Boolean isPrimary, Long minAssocIdInclusive, int maxResults)
    • selectPrimaryChildAcls

      protected abstract List<NodeIdAndAclId> selectPrimaryChildAcls(Long nodeId)
    • selectChildAssoc

      protected abstract List<ChildAssocEntity> selectChildAssoc(Long parentNodeId, Long childNodeId, QName assocTypeQName, QName assocQName)
    • selectChildAssocs

      protected abstract void selectChildAssocs(Long parentNodeId, Long childNodeId, QName assocTypeQName, QName assocQName, Boolean isPrimary, Boolean sameStore, NodeDAO.ChildAssocRefQueryCallback resultsCallback)
      Parameters are all optional except the parent node ID and the callback
    • selectChildAssocs

      protected abstract void selectChildAssocs(Long parentNodeId, QName assocTypeQName, QName assocQName, int maxResults, NodeDAO.ChildAssocRefQueryCallback resultsCallback)
    • selectChildAssocs

      protected abstract void selectChildAssocs(Long parentNodeId, Set<QName> assocTypeQNames, NodeDAO.ChildAssocRefQueryCallback resultsCallback)
    • selectChildAssoc

      protected abstract ChildAssocEntity selectChildAssoc(Long parentNodeId, QName assocTypeQName, String childName)
    • selectChildAssocs

      protected abstract void selectChildAssocs(Long parentNodeId, QName assocTypeQName, Collection<String> childNames, NodeDAO.ChildAssocRefQueryCallback resultsCallback)
    • selectChildAssocsByPropertyValue

      protected abstract void selectChildAssocsByPropertyValue(Long parentNodeId, QName propertyQName, NodePropertyValue nodeValue, NodeDAO.ChildAssocRefQueryCallback resultsCallback)
    • selectChildAssocsByChildTypes

      protected abstract void selectChildAssocsByChildTypes(Long parentNodeId, Set<QName> childNodeTypeQNames, NodeDAO.ChildAssocRefQueryCallback resultsCallback)
    • selectChildAssocsWithoutParentAssocsOfType

      protected abstract void selectChildAssocsWithoutParentAssocsOfType(Long parentNodeId, QName assocTypeQName, NodeDAO.ChildAssocRefQueryCallback resultsCallback)
    • selectParentAssocs

      protected abstract void selectParentAssocs(Long childNodeId, QName assocTypeQName, QName assocQName, Boolean isPrimary, NodeDAO.ChildAssocRefQueryCallback resultsCallback)
      Parameters are all optional except the parent node ID and the callback
    • selectParentAssocs

      protected abstract List<ChildAssocEntity> selectParentAssocs(Long childNodeId)
    • selectPrimaryParentAssocs

      protected abstract List<ChildAssocEntity> selectPrimaryParentAssocs(Long childNodeId)
      No DB constraint, so multiple returned
    • updatePrimaryParentAssocs

      protected abstract int updatePrimaryParentAssocs(Long childNodeId, Long parentNodeId, QName assocTypeQName, QName assocQName, String childNodeName)
    • moveNodeData

      protected abstract void moveNodeData(Long fromNodeId, Long toNodeId)
      Moves all node-linked data from one node to another. The source node will be left in an orphaned state and without any attached data other than the current transaction.
      Parameters:
      fromNodeId - the source node
      toNodeId - the target node
    • deleteSubscriptions

      protected abstract void deleteSubscriptions(Long nodeId)
    • selectLastTxnBeforeCommitTime

      protected abstract Transaction selectLastTxnBeforeCommitTime(Long maxCommitTime)
    • selectTransactionCount

      protected abstract int selectTransactionCount()
    • selectTxnById

      protected abstract Transaction selectTxnById(Long txnId)
    • selectTxnChanges

      protected abstract List<NodeEntity> selectTxnChanges(Long txnId, Long storeId)
    • selectTxns

      public abstract List<Transaction> selectTxns(Long fromTimeInclusive, Long toTimeExclusive, Integer count, List<Long> includeTxnIds, List<Long> excludeTxnIds, Boolean ascending)
    • selectTxnsUnused

      protected abstract List<Long> selectTxnsUnused(Long minTxnId, Long maxCommitTime, Integer count)
    • selectMinTxnCommitTime

      protected abstract Long selectMinTxnCommitTime()
    • selectMaxTxnCommitTime

      protected abstract Long selectMaxTxnCommitTime()
    • selectMinTxnCommitTimeForDeletedNodes

      protected abstract Long selectMinTxnCommitTimeForDeletedNodes()
    • selectMinTxnId

      protected abstract Long selectMinTxnId()
    • selectMaxTxnId

      protected abstract Long selectMaxTxnId()
    • selectMinUnusedTxnCommitTime

      protected abstract Long selectMinUnusedTxnCommitTime()
    • selectMinTxInNodeIdRange

      protected abstract Long selectMinTxInNodeIdRange(Long fromNodeId, Long toNodeId)
    • selectMaxTxInNodeIdRange

      protected abstract Long selectMaxTxInNodeIdRange(Long fromNodeId, Long toNodeId)
    • selectNextTxCommitTime

      protected abstract Long selectNextTxCommitTime(Long fromCommitTime)