Class DefaultContentEntityManager
- All Implemented Interfaces:
ContentEntityManager,ContentDraftManagerInternal,ContentEntityManagerInternal
- Direct Known Subclasses:
DefaultCommentManager,DefaultCustomContentManager,DefaultPageManager
- Since:
- 7.15
-
Field Summary
Fields inherited from interface com.atlassian.confluence.core.ContentEntityManager
ITERATE_ALL -
Constructor Summary
ConstructorsConstructorDescriptionDefaultContentEntityManager(ContentEntityObjectDaoInternal contentEntityObjectDao, org.hibernate.SessionFactory sessionFactory, WikiToStorageConverter wikiToStorageConverter, com.atlassian.event.api.EventPublisher eventPublisher, RelationManager relationManager, CollaborativeEditingHelper collaborativeEditingHelper, AuditingContext auditingContext, RetentionFeatureChecker retentionFeatureChecker, NotificationManager notificationManager) -
Method Summary
Modifier and TypeMethodDescriptionprotected @NonNull BodyContentconvertFromWikiToStorageFormatIfRequired(ContentEntityObject historicalVersion) intcountContentBySpaceIdAndStatus(long spaceId, String status) Retrieve the count of specific content type for a given space with a particular status.<T extends ContentEntityObject>
TcreateDraft(T draft, SaveContext saveContext) This method sets the common properties of theContentEntityObjectto be saved as a draftstatic <T extends ConfluenceEntityObject>
PageResponse<T>filteredResponseWithCursor(LimitedRequest originalRequest, @Nullable Predicate<? super T> filter, List<T> pages) static <T extends ConfluenceEntityObject>
PageResponse<T>filteredResponseWithCursor(LimitedRequest originalRequest, @Nullable Predicate<? super T> filter, List<T> pages, CursorType cursorType) <T extends ContentEntityObject>
List<T>findAllDraftsFor(long contentId) Retrieves a list of drafts for the given content ID if any exist.Retrieves the drafts for the givenUser<T extends ContentEntityObject>
TfindDraftFor(long contentId) Retrieves the draft for the given content ID if it exists<T extends ContentEntityObject>
TfindDraftFor(@NonNull T ceo) Retrieves the draft for the given content if exists.Retrieves the drafts for the givenUserIMPORTANT: this method doesn't return published shared drafts, only personal drafts and unpublished shared drafts@Nullable ContentEntityObjectgetById(long id) @Nullable ContentEntityObject@Nullable ContentEntityObject@NonNull PageResponse<ContentEntityObject>getByIdsAndFilters(List<ContentId> contentIds, LimitedRequest limitedRequest, Predicate<? super ContentEntityObject> filter) getContributionStatusByUser(@NonNull Collection<ContentId> contentIds, @Nullable com.atlassian.sal.api.user.UserKey userKey) Identifies the most recent contributions made to a set of content by the given user.@Nullable ContentEntityObjectGet the next version of the entity in the sequence ofVersioned.@Nullable ContentEntityObjectgetOtherVersion(ContentEntityObject ceo, int version) @NonNull PageResponse<AbstractPage>getPageAndBlogPostsVersionsLastEditedByUser(com.atlassian.sal.api.user.UserKey userKey, LimitedRequest request) Retrieve a page of entities that have been modified by the user, in order of the user's most recent modification.@NonNull PageResponse<AbstractPage>getPageAndBlogPostsVersionsLastEditedByUserIncludingDrafts(@Nullable com.atlassian.sal.api.user.UserKey userKey, LimitedRequest request) Retrieve a page of entities that have been modified by the user, in order of the user's most recent modification.@Nullable ContentEntityObjectGet the previous version of the entity in the sequence ofVersioned.@NonNull Iterator<ContentEntityObject>getRecentlyAddedEntities(@Nullable String spaceKey, int maxResults) Retrieve an iterator of recently added entities, in order of most recent to last.@NonNull Iterator<SpaceContentEntityObject>getRecentlyModifiedEntities(String spaceKey, int maxResults) Retrieve an iterator of recently modified entities, in order of most recent to last.@NonNull Iterator<ContentEntityObject>Retrieve an iterator of recently modified entities, in order of most recent to last.@NonNull List<ContentEntityObject>getRecentlyModifiedForChangeDigest(Date fromDate) Retrieves a list ofContentEntityObjects that have been newly added or modified since the date specified.@NonNull PageResponse<VersionHistorySummary>getVersionHistorySummaries(ContentId contentId, LimitedRequest limitedRequest) Get a VersionHistorySummary for all previous versions of a ContentEntityObject, list is ordered by Version number descending.@NonNull List<VersionHistorySummary>Get a VersionHistorySummary for all previous versions of a ContentEntityObject, starting with the current content.@NonNull Map<Long,ContentEntityObject> getVersionsLastEditedByUser(@NonNull Collection<ContentId> contentIds, @Nullable com.atlassian.sal.api.user.UserKey userKey) Gets theContentEntityObjectobjects relating to the version of the given contentIds that were last edited by the given user.protected voidpublishCreateEvent(ContentEntityObject obj, @Nullable SaveContext saveContext) protected voidprotected voidpublishUpdateEvent(ContentEntityObject obj, @Nullable ContentEntityObject origObj, @Nullable SaveContext saveContext) voidRefreshes the specified entity (including content) in the Hibernate session to ensure that subsequent retrievals are up-to-date.protected voidremoveContentEntities(Iterable<? extends ContentEntityObject> contentEntityObjects) voidRemoves given content entity object and all associated domain objects i.e.voidremoveHistoricalVersion(ContentEntityObject historicalVersion) Removes a historical ContentEntityObject.voidrevertContentEntityBackToVersion(ContentEntityObject entity, int version, @Nullable String revertComment, boolean revertTitle) Reverts aContentEntityObjectback to its state at the version specified byversion.voidrevertContentEntityBackToVersion(ContentEntityObject entity, int version, @Nullable String revertComment, boolean revertTitle, Function<ContentEntityObject, BodyContent> revertBodyContentFactory) voidsaveContentEntity(ContentEntityObject obj, @Nullable ContentEntityObject origObj, @Nullable SaveContext saveContext) In order to create a history for this object, we need to pass in the modified as well as the original version of the object.voidsaveContentEntity(ContentEntityObject obj, @Nullable SaveContext saveContext) <T extends ContentEntityObject>
voidsaveNewVersion(T current, Modification<T> modification) Applies the state changes supplied by modification and persists those changes to a new version.<T extends ContentEntityObject>
voidsaveNewVersion(T current, Modification<T> modification, @Nullable SaveContext saveContext) Applies the state changes supplied by modification and persists those changes to a new version.
-
Constructor Details
-
DefaultContentEntityManager
public DefaultContentEntityManager(ContentEntityObjectDaoInternal contentEntityObjectDao, org.hibernate.SessionFactory sessionFactory, WikiToStorageConverter wikiToStorageConverter, com.atlassian.event.api.EventPublisher eventPublisher, RelationManager relationManager, CollaborativeEditingHelper collaborativeEditingHelper, AuditingContext auditingContext, RetentionFeatureChecker retentionFeatureChecker, NotificationManager notificationManager)
-
-
Method Details
-
filteredResponseWithCursor
public static <T extends ConfluenceEntityObject> PageResponse<T> filteredResponseWithCursor(LimitedRequest originalRequest, @Nullable Predicate<? super T> filter, List<T> pages) -
filteredResponseWithCursor
public static <T extends ConfluenceEntityObject> PageResponse<T> filteredResponseWithCursor(LimitedRequest originalRequest, @Nullable Predicate<? super T> filter, List<T> pages, CursorType cursorType) -
refreshContentEntity
Description copied from interface:ContentEntityManagerRefreshes the specified entity (including content) in the Hibernate session to ensure that subsequent retrievals are up-to-date.- Specified by:
refreshContentEntityin interfaceContentEntityManager- Parameters:
obj- the object to be refreshed in the Hibernate session.
-
createDraft
Description copied from interface:ContentDraftManagerInternalThis method sets the common properties of theContentEntityObjectto be saved as a draft- Specified by:
createDraftin interfaceContentDraftManagerInternal- Parameters:
draft- - theContentEntityObjectto save as draftsaveContext- - aSaveContextholding additional parameters for the manager to use when saving.- Returns:
- the obj created as draft
- See Also:
-
findDraftFor
Description copied from interface:ContentDraftManagerInternalRetrieves the draft for the given content if exists.- Specified by:
findDraftForin interfaceContentDraftManagerInternal- Parameters:
ceo- the entity object to retrieve the draft for- Returns:
- the draft for the given content if exists, null otherwise
- See Also:
-
findDraftFor
Description copied from interface:ContentDraftManagerInternalRetrieves the draft for the given content ID if it exists- Specified by:
findDraftForin interfaceContentDraftManagerInternal- Parameters:
contentId- The content ID used to identify the draft- Returns:
- the draft for the given content ID if it exists, null otherwise
- See Also:
-
findAllDraftsFor
Description copied from interface:ContentDraftManagerInternalRetrieves a list of drafts for the given content ID if any exist.- Specified by:
findAllDraftsForin interfaceContentDraftManagerInternal- Parameters:
contentId- The content ID used to identify the drafts- Returns:
- A non-null list of drafts with 0 or more elements
- See Also:
-
findUnpublishedContentWithUserContributions
Description copied from interface:ContentDraftManagerInternalRetrieves the drafts for the givenUserIMPORTANT: this method doesn't return published shared drafts, only personal drafts and unpublished shared drafts- Specified by:
findUnpublishedContentWithUserContributionsin interfaceContentDraftManagerInternal- Parameters:
user- the owner of the drafts- Returns:
- a list of
ContentEntityObjectwith theContentEntityObject.DRAFTstatus
-
findAllDraftsWithUnpublishedChangesForUser
Description copied from interface:ContentDraftManagerInternalRetrieves the drafts for the givenUser- Specified by:
findAllDraftsWithUnpublishedChangesForUserin interfaceContentDraftManagerInternal- Parameters:
creator- the owner of the drafts- Returns:
- a list of user's drafts (
ContentEntityObjectobjects)
-
saveContentEntity
- Specified by:
saveContentEntityin interfaceContentEntityManager- Parameters:
obj- - theContentEntityObjectto savesaveContext- - aSaveContextholding additional parameters for the manager to use when saving.
-
saveContentEntity
public void saveContentEntity(ContentEntityObject obj, @Nullable ContentEntityObject origObj, @Nullable SaveContext saveContext) Description copied from interface:ContentEntityManagerIn order to create a history for this object, we need to pass in the modified as well as the original version of the object.- Specified by:
saveContentEntityin interfaceContentEntityManagersaveContext- - aSaveContextholding additional parameters for the manager to use when saving.
-
saveNewVersion
Description copied from interface:ContentEntityManagerApplies the state changes supplied by modification and persists those changes to a new version.manager.<Page>saveNewVersion(page, new Modification<Page>() { public void modify(Page page) { page.setTitle("foobar"); } });- Specified by:
saveNewVersionin interfaceContentEntityManager- Type Parameters:
T- the type content. This ensures that the type of current is the same as the type passed to the modification- Parameters:
current- the current / latest versionmodification- an implementation ofModificationwhich describes the state changes you require
-
saveNewVersion
public <T extends ContentEntityObject> void saveNewVersion(T current, Modification<T> modification, @Nullable SaveContext saveContext) Description copied from interface:ContentEntityManagerApplies the state changes supplied by modification and persists those changes to a new version.manager.<Page>saveNewVersion(page, new Modification<Page>() { public void modify(Page page) { page.setTitle("foobar"); } }, new DefaultSaveContext());- Specified by:
saveNewVersionin interfaceContentEntityManager- Type Parameters:
T- the type content. This ensures that the type of current is the same as the type passed to the modification- Parameters:
current- the current / latest versionmodification- an implementation ofModificationwhich describes the state changes you requiresaveContext- the save context (null if you have no specific requirements - or just useContentEntityManager.saveNewVersion(ContentEntityObject, Modification)).
-
removeContentEntities
-
removeContentEntity
Description copied from interface:ContentEntityManagerRemoves given content entity object and all associated domain objects i.e. if we remove a page it removes all its labels and attachments- Specified by:
removeContentEntityin interfaceContentEntityManager
-
getById
- Specified by:
getByIdin interfaceContentEntityManager- Returns:
- ContentEntityObject with the given id.
-
getById
- Specified by:
getByIdin interfaceContentEntityManagerInternal- Returns:
- ContentEntityObject with the given id.
-
getById
- Specified by:
getByIdin interfaceContentEntityManagerInternal- Parameters:
id- the id of the last version CEO. Previous version ids will make this method return null- Returns:
- the ContentEntityObject with the corresponding id and version or null if the object with that id and version does not exist. null will also be returned if the id points to a CEO which version is not the last one.
-
getByIdsAndFilters
public @NonNull PageResponse<ContentEntityObject> getByIdsAndFilters(List<ContentId> contentIds, LimitedRequest limitedRequest, Predicate<? super ContentEntityObject> filter) - Specified by:
getByIdsAndFiltersin interfaceContentEntityManagerInternal- Parameters:
contentIds- the contentIds of the candidate ContentEntityObjectslimitedRequest- the page request to applyfilter- an optional predicate- Returns:
- fetch multiple contentEntityObjects by id that match the provided predicate
-
getVersionHistorySummaries
public @NonNull PageResponse<VersionHistorySummary> getVersionHistorySummaries(ContentId contentId, LimitedRequest limitedRequest) Description copied from interface:ContentEntityManagerInternalGet a VersionHistorySummary for all previous versions of a ContentEntityObject, list is ordered by Version number descending. e.g. the list is started with the most recent content version as item 0.- Specified by:
getVersionHistorySummariesin interfaceContentEntityManagerInternal- Parameters:
contentId- the entity Id of the object to return the version history of- Returns:
- the full version history of that object, as VersionHistorySummary objects.
-
countContentBySpaceIdAndStatus
Description copied from interface:ContentEntityManagerInternalRetrieve the count of specific content type for a given space with a particular status.- Specified by:
countContentBySpaceIdAndStatusin interfaceContentEntityManagerInternal- Parameters:
spaceId- the id of the spacestatus- the status of the content being retrieved (e.g.ContentEntityObject.DELETED- Returns:
- the number of content objects with that status in that space
-
revertContentEntityBackToVersion
public void revertContentEntityBackToVersion(ContentEntityObject entity, int version, @Nullable String revertComment, boolean revertTitle) Description copied from interface:ContentEntityManagerReverts a
ContentEntityObjectback to its state at the version specified byversion. Creates a new latest version that resembles the previous state.Since Confluence 4.0 most ContentEntityObjects are assumed to be XHTML formatted. So in reverting a ContentEntityObject which actually has a WIKI
BodyTypethis will be migrated on the fly to XHTML.- Specified by:
revertContentEntityBackToVersionin interfaceContentEntityManager- Parameters:
entity- The ContentEntityObject to revertversion- The version to revert torevertComment- A comment to be associated with the revertrevertTitle- If true, the ContentEntityObject title will be reverted to the old state
-
revertContentEntityBackToVersion
public void revertContentEntityBackToVersion(ContentEntityObject entity, int version, @Nullable String revertComment, boolean revertTitle, Function<ContentEntityObject, BodyContent> revertBodyContentFactory) -
convertFromWikiToStorageFormatIfRequired
protected @NonNull BodyContent convertFromWikiToStorageFormatIfRequired(ContentEntityObject historicalVersion) -
getRecentlyAddedEntities
public @NonNull Iterator<ContentEntityObject> getRecentlyAddedEntities(@Nullable String spaceKey, int maxResults) Description copied from interface:ContentEntityManagerRetrieve an iterator of recently added entities, in order of most recent to last. The iterator is lazy-loading, so you can filter the output and return the first 'n' that interest you.For performance reasons, it's a VERY bad idea to supply both a space key, and infinite results.
If you supply a space key, this WILL NOT RETURN ANY COMMENTS. There is currently no way around this, you have to retrieve comments separately and splice the results together. Sorry.
- Specified by:
getRecentlyAddedEntitiesin interfaceContentEntityManager- Parameters:
spaceKey- the space key to look up the entities for. If spaceKey is null, there is assumed to be no space, and things like user info and space descriptions will also be returned.maxResults- the maximum number of entities to return in the iterator. Any number zero or less (Use the ITERATE_ALL constant) will cause the iterator to go over every entity.
-
getRecentlyModifiedEntities
public @NonNull Iterator<SpaceContentEntityObject> getRecentlyModifiedEntities(String spaceKey, int maxResults) Description copied from interface:ContentEntityManagerRetrieve an iterator of recently modified entities, in order of most recent to last. The iterator is lazy-loading, so you can filter the output and return the first 'n' that interest you.For performance reasons, it's a VERY bad idea to supply both a space key, and infinite results.
- Specified by:
getRecentlyModifiedEntitiesin interfaceContentEntityManager- Parameters:
spaceKey- the space key to look up the entities for.maxResults- the maximum number of entities to return in the iterator. Any number zero or less (Use the ITERATE_ALL constant) will cause the iterator to go over every entity.
-
getPageAndBlogPostsVersionsLastEditedByUser
public @NonNull PageResponse<AbstractPage> getPageAndBlogPostsVersionsLastEditedByUser(com.atlassian.sal.api.user.UserKey userKey, LimitedRequest request) Description copied from interface:ContentEntityManagerRetrieve a page of entities that have been modified by the user, in order of the user's most recent modification. Only content with a "current" status are returned.- Specified by:
getPageAndBlogPostsVersionsLastEditedByUserin interfaceContentEntityManager- Parameters:
userKey- the key for the user for whom to retrieve the modified contentrequest- the request
-
getPageAndBlogPostsVersionsLastEditedByUserIncludingDrafts
public @NonNull PageResponse<AbstractPage> getPageAndBlogPostsVersionsLastEditedByUserIncludingDrafts(@Nullable com.atlassian.sal.api.user.UserKey userKey, LimitedRequest request) Description copied from interface:ContentEntityManagerRetrieve a page of entities that have been modified by the user, in order of the user's most recent modification. Only content with "current" or "draft" status are returned.- Specified by:
getPageAndBlogPostsVersionsLastEditedByUserIncludingDraftsin interfaceContentEntityManager- Parameters:
userKey- the key for the user for whom to retrieve the modified contentrequest- the request
-
getRecentlyModifiedEntitiesForUser
public @NonNull Iterator<ContentEntityObject> getRecentlyModifiedEntitiesForUser(ConfluenceUser user) Description copied from interface:ContentEntityManagerRetrieve an iterator of recently modified entities, in order of most recent to last. The iterator is lazy-loading, so you can filter the output and return the first 'n' that interest you.- Specified by:
getRecentlyModifiedEntitiesForUserin interfaceContentEntityManager- Parameters:
user- the user for which to retrieve the modified content
-
getRecentlyModifiedForChangeDigest
Description copied from interface:ContentEntityManagerRetrieves a list ofContentEntityObjects that have been newly added or modified since the date specified. This list excludes drafts, space descriptions and mail.- Specified by:
getRecentlyModifiedForChangeDigestin interfaceContentEntityManager- Parameters:
fromDate- content modified after this date will be returned- Returns:
- a list of
ContentEntityObjects that have been newly added or modified since the date specified
-
getPreviousVersion
Description copied from interface:ContentEntityManagerGet the previous version of the entity in the sequence ofVersioned.Returns null for
ContentEntityObject.DRAFTs.- Specified by:
getPreviousVersionin interfaceContentEntityManager
-
getNextVersion
Description copied from interface:ContentEntityManagerGet the next version of the entity in the sequence ofVersioned.Returns null for
ContentEntityObject.DRAFTs.- Specified by:
getNextVersionin interfaceContentEntityManager
-
getOtherVersion
- Specified by:
getOtherVersionin interfaceContentEntityManager
-
getVersionsLastEditedByUser
public @NonNull Map<Long,ContentEntityObject> getVersionsLastEditedByUser(@NonNull Collection<ContentId> contentIds, @Nullable com.atlassian.sal.api.user.UserKey userKey) Description copied from interface:ContentEntityManagerGets theContentEntityObjectobjects relating to the version of the given contentIds that were last edited by the given user. Only content with a "current" status are returned.- Specified by:
getVersionsLastEditedByUserin interfaceContentEntityManager- Parameters:
contentIds- the ids of the content we're interested in. These *must* be ids of the latest version.userKey- the userKey of the user that we're interested in- Returns:
- the
ContentEntityObjectobjects relating to the version of the given contentIds that were last edited by the given user.
-
getContributionStatusByUser
public Map<Long,ContributionStatus> getContributionStatusByUser(@NonNull Collection<ContentId> contentIds, @Nullable com.atlassian.sal.api.user.UserKey userKey) Description copied from interface:ContentEntityManagerIdentifies the most recent contributions made to a set of content by the given user. A contribution can either be a page publish, or a set of unpublished changes which have been saved to a draft. Does not return aContributionStatusfor a content ID if the user has never contributed to the content.- Specified by:
getContributionStatusByUserin interfaceContentEntityManager- Parameters:
contentIds- the IDs of the content we want to query. These *must* be IDs of the latest versionuserKey- the userKey of the user who's changes we are interested in- Returns:
- the
ContributionStatusof each content
-
getVersionHistorySummaries
Description copied from interface:ContentEntityManagerGet a VersionHistorySummary for all previous versions of a ContentEntityObject, starting with the current content.- Specified by:
getVersionHistorySummariesin interfaceContentEntityManager- Parameters:
ceo- the entity object to return the version history of- Returns:
- the full version history of that object, as VersionHistorySummary objects.
-
removeHistoricalVersion
Description copied from interface:ContentEntityManagerRemoves a historical ContentEntityObject.- Specified by:
removeHistoricalVersionin interfaceContentEntityManager- Parameters:
historicalVersion- a historical entity object to remove
-
getContentAuthoredByUser
- Specified by:
getContentAuthoredByUserin interfaceContentEntityManagerInternal- Since:
- 9.5
- See Also:
-
ContentByUserMacro
-
publishCreateEvent
-
publishUpdateEvent
protected void publishUpdateEvent(ContentEntityObject obj, @Nullable ContentEntityObject origObj, @Nullable SaveContext saveContext) -
publishRemoveEvent
-