org.opencms.importexport
Class CmsImportExportManager

java.lang.Object
  extended byorg.opencms.importexport.CmsImportExportManager

public class CmsImportExportManager
extends Object

Provides information about how to handle imported resources.

Since:
6.0.0
Version:
$Revision: 1.27 $
Author:
Thomas Weckert
See Also:
OpenCms.getImportExportManager()

Field Summary
static String EXPORT_VERSION
          The version of the opencms export (appears in the export manifest-file).
static String EXPORT_XMLFILENAME
          The filename of the xml manifest.
static String N_ACCESS
          A tag in the manifest-file.
static String N_ACCESSCONTROL_ALLOWEDPERMISSIONS
          Tag to identify allowed permissions.
static String N_ACCESSCONTROL_DENIEDPERMISSIONS
          Tag to identify denied permissions.
static String N_ACCESSCONTROL_ENTRIES
          Tag to identify access control entries .
static String N_ACCESSCONTROL_ENTRY
          Tag to identify a single access control entry.
static String N_ACCESSCONTROL_PERMISSIONSET
          Tag to identify a permission set.
static String N_ACCESSCONTROL_PRINCIPAL
          Tag to identify a principal set.
static String N_CREATOR
          A tag in the export manifest-file, used as subtag of EXPORT_TAG_INFO.
static String N_DATE
          A tag in the export manifest-file, used as subtag of EXPORT_TAG_INFO.
static String N_DATECREATED
          The "datecreated" tag in the manifest-file.
static String N_DATEEXPIRED
          The "expire" tag in the manifest-file.
static String N_DATELASTMODIFIED
          The "datelastmodified" tag in the manifest-file.
static String N_DATERELEASED
          The "release" tag in the manifest-file.
static String N_DEFAULTGROUP
          A tag in the manifest-file.
static String N_DESCRIPTION
          A tag in the manifest-file.
static String N_DESTINATION
          A tag in the manifest-file.
static String N_EMAIL
          A tag in the manifest-file.
static String N_EXPORT
          A tag in the manifest-file.
static String N_FILE
          A tag in the manifest-file.
static String N_FIRSTNAME
          A tag in the manifest-file.
static String N_FLAGS
          A tag in the manifest-file.
static String N_GROUPDATA
          A tag in the manifest-file.
static String N_GROUPNAME
          A tag in the manifest-file.
static String N_ID
          Tag to identify a generic id.
static String N_INFO
          A tag in the export manifest-file.
static String N_LASTMODIFIED
          The "lastmodified" tag in the manifest-file.
static String N_LASTNAME
          A tag in the manifest-file.
static String N_NAME
          A tag in the manifest-file.
static String N_OC_VERSION
          A tag in the export manifest-file, used as subtag of C_EXPORT_TAG_INFO.
static String N_PARENTGROUP
          A tag in the manifest-file.
static String N_PASSWORD
          A tag in the manifest-file.
static String N_PROJECT
          A tag in the manifest-file, used as subtag of C_EXPORT_TAG_INFO.
static String N_PROPERTIES
          A tag in the manifest-file.
static String N_PROPERTY
          A tag in the manifest-file.
static String N_PROPERTY_ATTRIB_TYPE
          Key for the type attrib.
static String N_PROPERTY_ATTRIB_TYPE_SHARED
          Value for the "shared" type attrib.
static String N_SOURCE
          A tag in the manifest-file.
static String N_TAG_ADDRESS
          A tag in the manifest-file.
static String N_TYPE
          A tag in the manifest-file.
static String N_USER
          A tag in the manifest-file.
static String N_USERCREATED
          The "usercreated" tag in the manifest-file.
static String N_USERDATA
          A tag in the manifest-file.
static String N_USERGROUPDATA
          A tag in the manifest-file.
static String N_USERGROUPS
          A tag in the manifest-file.
static String N_USERINFO
          A tag in the manifest-file.
static String N_USERLASTMODIFIED
          The "userlastmodified" tag in the manifest-file.
static String N_UUIDRESOURCE
          The "uuidresource" tag in the manifest-file.
static String N_UUIDSTRUCTURE
          The "uuid" tag in the manifest-file.
static String N_VALUE
          A tag in the manifest-file.
static String N_VERSION
          A tag in the export manifest-file, used as subtag of C_EXPORT_TAG_INFO.
 
