class MsoTenantAdapterImpl implements MsoTenantAdapter {

    @Override
    public void queryTenant(String cloudSiteId, String tenantNameOrId, MsoRequest msoRequest, Holder<String> tenantId,
            Holder<String> tenantName, Holder<Map<String, String>> metadata) throws TenantException {

        logger.debug("Querying Tenant {} in {}", tenantNameOrId, cloudSiteId);

        MsoTenantUtils tUtils;
        try {
            tUtils = tFactory.getTenantUtils(cloudSiteId);
        } catch (MsoCloudSiteNotFound me) {
            logger.error("{} {} no implementation found for {}: ", MessageEnum.RA_CREATE_TENANT_ERR,
                    ErrorCode.DataError.getValue(), cloudSiteId, me);
            throw new TenantException(me);
        }

        MsoTenant qTenant = null;
        try {
            qTenant = tUtils.queryTenant(tenantNameOrId, cloudSiteId);
            if (qTenant == null) {
                // Not found by ID, Try by name.
                qTenant = tUtils.queryTenantByName(tenantNameOrId, cloudSiteId);
            }

            if (qTenant == null) {
                logger.debug("QueryTenant: Tenant {} not found", tenantNameOrId);
                tenantId.value = null;
                tenantName.value = null;
                metadata.value = null;
            } else {
                logger.debug("QueryTenant: Tenant {} found with ID {}", tenantNameOrId, qTenant.getTenantId());
                tenantId.value = qTenant.getTenantId();
                tenantName.value = qTenant.getTenantName();
                metadata.value = qTenant.getMetadata();
            }
        } catch (MsoException me) {
            logger.error("Exception in queryTenant for {}: ", MessageEnum.RA_GENERAL_EXCEPTION,
                    ErrorCode.DataError.getValue(), tenantNameOrId, me);
            throw new TenantException(me);
        }
        return;
    }

}