Search in sources :

Example 16 with Role

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

the class BaseGadgetPortlet method checkExpando.

protected void checkExpando(RenderRequest renderRequest, RenderResponse renderResponse) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
    ExpandoTable expandoTable = ExpandoTableLocalServiceUtil.getTable(themeDisplay.getCompanyId(), Layout.class.getName(), ShindigUtil.getTableOpenSocial());
    String namespace = renderResponse.getNamespace();
    String columnName = ShindigUtil.getColumnUserPrefs(namespace, themeDisplay);
    ExpandoColumn expandoColumn = ExpandoColumnLocalServiceUtil.getColumn(expandoTable.getTableId(), columnName);
    if (expandoColumn == null) {
        expandoColumn = ExpandoColumnLocalServiceUtil.addColumn(expandoTable.getTableId(), columnName, ExpandoColumnConstants.STRING);
        Map<Long, String[]> roleIdsToActionIds = new HashMap<Long, String[]>();
        Role guestRole = RoleLocalServiceUtil.getRole(expandoColumn.getCompanyId(), RoleConstants.GUEST);
        roleIdsToActionIds.put(guestRole.getRoleId(), new String[] { ActionKeys.VIEW });
        Role userRole = RoleLocalServiceUtil.getRole(expandoColumn.getCompanyId(), RoleConstants.USER);
        roleIdsToActionIds.put(userRole.getRoleId(), new String[] { ActionKeys.UPDATE, ActionKeys.VIEW });
        ResourcePermissionLocalServiceUtil.setResourcePermissions(expandoColumn.getCompanyId(), ExpandoColumn.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, String.valueOf(expandoColumn.getColumnId()), roleIdsToActionIds);
    }
}
Also used : Role(com.liferay.portal.model.Role) ExpandoTable(com.liferay.portlet.expando.model.ExpandoTable) Layout(com.liferay.portal.model.Layout) HashMap(java.util.HashMap) ExpandoColumn(com.liferay.portlet.expando.model.ExpandoColumn) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Aggregations

Role (com.liferay.portal.model.Role)16 UserGroupRole (com.liferay.portal.model.UserGroupRole)11 Group (com.liferay.portal.model.Group)5 Indexer (com.liferay.portal.kernel.search.Indexer)4 User (com.liferay.portal.model.User)3 ThemeDisplay (com.liferay.portal.theme.ThemeDisplay)3 ArrayList (java.util.ArrayList)3 UserGroup (com.liferay.portal.model.UserGroup)2 ExpandoColumn (com.liferay.portlet.expando.model.ExpandoColumn)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 LinkedHashMap (java.util.LinkedHashMap)2 NoSuchRoleException (com.liferay.portal.NoSuchRoleException)1 PortalException (com.liferay.portal.kernel.exception.PortalException)1 SystemException (com.liferay.portal.kernel.exception.SystemException)1 BooleanQuery (com.liferay.portal.kernel.search.BooleanQuery)1 SearchPermissionChecker (com.liferay.portal.kernel.search.SearchPermissionChecker)1 UnicodeProperties (com.liferay.portal.kernel.util.UnicodeProperties)1 UniqueList (com.liferay.portal.kernel.util.UniqueList)1 Layout (com.liferay.portal.model.Layout)1