Skip to content

Commit e8cbc7c

Browse files
lfbesadabrianchandotcom
authored andcommitted
LPD-49304 Check the portlet could be added to this page
1 parent 2e29e67 commit e8cbc7c

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

modules/apps/layout/layout-impl/src/main/java/com/liferay/layout/internal/struts/UpdateLayoutStrutsAction.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,12 +404,27 @@ private void _checkPortletPermission(
404404
themeDisplay.getPermissionChecker(), portletId,
405405
ActionKeys.ADD_TO_PAGE);
406406

407-
PortletCategory portletCategory = (PortletCategory)WebAppPool.get(
408-
themeDisplay.getCompanyId(), WebKeys.PORTLET_CATEGORY);
409-
410407
Portlet portlet = _portletLocalService.getPortletById(
411408
themeDisplay.getCompanyId(), portletId);
412409

410+
LayoutTypePortlet layoutTypePortlet =
411+
themeDisplay.getLayoutTypePortlet();
412+
413+
if (!portlet.isActive() || !portlet.isInclude() ||
414+
(!portlet.isInstanceable() &&
415+
layoutTypePortlet.hasPortletId(portlet.getPortletId())) ||
416+
portlet.isSystem() || portlet.isUndeployedPortlet()) {
417+
418+
throw new PrincipalException.MustHavePermission(
419+
themeDisplay.getPermissionChecker(),
420+
StringBundler.concat(
421+
Portlet.class.getName(), StringPool.UNDERLINE, portletId),
422+
0, ActionKeys.ADD_TO_PAGE);
423+
}
424+
425+
PortletCategory portletCategory = (PortletCategory)WebAppPool.get(
426+
themeDisplay.getCompanyId(), WebKeys.PORTLET_CATEGORY);
427+
413428
Set<String> categoryNames = portlet.getCategoryNames();
414429

415430
for (PortletCategory curPortletCategory :

0 commit comments

Comments
 (0)