Example usage for com.liferay.portal.kernel.portlet PortletLayoutListenerException PortletLayoutListenerException

List of usage examples for com.liferay.portal.kernel.portlet PortletLayoutListenerException PortletLayoutListenerException

Introduction

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

Prototype

public PortletLayoutListenerException(Throwable cause) 

Source Link

Usage

From source file:com.liferay.asset.publisher.web.AssetPublisherPortletLayoutListener.java

License:Open Source License

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

    try {/*from   w w w .ja va 2 s.c  o  m*/
        Layout layout = _layoutLocalService.getLayout(plid);

        if (_assetPublisherWebUtil.isDefaultAssetPublisher(layout, portletId, StringPool.BLANK)) {

            _journalArticleLocalService.deleteLayoutArticleReferences(layout.getGroupId(), layout.getUuid());
        }

        long ownerId = PortletKeys.PREFS_OWNER_ID_DEFAULT;
        int ownerType = PortletKeys.PREFS_OWNER_TYPE_LAYOUT;

        if (PortletIdCodec.hasUserId(portletId)) {
            ownerType = PortletKeys.PREFS_OWNER_TYPE_USER;
            ownerId = PortletIdCodec.decodeUserId(portletId);
        }

        _subscriptionLocalService.deleteSubscriptions(layout.getCompanyId(), PortletPreferences.class.getName(),
                _assetPublisherWebUtil.getSubscriptionClassPK(ownerId, ownerType, plid, portletId));
    } 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 onAddToLayout(String portletId, long plid) throws PortletLayoutListenerException {

    if (_log.isDebugEnabled()) {
        _log.debug("Add " + portletId + " to layout " + plid);
    }/*from w w  w .  j av  a2s.  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);
    }/*  w  w w. j  a  va  2 s. 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)) {
            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 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)) {
            _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);
    }
}

From source file:com.liferay.portlet.journalcontent.JournalContentPortletLayoutListener.java

License:Open Source License

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

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

    try {
        deleteContentSearch(portletId, plid);
    } catch (Exception e) {
        throw new PortletLayoutListenerException(e);
    }
}