java.lang.Object
org.springframework.dao.support.DaoSupport
com.atlassian.confluence.core.persistence.hibernate.HibernateObjectDao
com.atlassian.confluence.pages.persistence.dao.hibernate.HibernateDraftDao
All Implemented Interfaces:
DraftDao, org.springframework.beans.factory.InitializingBean

public class HibernateDraftDao extends HibernateObjectDao implements DraftDao
Database storage for drafts. Does not permit anonymous drafts (i.e. those with a null username), which should be stored in non-permanent storage like the HTTP session.
See Also:
  • Constructor Details

    • HibernateDraftDao

      public HibernateDraftDao()
  • Method Details

    • getPersistentClass

      public Class getPersistentClass()
      Specified by:
      getPersistentClass in class HibernateObjectDao
    • getByClassId

      protected Draft getByClassId(long id)
      Description copied from class: HibernateObjectDao
      Retrieve the object with a particular id from the database. The object must be of the same class as the DAO's getPersistentClass() method returns.
      Overrides:
      getByClassId in class HibernateObjectDao
      Parameters:
      id - the id of the object to look up
      Returns:
      the corresponding object, or null if the object does not exist with the appropriate class and id.
    • saveOrUpdate

      public void saveOrUpdate(Draft draft) throws IllegalArgumentException
      Description copied from interface: DraftDao
      Saves the draft.
      Specified by:
      saveOrUpdate in interface DraftDao
      Throws:
      IllegalArgumentException - if the draft has no page ID, owner or type.
    • getDraft

      public Draft getDraft(String pageId, ConfluenceUser creator, String draftType, String spaceKey)
      Description copied from interface: DraftDao
      Finds and returns a draft object with all the specified properties or null if none is found.
      Specified by:
      getDraft in interface DraftDao
      Parameters:
      pageId - the id of the page which this draft is associated with
      creator - the owner of the draft
      draftType - the type of draft, which is usually the result of calling ContentEntityObject.getType()
      spaceKey - space key, if relevant for the draft. This is used to enable NEW page drafts across multiple spaces
      Returns:
      a draft object with all the specified properties or null if no valid draft could be found
    • getDraft

      public Draft getDraft(long draftId)
      Description copied from interface: DraftDao
      Returns the draft with the given ID, or null if no draft is found with that ID.
      Specified by:
      getDraft in interface DraftDao
    • remove

      public void remove(Draft draft)
      Description copied from interface: DraftDao
      Removes a draft based on its page ID, owner and type. Does nothing if such a draft is not found in the data store.
      Specified by:
      remove in interface DraftDao
    • findByCreatorName

      public List<Draft> findByCreatorName(String creatorName)
      Description copied from interface: DraftDao
      Returns the drafts stored against the given username.
      Specified by:
      findByCreatorName in interface DraftDao
    • countDrafts

      public int countDrafts(String creatorName)
      Specified by:
      countDrafts in interface DraftDao
      Returns:
      count of number of drafts for this daos owner
    • setConfluenceUserDao

      public void setConfluenceUserDao(ConfluenceUserDao confluenceUserDao)
    • setEventPublisher

      public void setEventPublisher(com.atlassian.event.api.EventPublisher eventPublisher)
    • publishEvent

      protected void publishEvent(IndexerEventListener.VisitorEvent event)
      Overrides:
      publishEvent in class HibernateObjectDao