Search in sources :

Example 6 with ExpandoColumn

use of com.liferay.portlet.expando.model.ExpandoColumn 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

ExpandoColumn (com.liferay.portlet.expando.model.ExpandoColumn)6 Role (com.liferay.portal.model.Role)2 User (com.liferay.portal.model.User)2 ExpandoTable (com.liferay.portlet.expando.model.ExpandoTable)2 HashMap (java.util.HashMap)2 Layout (com.liferay.portal.model.Layout)1 ThemeDisplay (com.liferay.portal.theme.ThemeDisplay)1 NoSuchTableException (com.liferay.portlet.expando.NoSuchTableException)1 ExpandoBridge (com.liferay.portlet.expando.model.ExpandoBridge)1 Map (java.util.Map)1 DataCollection (org.apache.shindig.protocol.DataCollection)1 UserId (org.apache.shindig.social.opensocial.spi.UserId)1