Search in sources :

Example 1 with TenantListItem

use of org.wso2.carbon.identity.api.server.tenant.management.v1.model.TenantListItem in project identity-api-server by wso2.

the class ServerTenantManagementService method getTenantListItems.

private List<TenantListItem> getTenantListItems(List<Tenant> tenants) {
    List<TenantListItem> tenantListItems = new ArrayList<>();
    for (Tenant tenant : tenants) {
        TenantListItem listItem = new TenantListItem();
        listItem.setLifecycleStatus(getLifeCycleStatus(tenant.isActive()));
        listItem.setCreatedDate(getISOFormatDate(tenant.getCreatedDate()));
        listItem.setDomain(tenant.getDomain());
        listItem.setId(tenant.getTenantUniqueID());
        listItem.setOwners(getOwnerResponses(tenant));
        tenantListItems.add(listItem);
    }
    return tenantListItems;
}
Also used : Tenant(org.wso2.carbon.user.core.tenant.Tenant) TenantListItem(org.wso2.carbon.identity.api.server.tenant.management.v1.model.TenantListItem) ArrayList(java.util.ArrayList)

Example 2 with TenantListItem

use of org.wso2.carbon.identity.api.server.tenant.management.v1.model.TenantListItem 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;
}
Also used : Tenant(org.wso2.carbon.user.core.tenant.Tenant) TenantListItem(org.wso2.carbon.identity.api.server.tenant.management.v1.model.TenantListItem) TenantsListResponse(org.wso2.carbon.identity.api.server.tenant.management.v1.model.TenantsListResponse)

Aggregations

TenantListItem (org.wso2.carbon.identity.api.server.tenant.management.v1.model.TenantListItem)2 Tenant (org.wso2.carbon.user.core.tenant.Tenant)2 ArrayList (java.util.ArrayList)1 TenantsListResponse (org.wso2.carbon.identity.api.server.tenant.management.v1.model.TenantsListResponse)1