@ParametersAreNonnullByDefault public class DefaultContentEntityManager extends Object implements ContentEntityManagerInternal
Modifier and Type | Field and Description |
---|---|
protected CollaborativeEditingHelper |
collaborativeEditingHelper |
ITERATE_ALL
Constructor and Description |
---|
DefaultContentEntityManager(ContentEntityObjectDao contentEntityObjectDao,
LinkManager linkManager,
ConfluenceIndexer indexer,
LabelManager labelManager,
AttachmentManager attachmentManager,
HibernateSessionManager hibernateSessionManager,
com.google.common.base.Supplier<XhtmlContent> xhtmlContent,
com.atlassian.event.api.EventPublisher eventPublisher,
NotificationManager notificationManager,
RelationManager relationManager,
com.google.common.base.Supplier<UserAccessor> userAccessor,
com.google.common.base.Supplier<DarkFeaturesManager> darkFeaturesManager,
CollaborativeEditingHelper collaborativeEditingHelper) |
Modifier and Type | Method and Description |
---|---|
<T extends ContentEntityObject> |
createDraft(T draft,
SaveContext saveContext)
This method sets the common properties of the
ContentEntityObject to be saved as a draft |
<T extends ContentEntityObject> |
findAllDraftsFor(long contentId)
Retrieves a list of drafts for the given content ID if any exist.
|
<T extends ContentEntityObject> |
findDraftFor(long contentId)
Retrieves the draft for the given content ID if it exists
|
<T extends ContentEntityObject> |
findDraftFor(T ceo)
Retrieves the draft for the given content if exists.
|
List<ContentEntityObject> |
findUnpublishedContentWithUserContributions(String username)
Retrieves the drafts for the given
User |
protected AttachmentManager |
getAttachmentManager() |
protected @NonNull BodyContent |
getBodyContentForRevert(ContentEntityObject historicalVersion) |
@Nullable ContentEntityObject |
getById(ContentId id) |
@Nullable ContentEntityObject |
getById(ContentId id,
int version) |
@Nullable ContentEntityObject |
getById(long id) |
PageResponse<ContentEntityObject> |
getByIds(List<ContentId> contentIds,
LimitedRequest limitedRequest,
com.google.common.base.Predicate<? super ContentEntityObject>... filters)
Deprecated.
|
protected ContentEntityObjectDao |
getContentEntityObjectDao() |
Map<Long,ContributionStatus> |
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.
|
protected com.atlassian.event.api.EventPublisher |
getEventPublisher() |
protected HibernateSessionManager |
getHibernateSessionManager() |
protected ConfluenceIndexer |
getIndexer() |
protected LabelManager |
getLabelManager() |
protected LinkManager |
getLinkManager() |
@Nullable ContentEntityObject |
getNextVersion(ContentEntityObject ceo)
Get the next version of the entity in the sequence of
Versioned . |
protected NotificationManager |
getNotificationManager() |
@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 |
getPreviousVersion(ContentEntityObject ceo)
Get the previous version of the entity in the sequence of
Versioned . |
@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 |
getRecentlyModifiedEntitiesForUser(String username)
Retrieve an iterator of recently modified entities, in order of most recent to last.
|
@NonNull List |
getRecentlyModifiedForChangeDigest(Date fromDate)
Retrieves a list of
ContentEntityObject s that have been newly added or modified
since the date specified. |
@NonNull List<VersionHistorySummary> |
getVersionHistorySummaries(ContentEntityObject ceo)
Get a VersionHistorySummary for all previous versions of a ContentEntityObject, starting with the current
content.
|
@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 Map<Long,ContentEntityObject> |
getVersionsLastEditedByUser(@NonNull Collection<ContentId> contentIds,
@Nullable com.atlassian.sal.api.user.UserKey userKey)
Gets the
ContentEntityObject objects relating to the version of the given contentIds that were last
edited by the given user. |
protected void |
publishCreateEvent(ContentEntityObject obj)
This method publishes
*CreateEvents s. |
protected void |
publishCreateEvent(ContentEntityObject obj,
@Nullable SaveContext saveContext) |
protected void |
publishRemoveEvent(ContentEntityObject obj)
This method publishes
*RemoveEvent s. |
protected void |
publishUpdateEvent(ContentEntityObject obj,
@Nullable ContentEntityObject origObj,
@Nullable SaveContext saveContext)
This method publishes
*UpdateEvent s. |
void |
refreshContentEntity(ContentEntityObject obj)
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 |
removeContentEntity(ContentEntityObject obj)
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 a
ContentEntityObject back to its state at the version specified by version . |
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> |
saveNewVersion(T current,
Modification<T> modification)
Applies the state changes supplied by modification and persists those changes to a new version.
|
<T extends ContentEntityObject> |
saveNewVersion(T current,
Modification<T> modification,
@Nullable SaveContext saveContext)
Applies the state changes supplied by modification and persists those changes to a new version.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getByIdsAndFilters
protected final CollaborativeEditingHelper collaborativeEditingHelper
public DefaultContentEntityManager(ContentEntityObjectDao contentEntityObjectDao, LinkManager linkManager, ConfluenceIndexer indexer, LabelManager labelManager, AttachmentManager attachmentManager, HibernateSessionManager hibernateSessionManager, com.google.common.base.Supplier<XhtmlContent> xhtmlContent, com.atlassian.event.api.EventPublisher eventPublisher, NotificationManager notificationManager, RelationManager relationManager, com.google.common.base.Supplier<UserAccessor> userAccessor, com.google.common.base.Supplier<DarkFeaturesManager> darkFeaturesManager, CollaborativeEditingHelper collaborativeEditingHelper)
public void refreshContentEntity(ContentEntityObject obj)
ContentEntityManager
refreshContentEntity
in interface ContentEntityManager
obj
- the object to be refreshed in the Hibernate session.public <T extends ContentEntityObject> T createDraft(T draft, SaveContext saveContext)
ContentDraftManagerInternal
ContentEntityObject
to be saved as a draftcreateDraft
in interface ContentDraftManagerInternal
draft
- - the ContentEntityObject
to save as draftsaveContext
- - a SaveContext
holding additional parameters for the manager to use when saving.ContentEntityObject.DRAFT
public <T extends ContentEntityObject> T findDraftFor(T ceo)
ContentDraftManagerInternal
findDraftFor
in interface ContentDraftManagerInternal
ceo
- the entity object to retrieve the draft forContentEntityObject.DRAFT
public <T extends ContentEntityObject> T findDraftFor(long contentId)
ContentDraftManagerInternal
findDraftFor
in interface ContentDraftManagerInternal
contentId
- The content ID used to identify the draftContentEntityObject.DRAFT
public <T extends ContentEntityObject> List<T> findAllDraftsFor(long contentId)
ContentDraftManagerInternal
findAllDraftsFor
in interface ContentDraftManagerInternal
contentId
- The content ID used to identify the draftsContentEntityObject.DRAFT
public List<ContentEntityObject> findUnpublishedContentWithUserContributions(String username)
ContentDraftManagerInternal
User
findUnpublishedContentWithUserContributions
in interface ContentDraftManagerInternal
username
- the owner of the draftsContentEntityObject
with the
ContentEntityObject.DRAFT
statuspublic void saveContentEntity(ContentEntityObject obj, @Nullable SaveContext saveContext)
saveContentEntity
in interface ContentEntityManager
obj
- - the ContentEntityObject
to savesaveContext
- - a SaveContext
holding additional parameters for the manager to use when saving.public void saveContentEntity(ContentEntityObject obj, @Nullable ContentEntityObject origObj, @Nullable SaveContext saveContext)
ContentEntityManager
saveContentEntity
in interface ContentEntityManager
saveContext
- - a SaveContext
holding additional parameters for the manager to use when saving.public <T extends ContentEntityObject> void saveNewVersion(T current, Modification<T> modification)
ContentEntityManager
manager.<Page>saveNewVersion(page, new Modification<Page>() { public void modify(Page page) { page.setTitle("foobar"); } });
saveNewVersion
in interface ContentEntityManager
T
- the type content. This ensures that the type of current is the same as the type passed to the modificationcurrent
- the current / latest versionmodification
- an implementation of Modification
which describes the state changes you requirepublic <T extends ContentEntityObject> void saveNewVersion(T current, Modification<T> modification, @Nullable SaveContext saveContext)
ContentEntityManager
manager.<Page>saveNewVersion(page, new Modification<Page>() { public void modify(Page page) { page.setTitle("foobar"); } }, new DefaultSaveContext());
saveNewVersion
in interface ContentEntityManager
T
- the type content. This ensures that the type of current is the same as the type passed to the modificationcurrent
- the current / latest versionmodification
- an implementation of Modification
which describes the state changes you requiresaveContext
- the save context (null if you have no specific requirements - or just use ContentEntityManager.saveNewVersion(ContentEntityObject, Modification)
).protected void removeContentEntities(Iterable<? extends ContentEntityObject> contentEntityObjects)
public void removeContentEntity(ContentEntityObject obj)
ContentEntityManager
removeContentEntity
in interface ContentEntityManager
public @Nullable ContentEntityObject getById(long id)
getById
in interface ContentEntityManager
public @Nullable ContentEntityObject getById(ContentId id)
getById
in interface ContentEntityManagerInternal
public @Nullable ContentEntityObject getById(ContentId id, int version)
getById
in interface ContentEntityManagerInternal
id
- the id of the last version CEO. Previous version ids will make this method return null@Deprecated public PageResponse<ContentEntityObject> getByIds(List<ContentId> contentIds, LimitedRequest limitedRequest, com.google.common.base.Predicate<? super ContentEntityObject>... filters)
ContentEntityManagerInternal.getByIdsAndFilters(List, LimitedRequest, java.util.function.Predicate[])
getByIds
in interface ContentEntityManagerInternal
contentIds
- the contentIds of the candidate ContentEntityObjectslimitedRequest
- the page request to applyfilters
- an optional predicatepublic @NonNull PageResponse<VersionHistorySummary> getVersionHistorySummaries(ContentId contentId, LimitedRequest limitedRequest)
ContentEntityManagerInternal
getVersionHistorySummaries
in interface ContentEntityManagerInternal
contentId
- the entity Id of the object to return the version history ofpublic void revertContentEntityBackToVersion(ContentEntityObject entity, int version, @Nullable String revertComment, boolean revertTitle)
ContentEntityManager
Reverts a ContentEntityObject
back to its state at the version specified by version
.
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.
revertContentEntityBackToVersion
in interface ContentEntityManager
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 stateprotected @NonNull BodyContent getBodyContentForRevert(ContentEntityObject historicalVersion)
public @NonNull Iterator getRecentlyAddedEntities(@Nullable String spaceKey, int maxResults)
ContentEntityManager
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.
getRecentlyAddedEntities
in interface ContentEntityManager
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.public @NonNull Iterator getRecentlyModifiedEntities(String spaceKey, int maxResults)
ContentEntityManager
For performance reasons, it's a VERY bad idea to supply both a space key, and infinite results.
getRecentlyModifiedEntities
in interface ContentEntityManager
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.public @NonNull PageResponse<AbstractPage> getPageAndBlogPostsVersionsLastEditedByUser(com.atlassian.sal.api.user.UserKey userKey, LimitedRequest request)
ContentEntityManager
getPageAndBlogPostsVersionsLastEditedByUser
in interface ContentEntityManager
userKey
- the key for the user for whom to retrieve the modified contentrequest
- the requestpublic @NonNull PageResponse<AbstractPage> getPageAndBlogPostsVersionsLastEditedByUserIncludingDrafts(@Nullable com.atlassian.sal.api.user.UserKey userKey, LimitedRequest request)
ContentEntityManager
getPageAndBlogPostsVersionsLastEditedByUserIncludingDrafts
in interface ContentEntityManager
userKey
- the key for the user for whom to retrieve the modified contentrequest
- the requestpublic @NonNull Iterator getRecentlyModifiedEntitiesForUser(String username)
ContentEntityManager
getRecentlyModifiedEntitiesForUser
in interface ContentEntityManager
username
- the user for which to retrieve the modified contentpublic @NonNull List getRecentlyModifiedForChangeDigest(Date fromDate)
ContentEntityManager
ContentEntityObject
s that have been newly added or modified
since the date specified. This list excludes drafts, space descriptions and mail.getRecentlyModifiedForChangeDigest
in interface ContentEntityManager
fromDate
- content modified after this date will be returnedContentEntityObject
s that have been newly added or modified
since the date specifiedpublic @Nullable ContentEntityObject getPreviousVersion(ContentEntityObject ceo)
ContentEntityManager
Versioned
.
Returns null for ContentEntityObject.DRAFT
s.
getPreviousVersion
in interface ContentEntityManager
public @Nullable ContentEntityObject getNextVersion(ContentEntityObject ceo)
ContentEntityManager
Versioned
.
Returns null for ContentEntityObject.DRAFT
s.
getNextVersion
in interface ContentEntityManager
public @Nullable ContentEntityObject getOtherVersion(ContentEntityObject ceo, int version)
getOtherVersion
in interface ContentEntityManager
public @NonNull Map<Long,ContentEntityObject> getVersionsLastEditedByUser(@NonNull Collection<ContentId> contentIds, @Nullable com.atlassian.sal.api.user.UserKey userKey)
ContentEntityManager
ContentEntityObject
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.getVersionsLastEditedByUser
in interface ContentEntityManager
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 inContentEntityObject
objects relating to the version of the given contentIds that were last
edited by the given user.public Map<Long,ContributionStatus> getContributionStatusByUser(@NonNull Collection<ContentId> contentIds, @Nullable com.atlassian.sal.api.user.UserKey userKey)
ContentEntityManager
ContributionStatus
for a content ID if the user has never contributed to the content.getContributionStatusByUser
in interface ContentEntityManager
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 inContributionStatus
of each contentpublic @NonNull List<VersionHistorySummary> getVersionHistorySummaries(ContentEntityObject ceo)
ContentEntityManager
getVersionHistorySummaries
in interface ContentEntityManager
ceo
- the entity object to return the version history ofpublic void removeHistoricalVersion(ContentEntityObject historicalVersion)
ContentEntityManager
removeHistoricalVersion
in interface ContentEntityManager
historicalVersion
- a historical entity object to removeprotected void publishCreateEvent(ContentEntityObject obj)
*CreateEvents
s.
Specific content entity object manager that need to publish those events should override this method.obj
- the created content entity objectprotected void publishCreateEvent(ContentEntityObject obj, @Nullable SaveContext saveContext)
protected void publishUpdateEvent(ContentEntityObject obj, @Nullable ContentEntityObject origObj, @Nullable SaveContext saveContext)
*UpdateEvent
s.
Specific content entity object manager that need to publish those events should override this method.obj
- the updated content entity objectorigObj
- the old version of the content entity object, for history purposesaveContext
- the associated SaveContext
protected void publishRemoveEvent(ContentEntityObject obj)
*RemoveEvent
s.
Specific content entity object manager that need to publish those events should override this method.obj
- the removed content entity objectprotected ContentEntityObjectDao getContentEntityObjectDao()
protected LinkManager getLinkManager()
protected ConfluenceIndexer getIndexer()
protected LabelManager getLabelManager()
protected AttachmentManager getAttachmentManager()
protected HibernateSessionManager getHibernateSessionManager()
protected com.atlassian.event.api.EventPublisher getEventPublisher()
protected NotificationManager getNotificationManager()
Copyright © 2003–2020 Atlassian. All rights reserved.