Constructor Summary
CmsImportExportManager()
          Creates a new instance for the import/export manager, will be called by the import/export configuration manager.
 
Method Summary
 void addIgnoredProperty(String propertyName)
          Adds a property name to the list of properties that should be removed from imported resources.
 void addImmutableResource(String immutableResource)
          Adds a resource to the list of immutable resources that should remain unchanged when resources are imported.
 void addImportExportHandler(I_CmsImportExportHandler handler)
          Adds an import/export handler to the list of configured handlers.
 void addImportPrincipalTranslation(String type, String from, String to)
          Adds an import princial translation to the configuration.
 void addImportVersionClass(I_CmsImport importVersionClass)
          Adds a import version class name to the configuration.
 boolean convertToXmlPage()
          Checks if imported pages should be converted into XML pages.
 void exportData(CmsObject cms, I_CmsImportExportHandler handler, I_CmsReport report)
          Checks if the current user has permissions to export Cms data of a specified export handler, and if so, triggers the handler to write the export.
protected  void finalize()
           
 List getIgnoredProperties()
          Returns the list of property keys that should be removed from imported resources.
 List getImmutableResources()
          Returns the list of immutable resources that should remain unchanged when resources are imported.
 I_CmsImportExportHandler getImportExportHandler(String importFile)
          Returns an instance of an import/export handler implementation that is able to import a specified resource.
 List getImportExportHandlers()
          Returns the list of configured import/export handlers.
 Map getImportGroupTranslations()
          Returns the configured principal group translations.
 Map getImportUserTranslations()
          Returns the configured principal user translations.
 List getImportVersionClasses()
          Returns the configured import version class names.
static Document getManifest(File resource)
          Returns the "manifest.xml" of an available import resource as a dom4j document.
 String getOldWebAppUrl()
          Returns the URL of a 4.x OpenCms app.
 void importData(CmsObject cms, String importFile, String importPath, I_CmsReport report)
          Checks if the current user has permissions to import data into the Cms, and if so, creates a new import handler instance that imports the data.
 boolean overwriteCollidingResources()
          Checks if colliding resources should be overwritten during the import.
 void setConvertToXmlPage(boolean convertToXmlPage)
          Sets if imported pages should be converted into XML pages.
 void setConvertToXmlPage(String convertToXmlPage)
          Sets if imported pages should be converted into XML pages.
 void setOldWebAppUrl(String webAppUrl)
          Sets the URL of a 4.x OpenCms app.
 void setOverwriteCollidingResources(boolean overwriteCollidingResources)
          Sets whether colliding resources should be overwritten during the import for a specified import implementation.
 void setOverwriteCollidingResources(String overwriteCollidingResources)
           
 String translateGroup(String name)
          Returns the translated name for the given group name.
 String translateUser(String name)
          Returns the translated name for the given user name.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXPORT_VERSION

public static final String EXPORT_VERSION
The version of the opencms export (appears in the export manifest-file).

See Also:
Constant Field Values

EXPORT_XMLFILENAME

public static final String EXPORT_XMLFILENAME
The filename of the xml manifest.

See Also:
Constant Field Values

N_ACCESS

public static final String N_ACCESS
A tag in the manifest-file.

See Also:
Constant Field Values

N_ACCESSCONTROL_ALLOWEDPERMISSIONS

public static final String N_ACCESSCONTROL_ALLOWEDPERMISSIONS
Tag to identify allowed permissions.

See Also:
Constant Field Values

N_ACCESSCONTROL_DENIEDPERMISSIONS

public static final String N_ACCESSCONTROL_DENIEDPERMISSIONS
Tag to identify denied permissions.

See Also:
Constant Field Values

N_ACCESSCONTROL_ENTRIES

public static final String N_ACCESSCONTROL_ENTRIES
Tag to identify access control entries .

See Also:
Constant Field Values

N_ACCESSCONTROL_ENTRY

public static final String N_ACCESSCONTROL_ENTRY
Tag to identify a single access control entry.

See Also:
Constant Field Values

N_ACCESSCONTROL_PERMISSIONSET

public static final String N_ACCESSCONTROL_PERMISSIONSET
Tag to identify a permission set.

See Also:
Constant Field Values

N_ACCESSCONTROL_PRINCIPAL

public static final String N_ACCESSCONTROL_PRINCIPAL
Tag to identify a principal set.

See Also:
Constant Field Values

