All Implemented Interfaces:
ContentDao, ContentDaoInternal, org.springframework.beans.factory.InitializingBean

public class DefaultContentDao extends VersionedHibernateObjectDao<ContentEntityObject> implements ContentDaoInternal
Generic DAO for hibernate objects. Takes care of indexing and unindexing, and setting creation and update times for objects.

For this reason, you should always do object CRUD through the DAO, you shouldn't trust Hibernate to do it for you: Hibernate will save the object, but skip the additional stuff the DAO does.

Subclasses will need to implement the HibernateObjectDao.getPersistentClass() method to return the class that the DAO is serving: that way getByClassId() will perform correctly.

Subclasses should also override HibernateObjectDao.updateModificationData(EntityObject) if they want to perform any additional modifications on objects that are being saved through the DAO. Just remember to call super. (updateModificationData will not be called if an object is saved through #saveRawEntity(EntityObject))

  • Constructor Details

    • DefaultContentDao

      public DefaultContentDao()
  • Method Details

    • getPersistentClass

      public Class<ContentEntityObject> getPersistentClass()
      Specified by:
      getPersistentClass in class HibernateObjectDao<ContentEntityObject>
    • getById

      public ContentEntityObject getById(long id)
      Specified by:
      getById in interface ContentDao
    • getLatestContentCount

      public int getLatestContentCount()
      Specified by:
      getLatestContentCount in interface ContentDao
    • getLatestOrderedWikiContentFromContentId

      public List<ContentEntityObject> getLatestOrderedWikiContentFromContentId(long startContentId, int maxRows)
      Specified by:
      getLatestOrderedWikiContentFromContentId in interface ContentDao
      Parameters:
      startContentId - start content id
      maxRows - max rows
      Returns:
      the latest versions of wiki content within the specified bounds
    • getOrderedXhtmlContentFromContentId

      public List<ContentEntityObject> getOrderedXhtmlContentFromContentId(long startContentId, int maxRows)
      Description copied from interface: ContentDao

      This is for internal use only, Do not rely on it as a public API. This is used to retrieve batches of data during migration or upgrades.

      Warning: You will want to keep maxRows as small as possible because a list of CEO can be a very memory hungry structure. A good example is the default used in content migration which is 500.

      Specified by:
      getOrderedXhtmlContentFromContentId in interface ContentDao
      Returns:
      a list ordered by id of all the ContentEntityObjects with XHTML formatted bodies.
    • getLatestOrderedXhtmlContentFromContentIds

      public List<ContentEntityObject> getLatestOrderedXhtmlContentFromContentIds(long startContentId, long endContentId)
      Description copied from interface: ContentDao

      This is for internal use only, Do not rely on it as a public API. This is used to retrieve batches of data during migration or upgrades.

      Warning: You will want to keep maxRows as small as possible because a list of CEO can be a very memory hungry structure. A good example is the default used in content migration which is 500.

      Specified by:
      getLatestOrderedXhtmlContentFromContentIds in interface ContentDao
      Returns:
      a list ordered by id of all the latest ContentEntityObjects with XHTML formatted bodies.
    • getLatestOrderedXhtmlContentIds

      public List<Long> getLatestOrderedXhtmlContentIds(long startContentId, int maxRows)
      Description copied from interface: ContentDao

      This is for internal use only, Do not rely on it as a public API. This is used to retrieve batches of data during migration or upgrades.

      Specified by:
      getLatestOrderedXhtmlContentIds in interface ContentDao
      Returns:
      a ordered list of IDs of all the latest ContentEntityObjects with XHTML formatted bodies.
    • getCountOfXhtmlContent

      public int getCountOfXhtmlContent()
      Description copied from interface: ContentDao

      This is for internal use only, Do not rely on it as a public API.

      This is used to calculate the amount of work required when migrating or upgrading content.

      Specified by:
      getCountOfXhtmlContent in interface ContentDao
      Returns:
      the number of CEO's with XHTML content.
    • getCountOfLatestXhtmlContent

      public int getCountOfLatestXhtmlContent()
      Description copied from interface: ContentDao

      This is for internal use only, Do not rely on it as a public API.

      This is used to calculate the amount of work required when migrating or upgrading content.

      Specified by:
      getCountOfLatestXhtmlContent in interface ContentDao
      Returns:
      the number of latest CEO's with XHTML content.
    • saveRawWithoutReindex

      public void saveRawWithoutReindex(com.atlassian.core.bean.EntityObject objectToSave)
      Description copied from interface: ContentDao

      This is for internal use only, Do not rely on it as a public API.

      Perform a saveRaw but without performing the re-index; it is unnecessary in the context of a migration or upgrade.

      Specified by:
      saveRawWithoutReindex in interface ContentDao
    • getXhtmlSpaceDescriptionsFromContentId

      public List<ContentEntityObject> getXhtmlSpaceDescriptionsFromContentId(long startContentId, int maxRows)
      Description copied from interface: ContentDao

      This is for internal use only, Do not rely on it as a public API. This is used to retrieve batches of data during migration or upgrades.

      Warning: You will want to keep maxRows as small as possible because a list of CEO can be a very memory hungry structure. A good example is the default used in content migration which is 500.

      Specified by:
      getXhtmlSpaceDescriptionsFromContentId in interface ContentDao
      Returns:
      a list ordered by id of all the SpaceDescriptions with BodyContent of type BodyType.XHTML
    • getCountOfXhtmlSpaceDescriptions

      public int getCountOfXhtmlSpaceDescriptions()
      Description copied from interface: ContentDao

      This is for internal use only, Do not rely on it as a public API.

      This is used to calculate the amount of work required when migrating or upgrading content.

      Specified by:
      getCountOfXhtmlSpaceDescriptions in interface ContentDao
      Returns:
      the number of SpaceDescriptions with BodyContent of type BodyType.XHTML
    • updateModificationData

      protected void updateModificationData(ContentEntityObject objectToSave)
      This method overrides the default behaviour which is to get the current user from a thread local and to set the last updated time to the current time. We do not want this for the migration.

      We do however need to set the creationdate if it is not set.

      Overrides:
      updateModificationData in class ConfluenceHibernateObjectDao<ContentEntityObject>
      Parameters:
      objectToSave - the object that is about to be saved