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);
}
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);
}
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);
}
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());
}
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);
}
Aggregations