Example usage for com.liferay.portal.kernel.settings PortletInstanceSettingsLocator PortletInstanceSettingsLocator

List of usage examples for com.liferay.portal.kernel.settings PortletInstanceSettingsLocator PortletInstanceSettingsLocator

Introduction

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

Prototype

public PortletInstanceSettingsLocator(Layout layout, String portletInstanceKey) 

Source Link

Usage

From source file:blade.document.action.displaycontext.BladeActionDisplayContext.java

License:Apache License

/**
 * Read settings from page Documents And Media portlet "Show Actions" portlet configuration.<br/>
 * But for Documents And Media admin portlet, it will always be true.
 */// w  w w  .  j a  v  a  2 s.  co m
private boolean _showAction() throws SettingsException {
    PortletDisplay portletDisplay = _themeDisplay.getPortletDisplay();

    String portletName = portletDisplay.getPortletName();

    if (portletName.equals(PortletKeys.DOCUMENT_LIBRARY_ADMIN)) {
        return true;
    }

    Settings settings = SettingsFactoryUtil
            .getSettings(new PortletInstanceSettingsLocator(_themeDisplay.getLayout(), portletDisplay.getId()));

    TypedSettings typedSettings = new TypedSettings(settings);

    return typedSettings.getBooleanValue("showActions");
}

From source file:com.liferay.document.library.web.internal.settings.DLPortletInstanceSettings.java

License:Open Source License

public static DLPortletInstanceSettings getInstance(Layout layout, String portletId) throws PortalException {

    Settings settings = SettingsFactoryUtil.getSettings(new PortletInstanceSettingsLocator(layout, portletId));

    return new DLPortletInstanceSettings(settings);
}

From source file:com.liferay.document.library.web.internal.settings.DLPortletInstanceSettings.java

License:Open Source License

public static DLPortletInstanceSettings getInstance(Layout layout, String portletId,
        Map<String, String[]> parameterMap) throws PortalException {

    Settings settings = SettingsFactoryUtil.getSettings(new PortletInstanceSettingsLocator(layout, portletId));

    Settings parameterMapSettings = new ParameterMapSettings(parameterMap, settings);

    return new DLPortletInstanceSettings(parameterMapSettings);
}

From source file:com.liferay.layout.admin.web.internal.exportimport.data.handler.LayoutStagedModelDataHandler.java

License:Open Source License

protected Map<String, Object[]> getPortletids(PortletDataContext portletDataContext, Layout layout)
        throws Exception {

    if (!LayoutStagingUtil.prepareLayoutStagingHandler(portletDataContext, layout)
            || !layout.isSupportsEmbeddedPortlets()) {

        // Only portlet type layouts support page scoping

        return Collections.emptyMap();
    }/*from w ww  .j av a  2s .  c om*/

    Map<String, Object[]> portletIds = new HashMap<>();

    LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType();

    // The getAllPortlets method returns all effective nonsystem portlets
    // for any layout type, including embedded portlets, or in the case of
    // panel type layout, selected portlets

    for (Portlet portlet : layoutTypePortlet.getAllPortlets(false)) {
        String portletId = portlet.getPortletId();

        Settings portletInstanceSettings = SettingsFactoryUtil
                .getSettings(new PortletInstanceSettingsLocator(layout, portletId));

        String scopeType = portletInstanceSettings.getValue("lfrScopeType", null);
        String scopeLayoutUuid = portletInstanceSettings.getValue("lfrScopeLayoutUuid", null);

        long scopeGroupId = portletDataContext.getScopeGroupId();

        if (Validator.isNotNull(scopeType)) {
            Group scopeGroup = null;

            if (scopeType.equals("company")) {
                scopeGroup = _groupLocalService.getCompanyGroup(layout.getCompanyId());
            } else if (scopeType.equals("layout")) {
                Layout scopeLayout = null;

                scopeLayout = _layoutLocalService.fetchLayoutByUuidAndGroupId(scopeLayoutUuid,
                        portletDataContext.getGroupId(), portletDataContext.isPrivateLayout());

                if (scopeLayout == null) {
                    continue;
                }

                scopeGroup = scopeLayout.getScopeGroup();
            } else {
                throw new IllegalArgumentException("Scope type " + scopeType + " is invalid");
            }

            if (scopeGroup != null) {
                scopeGroupId = scopeGroup.getGroupId();
            }
        }

        String key = PortletPermissionUtil.getPrimaryKey(layout.getPlid(), portletId);

        portletIds.put(key, new Object[] { portletId, scopeGroupId, scopeType, scopeLayoutUuid });
    }

    return portletIds;
}

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,//w  w w. j  a  v a2s  .c  o  m
            _portal.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET, portletResource);
}

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

