Example usage for com.liferay.portal.kernel.settings ModifiableSettings store

List of usage examples for com.liferay.portal.kernel.settings ModifiableSettings store

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.settings ModifiableSettings store.

Prototype

public void store() throws IOException, ValidatorException;

Source Link

Usage

From source file:com.liferay.adaptive.media.image.internal.configuration.AdaptiveMediaImageConfigurationHelperImpl.java

License:Open Source License

private void _updateConfiguration(long companyId,
        List<AdaptiveMediaImageConfigurationEntry> configurationEntries) throws IOException {

    try {//  w ww  . j  a v a 2 s. co m
        Settings settings = SettingsFactoryUtil.getSettings(new CompanyServiceSettingsLocator(companyId,
                AdaptiveMediaImageCompanyConfiguration.class.getName()));

        ModifiableSettings modifiableSettings = settings.getModifiableSettings();

        Stream<AdaptiveMediaImageConfigurationEntry> configurationEntryStream = configurationEntries.stream();

        List<String> imageVariants = configurationEntryStream
                .map(_configurationEntryParser::getConfigurationString).collect(Collectors.toList());

        modifiableSettings.setValues("imageVariants", imageVariants.toArray(new String[imageVariants.size()]));

        modifiableSettings.store();
    } catch (SettingsException | ValidatorException e) {
        throw new AdaptiveMediaRuntimeException.InvalidConfiguration(e);
    }
}

From source file:com.liferay.adaptive.media.image.internal.configuration.AMImageConfigurationHelperImpl.java

License:Open Source License

private void _updateConfiguration(long companyId, List<AMImageConfigurationEntry> amImageConfigurationEntries)
        throws IOException {

    try {//www.j  ava2  s .c  om
        Settings settings = SettingsFactoryUtil.getSettings(
                new CompanyServiceSettingsLocator(companyId, AMImageCompanyConfiguration.class.getName()));

        ModifiableSettings modifiableSettings = settings.getModifiableSettings();

        Stream<AMImageConfigurationEntry> amImageConfigurationEntryStream = amImageConfigurationEntries
                .stream();

        List<String> imageVariants = amImageConfigurationEntryStream
                .map(_amImageConfigurationEntryParser::getConfigurationString).collect(Collectors.toList());

        modifiableSettings.setValues("imageVariants", imageVariants.toArray(new String[imageVariants.size()]));

        modifiableSettings.store();

        amImageConfigurationEntryStream = amImageConfigurationEntries.stream();

        _configurationEntries.put(companyId, amImageConfigurationEntryStream.collect(Collectors.toList()));
    } catch (SettingsException | ValidatorException e) {
        throw new AMRuntimeException.InvalidConfiguration(e);
    }
}

From source file:com.liferay.portlet.configuration.web.internal.portlet.PortletConfigurationPortlet.java

License:Open Source License

public void restoreArchivedSetup(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    Portlet portlet = ActionUtil.getPortlet(actionRequest);

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    Settings portletInstanceSettings = SettingsFactoryUtil
            .getSettings(new PortletInstanceSettingsLocator(themeDisplay.getLayout(), portlet.getPortletId()));

    ModifiableSettings portletInstanceModifiableSettings = portletInstanceSettings.getModifiableSettings();

    String name = ParamUtil.getString(actionRequest, "name");

    ArchivedSettings archivedSettings = SettingsFactoryUtil.getPortletInstanceArchivedSettings(
            themeDisplay.getSiteGroupId(), portlet.getRootPortletId(), name);

    portletInstanceModifiableSettings.reset();

    portletInstanceModifiableSettings.setValues(archivedSettings);

    portletInstanceModifiableSettings.store();

    String portletResource = ParamUtil.getString(actionRequest, "portletResource");

    SessionMessages.add(actionRequest,//from w  ww .  ja  va2 s .  com
            _portal.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET, portletResource);
}

From source file:com.liferay.wiki.web.configuration.definition.WikiPortletInstanceConfigurationOverrideImpl.java

License:Open Source License

@Override
public void store() throws IOException, ValidatorException {
    Settings settings = _typedSettings.getWrappedSettings();

    ModifiableSettings modifiableSettings = settings.getModifiableSettings();

    modifiableSettings.store();
}