use of com.liferay.portal.theme.ThemeDisplay in project liferay-ide by liferay.
the class ArticlePortlet method getResourcePrimKey.
protected long getResourcePrimKey(RenderRequest renderRequest) throws Exception {
ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
PortletPreferences preferences = renderRequest.getPreferences();
long defaultValue = GetterUtil.getLong(preferences.getValue("resourcePrimKey", null));
String mvcPath = ParamUtil.getString(renderRequest, "mvcPath");
if (((defaultValue == 0) && mvcPath.equals(viewTemplate)) || mvcPath.equals("/article/select_configuration_article.jsp")) {
return 0;
}
long resourcePrimKey = ParamUtil.getLong(renderRequest, "resourcePrimKey", defaultValue);
if ((resourcePrimKey == 0) || (resourcePrimKey != defaultValue)) {
return resourcePrimKey;
}
PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();
if (!KBArticlePermission.contains(permissionChecker, defaultValue, ActionKeys.VIEW)) {
return 0;
}
return defaultValue;
}
use of com.liferay.portal.theme.ThemeDisplay in project liferay-ide by liferay.
the class AdminPortlet method deleteKBTemplates.
public void deleteKBTemplates(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
long[] kbTemplateIds = StringUtil.split(ParamUtil.getString(actionRequest, "kbTemplateIds"), 0L);
KBTemplateServiceUtil.deleteKBTemplates(themeDisplay.getScopeGroupId(), kbTemplateIds);
}
use of com.liferay.portal.theme.ThemeDisplay in project liferay-ide by liferay.
the class AdminPortlet method buildEditURL.
@Override
protected String buildEditURL(ActionRequest actionRequest, ActionResponse actionResponse, KBArticle kbArticle) throws PortalException, SystemException {
try {
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
PortletURL portletURL = PortletURLFactoryUtil.create(actionRequest, PortletKeys.KNOWLEDGE_BASE_ADMIN, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);
portletURL.setParameter("mvcPath", templatePath + "edit_article.jsp");
portletURL.setParameter("redirect", getRedirect(actionRequest, actionResponse));
portletURL.setParameter("resourcePrimKey", String.valueOf(kbArticle.getResourcePrimKey()));
portletURL.setWindowState(actionRequest.getWindowState());
return portletURL.toString();
} catch (WindowStateException wse) {
throw new PortalException(wse);
}
}
use of com.liferay.portal.theme.ThemeDisplay in project liferay-ide by liferay.
the class AdminPortlet method updateKBFolder.
public void updateKBFolder(ActionRequest actionRequest, ActionResponse actionResponse) throws PortalException, SystemException {
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
long kbFolderId = ParamUtil.getLong(actionRequest, "kbFolderId");
long parentResourceClassNameId = ParamUtil.getLong(actionRequest, "parentResourceClassNameId");
long parentResourcePrimKey = ParamUtil.getLong(actionRequest, "parentResourcePrimKey");
String name = ParamUtil.getString(actionRequest, "name");
String description = ParamUtil.getString(actionRequest, "description");
ServiceContext serviceContext = ServiceContextFactory.getInstance(KBFolder.class.getName(), actionRequest);
if (cmd.equals(Constants.ADD)) {
KBFolderServiceUtil.addKBFolder(themeDisplay.getScopeGroupId(), parentResourceClassNameId, parentResourcePrimKey, name, description, serviceContext);
} else if (cmd.equals(Constants.UPDATE)) {
KBFolderServiceUtil.updateKBFolder(parentResourceClassNameId, parentResourcePrimKey, kbFolderId, name, description);
}
}
use of com.liferay.portal.theme.ThemeDisplay in project liferay-ide by liferay.
the class AdminPortlet method updateKBArticlesPriorities.
public void updateKBArticlesPriorities(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
Enumeration<String> enu = actionRequest.getParameterNames();
Map<Long, Double> resourcePrimKeyToPriorityMap = new HashMap<Long, Double>();
while (enu.hasMoreElements()) {
String name = enu.nextElement();
if (!name.startsWith("priority")) {
continue;
}
double priority = ParamUtil.getDouble(actionRequest, name);
long resourcePrimKey = GetterUtil.getLong(name.substring(8));
resourcePrimKeyToPriorityMap.put(resourcePrimKey, priority);
}
KBArticleServiceUtil.updateKBArticlesPriorities(themeDisplay.getScopeGroupId(), resourcePrimKeyToPriorityMap);
}
Aggregations