use of com.enonic.xp.impl.server.rest.model.ApplicationUninstalledJson in project xp by enonic.
the class SseEntryPoint method handleEvent.
private void handleEvent(final Event event, final String eventSubType) {
final SseContextHolder ctx = contextHolder;
if (ctx == null) {
LOG.debug("Skipping {} {}. Please to subscribe to send SSE events.", EVENT_TYPE, eventSubType);
return;
}
if (event.getValue(APPLICATION_KEY_PARAM).isPresent()) {
final OutboundSseEvent.Builder eventBuilder = ctx.sse.newEventBuilder().name(eventSubType).id(UUID.randomUUID().toString()).mediaType(MediaType.APPLICATION_JSON_TYPE);
if (UNINSTALLED.equals(eventSubType)) {
eventBuilder.data(ApplicationUninstalledJson.class, new ApplicationUninstalledJson(event.getValue(APPLICATION_KEY_PARAM).get().toString()));
} else {
final ApplicationKey applicationKey = ApplicationKey.from(event.getValue(APPLICATION_KEY_PARAM).get().toString());
final Application application = applicationService.getInstalledApplication(applicationKey);
if (application == null) {
LOG.warn("Application \"{}\" not found", applicationKey);
return;
}
final boolean localApplication = applicationService.isLocalApplication(application.getKey());
eventBuilder.data(ApplicationInfoJson.class, new ApplicationInfoJson(application, localApplication));
}
ctx.broadcaster.broadcast(eventBuilder.build());
}
}
Aggregations