use of org.wso2.carbon.identity.api.server.tenant.management.v1.model.TenantsListResponse in project identity-api-server by wso2.
the class ServerTenantManagementService method listTenants.
/**
* Get tenant list.
*
* @param limit Items per page.
* @param offset Offset.
* @param filter Filter string. E.g. filter="domainName" sw "wso2.com"
* @param sortBy Attribute to sort the tenants by. E.g. domainName
* @param sortOrder Order in which tenants should be sorted. Can be either ASC or DESC.
* @return TenantsListResponse.
*/
public TenantsListResponse listTenants(Integer limit, Integer offset, String sortOrder, String sortBy, String filter) {
handleNotImplementedCapabilities(filter);
TenantMgtService tenantMgtService = TenantManagementServiceHolder.getTenantMgtService();
try {
TenantSearchResult tenantSearchResult = tenantMgtService.listTenants(limit, offset, sortOrder, sortBy, filter);
return createTenantListResponse(tenantSearchResult);
} catch (TenantMgtException e) {
throw handleTenantManagementException(e, TenantManagementConstants.ErrorMessage.ERROR_CODE_ERROR_LISTING_TENANTS, null);
}
}
use of org.wso2.carbon.identity.api.server.tenant.management.v1.model.TenantsListResponse in project identity-api-server by wso2.
the class ServerTenantManagementService method createTenantListResponse.
private TenantsListResponse createTenantListResponse(TenantSearchResult tenantSearchResult) {
List<Tenant> tenants = tenantSearchResult.getTenantList();
TenantsListResponse listResponse = new TenantsListResponse();
if (CollectionUtils.isNotEmpty(tenants)) {
List<TenantListItem> tenantListItems = getTenantListItems(tenants);
listResponse.setTenants(tenantListItems);
listResponse.setCount(tenantListItems.size());
} else {
listResponse.setCount(0);
}
listResponse.setTotalResults(tenantSearchResult.getTotalTenantCount());
listResponse.setStartIndex(tenantSearchResult.getOffSet() + 1);
listResponse.setLinks(createLinks(V1_API_PATH_COMPONENT + TENANT_MANAGEMENT_PATH_COMPONENT, tenantSearchResult.getLimit(), tenantSearchResult.getOffSet(), tenantSearchResult.getTotalTenantCount(), tenantSearchResult.getFilter()));
return listResponse;
}
Aggregations