Example usage for com.liferay.portal.util PropsValues MODULE_FRAMEWORK_CONFIGS_DIR

List of usage examples for com.liferay.portal.util PropsValues MODULE_FRAMEWORK_CONFIGS_DIR

Introduction

In this page you can find the example usage for com.liferay.portal.util PropsValues MODULE_FRAMEWORK_CONFIGS_DIR.

Prototype

String MODULE_FRAMEWORK_CONFIGS_DIR

To view the source code for com.liferay.portal.util PropsValues MODULE_FRAMEWORK_CONFIGS_DIR.

Click Source Link

Usage

From source file:com.liferay.configuration.admin.web.internal.portlet.action.BindConfigurationMVCActionCommand.java

License:Open Source License

protected void configureTargetService(ConfigurationModel configurationModel, Configuration configuration,
        Dictionary<String, Object> properties) throws ConfigurationModelListenerException, PortletException {

    if (_log.isDebugEnabled()) {
        _log.debug("Properties: " + properties);
    }//from   ww w.  ja  va2s. c  o  m

    try {
        if (configuration == null) {
            if (configurationModel.isFactory()) {
                if (_log.isDebugEnabled()) {
                    _log.debug("Creating factory PID");
                }

                configuration = _configurationAdmin.createFactoryConfiguration(configurationModel.getID(),
                        StringPool.QUESTION);
            } else {
                if (_log.isDebugEnabled()) {
                    _log.debug("Creating instance PID");
                }

                configuration = _configurationAdmin.getConfiguration(configurationModel.getID(),
                        StringPool.QUESTION);
            }
        }

        Dictionary<String, Object> configuredProperties = configuration.getProperties();

        if (configuredProperties == null) {
            configuredProperties = new Hashtable<>();
        }

        if (_log.isDebugEnabled()) {
            _log.debug("Configuration properties: " + configuration.getProperties());
        }

        Enumeration<String> keys = properties.keys();

        while (keys.hasMoreElements()) {
            String key = keys.nextElement();

            Object value = properties.get(key);

            configuredProperties.put(key, value);
        }

        if (configurationModel.isCompanyFactory()) {
            configuredProperties.put(ConfigurationModel.PROPERTY_KEY_COMPANY_ID,
                    ConfigurationModel.PROPERTY_VALUE_COMPANY_ID_DEFAULT);
        }

        // LPS-69521

        if (configurationModel.isFactory()) {
            configuredProperties.put("configuration.cleaner.ignore", "true");

            String pid = configuration.getPid();

            int index = pid.lastIndexOf('.');

            String factoryPid = pid.substring(index + 1);

            StringBundler sb = new StringBundler(7);

            sb.append("file:");
            sb.append(PropsValues.MODULE_FRAMEWORK_CONFIGS_DIR);
            sb.append(StringPool.SLASH);
            sb.append(configuration.getFactoryPid());
            sb.append(StringPool.DASH);
            sb.append(factoryPid);
            sb.append(".config");

            configuredProperties.put("felix.fileinstall.filename", sb.toString());
        }

        configuration.update(configuredProperties);
    } catch (ConfigurationModelListenerException cmle) {
        throw cmle;
    } catch (IOException ioe) {
        throw new PortletException(ioe);
    }
}