public class URLManager extends Object implements IURLManager
IURLManager
implementation.IURLManager.CreateStrategy, IURLManager.PathReferenceType
Modifier and Type | Field and Description |
---|---|
static String |
LUM_DO_NOT_FIX_REFERENCE_PATHS |
EXTENSION_HTML_PROPERTY_NAME, EXTENSION_SHTML_PROPERTY_NAME, FORCE_FIRST_PAGE_LINK_TO_CHANNEL_LINK_PROPERTY_NAME, FRIENDLY_URL_ENABLE_PROPERTY_NAME, FRIENDLY_URL_PATTERN_PROPERTY_NAME, PATH_REFERENCE_TYPE_PROPERTY_NAME, URL_RESOLVER_PROPERTY_NAME, WEBSITE_PROPERTY_NAME
Constructor and Description |
---|
URLManager() |
Modifier and Type | Method and Description |
---|---|
void |
clearPageCacheReference(WebResource webResource)
Clears the page cache reference in a web resource.
|
String |
convertHTMLPathsToDynamicPaths(String html)
Deprecated.
|
String |
convertHTMLPathsToDynamicPaths(String html,
IWebsite baseWebsite)
Deprecated.
|
String |
convertHTMLPathToDynamicPath(String href,
IWebsite baseWebsite)
Replaces the given path to web resource by the corresponding dynamic path.
|
void |
deleteWebResourceByPageIds(SessionConfig sessionConfig,
Collection<String> pagesIds,
Map<String,String[]> parameters,
Locale locale,
PortalEventOperationType opType,
boolean isAutomaticBulkExpiration,
ITransaction transaction)
Delete the webresources by page identifier.
|
void |
deleteWebResourceRedirection(String sourceWebsiteId,
String sourcePath)
Deletes the web resource redirection rule for the specified source website and path.
|
void |
deleteWebResourcesFromPage(String pageId)
Delete all
web resources from the page that has the given identifier. |
void |
deleteWebResourcesInChannelTree(String rootChannelId)
Delete all
web resources in the tree for which the root is the given rootChannelId . |
WebResource |
findWebResourceByPathAndWebsite(String websiteId,
String path)
Finds a web resource by it's website identifier and path.
|
String |
fixReferencesAccordingToPath(String html,
String path)
Deprecated.
|
String |
fixReferencesAccordingToPath(String html,
String path,
IPortalMode portalMode)
Deprecated.
|
String |
fixReferencesAccordingToPath(String html,
String path,
IPortalMode portalMode,
String pageId)
Fixes references within an HTML according to the given path.
|
protected String |
getPathClashSuffix()
Returns a random unique suffix to be appended to web resource friendly paths whenever a path clash happens.
|
WebResource |
getWebResourceByDynamicPath(String dynamicPath,
IURLManager.CreateStrategy createStrategy,
Locale locale,
WebResource creator)
Returns a web resource for the given dynamic path.
|
Collection<WebResource> |
getWebResourceByParameterAndValue(String parameterName,
String parameterValue)
Get all
web resources that fits the given parameter name with the given parameter value. |
String |
getWebResourcePathByDynamicPath(String dynamicPath,
Locale locale)
Deprecated.
|
WebResource |
getWebResourceToRedirect(String sourceWebsiteId,
String sourcePath)
Returns the web resource to redirect to when the given path on the given website is accessed.
|
URI |
getWebResourceURI(String dynamicPath,
Locale locale,
IWebsite baseWebsite,
boolean baseSecure,
IPortalMode portalMode,
WebResource creator)
Returns the URI for referencing a web resource given its dynamic path.
|
protected String |
processBackgroundHref(lumis.portal.url.URLManager.IHrefProcessor processor,
String matchString) |
String |
processHref(String url,
List<ITheme> themes,
String applicationRequestedPath,
Locale locale,
IWebsiteBaseURL websiteBaseURL,
boolean baseSecure,
IPortalMode portalMode,
IURLManager.PathReferenceType pathfixType,
WebResource creator)
Processes a URL to be rendered correctly in a portal page.
|
String |
processHTML(String originalHtml,
IPageWebResourceRenderRequest request)
Processes a HTML to be rendered correctly in a portal page.
|
String |
processHTML(String originalHtml,
Locale locale)
Processes a HTML to be used.
|
String |
processHTML(String originalHtml,
Locale locale,
boolean baseSecure,
IWebsiteBaseURL baseURL)
Processes a HTML to be used.
|
String |
processHTMLDynamicPathReferences(String html)
Deprecated.
|
String |
processHTMLDynamicPathReferences(String htmlContent,
Locale locale,
boolean convertGuestOnlyCaches)
Deprecated.
|
String |
processHTMLDynamicPathReferences(String htmlContent,
Locale locale,
IWebsite baseWebsite,
boolean baseSecure)
Processes references to dynamic paths in a given HTML code.
|
void |
recalculateFriendlyPaths(Collection<? extends WebResource> webResources)
Calculates and updates friendly paths of the given web resources.
|
void |
recalculateFriendlyPathsInChannelTree(String rootChannelId)
Calculates and updates friendly paths of all
web resources in the tree for which the root is the given rootChannelId . |
void |
setWebResourcesMissingData(IWebResourceFactory webResourceFactory,
Collection<WebResource> webResources,
boolean cacheEnabled,
boolean friendlyURLEnabled)
Sets missing data in the given web resources.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getWebResourceByDynamicPath, getWebResourceByDynamicPath, getWebResourceURI, getWebResourceURI, processHref, processHref, processHref
public static final String LUM_DO_NOT_FIX_REFERENCE_PATHS
@Deprecated public String getWebResourcePathByDynamicPath(String dynamicPath, Locale locale) throws PortalException
IURLManager
AUTO
strategy for getting
the web resource.
The returned path may be a variant from the real web resource path, according to the dynamicPath parameters and other configurations.
getWebResourcePathByDynamicPath
in interface IURLManager
dynamicPath
- the dynamic path.locale
- the the web resource locale.PortalException
public WebResource getWebResourceByDynamicPath(String dynamicPath, IURLManager.CreateStrategy createStrategy, Locale locale, WebResource creator) throws PortalException
IURLManager
If the corresponding web resource already exists in the persistence, that
instance is returned. Otherwise, createStrategy
defines the
behavior:
PortalObjectNotFoundException
.This method uses its own transactions.
getWebResourceByDynamicPath
in interface IURLManager
dynamicPath
- the dynamic path.createStrategy
- the strategy used if no web resource exists in
persistence for the given dynamic path.locale
- the web resource's locale.creator
- the web resource that is requesting the given web resource (if any).PortalObjectNotFoundException
- if no web resource for the given
dynamic path exists, and createStrategy
is
NEVER
.PortalException
protected String getPathClashSuffix()
@Deprecated public String convertHTMLPathsToDynamicPaths(String html) throws PortalException
IURLManager
convertHTMLPathsToDynamicPaths
in interface IURLManager
PortalException
@Deprecated public String convertHTMLPathsToDynamicPaths(String html, IWebsite baseWebsite) throws PortalException
IURLManager
If the given HTML needs to be fully processed (including path fix, web resource and themes processing) prefer
IURLManager.processHTML(String, IPageWebResourceRenderRequest)
instead.
convertHTMLPathsToDynamicPaths
in interface IURLManager
baseWebsite
- the website the HTML belongs to.PortalException
public String convertHTMLPathToDynamicPath(String href, IWebsite baseWebsite) throws PortalException
IURLManager
convertHTMLPathToDynamicPath
in interface IURLManager
href
- the path.baseWebsite
- the website the HTML belongs to.PortalException
@Deprecated public String processHTMLDynamicPathReferences(String html) throws PortalException
IURLManager
processHTMLDynamicPathReferences
in interface IURLManager
html
- the HTML code.PortalException
@Deprecated public String processHTMLDynamicPathReferences(String htmlContent, Locale locale, boolean convertGuestOnlyCaches) throws PortalException
IURLManager
processHTMLDynamicPathReferences
in interface IURLManager
locale
- the locale.convertGuestOnlyCaches
- if true, pages with cache enabled only for
guest will also have their dynamic paths converted.PortalException
public String processHTMLDynamicPathReferences(String htmlContent, Locale locale, IWebsite baseWebsite, boolean baseSecure) throws PortalException
IURLManager
processHTMLDynamicPathReferences
in interface IURLManager
htmlContent
- the HTML code.locale
- the locale.baseWebsite
- the website the HTML is relative to (in case it is
generated as relative). May be null
if the base website is unknown.
If not specified, the generated hrefs will be absolute.baseSecure
- true
if the base URL for the HTML is
secure, false
otherwise. If a href requires a different
secure level (HTTP or HTTPS), it will have to be absolute.PortalException
public void setWebResourcesMissingData(IWebResourceFactory webResourceFactory, Collection<WebResource> webResources, boolean cacheEnabled, boolean friendlyURLEnabled) throws PortalException
IURLManager
setWebResourcesMissingData
in interface IURLManager
webResourceFactory
- the web resource factory of the given web resources.webResources
- the web resources.cacheEnabled
- indicates that cache is enabled.friendlyURLEnabled
- indicates that friendly URL is enabled.PortalException
public void recalculateFriendlyPaths(Collection<? extends WebResource> webResources) throws PortalException
IURLManager
The original values that get updated are stored to use for redirecting to the updated ones. This redirect
information can be obtained using IURLManager.getWebResourceToRedirect(String, String)
.
recalculateFriendlyPaths
in interface IURLManager
webResources
- the web resources.PortalException
@Deprecated public String fixReferencesAccordingToPath(String html, String path) throws PortalException
IURLManager
The HTML passed in to this method should be appropriate for the context root of the solution. This method changes path references in the HTML such that the references are relative to the specified path. The path must begin with the "/" character and be relative to the web application root.
fixReferencesAccordingToPath
in interface IURLManager
html
- the HTML content to be fixed.path
- the path.PortalException
@Deprecated public String fixReferencesAccordingToPath(String html, String path, IPortalMode portalMode) throws PortalException
IURLManager
The HTML passed in to this method should be appropriate for the context root of the solution. This method changes path references in the HTML such that the references are relative to the specified path. The path must begin with the "/" character and be relative to the web application root.
fixReferencesAccordingToPath
in interface IURLManager
html
- the HTML content to be fixed.path
- the path.portalMode
- the current Portal Mode.PortalException
public String fixReferencesAccordingToPath(String html, String path, IPortalMode portalMode, String pageId) throws PortalException
IURLManager
The HTML passed in to this method should be appropriate for the context root of the solution. This method changes path references in the HTML such that the references are relative to the specified path. The path must begin with the "/" character and be relative to the web application root.
fixReferencesAccordingToPath
in interface IURLManager
html
- the HTML content to be fixed.path
- the path.portalMode
- the current Portal Mode.pageId
- the identifier of the page being rendered.PortalException
public void clearPageCacheReference(WebResource webResource)
webResource
- the web resource.WebResource.pageCache
public URI getWebResourceURI(String dynamicPath, Locale locale, IWebsite baseWebsite, boolean baseSecure, IPortalMode portalMode, WebResource creator) throws PortalException
IURLManager
The returned URI may be relative to the specified base website, or absolute if it is not possible to create such relative URI.
getWebResourceURI
in interface IURLManager
dynamicPath
- the web resource's dynamic path.locale
- the web resource's locale.baseWebsite
- the website the URI is relative to (in case it is generated as relative). May be null
if the
base website is unknown. If not specified, the returned URI will be absolute.baseSecure
- true
if the base URL for the returned URI is secure, false
otherwise. If the web
resource requires a different secure level (HTTP or HTTPS), the URI will have to be absolute.portalMode
- the desired IPortalMode
.PortalException
public String processHTML(String originalHtml, IPageWebResourceRenderRequest request) throws PortalException
IURLManager
The given HTML is adjusted according with themes, relative path, web resource path translations, file download path translations and websites.
processHTML
in interface IURLManager
originalHtml
- the HTML to be processed.PortalException
public String processHTML(String originalHtml, Locale locale) throws PortalException
IURLManager
Resources referred by the given HTML are adjusted
processHTML
in interface IURLManager
originalHtml
- the HTML to be processed.locale
- the locale to use for resource resolution.PortalException
public String processHTML(String originalHtml, Locale locale, boolean baseSecure, IWebsiteBaseURL baseURL) throws PortalException
IURLManager
Resources referred by the given HTML are adjusted
processHTML
in interface IURLManager
originalHtml
- the HTML to be processed.locale
- the locale to use for resource resolution.baseSecure
- indicates if the process HTML should consider links to secure URLs.baseURL
- the base URL being accessed when the process is performed (if any).PortalException
protected String processBackgroundHref(lumis.portal.url.URLManager.IHrefProcessor processor, String matchString) throws PortalException
processor
- The Href Processor to usematchString
- The string to be processed for background hrefPortalException
public String processHref(String url, List<ITheme> themes, String applicationRequestedPath, Locale locale, IWebsiteBaseURL websiteBaseURL, boolean baseSecure, IPortalMode portalMode, IURLManager.PathReferenceType pathfixType, WebResource creator) throws PortalException
IURLManager
The given URL is adjusted according with themes, relative path, web resource path translations, file download path translations and websites.
The parameter applicationRequestedPath
is used to adjust the URL to the application requested path.
This method resolve path to public files.
processHref
in interface IURLManager
url
- the URL to resolve. The URL must be absolute or relative to the portal web application root. If
relative, a starting '/' character is optional.themes
- list of themes to be applied to the URL.applicationRequestedPath
- the application path of the request the URL will be used in. This path is used to adjust the URL.locale
- the locale for the URL. It is applied only if the URL does not already implies a specific locale.websiteBaseURL
- the website of the request the URL will be used in.baseSecure
- if the request the URL will be used in is secure or not.portalMode
- the portal mode.pathfixType
- specifies how paths should be referenced.creator
- the web resource that is requesting the processing.PortalException
- if any error occurs during the process.public WebResource findWebResourceByPathAndWebsite(String websiteId, String path) throws PortalException
IURLManager
findWebResourceByPathAndWebsite
in interface IURLManager
websiteId
- the website identifier.path
- the path.null
if no web resource matches the given parameters.PortalException
public void deleteWebResourcesInChannelTree(String rootChannelId) throws PortalException
IURLManager
web resources
in the tree for which the root is the given rootChannelId
.deleteWebResourcesInChannelTree
in interface IURLManager
rootChannelId
- The channelId to start recursing fromPortalException
public void recalculateFriendlyPathsInChannelTree(String rootChannelId) throws PortalException
IURLManager
web resources
in the tree for which the root is the given rootChannelId
.
The original values that get updated are stored to use for redirecting to the updated ones. This redirect
information can be obtained using IURLManager.getWebResourceToRedirect(String, String)
.
recalculateFriendlyPathsInChannelTree
in interface IURLManager
rootChannelId
- The channelId to start recursing fromPortalException
public void deleteWebResourcesFromPage(String pageId) throws PortalException
IURLManager
web resources
from the page that has the given identifier.deleteWebResourcesFromPage
in interface IURLManager
pageId
- The identifier of the page that has the web resources to be deletedPortalException
public Collection<WebResource> getWebResourceByParameterAndValue(String parameterName, String parameterValue)
IURLManager
web resources
that fits the given parameter name with the given parameter value.getWebResourceByParameterAndValue
in interface IURLManager
parameterName
- a given parameter nameparameterValue
- a given parameter valueweb resources
that satisfies parameter name equals parameter value.public WebResource getWebResourceToRedirect(String sourceWebsiteId, String sourcePath) throws PortalException
IURLManager
This method uses its own transaction.
getWebResourceToRedirect
in interface IURLManager
sourceWebsiteId
- the web site identifier.sourcePath
- the path, starting with '/', relative to the web site root.null
if there is no redirect information for the specified
website and path.PortalException
public void deleteWebResourceRedirection(String sourceWebsiteId, String sourcePath) throws PortalException
IURLManager
deleteWebResourceRedirection
in interface IURLManager
sourceWebsiteId
- the source website identifier.sourcePath
- the source path.PortalException
public void deleteWebResourceByPageIds(SessionConfig sessionConfig, Collection<String> pagesIds, Map<String,String[]> parameters, Locale locale, PortalEventOperationType opType, boolean isAutomaticBulkExpiration, ITransaction transaction) throws PortalException
sessionConfig
- the user's session.pagesIds
- the page identifiers.parameters
- the parameters.locale
- the locale.opType
- the operation type.isAutomaticBulkExpiration
- indicates whether this is a bulk operation.transaction
- the transaction.PortalException
LumisXP 12.5.0.200928 - Copyright © 2006–2020 Lumis EIP Tecnologia da Informação LTDA. All Rights Reserved.