info.magnolia.module.data
Class DataModule

java.lang.Object
  extended by info.magnolia.module.data.DataModule
All Implemented Interfaces:
info.magnolia.module.ModuleLifecycle

public class DataModule
extends Object
implements info.magnolia.module.ModuleLifecycle

This class handles the basic installation and configuration of the data module.

Version:
$Revision$ ($Author$)
Author:
Christoph Hoffmann (BeagleSoft GmbH), Bert Leunis (Neteffect, Amsterdam)

Field Summary
static MessageFormat NODE_TYPE_DEF_TEMPLATE
           
protected static String NODE_TYPE_DEFINITION
          Node type template for registering node types for the single types.
protected static String repository
           
 
Constructor Summary
DataModule()
           
 
Method Summary
 void addImporter(String name, ImportHandler importer)
           
 void addType(String name, TypeDefinition type)
           
protected  void createRootPath(TypeDefinition type)
          Create the root path in the repository if it does not exist yet.
 ImportHandler getImporter(String name)
           
 Map<String,ImportHandler> getImporters()
           
static DataModule getInstance()
           
static String getRepository()
           
 TypeDefinition getType(String name)
          Deprecated. since 1.4 Use getTypeDefinitionByName(String) instead.
 TypeDefinition getTypeDefinitionByName(String itemName)
           
 List<TypeDefinition> getTypeDefinitions()
          Get all TypeDefinitions.
 List<TypeDefinition> getTypeDefinitionsByRootPath(String rootPath)
          Get all TypeDefinitions that have a specified root path.
 Map<String,TypeDefinition> getTypes()
           
protected  void initChildTypes(info.magnolia.cms.core.Content parent, int level, String rootPath, Map<String,TypeDefinition> tempTypeNodes)
          Loads TypeDefinition child nodes from the repository.
protected  void initType(TypeDefinition type)
          Initializes the given type.
protected  void registerCustomTypes()
          Registers node types in the repository, creates rootpaths and menu items if necessary.
protected  void registerNodeType(TypeDefinition type)
          Deprecated. since 1.4 This method doesn't seem to be used anywhere. Use DataUtil.registerNodeType(TypeDefinition) instead
 void setImporters(Map<String,ImportHandler> importers)
           
 void setTypes(Map<String,TypeDefinition> types)
           
 void start(info.magnolia.module.ModuleLifecycleContext moduleLifecycleContext)
          Initialization of the module, means registration of all types and the corresponding dialogs and trees and optional importers.
 void stop(info.magnolia.module.ModuleLifecycleContext moduleLifecycleContext)
           
protected  void updateDataMenu(TypeDefinition type)
          Updates the sub menus for the data module menu based on the given type configuration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

repository

protected static String repository

NODE_TYPE_DEFINITION

protected static final String NODE_TYPE_DEFINITION
Node type template for registering node types for the single types.

See Also:
Constant Field Values

NODE_TYPE_DEF_TEMPLATE

public static final MessageFormat NODE_TYPE_DEF_TEMPLATE
Constructor Detail

DataModule

public DataModule()
Method Detail

getInstance

public static DataModule getInstance()

start

public void start(info.magnolia.module.ModuleLifecycleContext moduleLifecycleContext)
Initialization of the module, means registration of all types and the corresponding dialogs and trees and optional importers.

Specified by:
start in interface info.magnolia.module.ModuleLifecycle

stop

public void stop(info.magnolia.module.ModuleLifecycleContext moduleLifecycleContext)
Specified by:
stop in interface info.magnolia.module.ModuleLifecycle

registerCustomTypes

protected void registerCustomTypes()
Registers node types in the repository, creates rootpaths and menu items if necessary.


initType

protected void initType(TypeDefinition type)
                 throws javax.jcr.RepositoryException
Initializes the given type. IF the type was not registered yet, method will attempt to register the type with the repository.

Parameters:
type - Type to be initialized.
Throws:
javax.jcr.RepositoryException - when node type can't be registered. Most often this happens when the node type of given name already exists or when the definition is invalid

createRootPath

protected void createRootPath(TypeDefinition type)
Create the root path in the repository if it does not exist yet.


updateDataMenu

protected void updateDataMenu(TypeDefinition type)
Updates the sub menus for the data module menu based on the given type configuration.

Parameters:
type - the configuration of the data type

initChildTypes

protected void initChildTypes(info.magnolia.cms.core.Content parent,
                              int level,
                              String rootPath,
                              Map<String,TypeDefinition> tempTypeNodes)
Loads TypeDefinition child nodes from the repository. WARN: This method is called recursively, might cause stack size issues for very deep (+100) hierarchies.

Parameters:
parent - root or parent type node
level - the level of the nested types
rootPath - the parents rootPath or null

getRepository

public static String getRepository()
Returns:
Returns the repository.

registerNodeType

@Deprecated
protected void registerNodeType(TypeDefinition type)
                         throws javax.jcr.RepositoryException
Deprecated. since 1.4 This method doesn't seem to be used anywhere. Use DataUtil.registerNodeType(TypeDefinition) instead

Registers a new node type for the given repository and type.

Throws:
javax.jcr.RepositoryException

getImporters

public Map<String,ImportHandler> getImporters()

setImporters

public void setImporters(Map<String,ImportHandler> importers)

getImporter

public ImportHandler getImporter(String name)

addImporter

public void addImporter(String name,
                        ImportHandler importer)

getTypeDefinitions

public List<TypeDefinition> getTypeDefinitions()
Get all TypeDefinitions.


getTypeDefinitionsByRootPath

public List<TypeDefinition> getTypeDefinitionsByRootPath(String rootPath)
Get all TypeDefinitions that have a specified root path.

Parameters:
rootPath -

getTypeDefinitionByName

public TypeDefinition getTypeDefinitionByName(String itemName)

getTypes

public Map<String,TypeDefinition> getTypes()

setTypes

public void setTypes(Map<String,TypeDefinition> types)

addType

public void addType(String name,
                    TypeDefinition type)

getType

public TypeDefinition getType(String name)
Deprecated. since 1.4 Use getTypeDefinitionByName(String) instead.



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