Search in sources :

Example 71 with IdentityRoleManagementException

use of org.wso2.carbon.identity.role.mgt.core.IdentityRoleManagementException in project identity-inbound-provisioning-scim2 by wso2-extensions.

the class SCIMRoleManager method listRoles.

/**
 * Method to list roles.
 *
 * @param startIndex Starting index of the results.
 * @param count      Results count value.
 * @param sortBy     SortBy.
 * @param sortOrder  Sorting order.
 * @return List of roles.
 * @throws CharonException Error while listing users
 */
private List<Object> listRoles(Integer count, Integer startIndex, String sortBy, String sortOrder) throws CharonException, BadRequestException {
    List<Object> rolesList = new ArrayList<>();
    try {
        // 0th index is to store total number of results.
        rolesList.add(0);
        List<RoleBasicInfo> roles = roleManagementService.getRoles(count, startIndex, sortBy, sortOrder, tenantDomain);
        List<Object> scimRoles = getScimRolesList(roles);
        // Set total number of results to 0th index.
        rolesList.set(0, scimRoles.size());
        // Add the results list.
        rolesList.addAll(scimRoles);
    } catch (IdentityRoleManagementException e) {
        throw new CharonException("Error occurred while listing roles.", e);
    }
    return rolesList;
}
Also used : ArrayList(java.util.ArrayList) CharonException(org.wso2.charon3.core.exceptions.CharonException) RoleBasicInfo(org.wso2.carbon.identity.role.mgt.core.RoleBasicInfo) IdentityRoleManagementException(org.wso2.carbon.identity.role.mgt.core.IdentityRoleManagementException)

Aggregations

IdentityRoleManagementClientException (org.wso2.carbon.identity.role.mgt.core.IdentityRoleManagementClientException)29 IdentityRoleManagementServerException (org.wso2.carbon.identity.role.mgt.core.IdentityRoleManagementServerException)23 RoleBasicInfo (org.wso2.carbon.identity.role.mgt.core.RoleBasicInfo)22 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)20 Test (org.testng.annotations.Test)20 NamedPreparedStatement (org.wso2.carbon.database.utils.jdbc.NamedPreparedStatement)20 Connection (java.sql.Connection)19 SQLException (java.sql.SQLException)19 Matchers.anyString (org.mockito.Matchers.anyString)14 IdentityRoleManagementException (org.wso2.carbon.identity.role.mgt.core.IdentityRoleManagementException)14 Role (org.wso2.charon3.core.objects.Role)13 ResultSet (java.sql.ResultSet)12 RoleManagementEventPublisherProxy (org.wso2.carbon.identity.role.mgt.core.RoleManagementEventPublisherProxy)11 ArrayList (java.util.ArrayList)9 CharonException (org.wso2.charon3.core.exceptions.CharonException)8 ExpressionNode (org.wso2.charon3.core.utils.codeutils.ExpressionNode)8 Node (org.wso2.charon3.core.utils.codeutils.Node)8 OperationNode (org.wso2.charon3.core.utils.codeutils.OperationNode)8 UserStoreException (org.wso2.carbon.user.api.UserStoreException)6 BadRequestException (org.wso2.charon3.core.exceptions.BadRequestException)6