Search in sources :

Example 1 with UpdateTenantEntity

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

the class TenantServiceImpl method update.

@Override
public List<TenantEntity> update(final List<UpdateTenantEntity> tenantEntities) {
    final List<TenantEntity> savedTenants = new ArrayList<>(tenantEntities.size());
    tenantEntities.forEach(tenantEntity -> {
        try {
            Tenant tenant = convert(tenantEntity);
            Optional<Tenant> tenantOptional = tenantRepository.findById(tenant.getId());
            if (tenantOptional.isPresent()) {
                savedTenants.add(convert(tenantRepository.update(tenant)));
                auditService.createPortalAuditLog(Collections.singletonMap(TENANT, tenant.getId()), TENANT_UPDATED, new Date(), tenantOptional.get(), tenant);
            }
        } catch (TechnicalException ex) {
            LOGGER.error("An error occurs while trying to update tenant {}", tenantEntity.getName(), ex);
            throw new TechnicalManagementException("An error occurs while trying to update tenant " + tenantEntity.getName(), ex);
        }
    });
    return savedTenants;
}
Also used : Tenant(io.gravitee.repository.management.model.Tenant) TechnicalException(io.gravitee.repository.exceptions.TechnicalException) TenantEntity(io.gravitee.management.model.TenantEntity) NewTenantEntity(io.gravitee.management.model.NewTenantEntity) UpdateTenantEntity(io.gravitee.management.model.UpdateTenantEntity) TechnicalManagementException(io.gravitee.management.service.exceptions.TechnicalManagementException)

Aggregations

NewTenantEntity (io.gravitee.management.model.NewTenantEntity)1 TenantEntity (io.gravitee.management.model.TenantEntity)1 UpdateTenantEntity (io.gravitee.management.model.UpdateTenantEntity)1 TechnicalManagementException (io.gravitee.management.service.exceptions.TechnicalManagementException)1 TechnicalException (io.gravitee.repository.exceptions.TechnicalException)1 Tenant (io.gravitee.repository.management.model.Tenant)1