public class LinkUtil extends Object
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_EXTENSION |
static String |
DEFAULT_REPOSITORY |
static Pattern |
EXTERNAL_LINK_PATTERN
Pattern that matches external and mailto: links.
|
static Pattern |
IMAGE_PATTERN
Pattern to find a image.
|
static Pattern |
LINK_OR_IMAGE_PATTERN
Pattern to find a link.
|
static Pattern |
LINK_PATTERN
Pattern to find a link.
|
static Pattern |
UUID_PATTERN
Pattern to find a magnolia formatted uuid link.
|
Constructor and Description |
---|
LinkUtil() |
Modifier and Type | Method and Description |
---|---|
static String |
addFingerprintToLink(String link,
Calendar lastModified)
Insert a finger-print into a link that is based on the last modified date.
|
static void |
addParameter(StringBuffer uri,
String name,
String value)
Appends a parameter to the given url, using ?, or & if there are already
parameters in the given url.
|
static String |
convertAbsoluteLinksToUUIDs(String html)
Parses provided html and transforms all the links to the magnolia format.
|
static String |
convertLinksFromUUIDPattern(String str) |
static String |
convertLinksFromUUIDPattern(String str,
LinkTransformer transformer)
Converts provided html with links in UUID pattern format to any other kind of links based on provided link transformer.
|
static String |
convertUUIDtoHandle(String uuid,
String workspaceName)
Transforms a uuid to a handle beginning with a /.
|
static String |
convertUUIDtoURI(String uuid,
String workspaceName)
Transforms a uuid to an uri.
|
static String |
createAbsoluteLink(javax.jcr.Node node)
Creates absolute link including context path to the provided node and performing all URI2Repository mappings and applying locales.
|
static String |
createAbsoluteLink(javax.jcr.Property property)
Creates absolute link including context path for provided Property.
|
static String |
createAbsoluteLink(String workspaceName,
String uuid)
Creates absolute link including context path to the provided content and performing all URI2Repository mappings and applying locales.
|
static String |
createExternalLink(javax.jcr.Node node)
Creates a complete url to access given node from external systems applying all the URI2Repository mappings and locales.
|
static String |
createLink(javax.jcr.Node node)
Creates link guessing best possible link format from current site and provided node.
|
static String |
createLink(javax.jcr.Property property)
Creates link guessing best possible link format from current site and provided Property.
|
static String |
createLink(String workspaceName,
String uuid)
Creates link guessing best possible link format from current site and provided content.
|
static Link |
createLinkInstance(javax.jcr.Node node)
Creates Link to provided Node.
|
static Link |
createLinkInstance(javax.jcr.Property property) |
static Link |
createLinkInstance(String workspaceName,
String uuid)
Creates link to the content denoted by repository and uuid.
|
static Link |
createLinkInstance(String workspaceName,
String path,
String extension,
String anchor,
String parameters)
Creates link to the content identified by the repository and path.
|
static Link |
createLinkInstance(String uuid,
String workspaceName,
String fallbackHandle,
String nodeDataName,
String extension,
String anchor,
String parameters)
Creates link based on provided parameters.
|
static boolean |
isExternalLinkOrAnchor(String href)
Determines whether the given link is external link or anchor (i.e.
|
static boolean |
isInternalRelativeLink(String href)
Determines if the given link is internal and relative.
|
static String |
makePathRelative(String url,
String absolutePath)
Make a absolute path relative.
|
static String |
mapPathToRepository(String path)
Maps a path to a repository.
|
static Link |
parseLink(String link)
Parses provided URI to the link.
|
static Link |
parseUUIDLink(String uuidLink)
Parses UUID link pattern string and converts it into a Link object.
|
static String |
removeFingerprintAndExtensionFromLink(String originalPath)
Remove the extension and fingerPrint if present.
|
static String |
toPattern(Link link)
Converts provided Link to an UUID link pattern.
|
public static final Pattern EXTERNAL_LINK_PATTERN
public static final String DEFAULT_EXTENSION
public static final String DEFAULT_REPOSITORY
public static final Pattern LINK_OR_IMAGE_PATTERN
public static Pattern UUID_PATTERN
public static final Pattern LINK_PATTERN
public static final Pattern IMAGE_PATTERN
public static String convertUUIDtoHandle(String uuid, String workspaceName) throws LinkException
LinkException
public static String convertUUIDtoURI(String uuid, String workspaceName) throws LinkException
Link.getPath()
,
this method will apply all uri to repository mappings as well as i18n.LinkException
public static String convertAbsoluteLinksToUUIDs(String html)
html
- html code with links to be convertedpublic static String convertLinksFromUUIDPattern(String str, LinkTransformer transformer) throws LinkException
str
- Html with UUID linkstransformer
- Link transformerLinkException
LinkTransformerManager
public static String convertLinksFromUUIDPattern(String str) throws LinkException
LinkException
public static boolean isInternalRelativeLink(String href)
public static boolean isExternalLinkOrAnchor(String href)
public static String makePathRelative(String url, String absolutePath)
absolutePath
- absolute pathurl
- page to be relative topublic static String mapPathToRepository(String path)
path
- URIpublic static void addParameter(StringBuffer uri, String name, String value)
public static String createAbsoluteLink(javax.jcr.Property property) throws LinkException
LinkException
public static String createAbsoluteLink(String workspaceName, String uuid) throws javax.jcr.RepositoryException
uuid
- UUID of content to create link to.workspaceName
- Name of the repository where content is located.javax.jcr.RepositoryException
AbstractI18nContentSupport
public static String createAbsoluteLink(javax.jcr.Node node)
public static String createExternalLink(javax.jcr.Node node)
public static String createLink(javax.jcr.Node node)
node
- Node to create link for.public static String createLink(javax.jcr.Property property) throws LinkException
property
- Property to create link for.LinkException
public static String createLink(String workspaceName, String uuid) throws javax.jcr.RepositoryException
uuid
- UUID of content to create link to.workspaceName
- Name of the repository where content is located.javax.jcr.RepositoryException
AbstractI18nContentSupport
public static Link createLinkInstance(javax.jcr.Node node)
public static Link createLinkInstance(javax.jcr.Property property) throws LinkException
LinkException
public static Link createLinkInstance(String workspaceName, String uuid) throws LinkException
workspaceName
- Parent repository of the content of interest.uuid
- UUID of the content to create link to.LinkException
public static Link createLinkInstance(String workspaceName, String path, String extension, String anchor, String parameters) throws LinkException
workspaceName
- Source repository for the content.path
- Path to the content of interest.extension
- Optional extension to be used in the linkanchor
- Optional link anchor.parameters
- Optional link parameters.LinkException
public static Link createLinkInstance(String uuid, String workspaceName, String fallbackHandle, String nodeDataName, String extension, String anchor, String parameters) throws LinkException
Link
object,
pointing to the non existing uuid so that broken link detection tools can find it.uuid
- UUID of the contentworkspaceName
- Content repository name.fallbackHandle
- Optional fallback content handle.nodeDataName
- Content node data name for binary data.extension
- Optional link extension.anchor
- Optional link anchor.parameters
- Optional link parameters.LinkException
public static Link parseUUIDLink(String uuidLink) throws LinkException
uuidLink
- String containing reference to content as a UUID link pattern.LinkException
public static Link parseLink(String link) throws LinkException
link
- URI representing path to piece of contentLinkException
public static String toPattern(Link link)
link
- Link to convert.public static String addFingerprintToLink(String link, Calendar lastModified)
Copyright © 2003–2019 Magnolia International Ltd.. All rights reserved.