Search in sources :

Example 1 with ExpandoTable

use of com.liferay.portlet.expando.model.ExpandoTable in project liferay-ide by liferay.

the class UpgradeExpandoTable method updateExpandoTable.

protected void updateExpandoTable(long companyId) throws Exception {
    ExpandoTable expandoTable = null;
    try {
        expandoTable = ExpandoTableLocalServiceUtil.getTable(companyId, Subscription.class.getName(), "KB");
    } catch (NoSuchTableException nste) {
        return;
    }
    ExpandoTableLocalServiceUtil.deleteExpandoTable(expandoTable);
}
Also used : ExpandoTable(com.liferay.portlet.expando.model.ExpandoTable) NoSuchTableException(com.liferay.portlet.expando.NoSuchTableException)

Example 2 with ExpandoTable

use of com.liferay.portlet.expando.model.ExpandoTable in project liferay-ide by liferay.

the class LiferayAppDataService method getExpandoColumn.

protected ExpandoColumn getExpandoColumn(long companyId, String columnName) throws Exception {
    ExpandoTable expandoTable = null;
    try {
        expandoTable = ExpandoTableLocalServiceUtil.getTable(companyId, User.class.getName(), ShindigUtil.getTableOpenSocial());
    } catch (NoSuchTableException nste) {
        _log.error(nste, nste);
    }
    ExpandoColumn expandoColumn = ExpandoColumnLocalServiceUtil.getColumn(expandoTable.getTableId(), columnName);
    if (expandoColumn == null) {
        expandoColumn = ExpandoColumnLocalServiceUtil.addColumn(expandoTable.getTableId(), columnName, ExpandoColumnConstants.STRING);
    }
    return expandoColumn;
}
Also used : ExpandoTable(com.liferay.portlet.expando.model.ExpandoTable) ExpandoColumn(com.liferay.portlet.expando.model.ExpandoColumn) NoSuchTableException(com.liferay.portlet.expando.NoSuchTableException)

Example 3 with ExpandoTable

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

ExpandoTable (com.liferay.portlet.expando.model.ExpandoTable)3 NoSuchTableException (com.liferay.portlet.expando.NoSuchTableException)2 ExpandoColumn (com.liferay.portlet.expando.model.ExpandoColumn)2 Layout (com.liferay.portal.model.Layout)1 Role (com.liferay.portal.model.Role)1 ThemeDisplay (com.liferay.portal.theme.ThemeDisplay)1 HashMap (java.util.HashMap)1