Class CmsHtmlImport
- java.lang.Object
-
- org.opencms.workplace.tools.database.CmsHtmlImport
-
public class CmsHtmlImport extends java.lang.Object
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
Fields Modifier and Type Field Description static java.lang.String
META_PROPERTIES
filename of the meta.properties file.
-
Constructor Summary
Constructors Constructor Description CmsHtmlImport()
Default Constructor.CmsHtmlImport(org.opencms.file.CmsObject cms)
Creates a new import object for the given cms object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.io.File
createTempFolder(java.lang.String name)
This function creates a folder in the temporary-directory.java.lang.String
getAbsoluteUri(java.lang.String relativeUri, java.lang.String baseUri)
Calculates an absolute uri from a relative "uri" and the given absolute "baseUri".java.lang.String
getDestinationDir()
Returns the destinationDir.java.lang.String
getDownloadGallery()
Returns the downloadGallery.java.lang.String
getElement()
Returns the element.java.lang.String
getEndPattern()
Returns the endPattern.java.lang.String
getHttpDir()
Returns the httpDir.java.lang.String
getImageGallery()
Returns the imageGallery.java.lang.String
getInputDir()
Returns the inputDir.java.lang.String
getInputEncoding()
Returns the inputEncoding.java.lang.String
getLinkGallery()
Returns the linkGallery.java.lang.String
getLocale()
Returns the local.java.lang.String
getStartPattern()
Returns the startPattern.java.lang.String
getTemplate()
Returns the template.boolean
isKeepBrokenLinks()
Returns the keepBrokenLinks.boolean
isOverwrite()
Returns the overwrite.void
setCmsObject(org.opencms.file.CmsObject cmsObject)
Sets the cmsObject.void
setDestinationDir(java.lang.String destinationDir)
Sets the destinationDir.void
setDownloadGallery(java.lang.String downloadGallery)
Sets the downloadGallery.void
setElement(java.lang.String element)
Sets the element.void
setEndPattern(java.lang.String endPattern)
Sets the endPattern.void
setHttpDir(java.lang.String httpDir)
Sets the httpDir.void
setImageGallery(java.lang.String imageGallery)
Sets the imageGallery.void
setInputDir(java.lang.String inputDir)
Sets the inputDir.void
setInputEncoding(java.lang.String inputEncoding)
Sets the inputEncoding.void
setKeepBrokenLinks(boolean keepBrokenLinks)
Sets the keepBrokenLinks.void
setLinkGallery(java.lang.String linkGallery)
Sets the linkGallery.void
setLocale(java.lang.String locale)
Sets the local.void
setOverwrite(boolean overwrite)
Sets the overwrite.void
setStartPattern(java.lang.String startPattern)
Sets the startPattern.void
setTemplate(java.lang.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.java.lang.String
storeExternalLink(java.lang.String externalLink)
Add a new external link to the storage of external links.void
storeImageInfo(java.lang.String image, java.lang.String altText)
Add a new image info to the storage of image info's.java.lang.String
translateLink(java.lang.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 Detail
-
META_PROPERTIES
public static final java.lang.String META_PROPERTIES
filename of the meta.properties file.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CmsHtmlImport
public CmsHtmlImport()
Default Constructor.
-
CmsHtmlImport
public CmsHtmlImport(org.opencms.file.CmsObject cms)
Creates a new import object for the given cms object.- Parameters:
cms
- the current cms context
-
-
Method Detail
-
createTempFolder
public static java.io.File createTempFolder(java.lang.String name) throws java.lang.Exception
This function creates a folder in the temporary-directory.- Parameters:
name
- the name of the folder- Returns:
- the folder file
- Throws:
java.lang.Exception
- if the folder can not create
-
getAbsoluteUri
public java.lang.String getAbsoluteUri(java.lang.String relativeUri, java.lang.String baseUri)
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
public java.lang.String getDestinationDir()
Returns the destinationDir.- Returns:
- the destinationDir
-
getDownloadGallery
public java.lang.String getDownloadGallery()
Returns the downloadGallery.- Returns:
- the downloadGallery
-
getElement
public java.lang.String getElement()
Returns the element.- Returns:
- the element
-
getEndPattern
public java.lang.String getEndPattern()
Returns the endPattern.- Returns:
- the endPattern
-
getHttpDir
public java.lang.String getHttpDir()
Returns the httpDir.- Returns:
- the httpDir
-
getImageGallery
public java.lang.String getImageGallery()
Returns the imageGallery.- Returns:
- the imageGallery
-
getInputDir
public java.lang.String getInputDir()
Returns the inputDir.- Returns:
- the inputDir
-
getInputEncoding
public java.lang.String getInputEncoding()
Returns the inputEncoding.- Returns:
- the inputEncoding
-
getLinkGallery
public java.lang.String getLinkGallery()
Returns the linkGallery.- Returns:
- the linkGallery
-
getLocale
public java.lang.String getLocale()
Returns the local.- Returns:
- the local
-
getStartPattern
public java.lang.String getStartPattern()
Returns the startPattern.- Returns:
- the startPattern
-
getTemplate
public java.lang.String getTemplate()
Returns the template.- Returns:
- the template
-
isKeepBrokenLinks
public boolean isKeepBrokenLinks()
Returns the keepBrokenLinks.- Returns:
- the keepBrokenLinks
-
isOverwrite
public boolean isOverwrite()
Returns the overwrite.- Returns:
- the overwrite
-
setCmsObject
public void setCmsObject(org.opencms.file.CmsObject cmsObject)
Sets the cmsObject.- Parameters:
cmsObject
- the cmsObject to set
-
setDestinationDir
public void setDestinationDir(java.lang.String destinationDir)
Sets the destinationDir.- Parameters:
destinationDir
- the destinationDir to set
-
setDownloadGallery
public void setDownloadGallery(java.lang.String downloadGallery)
Sets the downloadGallery.- Parameters:
downloadGallery
- the downloadGallery to set
-
setElement
public void setElement(java.lang.String element)
Sets the element.- Parameters:
element
- the element to set
-
setEndPattern
public void setEndPattern(java.lang.String endPattern)
Sets the endPattern.- Parameters:
endPattern
- the endPattern to set
-
setHttpDir
public void setHttpDir(java.lang.String httpDir)
Sets the httpDir.- Parameters:
httpDir
- the httpDir to set
-
setImageGallery
public void setImageGallery(java.lang.String imageGallery)
Sets the imageGallery.- Parameters:
imageGallery
- the imageGallery to set
-
setInputDir
public void setInputDir(java.lang.String inputDir)
Sets the inputDir.- Parameters:
inputDir
- the inputDir to set
-
setInputEncoding
public void setInputEncoding(java.lang.String inputEncoding)
Sets the inputEncoding.- Parameters:
inputEncoding
- the inputEncoding to set
-
setKeepBrokenLinks
public void setKeepBrokenLinks(boolean keepBrokenLinks)
Sets the keepBrokenLinks.- Parameters:
keepBrokenLinks
- the keepBrokenLinks to set
-
setLinkGallery
public void setLinkGallery(java.lang.String linkGallery)
Sets the linkGallery.- Parameters:
linkGallery
- the linkGallery to set
-
setLocale
public void setLocale(java.lang.String locale)
Sets the local.- Parameters:
locale
- the local to set
-
setOverwrite
public void setOverwrite(boolean overwrite)
Sets the overwrite.- Parameters:
overwrite
- the overwrite to set
-
setStartPattern
public void setStartPattern(java.lang.String startPattern)
Sets the startPattern.- Parameters:
startPattern
- the startPattern to set
-
setTemplate
public void setTemplate(java.lang.String template)
Sets the template.- Parameters:
template
- the template to set
-
startImport
public void startImport(org.opencms.report.I_CmsReport report) throws java.lang.Exception
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:
java.lang.Exception
- if something goes wrong
-
storeExternalLink
public java.lang.String storeExternalLink(java.lang.String externalLink)
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
public void storeImageInfo(java.lang.String image, java.lang.String altText)
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
public java.lang.String translateLink(java.lang.String link)
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
-
-