Search in sources :

Example 1 with PortletPreferences

use of javax.portlet.PortletPreferences in project liferay-ide by liferay.

the class ConfigurationActionImpl method getGadget.

@Override
protected Gadget getGadget(PortletConfig portletConfig, PortletRequest portletRequest) throws Exception {
    String portletResource = ParamUtil.getString(portletRequest, "portletResource");
    PortletPreferences portletPreferences = portletRequest.getPreferences();
    return ShindigUtil.getGadget(portletPreferences);
}
Also used : PortletPreferences(javax.portlet.PortletPreferences)

Example 2 with PortletPreferences

use of javax.portlet.PortletPreferences in project liferay-ide by liferay.

the class AdhocGadgetPortlet method getGadget.

@Override
protected Gadget getGadget(RenderRequest renderRequest) throws Exception {
    Portlet portlet = (Portlet) renderRequest.getAttribute(WebKeys.RENDER_PORTLET);
    PortletPreferences portletPreferences = PortletPreferencesFactoryUtil.getPortletSetup(renderRequest, portlet.getPortletId());
    return ShindigUtil.getGadget(portletPreferences);
}
Also used : Portlet(com.liferay.portal.model.Portlet) BaseGadgetPortlet(com.liferay.opensocial.gadget.portlet.BaseGadgetPortlet) PortletPreferences(javax.portlet.PortletPreferences)

Example 3 with PortletPreferences

use of javax.portlet.PortletPreferences in project liferay-ide by liferay.

the class DisplayPortlet method getKBArticle.

protected KBArticle getKBArticle(RenderRequest renderRequest) throws PortalException, SystemException {
    String mvcPath = ParamUtil.getString(renderRequest, "mvcPath");
    if (mvcPath.endsWith("/edit_article.jsp")) {
        long resourcePrimKey = ParamUtil.getLong(renderRequest, "resourcePrimKey");
        return KBArticleLocalServiceUtil.getLatestKBArticle(resourcePrimKey, WorkflowConstants.STATUS_ANY);
    }
    PortletPreferences portletPreferences = renderRequest.getPreferences();
    long kbFolderClassNameId = ClassNameLocalServiceUtil.getClassNameId(KBFolderConstants.getClassName());
    long parentResourcePrimKey = GetterUtil.getLong(portletPreferences.getValue("resourcePrimKey", null));
    long parentResourceClassNameId = GetterUtil.getLong(portletPreferences.getValue("resourceClassNameId", null), kbFolderClassNameId);
    KBArticleSelector kbArticleSelector = KBArticleSelectorFactoryUtil.getKBArticleSelector(parentResourceClassNameId);
    String urlTitle = ParamUtil.getString(renderRequest, "urlTitle");
    String preferredKBFolderURLTitle = getPreferredKBFolderUrlTitle(renderRequest, portletPreferences);
    if (Validator.isNotNull(urlTitle)) {
        String kbFolderUrlTitle = ParamUtil.getString(renderRequest, "kbFolderUrlTitle");
        return kbArticleSelector.findByUrlTitle(PortalUtil.getScopeGroupId(renderRequest), preferredKBFolderURLTitle, parentResourcePrimKey, kbFolderUrlTitle, urlTitle);
    }
    long resourcePrimKey = ParamUtil.getLong(renderRequest, "resourcePrimKey", KBArticleConstants.DEFAULT_PARENT_RESOURCE_PRIM_KEY);
    return kbArticleSelector.findByResourcePrimKey(PortalUtil.getScopeGroupId(renderRequest), preferredKBFolderURLTitle, parentResourcePrimKey, resourcePrimKey);
}
Also used : PortletPreferences(javax.portlet.PortletPreferences) KBArticleSelector(com.liferay.knowledgebase.display.selector.KBArticleSelector)

Example 4 with PortletPreferences

use of javax.portlet.PortletPreferences in project liferay-ide by liferay.

the class DisplayPortlet method updateRootKBFolderId.

