Class XhtmlLinksUpdater
java.lang.Object
com.atlassian.confluence.content.render.xhtml.links.XhtmlLinksUpdater
- All Implemented Interfaces:
LinksUpdater
Updates all canonical links in an XHTML document to reflect a modified space key or title or both.
This will update space keys and titles in page, blogpost and attachment links.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.atlassian.confluence.content.render.xhtml.links.LinksUpdater
LinksUpdater.AttachmentReferenceDetails, LinksUpdater.PartialReferenceDetails
-
Constructor Summary
ConstructorDescriptionXhtmlLinksUpdater
(XmlEventReaderFactory xmlEventReaderFactory, XMLOutputFactory xmlOutputFactory, XMLEventFactory xmlEventFactory, Marshaller<ResourceIdentifier> resourceIdentifierMarshaller, ResourceIdentifierFactory resourceIdentifierFactory) -
Method Summary
Modifier and TypeMethodDescriptioncanonicalize
(String content) Applies the same rewriter as on any of contract/expand methods.A companion method to {LinksUpdater.expandRelativeReferencesInContent(SpaceContentEntityObject)
that will convert any absolute references to itself to be relative.Expand any relative links or embedded images encountered in the supplied content.expandRelativeReferencesInContent
(Comment comment) Expand any relative links or embedded files/images encountered in the supplied comment.updateAttachmentReferencesInContent
(String content, LinksUpdater.AttachmentReferenceDetails old, LinksUpdater.AttachmentReferenceDetails updated) Update all the attachment references in the content that referred to the 'old' attachment to now refer to the 'updated' attachment.updateAttachmentReferencesInContent
(String content, Map<LinksUpdater.AttachmentReferenceDetails, LinksUpdater.AttachmentReferenceDetails> oldToNewLinkDetails) Update all the attachment references in the content that referred to the 'old' attachment to now refer to the 'updated' attachment.updateReferencesInContent
(String content, LinksUpdater.PartialReferenceDetails oldLinkDetails, LinksUpdater.PartialReferenceDetails newLinkDetails) Update all the links and embedded image references in the content that referred to 'oldDetails' to now refer to 'newDetails'.updateReferencesInContent
(String content, Map<LinksUpdater.PartialReferenceDetails, LinksUpdater.PartialReferenceDetails> oldToNewLinkDetails) Update all the links and embedded image references in the content that referred to 'oldDetails' to now refer to 'newDetails'.
-
Constructor Details
-
XhtmlLinksUpdater
public XhtmlLinksUpdater(XmlEventReaderFactory xmlEventReaderFactory, XMLOutputFactory xmlOutputFactory, XMLEventFactory xmlEventFactory, Marshaller<ResourceIdentifier> resourceIdentifierMarshaller, ResourceIdentifierFactory resourceIdentifierFactory)
-
-
Method Details
-
updateReferencesInContent
public String updateReferencesInContent(String content, LinksUpdater.PartialReferenceDetails oldLinkDetails, LinksUpdater.PartialReferenceDetails newLinkDetails) Description copied from interface:LinksUpdater
Update all the links and embedded image references in the content that referred to 'oldDetails' to now refer to 'newDetails'. It should be noted that any relative references encountered in the content will not be modified since it cannot be known whether they would be a match for the 'oldDetails' parameter. You should callLinksUpdater.expandRelativeReferencesInContent(SpaceContentEntityObject)
prior to calling this method to ensure there are no relative links in the content to confuse matters.- Specified by:
updateReferencesInContent
in interfaceLinksUpdater
- Parameters:
content
- the content to update references inoldLinkDetails
- specifies the references to be modifiednewLinkDetails
- specifies the reference to be used in place of those identified by 'oldDetails'.- Returns:
- content with relevant references updated
-
updateReferencesInContent
public String updateReferencesInContent(String content, Map<LinksUpdater.PartialReferenceDetails, LinksUpdater.PartialReferenceDetails> oldToNewLinkDetails) Description copied from interface:LinksUpdater
Update all the links and embedded image references in the content that referred to 'oldDetails' to now refer to 'newDetails'. It should be noted that any relative references encountered in the content will not be modified since it cannot be known whether they would be a match for the 'oldDetails' parameter. You should callLinksUpdater.expandRelativeReferencesInContent(SpaceContentEntityObject)
prior to calling this method to ensure there are no relative links in the content to confuse matters.- Specified by:
updateReferencesInContent
in interfaceLinksUpdater
- Parameters:
content
- the content to update references inoldToNewLinkDetails
- the map from old reference to new reference- Returns:
- content with relevant references updated
-
expandRelativeReferencesInContent
Description copied from interface:LinksUpdater
Expand any relative links or embedded images encountered in the supplied content. A relative reference is one that either has no space key (implying "current space") or one with no ResourceIdentifier at all.This method will convert such references to an absolute reference to either it's containing space or itself (in the case of an attachment or link with no resource identifier at all).
- Specified by:
expandRelativeReferencesInContent
in interfaceLinksUpdater
- Parameters:
content
- the content to be expanded- Returns:
- the body of the supplied SpaceContentEntityObject with all relative references expanded.
-
expandRelativeReferencesInContent
Description copied from interface:LinksUpdater
Expand any relative links or embedded files/images encountered in the supplied comment. A relative reference is one that either has no space key (implying "current space") or one with no ResourceIdentifier at all.This method will convert such references to an absolute reference to either it's containing space or itself (in the case of an attachment or link with no resource identifier at all).
- Specified by:
expandRelativeReferencesInContent
in interfaceLinksUpdater
- Parameters:
comment
- the comment to be expanded- Returns:
- the body of the supplied SpaceContentEntityObject with all relative references expanded.
-
updateAttachmentReferencesInContent
public String updateAttachmentReferencesInContent(String content, LinksUpdater.AttachmentReferenceDetails old, LinksUpdater.AttachmentReferenceDetails updated) Description copied from interface:LinksUpdater
Update all the attachment references in the content that referred to the 'old' attachment to now refer to the 'updated' attachment. It should be noted that any relative links encountered in the content will not be modified since it cannot be known whether they would be a match for the 'old' parameter. You should callLinksUpdater.expandRelativeReferencesInContent(SpaceContentEntityObject)
prior to calling this method to ensure there are no relative attachment references in the content to confuse matters.- Specified by:
updateAttachmentReferencesInContent
in interfaceLinksUpdater
- Parameters:
content
- the content to update attachment references inold
- specifies the attachment references to be modifiedupdated
- specifies the new attachment reference to replace the old one with- Returns:
- content with specified attachment references updated.
-
updateAttachmentReferencesInContent
public String updateAttachmentReferencesInContent(String content, Map<LinksUpdater.AttachmentReferenceDetails, LinksUpdater.AttachmentReferenceDetails> oldToNewLinkDetails) Description copied from interface:LinksUpdater
Update all the attachment references in the content that referred to the 'old' attachment to now refer to the 'updated' attachment. It should be noted that any relative links encountered in the content will not be modified since it cannot be known whether they would be a match for the 'old' parameter. You should callLinksUpdater.expandRelativeReferencesInContent(SpaceContentEntityObject)
prior to calling this method to ensure there are no relative attachment references in the content to confuse matters.- Specified by:
updateAttachmentReferencesInContent
in interfaceLinksUpdater
- Parameters:
content
- the content to update attachment references inoldToNewLinkDetails
- the map from old reference to new reference- Returns:
- content with specified attachment references updated. * @since 5.10
-
contractAbsoluteReferencesInContent
Description copied from interface:LinksUpdater
A companion method to {LinksUpdater.expandRelativeReferencesInContent(SpaceContentEntityObject)
that will convert any absolute references to itself to be relative. So in a ResourceIdentifier, if a space key is present for the same space as the supplied content then this will be dropped. If the ResourceIdentifier actually refers to the SpaceContentEntityObject supplied then it will be dropped altogether.- Specified by:
contractAbsoluteReferencesInContent
in interfaceLinksUpdater
- Parameters:
content
- the content to have any suitable absolute references contracted.- Returns:
- the body of the supplied SpaceContentEntityObject modified as appropriate.
-
canonicalize
Description copied from interface:LinksUpdater
Applies the same rewriter as on any of contract/expand methods.This method is needed because even if xml structure of content is the same entity replacing by javax.xml.* and substitution done in ConfluenceXMLEventWriter will make two equal contents look different on equals method.
- Specified by:
canonicalize
in interfaceLinksUpdater
- Returns:
- canonicalized content
-