Class AbstractContentDataDAOImpl

  • All Implemented Interfaces:
    ContentDataDAO
    Direct Known Subclasses:
    ContentDataDAOImpl

    public abstract class AbstractContentDataDAOImpl
    extends java.lang.Object
    implements ContentDataDAO
    Abstract implementation for ContentData DAO.

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

    The DAO deals in ContentData instances. The cache is primarily present to decode IDs into ContentData instances.

    Since:
    3.2
    Author:
    Derek Hulley, sglover
    • Constructor Detail

      • AbstractContentDataDAOImpl

        public AbstractContentDataDAOImpl()
        Default constructor
    • Method Detail

      • setControlDAO

        public void setControlDAO​(ControlDAO controlDAO)
      • setMimetypeDAO

        public void setMimetypeDAO​(MimetypeDAO mimetypeDAO)
      • setEncodingDAO

        public void setEncodingDAO​(EncodingDAO encodingDAO)
      • setLocaleDAO

        public void setLocaleDAO​(LocaleDAO localeDAO)
      • setContentStoreCleaner

        public void setContentStoreCleaner​(EagerContentStoreCleaner contentStoreCleaner)
        Set this property to enable eager cleanup of orphaned content.
        Parameters:
        contentStoreCleaner - an eager cleaner (may be null)
      • setContentDataCache

        public void setContentDataCache​(org.alfresco.repo.cache.SimpleCache<java.lang.Long,​org.alfresco.service.cmr.repository.ContentData> contentDataCache)
        Parameters:
        contentDataCache - the cache of IDs to ContentData and vice versa
      • setContentUrlCache

        public void setContentUrlCache​(org.alfresco.repo.cache.SimpleCache<java.lang.Long,​ContentUrlEntity> contentUrlCache)
      • registerDereferencedContentUrl

        protected void registerDereferencedContentUrl​(java.lang.String contentUrl)
        A content_url entity was dereferenced. This makes no assumptions about the current references - dereference deletion is handled in the commit phase.
      • createContentData

        public org.alfresco.util.Pair<java.lang.Long,​org.alfresco.service.cmr.repository.ContentData> createContentData​(org.alfresco.service.cmr.repository.ContentData contentData)
        Description copied from interface: ContentDataDAO
        Create a new ContentData instance.
        Specified by:
        createContentData in interface ContentDataDAO
        Parameters:
        contentData - the ContentData details
        Returns:
        the ContentData pair (id, ContentData) (never null)
      • getContentData

        public org.alfresco.util.Pair<java.lang.Long,​org.alfresco.service.cmr.repository.ContentData> getContentData​(java.lang.Long id)
        Specified by:
        getContentData in interface ContentDataDAO
        Parameters:
        id - the unique ID of the entity
        Returns:
        the ContentData pair (id, ContentData) or null if it doesn't exist
      • cacheContentDataForNodes

        public void cacheContentDataForNodes​(java.util.Set<java.lang.Long> nodeIds)
        Specified by:
        cacheContentDataForNodes in interface ContentDataDAO
        Parameters:
        nodeIds - the nodeIds
      • updateContentData

        public void updateContentData​(java.lang.Long id,
                                      org.alfresco.service.cmr.repository.ContentData contentData)
        Description copied from interface: ContentDataDAO
        Update a content data instance
        Specified by:
        updateContentData in interface ContentDataDAO
        Parameters:
        id - the unique ID of the entity
        contentData - the new data
      • deleteContentData

        public void deleteContentData​(java.lang.Long id)
        Description copied from interface: ContentDataDAO
        Delete an instance of content.
        Specified by:
        deleteContentData in interface ContentDataDAO
        Parameters:
        id - the unique ID of the entity
      • createContentDataEntity

        protected ContentDataEntity createContentDataEntity​(org.alfresco.service.cmr.repository.ContentData contentData)
        Translates the ContentData into persistable values using the helper DAOs
      • updateContentDataEntity

        protected int updateContentDataEntity​(ContentDataEntity contentDataEntity,
                                              org.alfresco.service.cmr.repository.ContentData contentData)
        Translates the ContentData into persistable values using the helper DAOs
      • createContentUrlEntity

        protected abstract ContentUrlEntity createContentUrlEntity​(java.lang.String contentUrl,
                                                                   long size,
                                                                   ContentUrlKeyEntity contentUrlKey)
        Parameters:
        contentUrl - the content URL to create or search for
      • getContentUrlEntity

        protected abstract ContentUrlEntity getContentUrlEntity​(java.lang.Long id)
        Parameters:
        id - the ID of the content url entity
        Returns:
        Return the entity or null if it doesn't exist
      • getContentUrlEntity

        protected abstract ContentUrlEntity getContentUrlEntity​(java.lang.String contentUrl)
      • getContentUrlEntityUnreferenced

        protected abstract ContentUrlEntity getContentUrlEntityUnreferenced​(java.lang.String contentUrl)
        Parameters:
        contentUrl - the URL of the content url entity
        Returns:
        Return the entity or null if it doesn't exist or is still referenced by a content_data entity
      • updateContentUrlOrphanTime

        protected abstract int updateContentUrlOrphanTime​(java.lang.Long id,
                                                          java.lang.Long orphanTime,
                                                          java.lang.Long oldOrphanTime)
        Update a content URL with the given orphan time
        Parameters:
        id - the unique ID of the entity
        orphanTime - the time (ms since epoch) that the entity was orphaned
        oldOrphanTime - the orphan time we expect to update for optimistic locking (may be null)
        Returns:
        Returns the number of rows updated
      • createContentDataEntity

        protected abstract ContentDataEntity createContentDataEntity​(java.lang.Long contentUrlId,
                                                                     java.lang.Long mimetypeId,
                                                                     java.lang.Long encodingId,
                                                                     java.lang.Long localeId)
        Create the row for the alf_content_data
      • getContentDataEntity

        protected abstract ContentDataEntity getContentDataEntity​(java.lang.Long id)
        Parameters:
        id - the entity ID
        Returns:
        Returns the entity or null if it doesn't exist
      • getContentDataEntitiesForNodes

        protected abstract java.util.List<ContentDataEntity> getContentDataEntitiesForNodes​(java.util.Set<java.lang.Long> nodeIds)
        Parameters:
        nodeIds - the node ID
        Returns:
        Returns the associated entities or null if none exist
      • updateContentDataEntity

        protected abstract int updateContentDataEntity​(ContentDataEntity entity)
        Update an existing alf_content_data entity
        Parameters:
        entity - the existing entity that will be updated
        Returns:
        Returns the number of rows updated (should be 1)
      • deleteContentDataEntity

        protected abstract int deleteContentDataEntity​(java.lang.Long id)
        Delete the entity with the given ID
        Returns:
        Returns the number of rows deleted
      • deleteContentUrlEntity

        protected abstract int deleteContentUrlEntity​(long id)