Class ComponentTypeBase

    • Field Detail

      • mySiteworksUtil

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

      • ComponentTypeBase

        public ComponentTypeBase()
    • Method Detail

      • installComponent

        public boolean installComponent​(ComponentDefinition componentDefinition)
        Description copied from interface: ComponentType
        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
      • installComponent

        public boolean installComponent​(ComponentDefinition componentDefinition,
                                        Component component)
        Description copied from interface: ComponentType
        Installs a component of this component type. 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
        component - Component that is to be installed
        Returns:
        true if the component was successfully installed
      • updateComponent

        public boolean updateComponent​(ComponentDefinition componentDefinition)
        Description copied from interface: ComponentType
        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)
        Description copied from interface: ComponentType
        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)
        Description copied from interface: ComponentType
        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)
        Description copied from interface: ComponentType
        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)
        Description copied from interface: ComponentType
        Stops an installed component.
        Specified by:
        stopComponent in interface ComponentType
        Parameters:
        component - Component that should be stopped
        Returns:
        true if the component was successfully stopped
      • checkComponentDefinition

        public boolean checkComponentDefinition​(ComponentDefinition componentDefinition)
        Description copied from interface: ComponentType
        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​(String id)
        Description copied from interface: ComponentType
        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()
        Description copied from interface: ComponentType
        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()
        Description copied from interface: ComponentType
        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,
                                         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,
                                           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.
      • deployResources

        public void deployResources​(ComponentDefinition componentDefinition)
        Description copied from interface: ComponentType
        Deploys the necessary resources for a component. This should deploy all resources that are removed on a restart of an installation, for instance mediaitem icons.
        Specified by:
        deployResources in interface ComponentType
        Parameters:
        componentDefinition - the ComponentDefinition of the component that is enabled
      • getLocaleIdFromResourceName

        protected static String getLocaleIdFromResourceName​(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,
                                       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,
                                        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,
                                                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
      • 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​(String error,
                                Exception e,
                                ComponentDefinition compDef)
        Log an error message that installation, update, purge or uninstallation failed.
        Parameters:
        error -
        e -
        compDef -