org.opencms.importexport
Class A_CmsImport

java.lang.Object
  extended by org.opencms.importexport.A_CmsImport
All Implemented Interfaces:
I_CmsImport
Direct Known Subclasses:
CmsImportVersion2, CmsImportVersion3, CmsImportVersion4, CmsImportVersion5

public abstract class A_CmsImport
extends java.lang.Object
implements I_CmsImport

Collection of common used methods for implementing OpenCms Import classes.

This class does not implement a real OpenCms import, real import implmentation should be inherited form this class.

Since:
6.0.0
Version:
$Revision: 1.85 $
Author:
Michael Emmerich, Thomas Weckert
See Also:
I_CmsImport

Field Summary
protected static int DEBUG
          Debug flag to show debug output.
protected  CmsObject m_cms
          The cms context to do the import operations with.
protected  boolean m_convertToXmlPage
          Flag for conversion to xml pages.
protected  org.dom4j.Document m_docXml
          The xml manifest-file.
protected  java.util.Stack m_groupsToCreate
          Groups to create during import are stored here.
protected  java.lang.String m_importPath
          The import-path to write resources into the cms.
protected  java.io.File m_importResource
          The import-resource (folder) to load resources from.
protected  java.util.zip.ZipFile m_importZip
          The import-resource (zip) to load resources from.
protected  java.util.Map m_linkPropertyStorage
          Storage for all pointer properties which must be converted into links.
protected  java.util.Map m_linkStorage
          Storage for all pointers which must be converted into links.
protected  I_CmsReport m_report
          The object to report the log messages.
protected  I_CmsMessageBundle m_userMessages
          Messages object with the locale of the current user.
static java.lang.String RESOURCE_TYPE_LEGACY_PAGE_NAME
          The name of the legacy resource type "page".
protected static int RESOURCE_TYPE_LINK_ID
          The id of the legacy resource type "link".
protected static java.lang.String RESOURCE_TYPE_LINK_NAME
          The name of the legacy resource type "link".
protected static int RESOURCE_TYPE_NEWPAGE_ID
          The id of the legacy resource type "newpage".
protected static java.lang.String RESOURCE_TYPE_NEWPAGE_NAME
          The name of the legacy resource type "newpage".
 
Constructor Summary
A_CmsImport()
           
 
Method Summary
protected  boolean checkImmutable(java.lang.String translatedName, java.util.List immutableResources)
          Checks if the resources is in the list of immutalbe resources.
protected  void cleanUp()
          Cleans up member variables after the import is finished.
 java.lang.String convertDigestEncoding(java.lang.String value)
          Converts a given digest to base64 encoding.
protected  void convertPointerToSiblings()
          Converts old style pointers to siblings if possible.
protected  byte[] getFileBytes(java.lang.String filename)
          Returns a byte array containing the content of the file.
protected  CmsAccessControlEntry getImportAccessControlEntry(CmsResource res, java.lang.String id, java.lang.String allowed, java.lang.String denied, java.lang.String flags)
          Creates a new access control entry and stores it for later write out.
protected  java.util.Locale getLocale(java.lang.String destination, java.util.List properties)
          Returns the appropriate locale for the given destination.
protected  void importAccessControlEntries(CmsResource resource, java.util.List aceList)
          Writes alread imported access control entries for a given resource.
protected  void importGroup(java.lang.String name, java.lang.String description, java.lang.String flags, java.lang.String parentgroupName)
          Imports a single group.
protected  void importGroups()
          Imports the OpenCms groups.
protected  void importUser(java.lang.String name, java.lang.String flags, java.lang.String password, java.lang.String firstname, java.lang.String lastname, java.lang.String email, long dateCreated, java.util.Map userInfo, java.util.List userGroups)
          Imports a single user.
protected  void importUsers()
          Imports the OpenCms users.
protected  void initialize()
          Initializes all member variables before the import is started.
protected  java.util.List readPropertiesFromManifest(org.dom4j.Element parentElement, java.util.List ignoredPropertyKeys)
          Reads all properties below a specified parent element from the manifest.xml.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.opencms.importexport.I_CmsImport
getVersion, importResources
 

Field Detail

RESOURCE_TYPE_LEGACY_PAGE_NAME

public static final java.lang.String RESOURCE_TYPE_LEGACY_PAGE_NAME
The name of the legacy resource type "page".

See Also:
Constant Field Values

DEBUG

protected static final int DEBUG
Debug flag to show debug output.

See Also:
Constant Field Values

RESOURCE_TYPE_LINK_ID

protected static final int RESOURCE_TYPE_LINK_ID
The id of the legacy resource type "link".

See Also:
Constant Field Values

RESOURCE_TYPE_LINK_NAME

protected static final java.lang.String RESOURCE_TYPE_LINK_NAME
The name of the legacy resource type "link".

See Also:
Constant Field Values

RESOURCE_TYPE_NEWPAGE_ID

protected static final int RESOURCE_TYPE_NEWPAGE_ID
The id of the legacy resource type "newpage".

