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
ConstructorDescriptionDefaultContentEntityManager
(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 BodyContent
convertFromWikiToStorageFormatIfRequired
(ContentEntityObject historicalVersion) <T extends ContentEntityObject>
TcreateDraft
(T draft, SaveContext saveContext) This method sets the common properties of theContentEntityObject
to be saved as a draftstatic <T extends ConfluenceEntityObject>
PageResponse<T>filteredResponseWithCursor
(LimitedRequest originalRequest, @Nullable Predicate<? super T> filter, List<T> pages) <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 givenUser
IMPORTANT: this method doesn't return published shared drafts, only personal drafts and unpublished shared drafts@Nullable ContentEntityObject
getById
(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 ContentEntityObject
Get the next version of the entity in the sequence ofVersioned
.@Nullable ContentEntityObject
getOtherVersion
(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 ContentEntityObject
Get the previous version of the entity in the sequence ofVersioned
.@NonNull Iterator
getRecentlyAddedEntities
(@Nullable String spaceKey, int maxResults) Retrieve an iterator of recently added entities, in order of most recent to last.@NonNull Iterator
getRecentlyModifiedEntities
(String spaceKey, int maxResults) Retrieve an iterator of recently modified entities, in order of most recent to last.@NonNull Iterator
Retrieve an iterator of recently modified entities, in order of most recent to last.@NonNull List
getRecentlyModifiedForChangeDigest
(Date fromDate) Retrieves a list ofContentEntityObject
s 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 theContentEntityObject
objects relating to the version of the given contentIds that were last edited by the given user.protected void
publishCreateEvent
(ContentEntityObject obj, @Nullable SaveContext saveContext) protected void
protected void
publishUpdateEvent
(ContentEntityObject obj, @Nullable ContentEntityObject origObj, @Nullable SaveContext saveContext) void
Refreshes the specified entity (including content) in the Hibernate session to ensure that subsequent retrievals are up-to-date.protected void
removeContentEntities
(Iterable<? extends ContentEntityObject> contentEntityObjects) void
Removes given content entity object and all associated domain objects i.e.void
removeHistoricalVersion
(ContentEntityObject historicalVersion) Removes a historical ContentEntityObject.void
revertContentEntityBackToVersion
(ContentEntityObject entity, int version, @Nullable String revertComment, boolean revertTitle) Reverts aContentEntityObject
back to its state at the version specified byversion
.void
revertContentEntityBackToVersion
(ContentEntityObject entity, int version, @Nullable String revertComment, boolean revertTitle, Function<ContentEntityObject, BodyContent> revertBodyContentFactory) void
saveContentEntity
(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.void
saveContentEntity
(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) -
refreshContentEntity
Description copied from interface:ContentEntityManager
Refreshes the specified entity (including content) in the Hibernate session to ensure that subsequent retrievals are up-to-date.- Specified by:
refreshContentEntity
in interfaceContentEntityManager
- Parameters:
obj
- the object to be refreshed in the Hibernate session.
-
createDraft
Description copied from interface:ContentDraftManagerInternal
This method sets the common properties of theContentEntityObject
to be saved as a draft- Specified by:
createDraft
in interfaceContentDraftManagerInternal
- Parameters:
draft
- - theContentEntityObject
to save as draftsaveContext
- - aSaveContext
holding additional parameters for the manager to use when saving.- Returns:
- the obj created as draft
- See Also:
-
findDraftFor
Description copied from interface:ContentDraftManagerInternal
Retrieves the draft for the given content if exists.- Specified by:
findDraftFor
in 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:ContentDraftManagerInternal
Retrieves the draft for the given content ID if it exists- Specified by:
findDraftFor
in 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:ContentDraftManagerInternal
Retrieves a list of drafts for the given content ID if any exist.- Specified by:
findAllDraftsFor
in 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:ContentDraftManagerInternal
Retrieves the drafts for the givenUser
IMPORTANT: this method doesn't return published shared drafts, only personal drafts and unpublished shared drafts- Specified by:
findUnpublishedContentWithUserContributions
in interfaceContentDraftManagerInternal
- Parameters:
user
- the owner of the drafts- Returns:
- a list of
ContentEntityObject
with theContentEntityObject.DRAFT
status
-
findAllDraftsWithUnpublishedChangesForUser
Description copied from interface:ContentDraftManagerInternal
Retrieves the drafts for the givenUser
- Specified by:
findAllDraftsWithUnpublishedChangesForUser
in interfaceContentDraftManagerInternal
- Parameters:
creator
- the owner of the drafts- Returns:
- a list of user's drafts (
ContentEntityObject
objects)
-
saveContentEntity
- Specified by:
saveContentEntity
in interfaceContentEntityManager
- Parameters:
obj
- - theContentEntityObject
to savesaveContext
- - aSaveContext
holding 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:ContentEntityManager
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.- Specified by:
saveContentEntity
in interfaceContentEntityManager
saveContext
- - aSaveContext
holding additional parameters for the manager to use when saving.
-
saveNewVersion
Description copied from interface:ContentEntityManager
Applies 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:
saveNewVersion
in 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 ofModification
which 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:ContentEntityManager
Applies 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:
saveNewVersion
in 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 ofModification
which 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:ContentEntityManager
Removes 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:
removeContentEntity
in interfaceContentEntityManager
-
getById
- Specified by:
getById
in interfaceContentEntityManager
- Returns:
- ContentEntityObject with the given id.
-
getById
- Specified by:
getById
in interfaceContentEntityManagerInternal
- Returns:
- ContentEntityObject with the given id.
-
getById
- Specified by:
getById
in 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:
getByIdsAndFilters
in 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:ContentEntityManagerInternal
Get 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:
getVersionHistorySummaries
in 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.
-
revertContentEntityBackToVersion
public void revertContentEntityBackToVersion(ContentEntityObject entity, int version, @Nullable String revertComment, boolean revertTitle) Description copied from interface:ContentEntityManager
Reverts a
ContentEntityObject
back 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
BodyType
this will be migrated on the fly to XHTML.- Specified by:
revertContentEntityBackToVersion
in 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
Description copied from interface:ContentEntityManager
Retrieve 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:
getRecentlyAddedEntities
in 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
Description copied from interface:ContentEntityManager
Retrieve 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:
getRecentlyModifiedEntities
in 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:ContentEntityManager
Retrieve 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:
getPageAndBlogPostsVersionsLastEditedByUser
in 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:ContentEntityManager
Retrieve 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:
getPageAndBlogPostsVersionsLastEditedByUserIncludingDrafts
in interfaceContentEntityManager
- Parameters:
userKey
- the key for the user for whom to retrieve the modified contentrequest
- the request
-
getRecentlyModifiedEntitiesForUser
Description copied from interface:ContentEntityManager
Retrieve 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:
getRecentlyModifiedEntitiesForUser
in interfaceContentEntityManager
- Parameters:
user
- the user for which to retrieve the modified content
-
getRecentlyModifiedForChangeDigest
Description copied from interface:ContentEntityManager
Retrieves a list ofContentEntityObject
s that have been newly added or modified since the date specified. This list excludes drafts, space descriptions and mail.- Specified by:
getRecentlyModifiedForChangeDigest
in interfaceContentEntityManager
- Parameters:
fromDate
- content modified after this date will be returned- Returns:
- a list of
ContentEntityObject
s that have been newly added or modified since the date specified
-
getPreviousVersion
Description copied from interface:ContentEntityManager
Get the previous version of the entity in the sequence ofVersioned
.Returns null for
ContentEntityObject.DRAFT
s.- Specified by:
getPreviousVersion
in interfaceContentEntityManager
-
getNextVersion
Description copied from interface:ContentEntityManager
Get the next version of the entity in the sequence ofVersioned
.Returns null for
ContentEntityObject.DRAFT
s.- Specified by:
getNextVersion
in interfaceContentEntityManager
-
getOtherVersion
- Specified by:
getOtherVersion
in interfaceContentEntityManager
-
getVersionsLastEditedByUser
public @NonNull Map<Long,ContentEntityObject> getVersionsLastEditedByUser(@NonNull Collection<ContentId> contentIds, @Nullable com.atlassian.sal.api.user.UserKey userKey) Description copied from interface:ContentEntityManager
Gets theContentEntityObject
objects 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:
getVersionsLastEditedByUser
in 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
ContentEntityObject
objects 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:ContentEntityManager
Identifies 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 aContributionStatus
for a content ID if the user has never contributed to the content.- Specified by:
getContributionStatusByUser
in 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
ContributionStatus
of each content
-
getVersionHistorySummaries
Description copied from interface:ContentEntityManager
Get a VersionHistorySummary for all previous versions of a ContentEntityObject, starting with the current content.- Specified by:
getVersionHistorySummaries
in 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:ContentEntityManager
Removes a historical ContentEntityObject.- Specified by:
removeHistoricalVersion
in interfaceContentEntityManager
- Parameters:
historicalVersion
- a historical entity object to remove
-
publishCreateEvent
-
publishUpdateEvent
protected void publishUpdateEvent(ContentEntityObject obj, @Nullable ContentEntityObject origObj, @Nullable SaveContext saveContext) -
publishRemoveEvent
-