nl.gx.webmanager.wcb.foundation
Class ComponentTypeBase

java.lang.Object
  extended by nl.gx.webmanager.wcb.foundation.ComponentBase
      extended by nl.gx.webmanager.wcb.foundation.ComponentTypeBase
All Implemented Interfaces:
DelegatedControllerAware, Component, ComponentType
Direct Known Subclasses:
ElementComponentTypeImpl, FormComponentTypeImpl, MediaItemComponentTypeImpl, PageMetaDataComponentTypeImpl, PanelComponentTypeImpl, PresentationComponentTypeImpl, ProfileProviderComponentTypeImpl, ServiceComponentTypeImpl, ServletComponentTypeImpl

public abstract class ComponentTypeBase
extends ComponentBase
implements ComponentType

Base class for component type's containing utility functions that are used in component type implementations.

Author:
bramk

Field Summary
protected  JcrRepository myJcrService
           
protected  nl.gx.siteworks.util.SiteworksUtil mySiteworksUtil
           
 
Fields inherited from class nl.gx.webmanager.wcb.foundation.ComponentBase
myBundleContext, myComponentBundle, myComponentDefinition
 
Constructor Summary
ComponentTypeBase()
           
 
Method Summary
 boolean checkComponentDefinition(ComponentDefinition componentDefinition)
          Check whether a componentDefinition is valid for this componentType.
 void componentAdded(org.osgi.framework.ServiceReference serviceReference, java.lang.Object service)
          Adds a reference of the component service to the local map.
 void componentRemoved(org.osgi.framework.ServiceReference serviceReference, java.lang.Object service)
          Removes a reference of the component service to the local map.
protected  void createEditLanguageLabels(ComponentDefinition componentDefinition, nl.gx.siteworks.core.HtmlObject object, java.lang.String key)
          Create language edit labels.
protected  nl.gx.siteworks.core.HtmlObject createOrUpdatePermissions(ComponentDefinition componentDefinition)
          Creates or updates the permissions as defined in the component definition and returns the rbac category to which the permissions are assigned.
protected  nl.gx.siteworks.core.HtmlObject createOrUpdatePermissions(MenuItemComponentDefinition componentDefinition, nl.gx.siteworks.core.HtmlObject menuItem)
          Creates or updates the permissions as defined in the component definition and returns the rbac category to which the permissions are assigned.
protected  nl.gx.siteworks.core.HtmlObject createOrUpdateRbacCategory(MenuItemComponentDefinition componentDefinition)
          Creates or updates the rbac category as defined in the component definition and returns it.
protected  nl.gx.siteworks.core.HtmlObject createPermission(Permission permission, ComponentDefinition componentDefinition, nl.gx.siteworks.core.HtmlObject rbacCategory)
          Creates and returns a single persistent rbac permission HtmlObject based on the given Permission and ComponentDefinition object and assigns it to the given rbac category HtmlObject.
protected  nl.gx.siteworks.core.HtmlObject createPermission(Permission permission, MenuItemComponentDefinition componentDefinition, nl.gx.siteworks.core.HtmlObject rbacCategory, nl.gx.siteworks.core.HtmlObject menuItem)
          Creates and returns a single persistent rbac permission HtmlObject based on the given Permission and ComponentDefinition object and assigns it to the given rbac category HtmlObject and associates it with the given menu item HtmlObject in the WebManager menu structure.
protected  void createPermissions(ComponentDefinition componentDefinition)
          Creates the permissions as defined in the component definition.
protected  void createPermissions(MenuItemComponentDefinition componentDefinition, nl.gx.siteworks.core.HtmlObject menuItem)
          Creates the permissions as defined in the component definition.
protected  void deleteEditLanguageLabels(nl.gx.siteworks.core.HtmlObject htmlObject)
          Deletes all language labels from the given HtmlObject object.
protected  void deletePermissions(ComponentDefinition componentDefinition)
          Deletes the permissions as defined in the component definition.
protected  void deletePermissions(MenuItemComponentDefinition componentDefinition)
          Deletes the permissions as defined in the component definition.
protected  void disableMenuItems(MenuItemComponentDefinition componentDefinition, java.lang.String menuType)
          Disables the menu items for the component by de-assigning them from the permission free menu items or from the corresponding rbac permissions.
