Class DefaultRelatedContentRefactorer
- java.lang.Object
-
- com.atlassian.confluence.links.DefaultRelatedContentRefactorer
-
- All Implemented Interfaces:
RelatedContentRefactorer
public class DefaultRelatedContentRefactorer extends Object implements RelatedContentRefactorer
A component responsible for refactoring the relationships between pages.
-
-
Constructor Summary
Constructors Constructor Description DefaultRelatedContentRefactorer(PageManager pageManager, LinkManager linkManager, LinksUpdater linksUpdater)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
contractAbsoluteReferencesInContent(List<Page> movedPageList)
Contract all links in moved pages and their referencing pages to relative linksvoid
contractAbsoluteReferencesInContent(List<Page> movedPageList, Space previousSpace)
Deprecated.since 5.9 usecontractAbsoluteReferencesInContent(List)
insteadString
refactorReferencesToBeRelative(SpaceContentEntityObject content)
Update any references to the content itself (such as attachment links or embedded images) or to content in the same space.void
updateReferences(SpaceContentEntityObject content, Space previousSpace, String previousTitle)
Update all the references in the supplied content when the content has moved or renamed from 'previousSpace' and/or had it's title changed from 'previousTitle'.void
updateReferencesForMovingPage(SpaceContentEntityObject content, Space previousSpace, String previousTitle)
Update all the references in the supplied content when the content has moved from 'previousSpace' and/or had it's title changed from 'previousTitle'.void
updateReferrers(SpaceContentEntityObject referee, Space previousSpace, String previousTitle)
Iterate through all the content that currently links to 'referee' and renames all the links, saving the changed content as it goes.void
updateReferrers(Attachment attachment, Attachment previousAttachment)
Iterate through all the content that links to (or embeds) the supplied attachment (prior to it's update) and update the details of this relationship to reflect the current name and owner of the attachment.void
updateReferrersForMovingPage(SpaceContentEntityObject referee, Space previousSpace, String previousTitle, List<Page> movedPageList)
Iterate through all the content that currently links to 'referee' and renames all the links, saving the changed content as it goes.
-
-
-
Constructor Detail
-
DefaultRelatedContentRefactorer
public DefaultRelatedContentRefactorer(PageManager pageManager, LinkManager linkManager, LinksUpdater linksUpdater)
-
-
Method Detail
-
updateReferrersForMovingPage
public void updateReferrersForMovingPage(SpaceContentEntityObject referee, Space previousSpace, String previousTitle, List<Page> movedPageList)
Description copied from interface:RelatedContentRefactorer
Iterate through all the content that currently links to 'referee' and renames all the links, saving the changed content as it goes. You should note that the referee itself won't be updated even if it does include references to itself. Instead you should use
RelatedContentRefactorer.updateReferences(SpaceContentEntityObject, Space, String)
.This rename will be recorded in the content's history
Note: The change of reference assumes that the content referred to has not changed type. It has simply changed space and/or title. For example, there is currently no way of refactoring a reference to blog post to become a reference to a page.
- Specified by:
updateReferrersForMovingPage
in interfaceRelatedContentRefactorer
- Parameters:
referee
- the content we want to update references to, with it's new attributes already saved (e.g. new title, or new space)previousSpace
- the space that the content was in previous to the update (this may be the current space for the content)previousTitle
- the title of the content prior to it being updated (may be the same as the current title)movedPageList
- list of all moved pages, used to check if referee is moved or not
-
updateReferrers
public void updateReferrers(SpaceContentEntityObject referee, Space previousSpace, String previousTitle)
Description copied from interface:RelatedContentRefactorer
Iterate through all the content that currently links to 'referee' and renames all the links, saving the changed content as it goes. You should note that the referee itself won't be updated even if it does include references to itself. Instead you should use
RelatedContentRefactorer.updateReferences(SpaceContentEntityObject, Space, String)
.This rename will be recorded in the content's history
Note: The change of reference assumes that the content referred to has not changed type. It has simply changed space and/or title. For example, there is currently no way of refactoring a reference to blog post to become a reference to a page.
- Specified by:
updateReferrers
in interfaceRelatedContentRefactorer
- Parameters:
referee
- the content we want to update references to, with it's new attributes already saved (e.g. new title, or new space)previousSpace
- the space that the content was in previous to the update (this may be the current space for the content)previousTitle
- the title of the content prior to it being updated (may be the same as the current title)
-
updateReferrers
public void updateReferrers(Attachment attachment, Attachment previousAttachment)
Description copied from interface:RelatedContentRefactorer
Iterate through all the content that links to (or embeds) the supplied attachment (prior to it's update) and update the details of this relationship to reflect the current name and owner of the attachment. All modified referring content will be saved.
- Specified by:
updateReferrers
in interfaceRelatedContentRefactorer
- Parameters:
attachment
- the attachment after it's update (reflecting it's new name and ownership)previousAttachment
- the attachment prior to it's update (with the old containing ContentEntityObject, etc).
-
updateReferences
public void updateReferences(SpaceContentEntityObject content, Space previousSpace, String previousTitle)
Description copied from interface:RelatedContentRefactorer
Update all the references in the supplied content when the content has moved or renamed from 'previousSpace' and/or had it's title changed from 'previousTitle'. The updated SpaceContentEntityObject will be saved.
A typical usage of this would be to fix the relative and self references in a SpaceContentEntityObject that has been moved from one space to another or had it's titled changed.
Note: The change of reference assumes that the supplied content has not changed type. It has simply changed space and/or title. For example, there is currently no way of refactoring a reference to page to become a reference to a blog post.
- Specified by:
updateReferences
in interfaceRelatedContentRefactorer
- Parameters:
content
- the content to be updatedpreviousSpace
- the space to update relative links to refer to (the space the content was previously in)previousTitle
- the title of the content prior to it being updated (may be the same as the current title)
-
updateReferencesForMovingPage
public void updateReferencesForMovingPage(SpaceContentEntityObject content, Space previousSpace, String previousTitle)
Description copied from interface:RelatedContentRefactorer
Update all the references in the supplied content when the content has moved from 'previousSpace' and/or had it's title changed from 'previousTitle'. The updated SpaceContentEntityObject will be saved.
A typical usage of this would be to fix the relative and self references in a SpaceContentEntityObject that has been moved from one space to another or had it's titled changed.
Note: The change of reference assumes that the supplied content has not changed type. It has simply changed space and/or title. For example, there is currently no way of refactoring a reference to page to become a reference to a blog post.
- Specified by:
updateReferencesForMovingPage
in interfaceRelatedContentRefactorer
- Parameters:
content
- the content to be updatedpreviousSpace
- the space to update relative links to refer to (the space the content was previously in)previousTitle
- the title of the content prior to it being updated (may be the same as the current title)
-
refactorReferencesToBeRelative
public String refactorReferencesToBeRelative(SpaceContentEntityObject content)
Description copied from interface:RelatedContentRefactorer
Update any references to the content itself (such as attachment links or embedded images) or to content in the same space. These references will be converted to be relative references.
- Specified by:
refactorReferencesToBeRelative
in interfaceRelatedContentRefactorer
- Parameters:
content
- the content to be refactored- Returns:
- a refactored version of the body of the supplied content.
-
contractAbsoluteReferencesInContent
@Deprecated public void contractAbsoluteReferencesInContent(List<Page> movedPageList, Space previousSpace)
Deprecated.since 5.9 usecontractAbsoluteReferencesInContent(List)
insteadContract all links in moved pages and their referencing pages to relative links- Specified by:
contractAbsoluteReferencesInContent
in interfaceRelatedContentRefactorer
- Parameters:
movedPageList
- list of all moved pagespreviousSpace
-
-
contractAbsoluteReferencesInContent
public void contractAbsoluteReferencesInContent(List<Page> movedPageList)
Contract all links in moved pages and their referencing pages to relative links- Specified by:
contractAbsoluteReferencesInContent
in interfaceRelatedContentRefactorer
- Parameters:
movedPageList
- list of all moved pages- Since:
- 5.9
-
-