Search in sources :

Example 6 with Portlet

use of com.liferay.portal.model.Portlet in project liferay-ide by liferay.

the class EditConfigurationAction method serveResource.

@Override
public void serveResource(ActionMapping actionMapping, ActionForm actionForm, PortletConfig portletConfig, ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception {
    Portlet portlet = null;
    try {
        portlet = ActionUtil.getPortlet(resourceRequest);
    } catch (PrincipalException pe) {
        return;
    }
    resourceRequest = ActionUtil.getWrappedResourceRequest(resourceRequest, null);
    ResourceServingConfigurationAction resourceServingConfigurationAction = (ResourceServingConfigurationAction) getConfigurationAction(portlet);
    if (resourceServingConfigurationAction == null) {
        return;
    }
    resourceServingConfigurationAction.serveResource(portletConfig, resourceRequest, resourceResponse);
}
Also used : Portlet(com.liferay.portal.model.Portlet) PrincipalException(com.liferay.portal.security.auth.PrincipalException) ResourceServingConfigurationAction(com.liferay.portal.kernel.portlet.ResourceServingConfigurationAction)

Example 7 with Portlet

use of com.liferay.portal.model.Portlet in project liferay-ide by liferay.

the class EditConfigurationAction method processAction.

@Override
public void processAction(ActionMapping actionMapping, ActionForm actionForm, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    Portlet portlet = null;
    try {
        portlet = ActionUtil.getPortlet(actionRequest);
    } catch (PrincipalException pe) {
        SessionErrors.add(actionRequest, PrincipalException.class.getName());
        setForward(actionRequest, "portlet.portlet_configuration.error");
        return;
    }
    actionRequest = ActionUtil.getWrappedActionRequest(actionRequest, null);
    ConfigurationAction configurationAction = getConfigurationAction(portlet);
    if (configurationAction == null) {
        return;
    }
    configurationAction.processAction(portletConfig, actionRequest, actionResponse);
}
Also used : Portlet(com.liferay.portal.model.Portlet) PrincipalException(com.liferay.portal.security.auth.PrincipalException) ConfigurationAction(com.liferay.portal.kernel.portlet.ConfigurationAction) ResourceServingConfigurationAction(com.liferay.portal.kernel.portlet.ResourceServingConfigurationAction)

Example 8 with Portlet

use of com.liferay.portal.model.Portlet in project liferay-ide by liferay.

the class EditConfigurationAction method render.

@Override
public ActionForward render(ActionMapping actionMapping, ActionForm actionForm, PortletConfig portletConfig, RenderRequest renderRequest, RenderResponse renderResponse) throws Exception {
    Portlet portlet = null;
    try {
        portlet = ActionUtil.getPortlet(renderRequest);
    } catch (PrincipalException pe) {
        SessionErrors.add(renderRequest, PrincipalException.class.getName());
        return actionMapping.findForward("portlet.portlet_configuration.error");
    }
    renderRequest = ActionUtil.getWrappedRenderRequest(renderRequest, null);
    renderResponse.setTitle(ActionUtil.getTitle(portlet, renderRequest));
    ConfigurationAction configurationAction = getConfigurationAction(portlet);
    if (configurationAction != null) {
        String path = configurationAction.render(portletConfig, renderRequest, renderResponse);
        if (_log.isDebugEnabled()) {
            _log.debug("Configuration action returned render path " + path);
        }
        if (Validator.isNotNull(path)) {
            renderRequest.setAttribute(WebKeys.CONFIGURATION_ACTION_PATH, path);
        } else {
            _log.error("Configuration action returned a null path");
        }
    }
    return actionMapping.findForward(getForward(renderRequest, "portlet.portlet_configuration.edit_configuration"));
}
Also used : Portlet(com.liferay.portal.model.Portlet) PrincipalException(com.liferay.portal.security.auth.PrincipalException) ConfigurationAction(com.liferay.portal.kernel.portlet.ConfigurationAction) ResourceServingConfigurationAction(com.liferay.portal.kernel.portlet.ResourceServingConfigurationAction)

Example 9 with Portlet

use of com.liferay.portal.model.Portlet in project liferay-ide by liferay.

the class FindKBArticleAction method getKBArticleURL.

protected PortletURL getKBArticleURL(long plid, boolean privateLayout, KBArticle kbArticle, HttpServletRequest request) throws Exception {
    PortletURL firstMatchPortletURL = null;
    List<Layout> layouts = getCandidateLayouts(plid, privateLayout, kbArticle);
    for (Layout layout : layouts) {
        LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType();
        List<Portlet> portlets = layoutTypePortlet.getAllPortlets();
        for (Portlet portlet : portlets) {
            String rootPortletId = PortletConstants.getRootPortletId(portlet.getPortletId());
            if (rootPortletId.equals(PortletKeys.KNOWLEDGE_BASE_DISPLAY)) {
                PortletPreferences portletPreferences = PortletPreferencesFactoryUtil.getPortletSetup(layout, portlet.getPortletId(), StringPool.BLANK);
                long kbFolderClassNameId = PortalUtil.getClassNameId(KBFolderConstants.getClassName());
                long resourceClassNameId = GetterUtil.getLong(portletPreferences.getValue("resourceClassNameId", null), kbFolderClassNameId);
                long resourcePrimKey = GetterUtil.getLong(portletPreferences.getValue("resourcePrimKey", null), KBFolderConstants.DEFAULT_PARENT_FOLDER_ID);
                if (resourceClassNameId == kbFolderClassNameId) {
                    if (isParentFolder(resourcePrimKey, kbArticle.getKbFolderId())) {
                        return getKBArticleURL(layout.getPlid(), portlet.getPortletId(), kbArticle, request);
                    }
                } else if (resourcePrimKey == kbArticle.getResourcePrimKey()) {
                    return getKBArticleURL(layout.getPlid(), portlet.getPortletId(), kbArticle, request);
                }
                if (firstMatchPortletURL == null) {
                    firstMatchPortletURL = getKBArticleURL(layout.getPlid(), portlet.getPortletId(), kbArticle, request);
                }
            }
            if (rootPortletId.equals(PortletKeys.KNOWLEDGE_BASE_SECTION)) {
                PortletPreferences portletPreferences = PortletPreferencesFactoryUtil.getPortletSetup(layout, portlet.getPortletId(), StringPool.BLANK);
                String[] kbArticlesSections = portletPreferences.getValues("kbArticlesSections", new String[0]);
                KBArticle rootKBArticle = KBArticleLocalServiceUtil.fetchLatestKBArticle(kbArticle.getRootResourcePrimKey(), WorkflowConstants.STATUS_APPROVED);
                if (rootKBArticle == null) {
                    continue;
                }
                String[] sections = AdminUtil.unescapeSections(rootKBArticle.getSections());
                for (String section : sections) {
                    if (!ArrayUtil.contains(kbArticlesSections, section)) {
                        continue;
                    }
                    return getKBArticleURL(layout.getPlid(), portlet.getPortletId(), kbArticle, request);
                }
            }
            if (rootPortletId.equals(PortletKeys.KNOWLEDGE_BASE_ARTICLE)) {
                PortletPreferences portletPreferences = PortletPreferencesFactoryUtil.getPortletSetup(layout, portlet.getPortletId(), StringPool.BLANK);
                long resourcePrimKey = GetterUtil.getLong(portletPreferences.getValue("resourcePrimKey", null));
                KBArticle selKBArticle = KBArticleLocalServiceUtil.fetchLatestKBArticle(resourcePrimKey, WorkflowConstants.STATUS_APPROVED);
                if (selKBArticle == null) {
                    continue;
                }
                long rootResourcePrimKey = kbArticle.getRootResourcePrimKey();
                long selRootResourcePrimKey = selKBArticle.getRootResourcePrimKey();
                if (rootResourcePrimKey == selRootResourcePrimKey) {
                    return getKBArticleURL(layout.getPlid(), portlet.getPortletId(), kbArticle, request);
                }
                if (firstMatchPortletURL == null) {
                    firstMatchPortletURL = getKBArticleURL(layout.getPlid(), portlet.getPortletId(), kbArticle, request);
                }
            }
        }
    }
    return firstMatchPortletURL;
}
Also used : LayoutTypePortlet(com.liferay.portal.model.LayoutTypePortlet) LayoutTypePortlet(com.liferay.portal.model.LayoutTypePortlet) Portlet(com.liferay.portal.model.Portlet) KBArticle(com.liferay.knowledgebase.model.KBArticle) Layout(com.liferay.portal.model.Layout) PortletPreferences(javax.portlet.PortletPreferences) PortletURL(javax.portlet.PortletURL)

Aggregations

Portlet (com.liferay.portal.model.Portlet)9 GadgetPortlet (com.liferay.opensocial.gadget.portlet.GadgetPortlet)3 ResourceServingConfigurationAction (com.liferay.portal.kernel.portlet.ResourceServingConfigurationAction)3 PrincipalException (com.liferay.portal.security.auth.PrincipalException)3 InvokerPortlet (com.liferay.portlet.InvokerPortlet)3 DuplicateGadgetURLException (com.liferay.opensocial.DuplicateGadgetURLException)2 GadgetPortletCategoryNamesException (com.liferay.opensocial.GadgetPortletCategoryNamesException)2 GadgetURLException (com.liferay.opensocial.GadgetURLException)2 NoSuchGadgetException (com.liferay.opensocial.NoSuchGadgetException)2 Clusterable (com.liferay.portal.kernel.cluster.Clusterable)2 PortalException (com.liferay.portal.kernel.exception.PortalException)2 SystemException (com.liferay.portal.kernel.exception.SystemException)2 ConfigurationAction (com.liferay.portal.kernel.portlet.ConfigurationAction)2 PortletPreferences (javax.portlet.PortletPreferences)2 KBArticle (com.liferay.knowledgebase.model.KBArticle)1 BaseGadgetPortlet (com.liferay.opensocial.gadget.portlet.BaseGadgetPortlet)1 Gadget (com.liferay.opensocial.model.Gadget)1 PortletBag (com.liferay.portal.kernel.portlet.PortletBag)1 Layout (com.liferay.portal.model.Layout)1 LayoutTypePortlet (com.liferay.portal.model.LayoutTypePortlet)1