use of io.gravitee.rest.api.model.api.ApiEntity in project gravitee-management-rest-api by gravitee-io.
the class TicketServiceImpl method getApiNameAndApplicationName.
private Ticket getApiNameAndApplicationName(Ticket ticket) {
// Retrieve application name
if (StringUtils.isNotEmpty(ticket.getApplication())) {
ApplicationEntity application = applicationService.findById(ticket.getApplication());
ticket.setApplication(application.getName());
}
// Retrieve api name
if (StringUtils.isNotEmpty(ticket.getApi())) {
ApiEntity api = apiService.findById(ticket.getApi());
ticket.setApi(api.getName());
}
return ticket;
}
use of io.gravitee.rest.api.model.api.ApiEntity in project gravitee-management-rest-api by gravitee-io.
the class VirtualHostServiceImpl method convert.
private ApiEntity convert(Api api) {
ApiEntity apiEntity = new ApiEntity();
apiEntity.setId(api.getId());
if (api.getDefinition() != null) {
try {
io.gravitee.definition.model.Api apiDefinition = objectMapper.readValue(api.getDefinition(), io.gravitee.definition.model.Api.class);
apiEntity.setProxy(apiDefinition.getProxy());
// Sanitize virtual hosts
apiEntity.getProxy().setVirtualHosts(apiEntity.getProxy().getVirtualHosts().stream().map(this::sanitize).collect(Collectors.toList()));
} catch (IOException ioe) {
LOGGER.error("Unexpected error while getting API definition", ioe);
}
}
return apiEntity;
}
use of io.gravitee.rest.api.model.api.ApiEntity in project gravitee-management-rest-api by gravitee-io.
the class SubscriptionServiceImpl method getMetadata.
@Override
public Metadata getMetadata(List<SubscriptionEntity> subscriptions) {
Metadata metadata = new Metadata();
subscriptions.forEach(subscription -> {
if (!metadata.containsKey(subscription.getApplication())) {
ApplicationEntity applicationEntity = applicationService.findById(subscription.getApplication());
metadata.put(subscription.getApplication(), "name", applicationEntity.getName());
}
if (!metadata.containsKey(subscription.getPlan())) {
PlanEntity planEntity = planService.findById(subscription.getPlan());
metadata.put(subscription.getPlan(), "name", planEntity.getName());
}
if (!metadata.containsKey(subscription.getApi())) {
ApiEntity api = apiService.findById(subscription.getApi());
metadata.put(subscription.getApi(), "name", api.getName());
}
});
return metadata;
}
use of io.gravitee.rest.api.model.api.ApiEntity in project gravitee-management-rest-api by gravitee-io.
the class ScheduledSubscriptionPreExpirationNotificationService method notifySubscription.
private SubscriptionEntity notifySubscription(Integer daysToExpiration, SubscriptionEntity subscription) {
ApiEntity api = apiService.findById(subscription.getApi());
PlanEntity plan = planService.findById(subscription.getPlan());
ApplicationEntity application = applicationService.findById(subscription.getApplication());
findEmailsToNotify(subscription, application).forEach(email -> this.sendEmail(email, daysToExpiration, api, plan, application, null));
return subscriptionService.updateDaysToExpirationOnLastNotification(subscription.getId(), daysToExpiration);
}
use of io.gravitee.rest.api.model.api.ApiEntity in project gravitee-management-rest-api by gravitee-io.
the class ScheduledSubscriptionPreExpirationNotificationService method notificationApiKeyExpiration.
private ApiKeyEntity notificationApiKeyExpiration(Integer daysToExpiration, ApiKeyEntity apiKey) {
SubscriptionEntity subscription = subscriptionService.findById(apiKey.getSubscription());
ApiEntity api = apiService.findById(subscription.getApi());
PlanEntity plan = planService.findById(subscription.getPlan());
ApplicationEntity application = applicationService.findById(subscription.getApplication());
findEmailsToNotify(subscription, application).forEach(email -> this.sendEmail(email, daysToExpiration, api, plan, application, apiKey));
return apiKeyService.updateDaysToExpirationOnLastNotification(apiKey.getKey(), daysToExpiration);
}
Aggregations