License:Open Source License

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

    Portlet portlet = ActionUtil.getPortlet(actionRequest);

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

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

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

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

    ModifiableSettings portletInstanceModifiableSettings = portletInstanceSettings.getModifiableSettings();

    archivedSettings.setValues(portletInstanceModifiableSettings);

    archivedSettings.store();/*from  w  w w .j  a v a2 s .  c o  m*/
}

From source file:com.liferay.wiki.web.internal.display.context.util.WikiRequestHelper.java

License:Open Source License

public WikiPortletInstanceOverriddenConfiguration getWikiPortletInstanceOverridenConfiguration() {

    try {//from www .j a v  a  2 s . c  om
        if (_wikiPortletInstanceOverridenConfiguration == null) {
            String portletResource = getPortletResource();

            if (Validator.isNotNull(portletResource)) {
                _wikiPortletInstanceOverridenConfiguration = ConfigurationProviderUtil.getConfiguration(
                        WikiPortletInstanceOverriddenConfiguration.class,
                        new ParameterMapSettingsLocator(getRequest().getParameterMap(),
                                new PortletInstanceSettingsLocator(getLayout(), getResourcePortletId())));
            } else {
                _wikiPortletInstanceOverridenConfiguration = ConfigurationProviderUtil.getConfiguration(
                        WikiPortletInstanceOverriddenConfiguration.class,
                        new PortletInstanceSettingsLocator(getLayout(), getPortletId()));
            }
        }

        return _wikiPortletInstanceOverridenConfiguration;
    } catch (PortalException pe) {
        throw new SystemException(pe);
    }
}

From source file:com.liferay.wiki.web.internal.portlet.action.ActionUtil.java

License:Open Source License

public static WikiNode getFirstNode(PortletRequest portletRequest) throws PortalException {

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

    long groupId = themeDisplay.getScopeGroupId();
    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    List<WikiNode> nodes = WikiNodeLocalServiceUtil.getNodes(groupId);

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    WikiPortletInstanceOverriddenConfiguration wikiPortletInstanceOverriddenConfiguration = ConfigurationProviderUtil
            .getConfiguration(WikiPortletInstanceOverriddenConfiguration.class,
                    new PortletInstanceSettingsLocator(themeDisplay.getLayout(), portletDisplay.getId()));

    String[] visibleNodeNames = wikiPortletInstanceOverriddenConfiguration.visibleNodes();

    nodes = WikiUtil.orderNodes(nodes, visibleNodeNames);

    String[] hiddenNodes = wikiPortletInstanceOverriddenConfiguration.hiddenNodes();

    Arrays.sort(hiddenNodes);/*from   www.  j  a v a  2s  . c o m*/

    for (WikiNode node : nodes) {
        if ((Arrays.binarySearch(hiddenNodes, node.getName()) < 0)
                && WikiNodePermissionChecker.contains(permissionChecker, node, ActionKeys.VIEW)) {

            return node;
        }
    }

    return null;
}

From source file:com.liferay.wiki.web.internal.portlet.action.EditNodeMVCActionCommand.java

License:Open Source License

protected WikiPortletInstanceOverriddenConfiguration getWikiPortletInstanceOverriddenConfiguration(
        ActionRequest actionRequest) throws PortalException {

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

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    WikiPortletInstanceOverriddenConfiguration wikiPortletInstanceOverriddenConfiguration = ConfigurationProviderUtil
            .getConfiguration(WikiPortletInstanceOverriddenConfiguration.class,
                    new PortletInstanceSettingsLocator(themeDisplay.getLayout(), portletDisplay.getId()));

    return wikiPortletInstanceOverriddenConfiguration;
}