Class CmsStaticExportManager
- All Implemented Interfaces:
I_CmsEventListener
- Since:
- 6.0.0
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Name for the default file.static final String
Marker for error message attribute.static final String
Marker for error request uri attribute.static final String
Marker for error servlet name attribute.static final String
Marker for error status code attribute.static final String
Name for the backup folder default name.static final Integer
Name for the default work path.static final String
Name for the folder default index file.static final String
Name for the default work path.static final int
Flag value for links without parameters.static final int
Flag value for links without parameters.static final String
Marker for externally redirected 404 uri's.static final int
Time given (in seconds) to the static export handler to finish a publish task.static final String
If the property 'secure' is set to this value, the resource will be delivered through http and https depending on the link source.Fields inherited from interface org.opencms.main.I_CmsEventListener
EVENT_BEFORE_PUBLISH_PROJECT, EVENT_CLEAR_CACHES, EVENT_CLEAR_OFFLINE_CACHES, EVENT_CLEAR_ONLINE_CACHES, EVENT_CLEAR_PRINCIPAL_CACHES, EVENT_FLEX_CACHE_CLEAR, EVENT_FLEX_PURGE_JSP_REPOSITORY, EVENT_FULLSTATIC_EXPORT, EVENT_GROUP_MODIFIED, EVENT_LOGIN_USER, EVENT_OU_MODIFIED, EVENT_PROJECT_MODIFIED, EVENT_PROPERTY_DEFINITION_CREATED, EVENT_PROPERTY_DEFINITION_MODIFIED, EVENT_PROPERTY_MODIFIED, EVENT_PUBLISH_PROJECT, EVENT_REBUILD_SEARCHINDEXES, EVENT_REINDEX_OFFLINE, EVENT_REINDEX_ONLINE, EVENT_RESOURCE_AND_PROPERTIES_MODIFIED, EVENT_RESOURCE_COPIED, EVENT_RESOURCE_CREATED, EVENT_RESOURCE_DELETED, EVENT_RESOURCE_MODIFIED, EVENT_RESOURCE_MOVED, EVENT_RESOURCES_AND_PROPERTIES_MODIFIED, EVENT_RESOURCES_MODIFIED, EVENT_SITEMAP_CHANGED, EVENT_UPDATE_EXPORTS, EVENT_USER_MODIFIED, KEY_CHANGE, KEY_DBCONTEXT, KEY_GROUP_ID, KEY_GROUP_NAME, KEY_INDEX_NAMES, KEY_IS_ONLINE, KEY_OU_ID, KEY_OU_NAME, KEY_PROJECTID, KEY_PUBLISHID, KEY_PUBLISHLIST, KEY_REINDEX_RELATED, KEY_REPORT, KEY_RESOURCE, KEY_RESOURCES, KEY_SKIPINDEX, KEY_USER_ACTION, KEY_USER_CHANGES, KEY_USER_ID, KEY_USER_NAME, LISTENERS_FOR_ALL_EVENTS, VALUE_CREATE_SIBLING, VALUE_GROUP_MODIFIED_ACTION_CREATE, VALUE_GROUP_MODIFIED_ACTION_DELETE, VALUE_GROUP_MODIFIED_ACTION_WRITE, VALUE_OU_MODIFIED_ACTION_CREATE, VALUE_OU_MODIFIED_ACTION_DELETE, VALUE_USER_MODIFIED_ACTION_ADD_USER_TO_GROUP, VALUE_USER_MODIFIED_ACTION_CREATE_USER, VALUE_USER_MODIFIED_ACTION_DELETE_USER, VALUE_USER_MODIFIED_ACTION_REMOVE_USER_FROM_GROUP, VALUE_USER_MODIFIED_ACTION_RESET_PASSWORD, VALUE_USER_MODIFIED_ACTION_SET_OU, VALUE_USER_MODIFIED_ACTION_WRITE_USER
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddDefaultFileNameToFolder
(String rfsName, boolean isFolder) Returns the real file system name plus the default file name.void
addExportRule
(String name, String description) Adds a new export rule to the configuration.void
addExportRuleRegex
(String regex) Adds a regex to the latest export rule.void
addExportRuleUri
(String exportUri) Adds a export uri to the latest export rule.void
addProtectedExportPoint
(String uri, String destination) Adds an protected export point.void
addRfsRule
(String name, String description, String source, String rfsPrefix, String exportPath, String exportWorkPath, String exportBackups, String useRelativeLinks) Adds a new rfs rule to the configuration.void
addRfsRuleSystemRes
(String regex) Adds a regex of related system resources to the latest rfs-rule.void
cacheOnlineLink
(String linkName, String vfsName) Caches a calculated online link.protected void
clearCaches
(CmsEvent event) Clears the caches in the export manager.void
Implements the CmsEvent interface, the static export properties uses the events to clear the list of cached keys in case a project is published.protected void
createExportBackupFolders
(File staticExport, String exportPath, int exportBackups, String ruleBackupExtension) Creates the backup folders for the given export folder and deletes the oldest if the maximum number is reached.protected void
createExportFolder
(String exportPath, String rfsName) Creates the parent folder for a exported resource in the RFS.int
export
(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, CmsObject cms, CmsStaticExportData data) Exports the requested uri and at the same time writes the uri to the response output stream if required.void
exportFullStaticRender
(boolean purgeFirst, I_CmsReport report) Starts a complete static export of all resources.Returns the accept-charset header used for internal requests.Returns the accept-language header used for internal requests.getCachedOnlineLink
(String vfsName) Returns a cached link for the given vfs name.Returns the cacheExportLinks.getCacheKey
(String siteRoot, String uri) Returns the key for the online, export and secure cache.Returns the cacheSecureLinks.Gets the default property value as a string representation.Returns the current default charset header.Returns the current default locale header.Returns the default prefix for exported links in the "real" file system.Returns the number of stored backups.getExportData
(javax.servlet.http.HttpServletRequest request, CmsObject cms) Returns the export data for the request, if null is returned no export is required.Gets the export enabled value as a string representation.Returns the current folder matcher.Returns list of resources patterns which are part of the export.Returns specific http headers for the static export.Returns a map of all export names with export name as key and the vfs folder path as value.getExportPath
(String vfsName) Returns the export path for the static export, that is the folder where the static exported resources will be written to.Returns the original configured export path for the static export without the complete rfs path, to be used when re-writing the configuration.Returns the protected export points.boolean
Returns true if the default value for the resource property "export" is true.Returns the export Rules.Gets the list of resource suffixes which will be exported by default.Returns the export URL used for internal requests for exporting resources that require a request / response (like JSP).Returns the export URL used for internal requests with unsubstituted context values, to be used when re-writing the configuration.Returns the export URL used for internal requests for exporting resources that require a request / response (like JSP) without http://servername.Returns the export work path for the static export, that is the folder where the static exported resources will be written to during the export process.Returns the original configured export work path for the static export without the complete rfs path, to be used when re-writing the configuration.Returns the configured static export handler class.Returns the configured link substitution handler class.Gets the plain export optimization value as a string representation.getProtectedExportName
(String rootPath) Returns the protected export name for the given root path.Returns the protected export path.Returns the protected export points.boolean
Returns true if the quick plain export is enabled.Gets the relative links value as a string representation.Returns the remote address used for internal requests.Returns the remote address.protected CmsStaticExportData
getRfsExportData
(CmsObject cms, String uri) Returns the export data for a requested resource, if null is returned no export is required.getRfsName
(CmsObject cms, String vfsName) Returns the static export rfs name for a given vfs resource.getRfsName
(CmsObject cms, String vfsName, String parameters, String targetDetailPage) Returns the static export rfs name for a given vfs resource where the link to the resource includes request parameters.protected String
getRfsNameWithExportName
(CmsObject cms, String vfsName) Returns the rfs name for a given vfs name with consideration of the export name.static String
getRfsPath
(String filename, String extension, String parameters) Creates unique, valid RFS name for the given filename that contains a coded version of the given parameters, with the given file extension appended.getRfsPrefix
(String vfsName) Returns the prefix for exported links in the "real" file system.Returns the original configured prefix for exported links in the "real" file, to be used when re-writing the configuration.protected String
getRfsPrefixForRfsName
(String rfsName) Returns the longest rfs prefix matching a given already translated rfs name.Returns the rfs Rules.Returns the vfs name of the test resource.getVfsExportData
(CmsObject cms, String vfsName) Returns the export data for a requested resource, if null is returned no export is required.getVfsName
(CmsObject cms, String rfsName) Returns the VFS name for the given RFS name, being the exact reverse of
.getRfsName(CmsObject, String)
getVfsNameInternal
(CmsObject cms, String rfsName) Returns the VFS name from a given RFS name.Returns the prefix for the internal in the VFS.Returns the original configured prefix for internal links in the VFS, to be used when re-writing the configuration.void
initialize
(CmsObject cms) Initializes the static export manager with the OpenCms system configuration.protected String
insertContextStrings
(String path) Substitutes the ${CONTEXT_NAME} and ${SERVLET_NAME} in a path with the real values.boolean
isExportLink
(CmsObject cms, String vfsName) Checks if the static export is required for the given VFS resource.boolean
Returns true if the export process is a full static export.boolean
isSecureLink
(CmsObject cms, String vfsName) Returnstrue
if the given VFS resource should be transported through a secure channel.boolean
isSecureLink
(CmsObject cms, String vfsName, boolean fromSecure) Returnstrue
if the given VFS resource should be transported through a secure channel.boolean
isSecureLink
(CmsObject cms, String vfsName, String siteRoot) Returnstrue
if the given VFS resource that is located under the given site root should be transported through a secure channel.boolean
isSecureLink
(CmsObject cms, String vfsName, String siteRoot, boolean fromSecure) Returnstrue
if the given VFS resource should be transported through a secure channel.boolean
Returns true if the static export is enabled.boolean
isSuffixExportable
(String resourceName) Returns true if the given resource name is exportable because of it's suffix.boolean
Checks if we have to use temporary directories during export.protected boolean
isValidRfsName
(String rfsName) Returns true if the rfs Name match against any of the defined export urls.protected boolean
isValidURL
(String inputString) Checks if a String is a valid URL.protected String
normalizeExportPath
(String exportPath) Returns a normalized export path.protected String
normalizeRfsPrefix
(String rfsPrefix) Returns a normalized rfs prefix.protected CmsStaticExportData
readResource
(CmsObject cms, String uri) Reads the resource with the given URI.boolean
relativeLinksInExport
(String vfsName) Returns true if the links in the static export should be relative.protected void
scrubExportFolders
(I_CmsReport report) Scrubs all the "export" folders.void
setAcceptCharsetHeader
(String value) Sets the accept-charset header value.void
setAcceptLanguageHeader
(String value) Sets the accept-language header value.void
setDefault
(String value) Sets the default property value.void
setExportBackups
(String backup) Sets the number of backups for the static export.void
setExportEnabled
(String value) Sets the export enabled value.void
setExportFolderPattern
(String folder) Adds a resource pattern to the list of resources which are part of the export.void
setExportHeader
(String exportHeader) Sets specific http header for the static export.void
setExportPath
(String path) Sets the path where the static export is written.void
setExportSuffix
(String suffix) Adds a suffix to the list of resource suffixes which will be exported by default.void
setExportUrl
(String url) Sets the export url.void
setExportWorkPath
(String path) Sets the path where the static export is temporarily written.void
setHandler
(String handlerClassName) Sets the link substitution handler class.void
setLinkSubstitutionHandler
(String handlerClassName) Sets the static export handler class.void
setPlainExportOptimization
(String value) Sets the plain export optimization value.void
setProtectedExportPath
(String exportPath) Sets the protected export path.void
setRelativeLinks
(String value) Sets the relative links value.void
setRemoteAddr
(String addr) Sets the remote address which will be used for internal requests during the static export.void
setRfsPrefix
(String rfsPrefix) Sets the prefix for exported links in the "real" file system.void
setTestResource
(String testResource) Sets the test resource.void
setVfsPrefix
(String vfsPrefix) Sets the prefix for internal links in the vfs.void
shutDown()
Shuts down all this static export manager.protected void
writeResource
(javax.servlet.http.HttpServletRequest req, String exportPath, String rfsName, CmsResource resource, byte[] content) Writes a resource to the given export path with the given rfs name and the given content.
-
Field Details
-
DEFAULT_FILE
Name for the default file.- See Also:
-
EXPORT_ATTRIBUTE_ERROR_MESSAGE
Marker for error message attribute.- See Also:
-
EXPORT_ATTRIBUTE_ERROR_REQUEST_URI
Marker for error request uri attribute.- See Also:
-
EXPORT_ATTRIBUTE_ERROR_SERVLET_NAME
Marker for error servlet name attribute.- See Also:
-
EXPORT_ATTRIBUTE_ERROR_STATUS_CODE
Marker for error status code attribute.- See Also:
-
EXPORT_BACKUP_FOLDER_NAME
Name for the backup folder default name.- See Also:
-
EXPORT_DEFAULT_BACKUPS
Name for the default work path. -
EXPORT_DEFAULT_FILE
Name for the folder default index file.- See Also:
-
EXPORT_DEFAULT_WORKPATH
Name for the default work path. -
EXPORT_LINK_WITH_PARAMETER
Flag value for links without parameters.- See Also:
-
EXPORT_LINK_WITHOUT_PARAMETER
Flag value for links without parameters.- See Also:
-
EXPORT_MARKER
Marker for externally redirected 404 uri's.- See Also:
-
HANDLER_FINISH_TIME
Time given (in seconds) to the static export handler to finish a publish task.- See Also:
-
SECURE_PROPERTY_VALUE_BOTH
If the property 'secure' is set to this value, the resource will be delivered through http and https depending on the link source.- See Also:
-
-
Constructor Details
-
CmsStaticExportManager
public CmsStaticExportManager()Creates a new static export property object.
-
-
Method Details
-
getRfsPath
Creates unique, valid RFS name for the given filename that contains a coded version of the given parameters, with the given file extension appended.Adapted from CmsFileUtil.getRfsPath().
- Parameters:
filename
- the base file nameextension
- the extension to useparameters
- the parameters to code in the result file name- Returns:
- a unique, valid RFS name for the given parameters
- See Also:
-
addDefaultFileNameToFolder
Returns the real file system name plus the default file name.- Parameters:
rfsName
- the real file system name to append the default file name toisFolder
- signals whether the according virtual file system resource is an folder or not- Returns:
- the real file system name plus the default file name
-
addExportRule
Adds a new export rule to the configuration.- Parameters:
name
- the name of the ruledescription
- the description for the rule
-
addExportRuleRegex
Adds a regex to the latest export rule.- Parameters:
regex
- the regex to add
-
addExportRuleUri
Adds a export uri to the latest export rule.- Parameters:
exportUri
- the export uri to add
-
addProtectedExportPoint
Adds an protected export point.- Parameters:
uri
- the source URIdestination
- the export destination
-
addRfsRule
public void addRfsRule(String name, String description, String source, String rfsPrefix, String exportPath, String exportWorkPath, String exportBackups, String useRelativeLinks) Adds a new rfs rule to the configuration.- Parameters:
name
- the name of the ruledescription
- the description for the rulesource
- the source regexrfsPrefix
- the url prefixexportPath
- the rfs export pathexportWorkPath
- the rfs export work pathexportBackups
- the number of backupsuseRelativeLinks
- the relative links value
-
addRfsRuleSystemRes
Adds a regex of related system resources to the latest rfs-rule.- Parameters:
regex
- the regex to add
-
cacheOnlineLink
Caches a calculated online link.- Parameters:
linkName
- the linkvfsName
- the name of the VFS resource
-
cmsEvent
Implements the CmsEvent interface, the static export properties uses the events to clear the list of cached keys in case a project is published.- Specified by:
cmsEvent
in interfaceI_CmsEventListener
- Parameters:
event
- CmsEvent that has occurred
-
export
public int export(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, CmsObject cms, CmsStaticExportData data) throws CmsException, IOException, javax.servlet.ServletException, CmsStaticExportException Exports the requested uri and at the same time writes the uri to the response output stream if required.- Parameters:
req
- the current requestres
- the current responsecms
- an initialised cms context (should be initialised with the "Guest" user only)data
- the static export data set- Returns:
- status code of the export operation, status codes are the same as http status codes (200,303,304)
- Throws:
CmsException
- in case of errors accessing the VFSjavax.servlet.ServletException
- in case of errors accessing the servletIOException
- in case of errors writing to the export output streamCmsStaticExportException
- if static export is disabled
-
exportFullStaticRender
public void exportFullStaticRender(boolean purgeFirst, I_CmsReport report) throws CmsException, IOException, javax.servlet.ServletException Starts a complete static export of all resources.- Parameters:
purgeFirst
- flag to delete all resources in the export folder of the rfsreport
- an I_CmsReport instance to print output message, or null to write messages to the log file- Throws:
CmsException
- in case of errors accessing the VFSIOException
- in case of errors writing to the export output streamjavax.servlet.ServletException
- in case of errors accessing the servlet
-
getAcceptCharsetHeader
Returns the accept-charset header used for internal requests.- Returns:
- the accept-charset header
-
getAcceptLanguageHeader
Returns the accept-language header used for internal requests.- Returns:
- the accept-language header
-
getCachedOnlineLink
Returns a cached link for the given vfs name.- Parameters:
vfsName
- the name of the vfs resource to get the cached link for- Returns:
- a cached link for the given vfs name, or null
-
getCacheKey
Returns the key for the online, export and secure cache.- Parameters:
siteRoot
- the site root of the resourceuri
- the URI of the resource- Returns:
- a key for the cache
-
getDefault
Gets the default property value as a string representation.- Returns:
"true"
or"false"
-
getDefaultAcceptCharsetHeader
Returns the current default charset header.- Returns:
- the current default charset header
-
getDefaultAcceptLanguageHeader
Returns the current default locale header.- Returns:
- the current default locale header
-
getDefaultRfsPrefix
Returns the default prefix for exported links in the "real" file system.- Returns:
- the default prefix for exported links in the "real" file system
-
getExportBackups
Returns the number of stored backups.- Returns:
- the number of stored backups
-
getExportData
public CmsStaticExportData getExportData(javax.servlet.http.HttpServletRequest request, CmsObject cms) Returns the export data for the request, if null is returned no export is required.- Parameters:
request
- the request to check for export datacms
- an initialized cms context (should be initialized with the "Guest" user only- Returns:
- the export data for the request, if null is returned no export is required
-
getExportEnabled
Gets the export enabled value as a string representation.- Returns:
"true"
or"false"
-
getExportFolderMatcher
Returns the current folder matcher.- Returns:
- the current folder matcher
-
getExportFolderPatterns
Returns list of resources patterns which are part of the export.- Returns:
- the of resources patterns which are part of the export.
-
getExportHeaders
Returns specific http headers for the static export.If the header
Cache-Control
is set, OpenCms will not use its default headers.- Returns:
- the list of http export headers
-
getExportnames
Returns a map of all export names with export name as key and the vfs folder path as value.- Returns:
- a map of export names
-
getExportPath
Returns the export path for the static export, that is the folder where the static exported resources will be written to.The returned value will be a directory like prefix. The value is configured in the
opencms-importexport.xml
configuration file. An optimization of the configured value will be performed, where all relative path information is resolved (for example/export/../static
will be resolved to/export
. Moreover, if the configured path ends with a/
, this will be cut off (for example/export/
becomes/export
.This is resource name based, and based on the rfs-rules defined in the
opencms-importexport.xml
configuration file.- Parameters:
vfsName
- the name of the resource to export- Returns:
- the export path for the static export, that is the folder where the
- See Also:
-
getExportPathForConfiguration
Returns the original configured export path for the static export without the complete rfs path, to be used when re-writing the configuration.This is required only to serialize the configuration again exactly as it was configured. This method should not be used otherwise. Use
to obtain the export path to use when exporting.getExportPath(String)
- Returns:
- the original configured export path for the static export without the complete rfs path
-
getExportPoints
Returns the protected export points.- Returns:
- the protected export points
-
getExportPropertyDefault
Returns true if the default value for the resource property "export" is true.- Returns:
- true if the default value for the resource property "export" is true
-
getExportRules
Returns the export Rules.- Returns:
- the export Rules
-
getExportSuffixes
Gets the list of resource suffixes which will be exported by default.- Returns:
- list of resource suffixes
-
getExportUrl
Returns the export URL used for internal requests for exporting resources that require a request / response (like JSP).- Returns:
- the export URL used for internal requests for exporting resources like JSP
-
getExportUrlForConfiguration
Returns the export URL used for internal requests with unsubstituted context values, to be used when re-writing the configuration.This is required only to serialize the configuration again exactly as it was configured. This method should not be used otherwise. Use
to obtain the export path to use when exporting.getExportUrl()
- Returns:
- the export URL used for internal requests with unsubstituted context values
-
getExportUrlPrefix
Returns the export URL used for internal requests for exporting resources that require a request / response (like JSP) without http://servername.- Returns:
- the export URL used for internal requests for exporting resources like JSP without http://servername
-
getExportWorkPath
Returns the export work path for the static export, that is the folder where the static exported resources will be written to during the export process.- Returns:
- the export work path for the static export
-
getExportWorkPathForConfiguration
Returns the original configured export work path for the static export without the complete rfs path, to be used when re-writing the configuration.- Returns:
- the original configured export work path for the static export without the complete rfs path
-
getHandler
Returns the configured static export handler class.If not set, a new
is created and returned.CmsAfterPublishStaticExportHandler
- Returns:
- the configured static export handler class
-
getLinkSubstitutionHandler
Returns the configured link substitution handler class.If not set, a new
is created and returned.CmsDefaultLinkSubstitutionHandler
- Returns:
- the configured link substitution handler class
-
getPlainExportOptimization
Gets the plain export optimization value as a string representation.- Returns:
"true"
or"false"
-
getProtectedExportName
Returns the protected export name for the given root path.- Parameters:
rootPath
- the root path- Returns:
- the protected export name
-
getProtectedExportPath
Returns the protected export path.- Returns:
- the protected export path
-
getProtectedExportPoints
Returns the protected export points.- Returns:
- the protected export points
-
getQuickPlainExport
Returns true if the quick plain export is enabled.- Returns:
- true if the quick plain export is enabled
-
getRelativeLinks
Gets the relative links value as a string representation.- Returns:
"true"
or"false"
-
getRemoteAddr
Returns the remote address used for internal requests.- Returns:
- the remote address
-
getRemoteAddress
Returns the remote address.- Returns:
- the remote address
-
getRfsName
Returns the static export rfs name for a given vfs resource.- Parameters:
cms
- an initialized cms contextvfsName
- the name of the vfs resource- Returns:
- the static export rfs name for a give vfs resource
- See Also:
-
getRfsName
Returns the static export rfs name for a given vfs resource where the link to the resource includes request parameters.- Parameters:
cms
- an initialized cms contextvfsName
- the name of the vfs resourceparameters
- the parameters of the link pointing to the resourcetargetDetailPage
- the target detail page to use- Returns:
- the static export rfs name for a give vfs resource
-
getRfsPrefix
Returns the prefix for exported links in the "real" file system.The returned value will be a directory like prefix. The value is configured in the
opencms-importexport.xml
configuration file. An optimization of the configured value will be performed, where all relative path information is resolved (for example/export/../static
will be resolved to/export
. Moreover, if the configured path ends with a/
, this will be cut off (for example/export/
becomes/export
.This is resource name based, and based on the rfs-rules defined in the
opencms-importexport.xml
configuration file.- Parameters:
vfsName
- the name of the resource to export- Returns:
- the prefix for exported links in the "real" file system
- See Also:
-
getRfsPrefixForConfiguration
Returns the original configured prefix for exported links in the "real" file, to be used when re-writing the configuration.This is required only to serialize the configuration again exactly as it was configured. This method should not be used otherwise. Use
to obtain the rfs prefix to use for the exported links.getRfsPrefix(String)
- Returns:
- the original configured prefix for exported links in the "real" file
-
getRfsRules
Returns the rfs Rules.- Returns:
- the rfs Rules
-
getTestResource
Returns the vfs name of the test resource.- Returns:
- the vfs name of the test resource.
-
getVfsExportData
Returns the export data for a requested resource, if null is returned no export is required.- Parameters:
cms
- an initialized cms context (should be initialized with the "Guest" user onlyvfsName
- the VFS name of the resource requested- Returns:
- the export data for the request, if null is returned no export is required
-
getVfsName
Returns the VFS name for the given RFS name, being the exact reverse of
.getRfsName(CmsObject, String)
Returns
null
if no matching VFS resource can be found for the given RFS name.- Parameters:
cms
- the current users OpenCms contextrfsName
- the RFS name to get the VFS name for- Returns:
- the VFS name for the given RFS name, or
null
if the RFS name does not match to the VFS - See Also:
-
getVfsNameInternal
public CmsStaticExportData getVfsNameInternal(CmsObject cms, String rfsName) throws CmsVfsResourceNotFoundException Returns the VFS name from a given RFS name.The RFS name must not contain the RFS prefix.
- Parameters:
cms
- an initialized OpenCms user contextrfsName
- the name of the RFS resource- Returns:
- the name of the VFS resource
- Throws:
CmsVfsResourceNotFoundException
- if something goes wrong
-
getVfsPrefix
Returns the prefix for the internal in the VFS.The returned value will be a directory like prefix. The value is configured in the
opencms-importexport.xml
configuration file. An optimization of the configured value will be performed, where all relative path information is resolved (for example/opencms/../mycms
will be resolved to/mycms
. Moreover, if the configured path ends with a/
, this will be cut off (for example/opencms/
becomes/opencms
.- Returns:
- the prefix for the internal in the VFS
- See Also:
-
getVfsPrefixForConfiguration
Returns the original configured prefix for internal links in the VFS, to be used when re-writing the configuration.This is required only to serialize the configuration again exactly as it was configured. This method should not be used otherwise. Use
to obtain the VFS prefix to use for the internal links.getVfsPrefix()
- Returns:
- the original configured prefix for internal links in the VFS
-
initialize
Initializes the static export manager with the OpenCms system configuration.- Parameters:
cms
- an OpenCms context object
-
isExportLink
Checks if the static export is required for the given VFS resource.Please note that the given OpenCms user context is NOT used to read the resource. The check for export is always done with the permissions of the "Export" user. The provided user context is just used to get the current site root.
Since the "Export" user always operates in the "Online" project, the resource is also read from the "Online" project, not from the current project of the given OpenCms context.
- Parameters:
cms
- the current users OpenCms contextvfsName
- the VFS resource name to check- Returns:
true
if static export is required for the given VFS resource
-
isFullStaticExport
Returns true if the export process is a full static export.- Returns:
- true if the export process is a full static export
-
isSecureLink
Returnstrue
if the given VFS resource should be transported through a secure channel.The secure mode is only checked in the "Online" project. If the given OpenCms context is currently not in the "Online" project,
false
is returned.The given resource is read from the site root of the provided OpenCms context.
- Parameters:
cms
- the current users OpenCms contextvfsName
- the VFS resource name to check- Returns:
true
if the given VFS resource should be transported through a secure channel- See Also:
-
isSecureLink
Returnstrue
if the given VFS resource should be transported through a secure channel.The secure mode is only checked in the "Online" project. If the given OpenCms context is currently not in the "Online" project,
false
is returned.The given resource is read from the site root of the provided OpenCms context.
- Parameters:
cms
- the current users OpenCms contextvfsName
- the VFS resource name to checkfromSecure
-true
if the link source is delivered secure- Returns:
true
if the given VFS resource should be transported through a secure channel- See Also:
-
isSecureLink
Returnstrue
if the given VFS resource that is located under the given site root should be transported through a secure channel.- Parameters:
cms
- the current users OpenCms contextvfsName
- the VFS resource name to checksiteRoot
- the site root where the the VFS resource should be read- Returns:
true
if the given VFS resource should be transported through a secure channel- See Also:
-
isSecureLink
Returnstrue
if the given VFS resource should be transported through a secure channel.The secure mode is only checked in the "Online" project. If the given OpenCms context is currently not in the "Online" project,
false
is returned.The given resource is read from the site root of the provided OpenCms context.
- Parameters:
cms
- the current users OpenCms contextvfsName
- the VFS resource name to checksiteRoot
- the site root where the the VFS resource should be readfromSecure
-true
if the link source is delivered secure- Returns:
true
if the given VFS resource should be transported through a secure channel- See Also:
-
isStaticExportEnabled
Returns true if the static export is enabled.- Returns:
- true if the static export is enabled
-
isSuffixExportable
Returns true if the given resource name is exportable because of it's suffix.- Parameters:
resourceName
- the name to check- Returns:
- true if the given resource name is exportable because of it's suffix
-
isUseTempDir
Checks if we have to use temporary directories during export.- Returns:
true
if using temporary directories
-
relativeLinksInExport
Returns true if the links in the static export should be relative.- Parameters:
vfsName
- the name of the resource to export- Returns:
- true if the links in the static export should be relative
-
setAcceptCharsetHeader
Sets the accept-charset header value.- Parameters:
value
- accept-language header value
-
setAcceptLanguageHeader
Sets the accept-language header value.- Parameters:
value
- accept-language header value
-
setDefault
Sets the default property value.- Parameters:
value
- must betrue
orfalse
-
setExportBackups
Sets the number of backups for the static export.- Parameters:
backup
- number of backups
-
setExportEnabled
Sets the export enabled value.- Parameters:
value
- must betrue
orfalse
-
setExportFolderPattern
Adds a resource pattern to the list of resources which are part of the export.- Parameters:
folder
- the folder pattern to add to the list.
-
setExportHeader
Sets specific http header for the static export.The format of the headers must be "header:value".
- Parameters:
exportHeader
- a specific http header
-
setExportPath
Sets the path where the static export is written.- Parameters:
path
- the path where the static export is written
-
setExportSuffix
Adds a suffix to the list of resource suffixes which will be exported by default.- Parameters:
suffix
- the suffix to add to the list.
-
setExportUrl
Sets the export url.- Parameters:
url
- the export url
-
setExportWorkPath
Sets the path where the static export is temporarily written.- Parameters:
path
- the path where the static export is temporarily written
-
setHandler
Sets the link substitution handler class.- Parameters:
handlerClassName
- the link substitution handler class name
-
setLinkSubstitutionHandler
Sets the static export handler class.- Parameters:
handlerClassName
- the static export handler class name
-
setPlainExportOptimization
Sets the plain export optimization value.- Parameters:
value
- must betrue
orfalse
-
setProtectedExportPath
Sets the protected export path.- Parameters:
exportPath
- the export path to set
-
setRelativeLinks
Sets the relative links value.- Parameters:
value
- must betrue
orfalse
-
setRemoteAddr
Sets the remote address which will be used for internal requests during the static export.- Parameters:
addr
- the remote address to be used
-
setRfsPrefix
Sets the prefix for exported links in the "real" file system.- Parameters:
rfsPrefix
- the prefix for exported links in the "real" file system
-
setTestResource
Sets the test resource.- Parameters:
testResource
- the vfs name of the test resource
-
setVfsPrefix
Sets the prefix for internal links in the vfs.- Parameters:
vfsPrefix
- the prefix for internal links in the vfs
-
shutDown
Shuts down all this static export manager.This is required since there may still be a thread running when the system is being shut down.
-
clearCaches
Clears the caches in the export manager.- Parameters:
event
- the event that requested to clear the caches
-
createExportBackupFolders
protected void createExportBackupFolders(File staticExport, String exportPath, int exportBackups, String ruleBackupExtension) Creates the backup folders for the given export folder and deletes the oldest if the maximum number is reached.- Parameters:
staticExport
- folder for which a new backup folder has to be createdexportPath
- export path to create backup path out of itexportBackups
- number of maximumruleBackupExtension
- extension for rule based backups
-
createExportFolder
Creates the parent folder for a exported resource in the RFS.- Parameters:
exportPath
- the path to export the filerfsName
- the rfs name of the resource- Throws:
CmsException
- if the folder could not be created
-
getCacheExportLinks
Returns the cacheExportLinks.- Returns:
- the cacheExportLinks
-
getCacheSecureLinks
Returns the cacheSecureLinks.- Returns:
- the cacheSecureLinks
-
getRfsExportData
Returns the export data for a requested resource, if null is returned no export is required.- Parameters:
cms
- an initialized cms context (should be initialized with the "Export" user only)uri
- the uri, ie RFS name of the requested resource, with or without the 'export' prefix- Returns:
- the export data for the request, if null is returned no export is required
-
getRfsNameWithExportName
Returns the rfs name for a given vfs name with consideration of the export name.- Parameters:
cms
- the cms obejctvfsName
- the the name of the vfs resource- Returns:
- the rfs name for a given vfs name with consideration of the export name
-
getRfsPrefixForRfsName
Returns the longest rfs prefix matching a given already translated rfs name.- Parameters:
rfsName
- the rfs name- Returns:
- its rfs prefix
- See Also:
-
insertContextStrings
Substitutes the ${CONTEXT_NAME} and ${SERVLET_NAME} in a path with the real values.- Parameters:
path
- the path to substitute- Returns:
- path with real context values
-
isValidRfsName
Returns true if the rfs Name match against any of the defined export urls.- Parameters:
rfsName
- the rfs Name to validate- Returns:
- true if the rfs Name match against any of the defined export urls
-
isValidURL
Checks if a String is a valid URL.- Parameters:
inputString
- The String to check can benull
- Returns:
true
if the String is notnull
and a valid URL
-
normalizeExportPath
Returns a normalized export path.Replacing macros, normalizing the path and taking care of relative paths.
- Parameters:
exportPath
- the export path to normalize- Returns:
- the normalized export path
-
normalizeRfsPrefix
Returns a normalized rfs prefix.Replacing macros and normalizing the path.
- Parameters:
rfsPrefix
- the prefix to normalize- Returns:
- the normalized rfs prefix
-
readResource
Reads the resource with the given URI.- Parameters:
cms
- the current CMS contexturi
- the URI to check- Returns:
- the resource export data
- Throws:
CmsException
- if soemthing goes wrong
-
scrubExportFolders
Scrubs all the "export" folders.- Parameters:
report
- an I_CmsReport instance to print output message, or null to write messages to the log file
-
writeResource
protected void writeResource(javax.servlet.http.HttpServletRequest req, String exportPath, String rfsName, CmsResource resource, byte[] content) throws CmsException Writes a resource to the given export path with the given rfs name and the given content.- Parameters:
req
- the current requestexportPath
- the path to export the resourcerfsName
- the rfs nameresource
- the resourcecontent
- the content- Throws:
CmsException
- if something goes wrong
-