use of io.gravitee.management.service.exceptions.TechnicalManagementException in project gravitee-management-rest-api by gravitee-io.
the class TagServiceImpl method update.
@Override
public List<TagEntity> update(final List<UpdateTagEntity> tagEntities) {
final List<TagEntity> savedTags = new ArrayList<>(tagEntities.size());
tagEntities.forEach(tagEntity -> {
try {
Tag tag = convert(tagEntity);
Optional<Tag> tagOptional = tagRepository.findById(tag.getId());
if (tagOptional.isPresent()) {
savedTags.add(convert(tagRepository.update(tag)));
auditService.createPortalAuditLog(Collections.singletonMap(TAG, tag.getId()), TAG_UPDATED, new Date(), tagOptional.get(), tag);
}
} catch (TechnicalException ex) {
LOGGER.error("An error occurs while trying to update tag {}", tagEntity.getName(), ex);
throw new TechnicalManagementException("An error occurs while trying to update tag " + tagEntity.getName(), ex);
}
});
return savedTags;
}
use of io.gravitee.management.service.exceptions.TechnicalManagementException in project gravitee-management-rest-api by gravitee-io.
the class TaskServiceImpl method convert.
private TaskEntity convert(SubscriptionEntity subscription) {
TaskEntity taskEntity = new TaskEntity();
try {
taskEntity.setType(TaskType.SUBSCRIPTION_APPROVAL);
taskEntity.setCreatedAt(subscription.getCreatedAt());
taskEntity.setData(subscription);
} catch (Exception e) {
LOGGER.error("Error converting subscription {} to a Task", subscription.getId());
throw new TechnicalManagementException("Error converting subscription " + subscription.getId() + " to a Task", e);
}
return taskEntity;
}
use of io.gravitee.management.service.exceptions.TechnicalManagementException 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;
}
use of io.gravitee.management.service.exceptions.TechnicalManagementException in project gravitee-management-rest-api by gravitee-io.
the class TenantServiceImpl method findById.
@Override
public TenantEntity findById(String tenantId) {
try {
LOGGER.debug("Find tenant by ID: {}", tenantId);
Optional<Tenant> optTenant = tenantRepository.findById(tenantId);
if (!optTenant.isPresent()) {
throw new TenantNotFoundException(tenantId);
}
return convert(optTenant.get());
} catch (TechnicalException ex) {
LOGGER.error("An error occurs while trying to find tenant by ID", ex);
throw new TechnicalManagementException("An error occurs while trying to find tenant by ID", ex);
}
}
use of io.gravitee.management.service.exceptions.TechnicalManagementException 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);
}
}
Aggregations