public class CmsExport
extends java.lang.Object
The ZIP file written will contain a copy of all exported files with their contents.
It will also contain a manifest.xml
file in which all meta-information
about this files are stored, like permissions etc.
构造器和说明 |
---|
CmsExport()
Constructs a new uninitialized export, required for special subclass data export.
|
CmsExport(CmsObject cms,
I_CmsReport report)
Constructs a new export.
|
限定符和类型 | 方法和说明 |
---|---|
protected void |
addChildResources(java.lang.String folderName)
Exports the given folder and all child resources.
|
protected void |
addFiles(java.util.List<java.lang.String> fileNames)
Adds all files in fileNames to the manifest.xml file.
|
protected void |
addParentFolders(java.lang.String resourceName)
Adds the parent folders of the given resource to the config file,
starting at the top, excluding the root folder.
|
protected void |
addPropertyNode(org.dom4j.Element propertiesElement,
java.lang.String propertyName,
java.lang.String propertyValue,
boolean shared)
Adds a property node to the manifest.xml.
|
protected void |
addRelationNode(org.dom4j.Element relationsElement,
java.lang.String structureId,
java.lang.String sitePath,
java.lang.String relationType)
Adds a relation node to the
manifest.xml . |
protected void |
appendResourceToManifest(CmsResource resource,
boolean source)
Writes the data for a resource (like access-rights) to the
manifest.xml file. |
protected boolean |
checkExportResource(java.lang.String resourcename)
Returns true if the checked resource name can be exported depending on the include settings.
|
protected void |
closeExportFile(org.dom4j.Element exportNode)
Closes the export ZIP file and saves the XML document for the manifest.
|
protected void |
digestElement(org.dom4j.Element parent,
org.dom4j.Element output)
Writes the output element to the XML output writer and detaches it
from it's parent element.
|
protected void |
exportAllResources(org.dom4j.Element parent,
java.util.List<java.lang.String> resourcesToExport)
Exports all resources and possible sub-folders form the provided list of resources.
|
void |
exportData(CmsExportParameters parameters)
Export the data.
|
protected void |
exportFile(CmsFile file)
Exports one single file with all its data and content.
|
protected void |
exportGroup(org.dom4j.Element parent,
CmsGroup group)
Exports one single group with all it's data.
|
protected void |
exportGroups(org.dom4j.Element parent,
CmsOrganizationalUnit orgunit)
Exports all groups of the given organizational unit.
|
protected void |
exportOrgUnit(org.dom4j.Element parent,
CmsOrganizationalUnit orgunit)
Exports one single organizational unit with all it's data.
|
protected void |
exportOrgUnits(org.dom4j.Element parent)
Exports all organizational units with all data.
|
protected void |
exportProject(org.dom4j.Element parent,
CmsProject project)
Exports one single project with all it's data.
|
protected void |
exportProjects(org.dom4j.Element parent)
Exports all projects with all data.
|
protected void |
exportUser(org.dom4j.Element parent,
CmsUser user)
Exports one single user with all its data.
|
protected void |
exportUsers(org.dom4j.Element parent,
CmsOrganizationalUnit orgunit)
Exports all users of the given organizational unit.
|
protected CmsObject |
getCms()
Returns the OpenCms context object this export was initialized with.
|
protected java.lang.String |
getExportFileName()
Returns the name of the export file.
|
protected java.lang.String |
getExportNodeName()
Returns the name of the main export node.
|
protected I_CmsReport |
getReport()
Returns the report to write progress messages to.
|
protected java.lang.String |
getResourceNodeName()
Returns the name for the main resource node.
|
protected org.dom4j.io.SAXWriter |
getSaxWriter()
Returns the SAX based xml writer to write the XML output to.
|
protected boolean |
isIgnoredProperty(CmsProperty property)
Checks if a property should be written to the export or not.
|
protected boolean |
isInExportableProject(CmsResource res)
Checks if a resource is belongs to the correct project for exporting.
|
protected org.dom4j.Element |
openExportFile()
Opens the export ZIP file and initializes the internal XML document for the manifest.
|
protected void |
setSaxWriter(org.dom4j.io.SAXWriter saxWriter)
Sets the SAX based XML writer to write the XML output to.
|
protected java.lang.String |
trimResourceName(java.lang.String resourceName)
Cuts leading and trailing '/' from the given resource name.
|
public CmsExport()
public CmsExport(CmsObject cms, I_CmsReport report) throws CmsRoleViolationException
cms
- the cms contextreport
- the reportCmsRoleViolationException
- if the current user has not the required rolepublic void exportData(CmsExportParameters parameters) throws CmsImportExportException
parameters
- the export parametersCmsImportExportException
- if something goes wrongprotected void addChildResources(java.lang.String folderName) throws CmsImportExportException, java.io.IOException, org.xml.sax.SAXException
folderName
- to complete path to the resource to exportCmsImportExportException
- if something goes wrongorg.xml.sax.SAXException
- if something goes wrong processing the manifest.xmljava.io.IOException
- if not all resources could be appended to the ZIP archiveprotected void addFiles(java.util.List<java.lang.String> fileNames) throws CmsImportExportException, java.io.IOException, org.xml.sax.SAXException
fileNames
- list of path Strings, e.g. /folder/index.html
CmsImportExportException
- if something goes wrongjava.io.IOException
- if a file could not be exportedorg.xml.sax.SAXException
- if something goes wrong processing the manifest.xmlprotected void addParentFolders(java.lang.String resourceName) throws CmsImportExportException, org.xml.sax.SAXException
resourceName
- the name of a resource in the VFSCmsImportExportException
- if something goes wrongorg.xml.sax.SAXException
- if something goes wrong processing the manifest.xmlprotected void addPropertyNode(org.dom4j.Element propertiesElement, java.lang.String propertyName, java.lang.String propertyValue, boolean shared)
propertiesElement
- the parent element to append the node topropertyName
- the name of the propertypropertyValue
- the value of the propertyshared
- if true
, add a shared property attribute to the generated property nodeprotected void addRelationNode(org.dom4j.Element relationsElement, java.lang.String structureId, java.lang.String sitePath, java.lang.String relationType)
manifest.xml
.relationsElement
- the parent element to append the node tostructureId
- the structure id of the target relationsitePath
- the site path of the target relationrelationType
- the type of the relationprotected void appendResourceToManifest(CmsResource resource, boolean source) throws CmsImportExportException, org.xml.sax.SAXException
manifest.xml
file.resource
- the resource to get the data fromsource
- flag to show if the source information in the xml file must be writtenCmsImportExportException
- if something goes wrongorg.xml.sax.SAXException
- if something goes wrong processing the manifest.xmlprotected boolean checkExportResource(java.lang.String resourcename)
resourcename
- the absolute path of the resourceprotected void closeExportFile(org.dom4j.Element exportNode) throws java.io.IOException, org.xml.sax.SAXException
exportNode
- the export root nodeorg.xml.sax.SAXException
- if something goes wrong processing the manifest.xmljava.io.IOException
- if something goes wrong while closing the export fileprotected void digestElement(org.dom4j.Element parent, org.dom4j.Element output) throws org.xml.sax.SAXException
parent
- the parent elementoutput
- the output elementorg.xml.sax.SAXException
- if something goes wrong processing the manifest.xmlprotected void exportAllResources(org.dom4j.Element parent, java.util.List<java.lang.String> resourcesToExport) throws CmsImportExportException, java.io.IOException, org.xml.sax.SAXException
parent
- the parent node to add the resources toresourcesToExport
- the list of resources to exportCmsImportExportException
- if something goes wrongorg.xml.sax.SAXException
- if something goes wrong processing the manifest.xmljava.io.IOException
- if not all resources could be appended to the ZIP archiveprotected void exportFile(CmsFile file) throws CmsImportExportException, org.xml.sax.SAXException, java.io.IOException
file
- the file to be exportedCmsImportExportException
- if something goes wrongorg.xml.sax.SAXException
- if something goes wrong processing the manifest.xmljava.io.IOException
- if the ZIP entry for the file could be appended to the ZIP archiveprotected void exportGroup(org.dom4j.Element parent, CmsGroup group) throws CmsImportExportException, org.xml.sax.SAXException
parent
- the parent node to add the groups togroup
- the group to be exportedCmsImportExportException
- if something goes wrongorg.xml.sax.SAXException
- if something goes wrong processing the manifest.xmlprotected void exportGroups(org.dom4j.Element parent, CmsOrganizationalUnit orgunit) throws CmsImportExportException, org.xml.sax.SAXException
parent
- the parent node to add the groups toorgunit
- the organizational unit to write the groups forCmsImportExportException
- if something goes wrongorg.xml.sax.SAXException
- if something goes wrong processing the manifest.xmlprotected void exportOrgUnit(org.dom4j.Element parent, CmsOrganizationalUnit orgunit) throws org.xml.sax.SAXException, CmsException
parent
- the parent node to add the groups toorgunit
- the group to be exportedorg.xml.sax.SAXException
- if something goes wrong processing the manifest.xmlCmsException
- if something goes wrong reading the data to exportprotected void exportOrgUnits(org.dom4j.Element parent) throws CmsImportExportException, org.xml.sax.SAXException
parent
- the parent node to add the organizational units toCmsImportExportException
- if something goes wrongorg.xml.sax.SAXException
- if something goes wrong processing the manifest.xmlprotected void exportProject(org.dom4j.Element parent, CmsProject project) throws CmsImportExportException, org.xml.sax.SAXException
parent
- the parent node to add the project toproject
- the project to be exportedCmsImportExportException
- if something goes wrongorg.xml.sax.SAXException
- if something goes wrong processing the manifest.xmlprotected void exportProjects(org.dom4j.Element parent) throws CmsImportExportException, org.xml.sax.SAXException
parent
- the parent node to add the projects toCmsImportExportException
- if something goes wrongorg.xml.sax.SAXException
- if something goes wrong processing the manifest.xmlprotected void exportUser(org.dom4j.Element parent, CmsUser user) throws CmsImportExportException, org.xml.sax.SAXException
parent
- the parent node to add the users touser
- the user to be exportedCmsImportExportException
- if something goes wrongorg.xml.sax.SAXException
- if something goes wrong processing the manifest.xmlprotected void exportUsers(org.dom4j.Element parent, CmsOrganizationalUnit orgunit) throws CmsImportExportException, org.xml.sax.SAXException
parent
- the parent node to add the users toorgunit
- the organizational unit to write the groups forCmsImportExportException
- if something goes wrongorg.xml.sax.SAXException
- if something goes wrong processing the manifest.xmlprotected CmsObject getCms()
protected java.lang.String getExportFileName()
protected java.lang.String getExportNodeName()
protected I_CmsReport getReport()
protected java.lang.String getResourceNodeName()
protected org.dom4j.io.SAXWriter getSaxWriter()
protected boolean isIgnoredProperty(CmsProperty property)
property
- the property to checkprotected boolean isInExportableProject(CmsResource res)
res
- the resource to checktrue
, if the resource can be exported, false otherwiseprotected org.dom4j.Element openExportFile() throws java.io.IOException, org.xml.sax.SAXException
org.xml.sax.SAXException
- if something goes wrong processing the manifest.xmljava.io.IOException
- if something goes wrong while closing the export fileprotected void setSaxWriter(org.dom4j.io.SAXWriter saxWriter)
saxWriter
- the SAX based XML writer to write the XML output toprotected java.lang.String trimResourceName(java.lang.String resourceName)
resourceName
- the absolute path of a resource