protected  void enableMenuItems(MenuItemComponentDefinition componentDefinition, java.lang.String menuType)
          Enables the menu items for the component by assigning them to the permission free menu items or to the corresponding rbac permissions.
 Component getComponent(java.lang.String id)
          Get a registered component by id.
 int getComponentCount()
          Get the number of registered components for this componentType.
 ComponentManager getComponentManager()
          Get the componentManager.
 Component[] getComponents()
          Get an array of registered component for this componentType.
protected static java.lang.String getLocaleIdFromResourceName(java.lang.String resourceName)
          Returns the programmatic name of the entire locale, based on the name of a resource file, with the language, country and variant separated by underbars.
protected  org.osgi.service.prefs.PreferencesService getPreferencesService()
          Override this method to return the preferences service.
protected  boolean grantsMenuItemAccess(MenuItemComponentDefinition componentDefinition, Permission permission)
          Returns if the given permission should grant the user access to the element menu item, according to the component definition
protected  void insertIntoMainMenu(MenuItemComponentDefinition componentDefinition, nl.gx.siteworks.core.HtmlObject menuStructureItem)
          Creates the permissions as defined in the component definition.
 boolean installComponent(ComponentDefinition componentDefinition)
          Invoked when a component of this component type is installed.
protected  void logError(java.lang.String error, java.lang.Exception e, ComponentDefinition compDef)
          Log an error message that installation, update, purge or uninstallation failed.
 boolean purgeComponent(ComponentDefinition componentDefinition)
          Deletes the content created by instances of the component type.
abstract  boolean startComponent(Component component)
          Starts an installed component.
abstract  boolean stopComponent(Component component)
          Stops an installed component.
 boolean uninstallComponent(ComponentDefinition componentDefinition)
          Uninstalls a component.
 boolean updateComponent(ComponentDefinition componentDefinition)
          Updates a component.
protected  void updatePermissionsForPermissionGroups(ComponentDefinition componentDefinition)
          Updates the permissions assigned to the permission groups Can be invoked both from install and update
 
Methods inherited from class nl.gx.webmanager.wcb.foundation.ComponentBase
dependencyAdded, dependencyRemoved, exportContent, extensionAdded, extensionRemoved, getBundleContext, getClassesFromBundle, getClassForName, getComponentBundle, getComponentDefinition, getDelegatedController, getExtensions, getId, getInstance, getInstanceForName, getPrivateNode, getPrivateNode, getTypeId, getWrapperDefinitions, importContent, internalDoStart, internalDoStop, onDestroy, onInit, onInstall, onPurge, onStart, onStop, onUninstall, onUpdate, purgeContent, setBundleContext, setComponentBundle, setComponentBundle, setComponentDefinition, setComponentManager, setDelegatedController
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface nl.gx.webmanager.wcb.ComponentType
getComponentInterface, getComponentTypeInterface
 

Field Detail

myJcrService

protected JcrRepository myJcrService

mySiteworksUtil

protected nl.gx.siteworks.util.SiteworksUtil mySiteworksUtil
Constructor Detail

ComponentTypeBase

public ComponentTypeBase()
Method Detail

getComponentManager

public ComponentManager getComponentManager()
Get the componentManager.

Overrides:
getComponentManager in class ComponentBase
Returns:
the componentmanager

installComponent

public boolean installComponent(ComponentDefinition componentDefinition)
Invoked when a component of this component type is installed. The component type implements installation logic that is applicable for all components of this type and then invokes onInstall to allow inherited component types to implement additional logic. The onInstall callback method is only invoked if the generic component installation logic was successful.

Specified by:
installComponent in interface ComponentType
Parameters:
componentDefinition - Definition of the component that is to be installed
Returns:
true if the component was successfully installed

updateComponent

public boolean updateComponent(ComponentDefinition componentDefinition)
Updates a component.

Specified by:
updateComponent in interface ComponentType
Parameters:
componentDefinition - Definition of the component that is to be installed
Returns:
true if the component was successfully updated

purgeComponent

public boolean purgeComponent(ComponentDefinition componentDefinition)
Deletes the content created by instances of the component type.

Specified by:
purgeComponent in interface ComponentType
Parameters:
componentDefinition - Definition of the component that is to be purged
Returns:
true if the component was successfully purged