See Also:
Constant Field Values

RESOURCE_TYPE_NEWPAGE_NAME

protected static final java.lang.String RESOURCE_TYPE_NEWPAGE_NAME
The name of the legacy resource type "newpage".

See Also:
Constant Field Values

m_cms

protected CmsObject m_cms
The cms context to do the import operations with.


m_convertToXmlPage

protected boolean m_convertToXmlPage
Flag for conversion to xml pages.


m_docXml

protected org.dom4j.Document m_docXml
The xml manifest-file.


m_groupsToCreate

protected java.util.Stack m_groupsToCreate
Groups to create during import are stored here.


m_importPath

protected java.lang.String m_importPath
The import-path to write resources into the cms.


m_importResource

protected java.io.File m_importResource
The import-resource (folder) to load resources from.


m_importZip

protected java.util.zip.ZipFile m_importZip
The import-resource (zip) to load resources from.


m_linkPropertyStorage

protected java.util.Map m_linkPropertyStorage
Storage for all pointer properties which must be converted into links.


m_linkStorage

protected java.util.Map m_linkStorage
Storage for all pointers which must be converted into links.


m_report

protected I_CmsReport m_report
The object to report the log messages.


m_userMessages

protected I_CmsMessageBundle m_userMessages
Messages object with the locale of the current user.

Constructor Detail

A_CmsImport

public A_CmsImport()
Method Detail

convertDigestEncoding

public java.lang.String convertDigestEncoding(java.lang.String value)
Converts a given digest to base64 encoding.

Parameters:
value - the digest value in the legacy encoding
Returns:
the digest in the new encoding

checkImmutable

protected boolean checkImmutable(java.lang.String translatedName,
                                 java.util.List immutableResources)
Checks if the resources is in the list of immutalbe resources.

Parameters:
translatedName - the name of the resource
immutableResources - the list of the immutable resources
Returns:
true or false

cleanUp

protected void cleanUp()
Cleans up member variables after the import is finished.

This is required since there is only one instance for each import version that is kept in memory and reused.


convertPointerToSiblings

protected void convertPointerToSiblings()
Converts old style pointers to siblings if possible.


getFileBytes

protected byte[] getFileBytes(java.lang.String filename)
Returns a byte array containing the content of the file.

Parameters:
filename - the name of the file to read
Returns:
a byte array containing the content of the file

getImportAccessControlEntry

protected CmsAccessControlEntry getImportAccessControlEntry(CmsResource res,
                                                            java.lang.String id,
                                                            java.lang.String allowed,
                                                            java.lang.String denied,
                                                            java.lang.String flags)
Creates a new access control entry and stores it for later write out.

Parameters:
res - the resource
id - the id of the principal
allowed - the allowed permissions
denied - the denied permissions
flags - the flags
Returns:
the created ACE

getLocale

protected java.util.Locale getLocale(java.lang.String destination,
                                     java.util.List properties)
Returns the appropriate locale for the given destination.

Parameters:
destination - the destination path (parent must exist)
properties - the properties to check at first
Returns:
the locale

importAccessControlEntries

protected void importAccessControlEntries(CmsResource resource,
                                          java.util.List aceList)
Writes alread imported access control entries for a given resource.

Parameters:
resource - the resource assigned to the access control entries
aceList - the access control entries to create

importGroup

protected void importGroup(java.lang.String name,
                           java.lang.String description,
                           java.lang.String flags,
                           java.lang.String parentgroupName)
                    throws CmsImportExportException
Imports a single group.

Parameters:
name - the name of the group
description - group description
flags - group flags
parentgroupName - name of the parent group
Throws:
CmsImportExportException - if something goes wrong

importGroups

protected void importGroups()
                     throws CmsImportExportException
Imports the OpenCms groups.

Throws:
CmsImportExportException - if something goes wrong

importUser

protected void importUser(java.lang.String name,
                          java.lang.String flags,
                          java.lang.String password,
                          java.lang.String firstname,
                          java.lang.String lastname,
                          java.lang.String email,
                          long dateCreated,
                          java.util.Map userInfo,
                          java.util.List userGroups)
                   throws CmsImportExportException
Imports a single user.

Parameters:
name - user name
flags - user flags
password - user password
firstname - firstname of the user
lastname - lastname of the user
email - user email
dateCreated - creation date
userInfo - user info
userGroups - user groups
Throws:
CmsImportExportException - in case something goes wrong

importUsers

protected void importUsers()
                    throws CmsImportExportException
Imports the OpenCms users.

Throws:
CmsImportExportException - if something goes wrong

initialize

protected void initialize()
Initializes all member variables before the import is started.

This is required since there is only one instance for each import version that is kept in memory and reused.


readPropertiesFromManifest

protected java.util.List readPropertiesFromManifest(org.dom4j.Element parentElement,
                                                    java.util.List ignoredPropertyKeys)
Reads all properties below a specified parent element from the manifest.xml.

Parameters:
parentElement - the current file node
ignoredPropertyKeys - a list of properies to be ignored
Returns:
a list with all properties