Class DefaultContentDao
- java.lang.Object
-
- org.springframework.dao.support.DaoSupport
-
- com.atlassian.confluence.core.persistence.hibernate.HibernateObjectDao<T>
-
- com.atlassian.confluence.core.persistence.hibernate.VersionedHibernateObjectDao<T>
-
- com.atlassian.confluence.internal.persistence.hibernate.AbstractContentEntityObjectHibernateDao<ContentEntityObject>
-
- com.atlassian.confluence.content.render.xhtml.migration.DefaultContentDao
-
- All Implemented Interfaces:
ObjectDao
,ContentDao
,ContentEntityObjectDao<ContentEntityObject>
,VersionedObjectDao<ContentEntityObject>
,ContentDaoInternal
,ContentEntityObjectDaoInternal<ContentEntityObject>
,ObjectDaoInternal<ContentEntityObject>
,VersionedObjectDaoInternal<ContentEntityObject>
,org.springframework.beans.factory.InitializingBean
public class DefaultContentDao extends AbstractContentEntityObjectHibernateDao<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
ObjectDaoInternal.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 throughHibernateObjectDao.saveRawEntity(EntityObject)
)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.atlassian.confluence.core.persistence.hibernate.HibernateObjectDao
HibernateObjectDao.Cacheability
-
-
Field Summary
-
Fields inherited from class com.atlassian.confluence.core.persistence.hibernate.VersionedHibernateObjectDao
cacheFactory, confluenceUserDao
-
-
Constructor Summary
Constructors Constructor Description DefaultContentDao()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getCountOfLatestXhtmlContent()
This is for internal use only, Do not rely on it as a public API.int
getCountOfXhtmlContent()
This is for internal use only, Do not rely on it as a public API.int
getCountOfXhtmlSpaceDescriptions()
This is for internal use only, Do not rely on it as a public API.int
getLatestContentCount()
List<ContentEntityObject>
getLatestOrderedWikiContentFromContentId(long startContentId, int maxRows)
List<ContentEntityObject>
getLatestOrderedXhtmlContentFromContentIds(long startContentId, long endContentId)
This is for internal use only, Do not rely on it as a public API.List<Long>
getLatestOrderedXhtmlContentIds(long startContentId, int maxRows)
This is for internal use only, Do not rely on it as a public API.List<ContentEntityObject>
getOrderedXhtmlContentFromContentId(long startContentId, int maxRows)
This is for internal use only, Do not rely on it as a public API.Class<ContentEntityObject>
getPersistentClass()
Gets the type ofEntityObject
this Dao works with.List<ContentEntityObject>
getXhtmlSpaceDescriptionsFromContentId(long startContentId, int maxRows)
This is for internal use only, Do not rely on it as a public API.void
saveRawWithoutReindex(com.atlassian.core.bean.EntityObject objectToSave)
This is for internal use only, Do not rely on it as a public API.protected void
updateEntityModificationData(ContentEntityObject objectToSave)
protected void
updateModificationData(com.atlassian.core.bean.EntityObject 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.-
Methods inherited from class com.atlassian.confluence.internal.persistence.hibernate.AbstractContentEntityObjectHibernateDao
countContentBySpaceIdAndStatus, findAllDraftsFor, findAllLegacyDraftsFor, findContentBySpaceIdAndStatus, findContentBySpaceIdAndStatus, findDraftFor, findDraftsWithUnpublishedChangesForUser, findHistoricalVersionsAfterVersion, findPreviousVersions, findUnpublishedContentWithUserContributions, getAllCurrentEntities, getAllModifiers, getByClassId, getById, getContentAuthoredByUser, getContributionStatusByUser, getFirstVersionAfter, getFirstVersionBefore, getLastEditedVersionsOf, getObjectType, getOldestPageCreationDate, getPageAndBlogPostsVersionsLastEditedByUser, getPageAndBlogPostsVersionsLastEditedByUserIncludingDrafts, getPagesByCursor, getRecentlyAddedEntities, getRecentlyModifiedEntities, getRecentlyModifiedEntities, getRecentlyModifiedEntitiesForUser, getRecentlyModifiedForChangeDigest, getTrashedContent, getTrashedContents, getTrashedContents, getTrashedEntities, getVersion, getVersionEditContributors, getVersionHistorySummary, getVersionHistorySummary, getVersionsLastEditedByUser, getVersionsLastEditedByUserNew
-
Methods inherited from class com.atlassian.confluence.core.persistence.hibernate.VersionedHibernateObjectDao
findAllSorted, findLatestVersionsCount, findLatestVersionsCount, findLatestVersionsIterator, findLatestVersionsIterator, findNamedQueryStringParams, findNamedQueryStringParams, save, saveEntity, setCacheFactory, setConfluenceUserDao
-
Methods inherited from class com.atlassian.confluence.core.persistence.hibernate.HibernateObjectDao
applyTransactionTimeout, applyTransactionTimeout, checkDaoConfig, createHibernateTemplate, findAll, findAllSorted, findByClassIds, findByClassIdsFiltered, findNamedQuery, findNamedQuery, findNamedQuery, findNamedQueryStringParam, findNamedQueryStringParam, findNamedQueryStringParam, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findSingleObject, getCountResult, getHibernateTemplate, getSessionFactory, index, indexEntity, refresh, refreshEntity, reIndex, reIndexEntity, remove, removeEntity, replicate, replicateEntity, save, saveEntity, saveRaw, saveRawEntity, setEventPublisher, setHibernateTemplate, setIndexer, setSessionFactory, unIndex, unIndexEntity, uniqueResult
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.atlassian.confluence.content.render.xhtml.migration.ContentDao
getById
-
Methods inherited from interface com.atlassian.confluence.core.persistence.ContentEntityObjectDao
countContentBySpaceIdAndStatus, findAllDraftsFor, findAllLegacyDraftsFor, findContentBySpaceIdAndStatus, findContentBySpaceIdAndStatus, findDraftFor, findDraftsWithUnpublishedChangesForUser, findHistoricalVersionsAfterVersion, findPreviousVersions, findUnpublishedContentWithUserContributions, getAllCurrentEntities, getAllModifiers, getAllModifiers, getContentAuthoredByUser, getContributionStatusByUser, getFirstVersionAfter, getFirstVersionBefore, getLastEditedVersionsOf, getObjectType, getOldestPageCreationDate, getPageAndBlogPostsVersionsLastEditedByUser, getPageAndBlogPostsVersionsLastEditedByUserIncludingDrafts, getRecentlyAddedEntities, getRecentlyModifiedEntities, getRecentlyModifiedEntities, getRecentlyModifiedEntitiesForUser, getRecentlyModifiedForChangeDigest, getTrashedContent, getTrashedContents, getTrashedContents, getVersion, getVersionEditContributors, getVersionHistorySummary, getVersionHistorySummary, getVersionsLastEditedByUser, getVersionsLastEditedByUserNew
-
Methods inherited from interface com.atlassian.confluence.internal.persistence.ContentEntityObjectDaoInternal
findContentBySpaceIdAndStatusAndFilter, getTrashedEntities
-
Methods inherited from interface com.atlassian.confluence.internal.persistence.ObjectDaoInternal
findAll, findAllSorted, findAllSorted, findByClassIds, findByClassIdsFiltered, refresh, refreshEntity, remove, removeEntity, replicate, replicateEntity, save, saveEntity, saveRaw, saveRawEntity
-
Methods inherited from interface com.atlassian.confluence.core.persistence.VersionedObjectDao
findLatestVersionsCount, findLatestVersionsIterator, save
-
Methods inherited from interface com.atlassian.confluence.internal.persistence.VersionedObjectDaoInternal
saveEntity
-
-
-
-
Method Detail
-
getPersistentClass
public Class<ContentEntityObject> getPersistentClass()
Description copied from interface:ObjectDaoInternal
Gets the type ofEntityObject
this Dao works with.- Specified by:
getPersistentClass
in interfaceObjectDao
- Specified by:
getPersistentClass
in interfaceObjectDaoInternal<ContentEntityObject>
- Returns:
- the type
-
getLatestContentCount
public int getLatestContentCount()
- Specified by:
getLatestContentCount
in interfaceContentDao
-
getLatestOrderedWikiContentFromContentId
public List<ContentEntityObject> getLatestOrderedWikiContentFromContentId(long startContentId, int maxRows)
- Specified by:
getLatestOrderedWikiContentFromContentId
in interfaceContentDao
- Parameters:
startContentId
- start content idmaxRows
- 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 interfaceContentDao
- 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 interfaceContentDao
- 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 interfaceContentDao
- 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 interfaceContentDao
- 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 interfaceContentDao
- 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 interfaceContentDao
- Specified by:
saveRawWithoutReindex
in interfaceContentEntityObjectDaoInternal<ContentEntityObject>
-
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 interfaceContentDao
- 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 interfaceContentDao
- Returns:
- the number of SpaceDescriptions with BodyContent of type BodyType.XHTML
-
updateModificationData
protected void updateModificationData(com.atlassian.core.bean.EntityObject 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 classVersionedHibernateObjectDao<ContentEntityObject>
- Parameters:
objectToSave
- the object that is about to be saved
-
updateEntityModificationData
protected void updateEntityModificationData(ContentEntityObject objectToSave)
- Overrides:
updateEntityModificationData
in classVersionedHibernateObjectDao<ContentEntityObject>
-
-