N_CREATOR

public static final String N_CREATOR
A tag in the export manifest-file, used as subtag of EXPORT_TAG_INFO.

See Also:
Constant Field Values

N_DATE

public static final String N_DATE
A tag in the export manifest-file, used as subtag of EXPORT_TAG_INFO.

See Also:
Constant Field Values

N_DATECREATED

public static final String N_DATECREATED
The "datecreated" tag in the manifest-file.

See Also:
Constant Field Values

N_DATEEXPIRED

public static final String N_DATEEXPIRED
The "expire" tag in the manifest-file.

See Also:
Constant Field Values

N_DATELASTMODIFIED

public static final String N_DATELASTMODIFIED
The "datelastmodified" tag in the manifest-file.

See Also:
Constant Field Values

N_DATERELEASED

public static final String N_DATERELEASED
The "release" tag in the manifest-file.

See Also:
Constant Field Values

N_DEFAULTGROUP

public static final String N_DEFAULTGROUP
A tag in the manifest-file.

See Also:
Constant Field Values

N_DESCRIPTION

public static final String N_DESCRIPTION
A tag in the manifest-file.

See Also:
Constant Field Values

N_DESTINATION

public static final String N_DESTINATION
A tag in the manifest-file.

See Also:
Constant Field Values

N_EMAIL

public static final String N_EMAIL
A tag in the manifest-file.

See Also:
Constant Field Values

N_EXPORT

public static final String N_EXPORT
A tag in the manifest-file.

See Also:
Constant Field Values

N_FILE

public static final String N_FILE
A tag in the manifest-file.

See Also:
Constant Field Values

N_FIRSTNAME

public static final String N_FIRSTNAME
A tag in the manifest-file.

See Also:
Constant Field Values

N_FLAGS

public static final String N_FLAGS
A tag in the manifest-file.

See Also:
Constant Field Values

N_GROUPDATA

public static final String N_GROUPDATA
A tag in the manifest-file.

See Also:
Constant Field Values

N_GROUPNAME

public static final String N_GROUPNAME
A tag in the manifest-file.

See Also:
Constant Field Values

N_ID

public static final String N_ID
Tag to identify a generic id.

See Also:
Constant Field Values

N_INFO

public static final String N_INFO
A tag in the export manifest-file.

See Also:
Constant Field Values

N_LASTMODIFIED

public static final String N_LASTMODIFIED
The "lastmodified" tag in the manifest-file.

See Also:
Constant Field Values

N_LASTNAME

public static final String N_LASTNAME
A tag in the manifest-file.

See Also:
Constant Field Values

N_NAME

public static final String N_NAME
A tag in the manifest-file.

See Also:
Constant Field Values

N_OC_VERSION

public static final String N_OC_VERSION
A tag in the export manifest-file, used as subtag of C_EXPORT_TAG_INFO.

See Also:
Constant Field Values

N_PARENTGROUP

public static final String N_PARENTGROUP
A tag in the manifest-file.

See Also:
Constant Field Values

N_PASSWORD

public static final String N_PASSWORD
A tag in the manifest-file.

See Also:
Constant Field Values

N_PROJECT

public static final String N_PROJECT
A tag in the manifest-file, used as subtag of C_EXPORT_TAG_INFO.

See Also:
Constant Field Values

N_PROPERTIES

public static final String N_PROPERTIES
A tag in the manifest-file.

See Also:
Constant Field Values

N_PROPERTY

public static final String N_PROPERTY
A tag in the manifest-file.

See Also:
Constant Field Values

N_PROPERTY_ATTRIB_TYPE

public static final String N_PROPERTY_ATTRIB_TYPE
Key for the type attrib. of a property element.

See Also:
Constant Field Values

N_PROPERTY_ATTRIB_TYPE_SHARED

public static final String N_PROPERTY_ATTRIB_TYPE_SHARED
Value for the "shared" type attrib. of a property element.

See Also:
Constant Field Values

N_SOURCE

public static final String N_SOURCE
A tag in the manifest-file.

See Also:
Constant Field Values

N_TAG_ADDRESS

public static final String N_TAG_ADDRESS
A tag in the manifest-file.

See Also:
Constant Field Values

N_TYPE

public static final String N_TYPE
A tag in the manifest-file.

See Also:
Constant Field Values

N_USER

public static final String N_USER
A tag in the manifest-file.

See Also:
Constant Field Values

