Example usage for com.liferay.portal.kernel.portlet PortletPreferencesFactoryUtil getPortletSetup

List of usage examples for com.liferay.portal.kernel.portlet PortletPreferencesFactoryUtil getPortletSetup

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.portlet PortletPreferencesFactoryUtil getPortletSetup.

Prototype

public static PortletPreferences getPortletSetup(Layout layout, String portletId, String defaultPreferences) 

Source Link

Usage

From source file:com.liferay.exportimport.test.ExportImportDateUtilTest.java

License:Open Source License

@Before
public void setUp() throws Exception {
    _group = GroupTestUtil.addGroup();//from   w  ww.  java2 s  . c  o  m

    _layout = LayoutTestUtil.addLayout(_group);

    _layoutSet = _layout.getLayoutSet();

    _portletPreferences = PortletPreferencesFactoryUtil.getPortletSetup(_layout, PortletKeys.EXPORT_IMPORT,
            null);
}

From source file:com.liferay.journal.content.web.internal.JournalContentPortletLayoutListener.java

License:Open Source License

@Override
public void onAddToLayout(String portletId, long plid) throws PortletLayoutListenerException {

    if (_log.isDebugEnabled()) {
        _log.debug("Add " + portletId + " to layout " + plid);
    }//  w w  w  . j av  a  2s .  c o m

    try {
        Layout layout = _layoutLocalService.getLayout(plid);

        PortletPreferences portletPreferences = PortletPreferencesFactoryUtil.getPortletSetup(layout, portletId,
                StringPool.BLANK);

        String articleId = portletPreferences.getValue("articleId", null);

        if (Validator.isNull(articleId)) {
            return;
        }

        _journalContentSearchLocalService.updateContentSearch(layout.getGroupId(), layout.isPrivateLayout(),
                layout.getLayoutId(), portletId, articleId, true);
    } catch (Exception e) {
        throw new PortletLayoutListenerException(e);
    }
}

From source file:com.liferay.journal.content.web.internal.JournalContentPortletLayoutListener.java

License:Open Source License

@Override
public void onRemoveFromLayout(String portletId, long plid) throws PortletLayoutListenerException {

    if (_log.isDebugEnabled()) {
        _log.debug("Remove " + portletId + " from layout " + plid);
    }/*from  w  ww .  ja  v  a 2 s . c  o m*/

    try {
        Layout layout = _layoutLocalService.getLayout(plid);

        PortletPreferences portletPreferences = PortletPreferencesFactoryUtil.getPortletSetup(layout, portletId,
                StringPool.BLANK);

        String articleId = portletPreferences.getValue("articleId", null);

        if (Validator.isNull(articleId)) {
            return;
        }

        _journalContentSearchLocalService.deleteArticleContentSearch(layout.getGroupId(),
                layout.isPrivateLayout(), layout.getLayoutId(), portletId, articleId);

        String[] runtimePortletIds = getRuntimePortletIds(layout.getCompanyId(), layout.getGroupId(),
                articleId);

        if (runtimePortletIds.length > 0) {
            _portletLocalService.deletePortlets(layout.getCompanyId(), runtimePortletIds, layout.getPlid());
        }
    } catch (Exception e) {
        throw new PortletLayoutListenerException(e);
    }
}

From source file:com.liferay.journal.content.web.internal.JournalContentPortletLayoutListener.java

License:Open Source License

@Override
public void onSetup(String portletId, long plid) throws PortletLayoutListenerException {

    if (_log.isDebugEnabled()) {
        _log.debug("Setup " + portletId + " from layout " + plid);
    }/*from   w  w  w . j a va  2s .c om*/

    try {
        Layout layout = _layoutLocalService.getLayout(plid);

        PortletPreferences portletPreferences = PortletPreferencesFactoryUtil.getPortletSetup(layout, portletId,
                StringPool.BLANK);

        String articleId = portletPreferences.getValue("articleId", null);

        if (Validator.isNull(articleId)) {
            _journalContentSearchLocalService.deleteArticleContentSearch(layout.getGroupId(),
                    layout.isPrivateLayout(), layout.getLayoutId(), portletId);

            return;
        }

        _journalContentSearchLocalService.updateContentSearch(layout.getGroupId(), layout.isPrivateLayout(),
                layout.getLayoutId(), portletId, articleId, true);
    } catch (Exception e) {
        throw new PortletLayoutListenerException(e);
    }
}