Example usage for com.liferay.portal.kernel.workflow WorkflowHandlerRegistryUtil register

List of usage examples for com.liferay.portal.kernel.workflow WorkflowHandlerRegistryUtil register

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.workflow WorkflowHandlerRegistryUtil register.

Prototype

public static void register(WorkflowHandler<?> workflowHandler) 

Source Link

Usage

From source file:au.com.permeance.liferay.util.startup.StartupListener.java

License:Open Source License

protected static synchronized void applicationStart() {
    if (!applicationStarted) {
        applicationStarted = true;// w w w . ja va 2s .c  o m
        _log.info("Starting up Web Content Workflow Configuration Portlet");
        oldWorkflowHandler = WorkflowHandlerRegistryUtil.getWorkflowHandler(JournalArticle.class.getName());
        WorkflowHandlerRegistryUtil.register(newWorkflowHandler);
    }
}

From source file:au.com.permeance.liferay.util.startup.StartupListener.java

License:Open Source License

protected static synchronized void applicationStop() {
    if (applicationStarted) {
        applicationStarted = false;//from   www. j ava  2s. c  o m
        WorkflowHandlerRegistryUtil.unregister(newWorkflowHandler);
        if (oldWorkflowHandler != null) {
            WorkflowHandlerRegistryUtil.register(oldWorkflowHandler);
        }
        _log.info("Shutting down Web Content Workflow Configuration Portlet");
    }
}

From source file:com.liferay.document.library.workflow.WorkflowHandlerReplacer.java

License:Open Source License

public WorkflowHandlerReplacer(String className, WorkflowHandler<T> replacementWorkflowHandler) {

    _originalWorkflowHandler = WorkflowHandlerRegistryUtil.getWorkflowHandler(className);
    _replacementWorkflowHandler = replacementWorkflowHandler;

    WorkflowHandlerRegistryUtil.unregister(_originalWorkflowHandler);
    WorkflowHandlerRegistryUtil.register(_replacementWorkflowHandler);
}

From source file:com.liferay.document.library.workflow.WorkflowHandlerReplacer.java

License:Open Source License

@Override
public void close() throws Exception {
    WorkflowHandlerRegistryUtil.unregister(_replacementWorkflowHandler);
    WorkflowHandlerRegistryUtil.register(_originalWorkflowHandler);
}

From source file:com.liferay.portlet.PortletBagFactory.java

License:Open Source License