N_USERCREATED

public static final String N_USERCREATED
The "usercreated" tag in the manifest-file.

See Also:
Constant Field Values

N_USERDATA

public static final String N_USERDATA
A tag in the manifest-file.

See Also:
Constant Field Values

N_USERGROUPDATA

public static final String N_USERGROUPDATA
A tag in the manifest-file.

See Also:
Constant Field Values

N_USERGROUPS

public static final String N_USERGROUPS
A tag in the manifest-file.

See Also:
Constant Field Values

N_USERINFO

public static final String N_USERINFO
A tag in the manifest-file.

See Also:
Constant Field Values

N_USERLASTMODIFIED

public static final String N_USERLASTMODIFIED
The "userlastmodified" tag in the manifest-file.

See Also:
Constant Field Values

N_UUIDRESOURCE

public static final String N_UUIDRESOURCE
The "uuidresource" tag in the manifest-file.

See Also:
Constant Field Values

N_UUIDSTRUCTURE

public static final String N_UUIDSTRUCTURE
The "uuid" tag in the manifest-file.

See Also:
Constant Field Values

N_VALUE

public static final String N_VALUE
A tag in the manifest-file.

See Also:
Constant Field Values

N_VERSION

public static final String N_VERSION
A tag in the export manifest-file, used as subtag of C_EXPORT_TAG_INFO.

See Also:
Constant Field Values
Constructor Detail

CmsImportExportManager

public CmsImportExportManager()
Creates a new instance for the import/export manager, will be called by the import/export configuration manager.

Method Detail

getManifest

public static Document getManifest(File resource)
Returns the "manifest.xml" of an available import resource as a dom4j document.

The manifest is either read as a ZIP entry, or from a subfolder of the specified file resource.

Parameters:
resource - a File resource
Returns:
the "manifest.xml" as a dom4j document

addIgnoredProperty

public void addIgnoredProperty(String propertyName)
Adds a property name to the list of properties that should be removed from imported resources.

Parameters:
propertyName - a property name

addImmutableResource

public void addImmutableResource(String immutableResource)
Adds a resource to the list of immutable resources that should remain unchanged when resources are imported.

Parameters:
immutableResource - a resources uri in the OpenCms VFS

addImportExportHandler

public void addImportExportHandler(I_CmsImportExportHandler handler)
Adds an import/export handler to the list of configured handlers.

Parameters:
handler - the import/export handler to add

addImportPrincipalTranslation

public void addImportPrincipalTranslation(String type,
                                          String from,
                                          String to)
Adds an import princial translation to the configuration.

Parameters:
type - the princial type ("USER" or "GROUP")
from - the "from" translation source
to - the "to" translation target

addImportVersionClass

public void addImportVersionClass(I_CmsImport importVersionClass)
Adds a import version class name to the configuration.

Parameters:
importVersionClass - the import version class name to add

convertToXmlPage

public boolean convertToXmlPage()
Checks if imported pages should be converted into XML pages.

Returns:
true, if imported pages should be converted into XML pages

exportData

public void exportData(CmsObject cms,
                       I_CmsImportExportHandler handler,
                       I_CmsReport report)
                throws CmsConfigurationException,
                       CmsImportExportException,
                       CmsRoleViolationException
Checks if the current user has permissions to export Cms data of a specified export handler, and if so, triggers the handler to write the export.

Parameters:
cms - the current OpenCms context object
handler - handler containing the export data
report - a Cms report to print log messages
Throws:
CmsRoleViolationException - if the current user is not a allowed to export the OpenCms database
CmsImportExportException - if operation was not successful
CmsConfigurationException - if something goes wrong
See Also:
I_CmsImportExportHandler

getIgnoredProperties

public List getIgnoredProperties()
Returns the list of property keys that should be removed from imported resources.

Returns:
the list of property keys that should be removed from imported resources, or Collections.EMPTY_LIST

getImmutableResources

public List getImmutableResources()
Returns the list of immutable resources that should remain unchanged when resources are imported.

Certain system resources should not be changed during import. This is the case for the main folders in the /system/ folder. Changes to these folders usually should not be imported to another system.

Returns:
the list of immutable resources, or Collections.EMPTY_LIST

getImportExportHandler

public I_CmsImportExportHandler getImportExportHandler(String importFile)
                                                throws CmsImportExportException
