info.magnolia.module.data.importer
Class ImportHandler

java.lang.Object
  extended by info.magnolia.module.data.importer.ImportHandler
Direct Known Subclasses:
CompanyImportHandler, SimpleImportHandler

public abstract class ImportHandler
extends Object

This abstract class represents the basic configuration for an importer. It manages the single import targets and the optional automatic execution. Extend this class to provide your own importer.

Version:
$Revision$ ($Author$)
Author:
Enrico Kufahl (BeagleSoft GmbH)

Field Summary
protected  boolean activateImport
           
protected  info.magnolia.module.scheduler.AutomatedExecutionConfig automatedExecution
           
protected  boolean backup
           
protected  File backupFile
           
protected  boolean deleteOldData
           
protected  boolean lockDuringImport
           
static int MILLI_2_HOUR
          Deprecated. since 1.3.1
protected  String name
           
static String NODE_DATA_IMPORT_STATE
           
static String NODE_DATA_IMPORT_STATE_NEW
           
static String NODE_DATA_IMPORT_STATE_OLD
           
static String NODE_DATA_USED_IMPORTER_TARGET
           
protected  String repository
           
protected  boolean running
           
protected  List<ImportTarget> targets
           
 
Constructor Summary
ImportHandler()
           
 
Method Summary
 void addTarget(ImportTarget target)
           
protected  void backup(ImportTarget target)
           
protected  void checkPreConditions()
           
protected  Set<String> collectOldContent(ImportTarget target, info.magnolia.cms.core.Content parent, Set<String> uuids)
          Searches for all content that have been imported (and tagged during import) with the target of given name.
 void destroy()
          Destroys this importer and the optional timer.
protected abstract  Set<String> doImport(ImportTarget target, info.magnolia.cms.core.Content parent, Set<String> uuids)
          Implement this method to do the import job.
protected  void doPostImport(ImportTarget target, Collection<String> oldContent, Collection<String> newContent)
           
 void execute()
          Public accessible method for manual import execution.
protected  void executeImport()
          Executes all import targets for this importer.
 info.magnolia.module.scheduler.AutomatedExecutionConfig getAutomatedExecution()
           
 String getName()
           
protected  info.magnolia.cms.core.Content getParent(info.magnolia.cms.core.HierarchyManager hm, ImportTarget target)
           
 String getRepository()
           
 List<ImportTarget> getTargets()
           
 boolean isActivateImport()
           
 boolean isBackup()
           
 boolean isDeleteOldData()
           
 boolean isLockDuringImport()
           
protected  void lock(info.magnolia.cms.core.HierarchyManager hm, ImportTarget target)
           
protected  void restore(ImportTarget target)
           
 void setActivateImport(boolean activateImport)
           
 void setAutomatedExecution(info.magnolia.module.scheduler.AutomatedExecutionConfig automaticExecution)
           
 void setBackup(boolean backup)
           
 void setDeleteOldData(boolean deleteOldData)
           
protected  void setImportState(Set<String> uuids, String state, ImportTarget target, info.magnolia.cms.core.HierarchyManager hm)
          Sets the given import state for the given imported content.
 void setLockDuringImport(boolean locking)
           
 void setName(String name)
           
 void setRepository(String repository)
           
 void setTargets(List<ImportTarget> targets)
           
protected  void unlock(info.magnolia.cms.core.HierarchyManager hm, ImportTarget target)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MILLI_2_HOUR

@Deprecated
public static final int MILLI_2_HOUR
Deprecated. since 1.3.1
See Also:
Constant Field Values

targets

protected List<ImportTarget> targets

running

protected boolean running

name

protected String name

repository

protected String repository

activateImport

protected boolean activateImport

deleteOldData

protected boolean deleteOldData

lockDuringImport

protected boolean lockDuringImport

automatedExecution

protected info.magnolia.module.scheduler.AutomatedExecutionConfig automatedExecution

backup

protected boolean backup

NODE_DATA_USED_IMPORTER_TARGET

public static final String NODE_DATA_USED_IMPORTER_TARGET
See Also:
Constant Field Values

NODE_DATA_IMPORT_STATE

public static final String NODE_DATA_IMPORT_STATE
See Also:
Constant Field Values

NODE_DATA_IMPORT_STATE_OLD