public PortletBag create(Portlet portlet) throws Exception {
    PortletApp portletApp = portlet.getPortletApp();

    if (!portletApp.isWARFile() && _warFile) {
        String contextPath = PortalUtil.getPathContext();

        _servletContext = ServletContextPool.get(contextPath);

        _classLoader = PortalClassLoaderUtil.getClassLoader();
    }// www  .j  a v  a  2  s.c o  m

    Class<?> portletClass = null;

    try {
        portletClass = _classLoader.loadClass(portlet.getPortletClass());
    } catch (Throwable e) {
        _log.error(e, e);

        PortletLocalServiceUtil.destroyPortlet(portlet);

        return null;
    }

    javax.portlet.Portlet portletInstance = (javax.portlet.Portlet) portletClass.newInstance();

    ConfigurationAction configurationActionInstance = newConfigurationAction(portlet);

    List<Indexer> indexerInstances = newIndexers(portlet);

    OpenSearch openSearchInstance = newOpenSearch(portlet);

    initSchedulers(portlet);

    FriendlyURLMapper friendlyURLMapperInstance = newFriendlyURLMapper(portlet);

    URLEncoder urlEncoderInstance = newURLEncoder(portlet);

    PortletDataHandler portletDataHandlerInstance = newPortletDataHandler(portlet);

    PortletLayoutListener portletLayoutListenerInstance = newPortletLayoutListener(portlet);

    PollerProcessor pollerProcessorInstance = newPollerProcessor(portlet);

    MessageListener popMessageListenerInstance = newPOPMessageListener(portlet);

    SocialActivityInterpreter socialActivityInterpreterInstance = initSocialActivityInterpreterInstance(
            portlet);

    SocialRequestInterpreter socialRequestInterpreterInstance = null;

    if (Validator.isNotNull(portlet.getSocialRequestInterpreterClass())) {
        socialRequestInterpreterInstance = (SocialRequestInterpreter) newInstance(
                SocialRequestInterpreter.class, portlet.getSocialRequestInterpreterClass());

        socialRequestInterpreterInstance = new SocialRequestInterpreterImpl(portlet.getPortletId(),
                socialRequestInterpreterInstance);

        SocialRequestInterpreterLocalServiceUtil.addRequestInterpreter(socialRequestInterpreterInstance);
    }

    WebDAVStorage webDAVStorageInstance = null;

    if (Validator.isNotNull(portlet.getWebDAVStorageClass())) {
        webDAVStorageInstance = (WebDAVStorage) newInstance(WebDAVStorage.class,
                portlet.getWebDAVStorageClass());

        webDAVStorageInstance.setToken(portlet.getWebDAVStorageToken());

        WebDAVUtil.addStorage(webDAVStorageInstance);
    }

    Method xmlRpcMethodInstance = null;

    if (Validator.isNotNull(portlet.getXmlRpcMethodClass())) {
        xmlRpcMethodInstance = (Method) newInstance(Method.class, portlet.getXmlRpcMethodClass());

        XmlRpcServlet.registerMethod(xmlRpcMethodInstance);
    }

    ControlPanelEntry controlPanelEntryInstance = null;

    if (Validator.isNotNull(portlet.getControlPanelEntryClass())) {
        controlPanelEntryInstance = (ControlPanelEntry) newInstance(ControlPanelEntry.class,
                portlet.getControlPanelEntryClass());
    }

    List<AssetRendererFactory> assetRendererFactoryInstances = newAssetRendererFactoryInstances(portlet);

    List<AtomCollectionAdapter<?>> atomCollectionAdapterInstances = newAtomCollectionAdapterInstances(portlet);

    List<CustomAttributesDisplay> customAttributesDisplayInstances = new ArrayList<CustomAttributesDisplay>();

    for (String customAttributesDisplayClass : portlet.getCustomAttributesDisplayClasses()) {

        CustomAttributesDisplay customAttributesDisplayInstance = (CustomAttributesDisplay) newInstance(
                CustomAttributesDisplay.class, customAttributesDisplayClass);

        customAttributesDisplayInstance
                .setClassNameId(PortalUtil.getClassNameId(customAttributesDisplayInstance.getClassName()));
        customAttributesDisplayInstance.setPortletId(portlet.getPortletId());

        customAttributesDisplayInstances.add(customAttributesDisplayInstance);
    }

    PermissionPropagator permissionPropagatorInstance = newPermissionPropagator(portlet);

    List<WorkflowHandler> workflowHandlerInstances = new ArrayList<WorkflowHandler>();

    for (String workflowHandlerClass : portlet.getWorkflowHandlerClasses()) {

        WorkflowHandler workflowHandlerInstance = (WorkflowHandler) newInstance(WorkflowHandler.class,
                workflowHandlerClass);

        workflowHandlerInstances.add(workflowHandlerInstance);

        WorkflowHandlerRegistryUtil.register(workflowHandlerInstance);
    }

    PreferencesValidator preferencesValidatorInstance = null;

    if (Validator.isNotNull(portlet.getPreferencesValidator())) {
        preferencesValidatorInstance = (PreferencesValidator) newInstance(PreferencesValidator.class,
                portlet.getPreferencesValidator());

        try {
            if (PropsValues.PREFERENCE_VALIDATE_ON_STARTUP) {
                preferencesValidatorInstance.validate(
                        PortletPreferencesFactoryUtil.fromDefaultXML(portlet.getDefaultPreferences()));
            }
        } catch (Exception e) {
            _log.warn("Portlet with the name " + portlet.getPortletId()
                    + " does not have valid default preferences");
        }
    }

    Map<String, ResourceBundle> resourceBundles = null;

    String resourceBundle = portlet.getResourceBundle();

    if (Validator.isNotNull(resourceBundle) && !resourceBundle.equals(StrutsResourceBundle.class.getName())) {

        resourceBundles = new HashMap<String, ResourceBundle>();

        initResourceBundle(resourceBundles, portlet, null);
        initResourceBundle(resourceBundles, portlet, LocaleUtil.getDefault());

        Set<String> supportedLocales = portlet.getSupportedLocales();

        if (supportedLocales.isEmpty()) {
            supportedLocales = SetUtil.fromArray(PropsValues.LOCALES);
        }

        for (String supportedLocale : supportedLocales) {
            Locale locale = LocaleUtil.fromLanguageId(supportedLocale);

            initResourceBundle(resourceBundles, portlet, locale);
        }
    }

    PortletBag portletBag = new PortletBagImpl(portlet.getPortletId(), _servletContext, portletInstance,
            configurationActionInstance, indexerInstances, openSearchInstance, friendlyURLMapperInstance,
            urlEncoderInstance, portletDataHandlerInstance, portletLayoutListenerInstance,
            pollerProcessorInstance, popMessageListenerInstance, socialActivityInterpreterInstance,
            socialRequestInterpreterInstance, webDAVStorageInstance, xmlRpcMethodInstance,
            controlPanelEntryInstance, assetRendererFactoryInstances, atomCollectionAdapterInstances,
            customAttributesDisplayInstances, permissionPropagatorInstance, workflowHandlerInstances,
            preferencesValidatorInstance, resourceBundles);

    PortletBagPool.put(portlet.getRootPortletId(), portletBag);

    try {
        PortletInstanceFactoryUtil.create(portlet, _servletContext);
    } catch (Exception e) {
        _log.error(e, e);
    }

    return portletBag;
}