public void updateRootKBFolderId(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortalException, SystemException {
    long kbFolderId = ParamUtil.getLong(actionRequest, "rootKBFolderId");
    if (kbFolderId == KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
        return;
    }
    KBFolder kbFolder = KBFolderServiceUtil.getKBFolder(kbFolderId);
    PortalPreferences portalPreferences = PortletPreferencesFactoryUtil.getPortalPreferences(PortalUtil.getLiferayPortletRequest(actionRequest));
    PortletPreferences portletPreferences = actionRequest.getPreferences();
    String contentRootPrefix = GetterUtil.getString(portletPreferences.getValue("contentRootPrefix", null));
    String previousPreferredKBFolderURLTitle = KnowledgeBaseUtil.getPreferredKBFolderURLTitle(portalPreferences, contentRootPrefix);
    KnowledgeBaseUtil.setPreferredKBFolderURLTitle(portalPreferences, contentRootPrefix, kbFolder.getUrlTitle());
    String urlTitle = ParamUtil.getString(actionRequest, "urlTitle");
    if (Validator.isNull(urlTitle)) {
        return;
    }
    KBArticle kbArticle = KBArticleLocalServiceUtil.fetchKBArticleByUrlTitle(kbFolder.getGroupId(), kbFolder.getUrlTitle(), urlTitle);
    if (kbArticle == null) {
        if (Validator.isNull(previousPreferredKBFolderURLTitle)) {
            return;
        }
        kbArticle = findClosestMatchingKBArticle(kbFolder.getGroupId(), previousPreferredKBFolderURLTitle, kbFolder.getKbFolderId(), urlTitle);
        if (kbArticle == null) {
            return;
        }
    }
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    if (!KBArticlePermission.contains(themeDisplay.getPermissionChecker(), kbArticle, ActionKeys.VIEW)) {
        return;
    }
    PortletURL redirectURL = PortletURLFactoryUtil.create(actionRequest, PortletKeys.KNOWLEDGE_BASE_DISPLAY, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);
    redirectURL.setParameter("kbFolderUrlTitle", kbFolder.getUrlTitle());
    redirectURL.setParameter("urlTitle", kbArticle.getUrlTitle());
    actionResponse.sendRedirect(redirectURL.toString());
}
Also used : KBFolder(com.liferay.knowledgebase.model.KBFolder) KBArticle(com.liferay.knowledgebase.model.KBArticle) PortalPreferences(com.liferay.portlet.PortalPreferences) PortletPreferences(javax.portlet.PortletPreferences) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay) PortletURL(javax.portlet.PortletURL)

Example 5 with PortletPreferences

use of javax.portlet.PortletPreferences in project liferay-ide by liferay.

the class UpgradePortletPreferences method upgradePreferences.

@Override
protected String upgradePreferences(long companyId, long ownerId, int ownerType, long plid, String portletId, String xml) throws Exception {
    PortletPreferences portletPreferences = PortletPreferencesFactoryUtil.fromXML(companyId, ownerId, ownerType, plid, portletId, xml);
    for (int i = 0; i < _PREFERENCE_NAMES.length; i++) {
        String sourcePreferenceName = _PREFERENCE_NAMES[i][0];
        String targetPreferenceName = _PREFERENCE_NAMES[i][1];
        String value = portletPreferences.getValue(sourcePreferenceName, null);
        portletPreferences.setValue(targetPreferenceName, value);
        portletPreferences.reset(sourcePreferenceName);
    }
    return PortletPreferencesFactoryUtil.toXML(portletPreferences);
}
Also used : BaseUpgradePortletPreferences(com.liferay.portal.kernel.upgrade.BaseUpgradePortletPreferences) PortletPreferences(javax.portlet.PortletPreferences)

Aggregations

PortletPreferences (javax.portlet.PortletPreferences)59 HashMap (java.util.HashMap)12 RenderMapping (org.springframework.web.portlet.bind.annotation.RenderMapping)10 ModelAndView (org.springframework.web.portlet.ModelAndView)9 List (java.util.List)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 PortletRequest (javax.portlet.PortletRequest)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 IPerson (org.apereo.portal.security.IPerson)5 ResourceMapping (org.springframework.web.portlet.bind.annotation.ResourceMapping)5 KBArticle (com.liferay.knowledgebase.model.KBArticle)4 Map (java.util.Map)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 ArrayList (java.util.ArrayList)3 LinkedHashMap (java.util.LinkedHashMap)3 AdminSubscriptionSender (com.liferay.knowledgebase.admin.util.AdminSubscriptionSender)2 KBFolder (com.liferay.knowledgebase.model.KBFolder)2 BaseUpgradePortletPreferences (com.liferay.portal.kernel.upgrade.BaseUpgradePortletPreferences)2 Portlet (com.liferay.portal.model.Portlet)2 ThemeDisplay (com.liferay.portal.theme.ThemeDisplay)2