uninstallComponent

public boolean uninstallComponent(ComponentDefinition componentDefinition)
Uninstalls a component. Uninstalling means all files and objects instantiated by the component's definition are deleted.

Specified by:
uninstallComponent in interface ComponentType
Parameters:
componentDefinition - Definition of the component that is to be uninstalled
Returns:
true if the component was successfully uninstalled

startComponent

public abstract boolean startComponent(Component component)
Starts an installed component.

Specified by:
startComponent in interface ComponentType
Parameters:
component - Component that should be started
Returns:
true if the component was successfully started

stopComponent

public abstract boolean stopComponent(Component component)
Stops an installed component.

Specified by:
stopComponent in interface ComponentType
Parameters:
component - Component that should be started
Returns:
true if the component was successfully stopped

checkComponentDefinition

public boolean checkComponentDefinition(ComponentDefinition componentDefinition)
Check whether a componentDefinition is valid for this componentType.

Specified by:
checkComponentDefinition in interface ComponentType
Parameters:
componentDefinition - definition of a component that is validated
Returns:
a boolean value indicating whether the componentDefinition is valid

getComponent

public Component getComponent(java.lang.String id)
Get a registered component by id.

Specified by:
getComponent in interface ComponentType
Parameters:
id - Unique identifier representing the component
Returns:
an array of registered component for this componentType.

getComponents

public Component[] getComponents()
Get an array of registered component for this componentType.

Specified by:
getComponents in interface ComponentType
Returns:
an array of registered component for this componentType.

getComponentCount

public int getComponentCount()
Get the number of registered components for this componentType.

Specified by:
getComponentCount in interface ComponentType
Returns:
the number of registered component for this componentType.

getPreferencesService

protected org.osgi.service.prefs.PreferencesService getPreferencesService()
Override this method to return the preferences service.

Returns:
The preferences service

componentAdded

public final void componentAdded(org.osgi.framework.ServiceReference serviceReference,
                                 java.lang.Object service)
Adds a reference of the component service to the local map. Call-back method of the dependency manager.

Parameters:
serviceReference - Component service reference.
service - Component service.

componentRemoved

public final void componentRemoved(org.osgi.framework.ServiceReference serviceReference,
                                   java.lang.Object service)
Removes a reference of the component service to the local map. Call-back method of the dependency manager.

Parameters:
serviceReference - Component service reference.
service - Component service.

getLocaleIdFromResourceName

protected static java.lang.String getLocaleIdFromResourceName(java.lang.String resourceName)
Returns the programmatic name of the entire locale, based on the name of a resource file, with the language, country and variant separated by underbars. Language (ISO 639) is always lower case, and country (ISO 3166) is always upper case.

Parameters:
resourceName - Name of the resource file from which the programmatic name is to be extracted.
Returns:
Programmatic name of the entire locale

enableMenuItems

protected void enableMenuItems(MenuItemComponentDefinition componentDefinition,
                               java.lang.String menuType)
                        throws nl.gx.siteworks.core.HtmlObjectNotFoundException
Enables the menu items for the component by assigning them to the permission free menu items or to the corresponding rbac permissions.

Parameters:
componentDefinition - Component definition to enable menu items for
Throws:
nl.gx.siteworks.core.HtmlObjectNotFoundException

disableMenuItems

protected void disableMenuItems(MenuItemComponentDefinition componentDefinition,
                                java.lang.String menuType)
                         throws nl.gx.siteworks.core.HtmlObjectNotFoundException
Disables the menu items for the component by de-assigning them from the permission free menu items or from the corresponding rbac permissions.

Parameters:
componentDefinition - Component definition to disable menu items for
Throws:
nl.gx.siteworks.core.HtmlObjectNotFoundException

createEditLanguageLabels

protected void createEditLanguageLabels(ComponentDefinition componentDefinition,
                                        nl.gx.siteworks.core.HtmlObject object,
                                        java.lang.String key)
                                 throws nl.gx.siteworks.core.DuplicateNameException
Create language edit labels.

Parameters:
componentDefinition - Component definition containing the language resources to read the labels from
object - Object to assign the created label to
key - Key to load the label from the language resources
Throws:
nl.gx.siteworks.core.DuplicateNameException