Returns an instance of an import/export handler implementation that is able to import a specified resource.

Parameters:
importFile - the name (absolute path) of the resource (zipfile or folder) to be imported
Returns:
an instance of an import/export handler implementation
Throws:
CmsImportExportException - if somethong goes wrong

getImportExportHandlers

public List getImportExportHandlers()
Returns the list of configured import/export handlers.

Returns:
the list of configured import/export handlers

getImportGroupTranslations

public Map getImportGroupTranslations()
Returns the configured principal group translations.

Returns:
the configured principal group translations

getImportUserTranslations

public Map getImportUserTranslations()
Returns the configured principal user translations.

Returns:
the configured principal user translations

getImportVersionClasses

public List getImportVersionClasses()
Returns the configured import version class names.

Returns:
the configured import version class names

getOldWebAppUrl

public String getOldWebAppUrl()
Returns the URL of a 4.x OpenCms app. (e.g. http://localhost:8080/opencms/opencms/) from which content was exported.

This setting is required to import content of 4.x OpenCms apps. correct into 5.x OpenCms apps.

Returns:
the webAppUrl.

importData

public void importData(CmsObject cms,
                       String importFile,
                       String importPath,
                       I_CmsReport report)
                throws CmsImportExportException,
                       CmsXmlException,
                       CmsRoleViolationException,
                       CmsException
Checks if the current user has permissions to import data into the Cms, and if so, creates a new import handler instance that imports the data.

Parameters:
cms - the current OpenCms context object
importFile - the name (absolute path) of the resource (zipfile or folder) to be imported
importPath - the name (absolute path) of the destination folder in the Cms if required, or null
report - a Cms report to print log messages
Throws:
CmsRoleViolationException - if the current user is not allowed to import the OpenCms database
CmsImportExportException - if operation was not successful
CmsXmlException - if the manifest of the import could not be unmarshalled
CmsException - in case of errors accessing the VFS
See Also:
I_CmsImportExportHandler

overwriteCollidingResources

public boolean overwriteCollidingResources()
Checks if colliding resources should be overwritten during the import.

Returns:
true, if colliding resources should be overwritten during the import
See Also:
setOverwriteCollidingResources(boolean)

setConvertToXmlPage

public void setConvertToXmlPage(boolean convertToXmlPage)
Sets if imported pages should be converted into XML pages.

Parameters:
convertToXmlPage - true, if imported pages should be converted into XML pages.

setConvertToXmlPage

public void setConvertToXmlPage(String convertToXmlPage)
Sets if imported pages should be converted into XML pages.

Parameters:
convertToXmlPage - "true", if imported pages should be converted into XML pages.

setOldWebAppUrl

public void setOldWebAppUrl(String webAppUrl)
Sets the URL of a 4.x OpenCms app. (e.g. http://localhost:8080/opencms/opencms/) from which content was exported.

This setting is required to import content of 4.x OpenCms apps. correct into 5.x OpenCms apps.

Parameters:
webAppUrl - a URL of the a OpenCms app. (e.g. http://localhost:8080/opencms/opencms/)

setOverwriteCollidingResources

public void setOverwriteCollidingResources(boolean overwriteCollidingResources)
Sets whether colliding resources should be overwritten during the import for a specified import implementation.

v1 and v2 imports (without resource UUIDs in the manifest) *MUST* overwrite colliding resources. Don't forget to set this flag back to it's original value in v1 and v2 import implementations!

This flag must be set to false to force imports > v2 to move colliding resources to /system/lost-found/.

The import implementation has to take care to set this flag correct!

Parameters:
overwriteCollidingResources - true if colliding resources should be overwritten during the import

setOverwriteCollidingResources

public void setOverwriteCollidingResources(String overwriteCollidingResources)
Parameters:
overwriteCollidingResources - "true" if colliding resources should be overwritten during the import
See Also:
setOverwriteCollidingResources(boolean)

translateGroup

public String translateGroup(String name)
Returns the translated name for the given group name.

If no matching name is found, the given group name is returned.

Parameters:
name - the group name to translate
Returns:
the translated name for the given group name

translateUser

public String translateUser(String name)
Returns the translated name for the given user name.

If no matching name is found, the given user name is returned.

Parameters:
name - the user name to translate
Returns:
the translated name for the given user name

finalize

protected void finalize()
                 throws Throwable
Throws:
Throwable
See Also:
Object.finalize()