Search in sources :

Example 6 with Tenant

use of io.gravitee.repository.management.model.Tenant in project gravitee-management-rest-api by gravitee-io.

the class TenantServiceImpl method delete.

@Override
public void delete(final String tenantId) {
    try {
        Optional<Tenant> tenantOptional = tenantRepository.findById(tenantId);
        if (tenantOptional.isPresent()) {
            tenantRepository.delete(tenantId);
            auditService.createPortalAuditLog(Collections.singletonMap(TENANT, tenantId), TENANT_DELETED, new Date(), null, tenantOptional.get());
            tenantRepository.delete(tenantId);
        }
    } catch (TechnicalException ex) {
        LOGGER.error("An error occurs while trying to delete tenant {}", tenantId, ex);
        throw new TechnicalManagementException("An error occurs while trying to delete tenant " + tenantId, ex);
    }
}
Also used : Tenant(io.gravitee.repository.management.model.Tenant) TechnicalException(io.gravitee.repository.exceptions.TechnicalException) TechnicalManagementException(io.gravitee.management.service.exceptions.TechnicalManagementException)

Aggregations

Tenant (io.gravitee.repository.management.model.Tenant)6 TechnicalManagementException (io.gravitee.management.service.exceptions.TechnicalManagementException)4 TechnicalException (io.gravitee.repository.exceptions.TechnicalException)4 NewTenantEntity (io.gravitee.management.model.NewTenantEntity)2 TenantEntity (io.gravitee.management.model.TenantEntity)2 UpdateTenantEntity (io.gravitee.management.model.UpdateTenantEntity)2 TenantNotFoundException (io.gravitee.management.service.exceptions.TenantNotFoundException)2 IdGenerator (io.gravitee.common.utils.IdGenerator)1 AuditService (io.gravitee.management.service.AuditService)1 TenantService (io.gravitee.management.service.TenantService)1 DuplicateTenantNameException (io.gravitee.management.service.exceptions.DuplicateTenantNameException)1 TenantRepository (io.gravitee.repository.management.api.TenantRepository)1 TENANT (io.gravitee.repository.management.model.Audit.AuditProperties.TENANT)1 TENANT_CREATED (io.gravitee.repository.management.model.Tenant.AuditEvent.TENANT_CREATED)1 TENANT_DELETED (io.gravitee.repository.management.model.Tenant.AuditEvent.TENANT_DELETED)1 TENANT_UPDATED (io.gravitee.repository.management.model.Tenant.AuditEvent.TENANT_UPDATED)1 java.util (java.util)1 Collectors (java.util.stream.Collectors)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1