deleteEditLanguageLabels

protected void deleteEditLanguageLabels(nl.gx.siteworks.core.HtmlObject htmlObject)
Deletes all language labels from the given HtmlObject object. This method requires that the language labels are assigned to the given HtmlObject object through the language_descriptions declaration.

Parameters:
htmlObject - HtmlObject object to remove the language labels from.

createOrUpdateRbacCategory

protected nl.gx.siteworks.core.HtmlObject createOrUpdateRbacCategory(MenuItemComponentDefinition componentDefinition)
                                                              throws nl.gx.siteworks.core.DuplicateNameException,
                                                                     nl.gx.siteworks.core.HtmlObjectNotFoundException
Creates or updates the rbac category as defined in the component definition and returns it.

Parameters:
componentDefinition - Component definition to create the rbac category for.
Returns:
The created or updated rbac category.
Throws:
nl.gx.siteworks.core.DuplicateNameException - If the rbac category HtmlObject object or on of its language label HtmlObject objects cannot be created because there already exists an HtmlObject object with the same name.
nl.gx.siteworks.core.HtmlObjectNotFoundException - If the all webs registry HtmlObject object cannot be found.

createPermission

protected nl.gx.siteworks.core.HtmlObject createPermission(Permission permission,
                                                           MenuItemComponentDefinition componentDefinition,
                                                           nl.gx.siteworks.core.HtmlObject rbacCategory,
                                                           nl.gx.siteworks.core.HtmlObject menuItem)
                                                    throws nl.gx.siteworks.core.DuplicateNameException
Creates and returns a single persistent rbac permission HtmlObject based on the given Permission and ComponentDefinition object and assigns it to the given rbac category HtmlObject and associates it with the given menu item HtmlObject in the WebManager menu structure.

Parameters:
permission - Permission object which contains the permission's data.
componentDefinition - ComponentDefinition object which is used to retrieve the needed text labels.
rbacCategory - HtmlObject object to which the new permission HtmlObject object has to be assigned.
menuItem - The menu item HtmlObject in the WebManager menu structure with which the new to be associated.
Returns:
A single persistent rbac permission HtmlObject based on the given Permission and ComponentDefinition object.
Throws:
nl.gx.siteworks.core.DuplicateNameException - If there already is a HtmlObject of the rbac_permission objecttype with the same name as the name for the created rbac permission.

createPermission

protected final nl.gx.siteworks.core.HtmlObject createPermission(Permission permission,
                                                                 ComponentDefinition componentDefinition,
                                                                 nl.gx.siteworks.core.HtmlObject rbacCategory)
                                                          throws nl.gx.siteworks.core.DuplicateNameException
Creates and returns a single persistent rbac permission HtmlObject based on the given Permission and ComponentDefinition object and assigns it to the given rbac category HtmlObject.

Parameters:
permission - Permission object which contains the permission's data.
componentDefinition - ComponentDefinition object which is used to retrieve the needed text labels.
rbacCategory - HtmlObject object to which the new permission HtmlObject object has to be assigned.
Returns:
A single persistent rbac permission HtmlObject based on the given Permission and ComponentDefinition object.
Throws:
nl.gx.siteworks.core.DuplicateNameException - If there already is a HtmlObject of the rbac_permission objecttype with the same name as the name for the created rbac permission.

grantsMenuItemAccess

protected boolean grantsMenuItemAccess(MenuItemComponentDefinition componentDefinition,
                                       Permission permission)
Returns if the given permission should grant the user access to the element menu item, according to the component definition

Parameters:
componentDefinition -
permission -
Returns:

updatePermissionsForPermissionGroups

protected void updatePermissionsForPermissionGroups(ComponentDefinition componentDefinition)
Updates the permissions assigned to the permission groups Can be invoked both from install and update


insertIntoMainMenu

protected void insertIntoMainMenu(MenuItemComponentDefinition componentDefinition,
                                  nl.gx.siteworks.core.HtmlObject menuStructureItem)
                           throws nl.gx.siteworks.core.HtmlObjectNotFoundException
Creates the permissions as defined in the component definition.

Parameters:
componentDefinition -
menuStructureItem -
Throws:
nl.gx.siteworks.core.HtmlObjectNotFoundException

createPermissions

