Class CmsHtmlImport
java.lang.Object
org.opencms.workplace.tools.database.CmsHtmlImport
This class implements the HTML->OpenCms Template converter for OpenCms 6.x.
The HTML files can lay in a directory or in a zip file. The entries in the zip file are saved temporary in the tmp-directory of the system. Every file is stored into the correct location in the OpenCms VFS.
- Since:
- 6.0.0
-
Field Summary
-
Constructor Summary
ConstructorDescriptionDefault Constructor.CmsHtmlImport
(org.opencms.file.CmsObject cms) Creates a new import object for the given cms object. -
Method Summary
Modifier and TypeMethodDescriptionstatic File
createTempFolder
(String name) This function creates a folder in the temporary-directory.getAbsoluteUri
(String relativeUri, String baseUri) Calculates an absolute uri from a relative "uri" and the given absolute "baseUri".Returns the destinationDir.Returns the downloadGallery.Returns the element.Returns the endPattern.Returns the httpDir.Returns the imageGallery.Returns the inputDir.Returns the inputEncoding.Returns the linkGallery.Returns the local.Returns the startPattern.Returns the template.boolean
Returns the keepBrokenLinks.boolean
Returns the overwrite.void
setCmsObject
(org.opencms.file.CmsObject cmsObject) Sets the cmsObject.void
setDestinationDir
(String destinationDir) Sets the destinationDir.void
setDownloadGallery
(String downloadGallery) Sets the downloadGallery.void
setElement
(String element) Sets the element.void
setEndPattern
(String endPattern) Sets the endPattern.void
setHttpDir
(String httpDir) Sets the httpDir.void
setImageGallery
(String imageGallery) Sets the imageGallery.void
setInputDir
(String inputDir) Sets the inputDir.void
setInputEncoding
(String inputEncoding) Sets the inputEncoding.void
setKeepBrokenLinks
(boolean keepBrokenLinks) Sets the keepBrokenLinks.void
setLinkGallery
(String linkGallery) Sets the linkGallery.void
Sets the local.void
setOverwrite
(boolean overwrite) Sets the overwrite.void
setStartPattern
(String startPattern) Sets the startPattern.void
setTemplate
(String template) Sets the template.void
startImport
(org.opencms.report.I_CmsReport report) Imports all resources from the real file system, stores them into the correct locations in the OpenCms VFS and modifies all links.storeExternalLink
(String externalLink) Add a new external link to the storage of external links.void
storeImageInfo
(String image, String altText) Add a new image info to the storage of image info's.translateLink
(String link) Translated a link into the real file system to its new location in the OpenCms VFS.void
validate
(org.apache.commons.fileupload.FileItem fi, boolean isdefault) Tests if all given input parameters for the HTML Import are valid, that is that all the given folders do exist.
-
Field Details
-
META_PROPERTIES
filename of the meta.properties file.- See Also:
-
-
Constructor Details
-
CmsHtmlImport
public CmsHtmlImport()Default Constructor. -
CmsHtmlImport
Creates a new import object for the given cms object.- Parameters:
cms
- the current cms context
-
-
Method Details
-
createTempFolder
This function creates a folder in the temporary-directory.- Parameters:
name
- the name of the folder- Returns:
- the folder file
- Throws:
Exception
- if the folder can not create
-
getAbsoluteUri
Calculates an absolute uri from a relative "uri" and the given absolute "baseUri".If "uri" is already absolute, it is returned unchanged. This method also returns "uri" unchanged if it is not well-formed.
- Parameters:
relativeUri
- the relative uri to calculate an absolute uri forbaseUri
- the base uri, this must be an absolute uri- Returns:
- an absolute uri calculated from "uri" and "baseUri"
-
getDestinationDir
Returns the destinationDir.- Returns:
- the destinationDir
-
getDownloadGallery
Returns the downloadGallery.- Returns:
- the downloadGallery
-
getElement
Returns the element.- Returns:
- the element
-
getEndPattern
Returns the endPattern.- Returns:
- the endPattern
-
getHttpDir
Returns the httpDir.- Returns:
- the httpDir
-
getImageGallery
Returns the imageGallery.- Returns:
- the imageGallery
-
getInputDir
Returns the inputDir.- Returns:
- the inputDir
-
getInputEncoding
Returns the inputEncoding.- Returns:
- the inputEncoding
-
getLinkGallery
Returns the linkGallery.- Returns:
- the linkGallery
-
getLocale
Returns the local.- Returns:
- the local
-
getStartPattern
Returns the startPattern.- Returns:
- the startPattern
-
getTemplate
Returns the template.- Returns:
- the template
-
isKeepBrokenLinks
Returns the keepBrokenLinks.- Returns:
- the keepBrokenLinks
-
isOverwrite
Returns the overwrite.- Returns:
- the overwrite
-
setCmsObject
Sets the cmsObject.- Parameters:
cmsObject
- the cmsObject to set
-
setDestinationDir
Sets the destinationDir.- Parameters:
destinationDir
- the destinationDir to set
-
setDownloadGallery
Sets the downloadGallery.- Parameters:
downloadGallery
- the downloadGallery to set
-
setElement
Sets the element.- Parameters:
element
- the element to set
-
setEndPattern
Sets the endPattern.- Parameters:
endPattern
- the endPattern to set
-
setHttpDir
Sets the httpDir.- Parameters:
httpDir
- the httpDir to set
-
setImageGallery
Sets the imageGallery.- Parameters:
imageGallery
- the imageGallery to set
-
setInputDir
Sets the inputDir.- Parameters:
inputDir
- the inputDir to set
-
setInputEncoding
Sets the inputEncoding.- Parameters:
inputEncoding
- the inputEncoding to set
-
setKeepBrokenLinks
Sets the keepBrokenLinks.- Parameters:
keepBrokenLinks
- the keepBrokenLinks to set
-
setLinkGallery
Sets the linkGallery.- Parameters:
linkGallery
- the linkGallery to set
-
setLocale
Sets the local.- Parameters:
locale
- the local to set
-
setOverwrite
Sets the overwrite.- Parameters:
overwrite
- the overwrite to set
-
setStartPattern
Sets the startPattern.- Parameters:
startPattern
- the startPattern to set
-
setTemplate
Sets the template.- Parameters:
template
- the template to set
-
startImport
Imports all resources from the real file system, stores them into the correct locations in the OpenCms VFS and modifies all links. This method is called form the JSP to start the import process.- Parameters:
report
- StringBuffer for reporting- Throws:
Exception
- if something goes wrong
-
storeExternalLink
Add a new external link to the storage of external links.All links in this storage are later used to create entries in the external link gallery.
- Parameters:
externalLink
- link to an external resource- Returns:
- the complete path to the external link file, if one is created.
-
storeImageInfo
Add a new image info to the storage of image info's.The image info's are later used to set the description properties of the images.
- Parameters:
image
- the name of the imagealtText
- the alt-text of the image
-
translateLink
Translated a link into the real file system to its new location in the OpenCms VFS.This is needed by the HtmlConverter to get the correct links for link translation.
- Parameters:
link
- link to the real file system- Returns:
- string containing absolute link into the OpenCms VFS
-
validate
public void validate(org.apache.commons.fileupload.FileItem fi, boolean isdefault) throws org.opencms.main.CmsIllegalArgumentException Tests if all given input parameters for the HTML Import are valid, that is that all the given folders do exist.- Parameters:
fi
- a file item if a file is uploaded per HTTP otherwisenull
isdefault
- if this sets, then the destination and input directory can be empty- Throws:
org.opencms.main.CmsIllegalArgumentException
- if some parameters are not valid
-