Search in sources :

Example 1 with TenantMgtService

use of org.wso2.carbon.tenant.mgt.services.TenantMgtService 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);
    }
}
Also used : TenantSearchResult(org.wso2.carbon.user.core.tenant.TenantSearchResult) TenantMgtException(org.wso2.carbon.stratos.common.exception.TenantMgtException) TenantMgtService(org.wso2.carbon.tenant.mgt.services.TenantMgtService)

Example 2 with TenantMgtService

use of org.wso2.carbon.tenant.mgt.services.TenantMgtService in project identity-api-server by wso2.

the class ServerTenantManagementService method addTenant.

public String addTenant(ChannelVerifiedTenantModel channelVerifiedTenantModel) {
    String resourceId;
    TenantMgtService tenantMgtService = TenantManagementServiceHolder.getTenantMgtService();
    try {
        validateInputAgainstCode(channelVerifiedTenantModel);
        Tenant tenant = createTenantInfoBean(channelVerifiedTenantModel);
        resourceId = tenantMgtService.addTenant(tenant);
    } catch (TenantMgtException e) {
        throw handleTenantManagementException(e, TenantManagementConstants.ErrorMessage.ERROR_CODE_ERROR_ADDING_TENANT, null);
    }
    return resourceId;
}
Also used : Tenant(org.wso2.carbon.user.core.tenant.Tenant) TenantMgtException(org.wso2.carbon.stratos.common.exception.TenantMgtException) TenantMgtService(org.wso2.carbon.tenant.mgt.services.TenantMgtService)

Example 3 with TenantMgtService

use of org.wso2.carbon.tenant.mgt.services.TenantMgtService in project identity-api-server by wso2.

the class ServerTenantManagementService method addTenant.

/**
 * Add a tenant.
 *
 * @param tenantModel tenantModel.
 * @return TenantResponseModel.
 */
public String addTenant(TenantModel tenantModel) {
    String resourceId;
    TenantMgtService tenantMgtService = TenantManagementServiceHolder.getTenantMgtService();
    try {
        Tenant tenant = createTenantInfoBean(tenantModel);
        resourceId = tenantMgtService.addTenant(tenant);
    } catch (TenantMgtException e) {
        throw handleTenantManagementException(e, TenantManagementConstants.ErrorMessage.ERROR_CODE_ERROR_ADDING_TENANT, null);
    }
    return resourceId;
}
Also used : Tenant(org.wso2.carbon.user.core.tenant.Tenant) TenantMgtException(org.wso2.carbon.stratos.common.exception.TenantMgtException) TenantMgtService(org.wso2.carbon.tenant.mgt.services.TenantMgtService)

Aggregations

TenantMgtException (org.wso2.carbon.stratos.common.exception.TenantMgtException)3 TenantMgtService (org.wso2.carbon.tenant.mgt.services.TenantMgtService)3 Tenant (org.wso2.carbon.user.core.tenant.Tenant)2 TenantSearchResult (org.wso2.carbon.user.core.tenant.TenantSearchResult)1