protected void createPermissions(MenuItemComponentDefinition componentDefinition,
                                 nl.gx.siteworks.core.HtmlObject menuItem)
                          throws nl.gx.siteworks.core.HtmlObjectNotFoundException,
                                 nl.gx.siteworks.core.DuplicateNameException
Creates the permissions as defined in the component definition.

Parameters:
componentDefinition - Component definition to update the permissions for
menuItem - menu item associated with the component
Throws:
nl.gx.siteworks.core.HtmlObjectNotFoundException - If the wm_all_webinitiatives_registry HtmlObject object cannot be found.
nl.gx.siteworks.core.DuplicateNameException - If the rbac category HtmlObject object or on of its language label HtmlObject objects cannot be created because there already exists an HtmlObject object with the same name.

createPermissions

protected final void createPermissions(ComponentDefinition componentDefinition)
                                throws nl.gx.siteworks.core.HtmlObjectNotFoundException,
                                       nl.gx.siteworks.core.DuplicateNameException
Creates the permissions as defined in the component definition.

Parameters:
componentDefinition - Component definition to update the permissions for.
Throws:
nl.gx.siteworks.core.HtmlObjectNotFoundException - If the wm_all_webinitiatives_registry HtmlObject object cannot be found.
nl.gx.siteworks.core.DuplicateNameException - If the rbac category HtmlObject object or on of its language label HtmlObject objects cannot be created because there already exists an HtmlObject object with the same name.

createOrUpdatePermissions

protected nl.gx.siteworks.core.HtmlObject createOrUpdatePermissions(MenuItemComponentDefinition componentDefinition,
                                                                    nl.gx.siteworks.core.HtmlObject menuItem)
                                                             throws nl.gx.siteworks.core.HtmlObjectNotFoundException,
                                                                    nl.gx.siteworks.core.DuplicateNameException
Creates or updates the permissions as defined in the component definition and returns the rbac category to which the permissions are assigned.

Parameters:
componentDefinition - Component definition to create or update the permissions for
menuItem - Menu item associated with the component
Throws:
nl.gx.siteworks.core.HtmlObjectNotFoundException - If the wm_all_webinitiatives_registry HtmlObject object cannot be found.
nl.gx.siteworks.core.DuplicateNameException - If the rbac category HtmlObject object or on of its language label HtmlObject objects cannot be created because there already exists an HtmlObject object with the same name.

createOrUpdatePermissions

protected final nl.gx.siteworks.core.HtmlObject createOrUpdatePermissions(ComponentDefinition componentDefinition)
                                                                   throws nl.gx.siteworks.core.HtmlObjectNotFoundException,
                                                                          nl.gx.siteworks.core.DuplicateNameException
Creates or updates the permissions as defined in the component definition and returns the rbac category to which the permissions are assigned.

Parameters:
componentDefinition - Component definition to create or update the permissions for
Returns:
The rbac_category HtmlObject to which the created or updated permissions are assigned.
Throws:
nl.gx.siteworks.core.HtmlObjectNotFoundException - If the wm_all_webinitiatives_registry HtmlObject object cannot be found.
nl.gx.siteworks.core.DuplicateNameException - If the rbac category HtmlObject object or on of its language label HtmlObject objects cannot be created because there already exists an HtmlObject object with the same name.

deletePermissions

protected void deletePermissions(MenuItemComponentDefinition componentDefinition)
                          throws nl.gx.siteworks.core.HtmlObjectNotFoundException,
                                 nl.gx.siteworks.core.DuplicateNameException
Deletes the permissions as defined in the component definition.

Parameters:
componentDefinition - Component definition to remove the permissions for
Throws:
nl.gx.siteworks.core.HtmlObjectNotFoundException - Is never thrown.
nl.gx.siteworks.core.DuplicateNameException - Is never thrown.

deletePermissions

protected final void deletePermissions(ComponentDefinition componentDefinition)
Deletes the permissions as defined in the component definition.

Parameters:
componentDefinition - Component definition to remove the permissions for

logError

protected void logError(java.lang.String error,
                        java.lang.Exception e,
                        ComponentDefinition compDef)
Log an error message that installation, update, purge or uninstallation failed.

Parameters:
error -
e -
compDef -


Copyright © 2007-2011 GX Software BV. All Rights Reserved.