Class DefaultCustomContentManager
- java.lang.Object
-
- com.atlassian.confluence.impl.content.DefaultContentEntityManager
-
- com.atlassian.confluence.impl.content.DefaultCustomContentManager
-
- All Implemented Interfaces:
CustomContentManager
,ContentEntityManager
,ContentDraftManagerInternal
,ContentEntityManagerInternal
@ParametersAreNonnullByDefault public class DefaultCustomContentManager extends DefaultContentEntityManager implements CustomContentManager
Generic manager for pluggable content.- Since:
- 7.15
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.atlassian.confluence.content.CustomContentManager
CustomContentManager.SortField, CustomContentManager.SortOrder
-
-
Field Summary
-
Fields inherited from interface com.atlassian.confluence.core.ContentEntityManager
ITERATE_ALL
-
-
Constructor Summary
Constructors Constructor Description DefaultCustomContentManager(CustomContentDao customContentDao, org.hibernate.SessionFactory sessionFactory, WikiToStorageConverter wikiToStorageConverter, com.atlassian.event.api.EventPublisher eventPublisher, ContentTypeManager contentTypeManager, RelationManager relationManager, ContentFactory contentFactory, CollaborativeEditingHelper collaborativeEditingHelper, AuditingContext auditingContext, RetentionFeatureChecker retentionFeatureChecker)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
countChildrenOfType(CustomContentEntityObject content, String contentModuleKey)
Get the total number of children of a piece of content with the given type@NonNull Iterator<CustomContentEntityObject>
findAllChildren(CustomContentEntityObject content)
Get an iterator of all children of a piece of content.@NonNull Iterator<CustomContentEntityObject>
findAllContainedOfType(long containerContentId, String pluginModuleKey)
Get an iterator of contained content of a piece of content with a given type.@NonNull Collection<CustomContentEntityObject>
findAllInSpace(Space space)
This method is required for space exports to work properly.<T> @NonNull Iterator<T>
findByQuery(ContentQuery<T> query, int offset, int maxResults)
Get the results of a query for CustomContentEntityObjects<T> @NonNull PageResponse<T>
findByQueryAndFilter(ContentQuery<T> query, boolean cacheable, LimitedRequest request, Predicate<T> predicate)
Get the results of a query for CustomContentEntityObjects@NonNull Iterator<CustomContentEntityObject>
findChildrenOfType(CustomContentEntityObject content, String pluginContentKey, int offset, int maxResults, CustomContentManager.SortField sortField, CustomContentManager.SortOrder sortOrder)
Get an iterator of children of a piece of content with a given type.@NonNull Iterator<CustomContentEntityObject>
findCurrentInSpace(Space space, String pluginContentKey, int offset, int maxResults, CustomContentManager.SortField sortField, CustomContentManager.SortOrder sortOrder)
Get an iterator of all the current, non-deleted content of the given type in the given space.<T> @Nullable T
findFirstObjectByQuery(ContentQuery<T> query)
Find the first result of a query for CustomContentEntityObjects.int
findTotalInSpace(Space space, String pluginContentKey)
Get the total count of current, non-deleted content of the given type in the given space.@Nullable CustomContentEntityObject
getById(long id)
Find a single CustomContentEntityObject by its id@NonNull PageResponse<Content>
getChildrenOfTypeAndFilter(ContentEntityObject entity, String contentModuleKey, LimitedRequest limitedRequest, Expansions expansions, Depth depth, Predicate<? super CustomContentEntityObject> predicate)
This method is used by the Content API to retrieve children of a specific type and filter them by a predicate.@NonNull CustomContentEntityObject
newPluginContentEntityObject(String contentModuleKey)
Create a new CustomContentEntityObject for the given module.<T> @NonNull List<T>
queryForList(ContentQuery<T> query)
It is strongly recommended that thequeryForList(ContentQuery, int, int)
method be used in preference to this one, as this method does not apply pagination limits to the result set.<T> @NonNull List<T>
queryForList(ContentQuery<T> query, int offset, int maxResults)
Get the results of a query for CustomContentEntityObjectsvoid
removeAllInSpace(String pluginContentKey, Space space)
Remove all plugin content of a particular type from a given space.void
removeAllPluginContent(String contentModuleKey)
Remove all plugin content of a particular typevoid
removeAllPluginContentInSpace(Space space)
Remove all plugin content (of all types) from a given space.void
removeContentEntity(ContentEntityObject obj)
Removes given content entity object and all associated domain objects i.e.void
setContentFactory(ContentFactory contentFactory)
void
setContentTypeManager(ContentTypeManager contentTypeManager)
@NonNull CustomContentEntityObject
updatePluginModuleKey(CustomContentEntityObject content, String pluginModuleKey)
Update the type of an existing CustomContentEntityObject with the specified module key.-
Methods inherited from class com.atlassian.confluence.impl.content.DefaultContentEntityManager
convertFromWikiToStorageFormatIfRequired, createDraft, filteredResponseWithCursor, findAllDraftsFor, findAllDraftsWithUnpublishedChangesForUser, findDraftFor, findDraftFor, findUnpublishedContentWithUserContributions, getById, getById, getByIdsAndFilters, getContributionStatusByUser, getNextVersion, getOtherVersion, getPageAndBlogPostsVersionsLastEditedByUser, getPageAndBlogPostsVersionsLastEditedByUserIncludingDrafts, getPreviousVersion, getRecentlyAddedEntities, getRecentlyModifiedEntities, getRecentlyModifiedEntitiesForUser, getRecentlyModifiedForChangeDigest, getVersionHistorySummaries, getVersionHistorySummaries, getVersionsLastEditedByUser, publishCreateEvent, publishRemoveEvent, publishUpdateEvent, refreshContentEntity, removeContentEntities, removeHistoricalVersion, revertContentEntityBackToVersion, revertContentEntityBackToVersion, saveContentEntity, saveContentEntity, saveNewVersion, saveNewVersion
-
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.core.ContentEntityManager
getContributionStatusByUser, getNextVersion, getOtherVersion, getPageAndBlogPostsVersionsLastEditedByUser, getPageAndBlogPostsVersionsLastEditedByUserIncludingDrafts, getPreviousVersion, getRecentlyAddedEntities, getRecentlyModifiedEntities, getRecentlyModifiedEntitiesForUser, getRecentlyModifiedForChangeDigest, getVersionHistorySummaries, getVersionsLastEditedByUser, refreshContentEntity, removeHistoricalVersion, revertContentEntityBackToVersion, saveContentEntity, saveNewVersion, saveNewVersion
-
Methods inherited from interface com.atlassian.confluence.internal.ContentEntityManagerInternal
getByIds
-
Methods inherited from interface com.atlassian.confluence.content.CustomContentManager
findByQuery, findByQuery, getChildrenOfType, saveContentEntity
-
-
-
-
Constructor Detail
-
DefaultCustomContentManager
public DefaultCustomContentManager(CustomContentDao customContentDao, org.hibernate.SessionFactory sessionFactory, WikiToStorageConverter wikiToStorageConverter, com.atlassian.event.api.EventPublisher eventPublisher, ContentTypeManager contentTypeManager, RelationManager relationManager, ContentFactory contentFactory, CollaborativeEditingHelper collaborativeEditingHelper, AuditingContext auditingContext, RetentionFeatureChecker retentionFeatureChecker)
- Since:
- 7.16
-
-
Method Detail
-
newPluginContentEntityObject
public @NonNull CustomContentEntityObject newPluginContentEntityObject(String contentModuleKey)
Description copied from interface:CustomContentManager
Create a new CustomContentEntityObject for the given module. This method will ensure that the plugin delegate and various necessary arguments are set.- Specified by:
newPluginContentEntityObject
in interfaceCustomContentManager
- Parameters:
contentModuleKey
- the module complete key of the content's ContentAdapter module- Returns:
- a blank entity object for that plugin
-
updatePluginModuleKey
public @NonNull CustomContentEntityObject updatePluginModuleKey(CustomContentEntityObject content, String pluginModuleKey)
Description copied from interface:CustomContentManager
Update the type of an existing CustomContentEntityObject with the specified module key.- Specified by:
updatePluginModuleKey
in interfaceCustomContentManager
pluginModuleKey
- the module complete key of the content's ContentAdapter module- Returns:
- a blank entity object for that plugin
-
getById
public @Nullable CustomContentEntityObject getById(long id)
Description copied from interface:CustomContentManager
Find a single CustomContentEntityObject by its id- Specified by:
getById
in interfaceContentEntityManager
- Specified by:
getById
in interfaceCustomContentManager
- Overrides:
getById
in classDefaultContentEntityManager
- Parameters:
id
- the ID of the entity to retrieve- Returns:
- ContentEntityObject with the given id.
-
findByQuery
public <T> @NonNull Iterator<T> findByQuery(ContentQuery<T> query, int offset, int maxResults)
Description copied from interface:CustomContentManager
Get the results of a query for CustomContentEntityObjects- Specified by:
findByQuery
in interfaceCustomContentManager
- Parameters:
query
- the query to performoffset
- the first result to returnmaxResults
- the maximum number of results to return- Returns:
- an iterator of the results of the query
-
queryForList
public <T> @NonNull List<T> queryForList(ContentQuery<T> query, int offset, int maxResults)
Description copied from interface:CustomContentManager
Get the results of a query for CustomContentEntityObjects- Specified by:
queryForList
in interfaceCustomContentManager
- Parameters:
query
- the query to performoffset
- the first result to returnmaxResults
- the maximum number of results to return- Returns:
- a list of the results of the query
- Since:
- 7.14
-
queryForList
public <T> @NonNull List<T> queryForList(ContentQuery<T> query)
It is strongly recommended that thequeryForList(ContentQuery, int, int)
method be used in preference to this one, as this method does not apply pagination limits to the result set. This can result in excessive memory pressure. This method should only be used when the query is self-limiting, or when the size of the result set is otherwise known in advance.- Specified by:
queryForList
in interfaceCustomContentManager
- Parameters:
query
- the query to perform- Returns:
- a list of the results of the query
- Since:
- 7.17
-
findByQueryAndFilter
public <T> @NonNull PageResponse<T> findByQueryAndFilter(ContentQuery<T> query, boolean cacheable, LimitedRequest request, Predicate<T> predicate)
Description copied from interface:CustomContentManager
Get the results of a query for CustomContentEntityObjects- Specified by:
findByQueryAndFilter
in interfaceCustomContentManager
- Parameters:
query
- the query to performcacheable
- whether the results for the given query can be cachedrequest
- the limited pagination requestpredicate
- the filter to apply to the results- Returns:
- a PageResponse of the results of the query, after filtering with the given predicate
-
findFirstObjectByQuery
public <T> @Nullable T findFirstObjectByQuery(ContentQuery<T> query)
Description copied from interface:CustomContentManager
Find the first result of a query for CustomContentEntityObjects. This is a convenience method for queries where we expect to only retrieve a single result.- Specified by:
findFirstObjectByQuery
in interfaceCustomContentManager
- Parameters:
query
- the query to perform- Returns:
- the first result of the query, or null if no results are returned
-
findTotalInSpace
public int findTotalInSpace(Space space, String pluginContentKey)
Description copied from interface:CustomContentManager
Get the total count of current, non-deleted content of the given type in the given space.- Specified by:
findTotalInSpace
in interfaceCustomContentManager
- Parameters:
space
- the space to count content inpluginContentKey
- the plugin module complete key of the content to be searched for- Returns:
- the total number of non-deleted, non-historical versions of content of the given type in that space
-
findCurrentInSpace
public @NonNull Iterator<CustomContentEntityObject> findCurrentInSpace(Space space, String pluginContentKey, int offset, int maxResults, CustomContentManager.SortField sortField, CustomContentManager.SortOrder sortOrder)
Description copied from interface:CustomContentManager
Get an iterator of all the current, non-deleted content of the given type in the given space.- Specified by:
findCurrentInSpace
in interfaceCustomContentManager
- Parameters:
space
- the space to retrieve content frompluginContentKey
- the plugin module complete key of the content to be searched forsortField
- what field to sort the content onsortOrder
- which direction to sort the content in- Returns:
- an iterator of the non-deleted, non-historical versions of content of the given type in that space
-
countChildrenOfType
public long countChildrenOfType(CustomContentEntityObject content, String contentModuleKey)
Description copied from interface:CustomContentManager
Get the total number of children of a piece of content with the given type- Specified by:
countChildrenOfType
in interfaceCustomContentManager
- Parameters:
content
- the content to look for children ofcontentModuleKey
- the module key for the type of child to look for- Returns:
- the number of available children of that type
-
findChildrenOfType
public @NonNull Iterator<CustomContentEntityObject> findChildrenOfType(CustomContentEntityObject content, String pluginContentKey, int offset, int maxResults, CustomContentManager.SortField sortField, CustomContentManager.SortOrder sortOrder)
Description copied from interface:CustomContentManager
Get an iterator of children of a piece of content with a given type.- Specified by:
findChildrenOfType
in interfaceCustomContentManager
- Parameters:
content
- the content to look for children ofpluginContentKey
- the module key of the type of child to look foroffset
- the offset of the first resultmaxResults
- the maximum total results to returnsortField
- what field to sort the content onsortOrder
- which direction to sort the content in
-
getChildrenOfTypeAndFilter
public @NonNull PageResponse<Content> getChildrenOfTypeAndFilter(ContentEntityObject entity, String contentModuleKey, LimitedRequest limitedRequest, Expansions expansions, Depth depth, Predicate<? super CustomContentEntityObject> predicate)
This method is used by the Content API to retrieve children of a specific type and filter them by a predicate.- Specified by:
getChildrenOfTypeAndFilter
in interfaceCustomContentManager
- Parameters:
entity
- the content to look for children ofcontentModuleKey
- the module key of the type of child to look forlimitedRequest
- the pagination requestedexpansions
- the expansions applied to resultsdepth
- the depth to return children topredicate
- predicates used to filter the CustomContentEntityObjects- Returns:
-
findAllChildren
public @NonNull Iterator<CustomContentEntityObject> findAllChildren(CustomContentEntityObject content)
Description copied from interface:CustomContentManager
Get an iterator of all children of a piece of content.- Specified by:
findAllChildren
in interfaceCustomContentManager
- Parameters:
content
- the content to look for children of
-
findAllContainedOfType
public @NonNull Iterator<CustomContentEntityObject> findAllContainedOfType(long containerContentId, String pluginModuleKey)
Description copied from interface:CustomContentManager
Get an iterator of contained content of a piece of content with a given type.- Specified by:
findAllContainedOfType
in interfaceCustomContentManager
- Parameters:
containerContentId
- the content id of the content to look contained forpluginModuleKey
- the module key of the type of contained to look for
-
removeAllInSpace
public void removeAllInSpace(String pluginContentKey, Space space)
Description copied from interface:CustomContentManager
Remove all plugin content of a particular type from a given space.- Specified by:
removeAllInSpace
in interfaceCustomContentManager
- Parameters:
pluginContentKey
- the plugin module complete key of the content to be searched forspace
- the space from which to delete all content of that type
-
removeAllPluginContentInSpace
public void removeAllPluginContentInSpace(Space space)
Description copied from interface:CustomContentManager
Remove all plugin content (of all types) from a given space. This usually happens when a space is removed. Plugins wishing to perform extra work on space removal should listen for the PluginContentWillBeRemovedForSpaceEvent event.- Specified by:
removeAllPluginContentInSpace
in interfaceCustomContentManager
-
removeAllPluginContent
public void removeAllPluginContent(String contentModuleKey)
Description copied from interface:CustomContentManager
Remove all plugin content of a particular type- Specified by:
removeAllPluginContent
in interfaceCustomContentManager
- Parameters:
contentModuleKey
- the plugin module complete key of the content to be searched for
-
removeContentEntity
public void removeContentEntity(ContentEntityObject obj)
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
- Overrides:
removeContentEntity
in classDefaultContentEntityManager
-
findAllInSpace
public @NonNull Collection<CustomContentEntityObject> findAllInSpace(Space space)
This method is required for space exports to work properly. Which is a good sign that space exports are evil and need to be rewritten. If you call it from anywhere else, I will kill a puppy.- Specified by:
findAllInSpace
in interfaceCustomContentManager
- Parameters:
space
- a space- Returns:
- all plugin content within that space
-
setContentTypeManager
public void setContentTypeManager(ContentTypeManager contentTypeManager)
-
setContentFactory
public void setContentFactory(ContentFactory contentFactory)
-
-