public static final String NODE_DATA_IMPORT_STATE_OLD
See Also:
Constant Field Values

NODE_DATA_IMPORT_STATE_NEW

public static final String NODE_DATA_IMPORT_STATE_NEW
See Also:
Constant Field Values

backupFile

protected File backupFile
Constructor Detail

ImportHandler

public ImportHandler()
Method Detail

getName

public String getName()

setName

public void setName(String name)

getAutomatedExecution

public info.magnolia.module.scheduler.AutomatedExecutionConfig getAutomatedExecution()

setAutomatedExecution

public void setAutomatedExecution(info.magnolia.module.scheduler.AutomatedExecutionConfig automaticExecution)

isLockDuringImport

public boolean isLockDuringImport()

setLockDuringImport

public void setLockDuringImport(boolean locking)

getRepository

public String getRepository()

setRepository

public void setRepository(String repository)

isDeleteOldData

public boolean isDeleteOldData()

setDeleteOldData

public void setDeleteOldData(boolean deleteOldData)

isActivateImport

public boolean isActivateImport()

setActivateImport

public void setActivateImport(boolean activateImport)

getTargets

public List<ImportTarget> getTargets()

setTargets

public void setTargets(List<ImportTarget> targets)

addTarget

public void addTarget(ImportTarget target)

executeImport

protected void executeImport()
                      throws ImportException
Executes all import targets for this importer.

Throws:
info.magnolia.cms.security.AccessDeniedException
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException
info.magnolia.cms.exchange.ExchangeException
ImportException

unlock

protected void unlock(info.magnolia.cms.core.HierarchyManager hm,
                      ImportTarget target)
               throws ImportException
Throws:
ImportException

lock

protected void lock(info.magnolia.cms.core.HierarchyManager hm,
                    ImportTarget target)
             throws ImportException
Throws:
ImportException

getParent

protected info.magnolia.cms.core.Content getParent(info.magnolia.cms.core.HierarchyManager hm,
                                                   ImportTarget target)
                                            throws ImportException
Throws:
ImportException

checkPreConditions

protected void checkPreConditions()
                           throws ImportException
Throws:
ImportException

restore

protected void restore(ImportTarget target)
                throws ImportException
Throws:
ImportException

backup

protected void backup(ImportTarget target)
               throws ImportException
Throws:
ImportException

collectOldContent

protected Set<String> collectOldContent(ImportTarget target,
                                        info.magnolia.cms.core.Content parent,
                                        Set<String> uuids)
Searches for all content that have been imported (and tagged during import) with the target of given name. Please note that changing the target name after the import means that the stale content will not be deleted when running the importer next time.

Parameters:
target - Target used to import the original content
parent - Parent path into which the content was imported
uuids - Set into which the UUIDs of the content should be collected.
Returns:
Set of the UUIDs that were previously imported by provided target into the specified path.

doPostImport

protected void doPostImport(ImportTarget target,
                            Collection<String> oldContent,
                            Collection<String> newContent)
                     throws ImportException
Throws:
ImportException

setImportState

protected void setImportState(Set<String> uuids,
                              String state,
                              ImportTarget target,
                              info.magnolia.cms.core.HierarchyManager hm)
                       throws info.magnolia.cms.security.AccessDeniedException,
                              javax.jcr.PathNotFoundException,
                              javax.jcr.RepositoryException
Sets the given import state for the given imported content.

Parameters:
uuids - the uuids of the nodes we like to set the status on
state - the state to set
target - the target used for the import
Throws:
info.magnolia.cms.security.AccessDeniedException
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException

doImport

protected abstract Set<String> doImport(ImportTarget target,
                                        info.magnolia.cms.core.Content parent,
                                        Set<String> uuids)
                                 throws ImportException
Implement this method to do the import job.

Parameters:
target - the import target to use
parent - the node to import below
uuids - ordered set containing the uuids
Returns:
uuids of the imported nodes
Throws:
ImportException

destroy

public void destroy()
Destroys this importer and the optional timer. If the importer is still running this method blocks until the importer is ready.


execute

public void execute()
             throws ImportException
Public accessible method for manual import execution.

Throws:
ImportException

isBackup

public boolean isBackup()

setBackup

public void setBackup(boolean backup)


Copyright © 2012 Magnolia International Ltd.. All Rights Reserved.