@Override public void showMessage(MessageParams messageParams) { eventService.publish(messageParams); }
private <T> void handle(T event) { eventService.publish(event); } }
@Override public void publishDiagnostics(PublishDiagnosticsParams diagnostics) { eventService.publish(new ExtendedPublishDiagnosticsParams(serverId, diagnostics)); }
/** Synchronously stops corresponding services. */ private void doStopServices() { LOG.info("Preparing system to shutdown"); eventService.publish(asDto(new SystemStatusChangedEvent(RUNNING, PREPARING_TO_SHUTDOWN))); try { terminator.terminateAll(); statusRef.set(READY_TO_SHUTDOWN); eventService.publish( asDto(new SystemStatusChangedEvent(PREPARING_TO_SHUTDOWN, READY_TO_SHUTDOWN))); LOG.info("System is ready to shutdown"); } catch (InterruptedException x) { LOG.error("Interrupted while waiting for system service to shutdown components"); Thread.currentThread().interrupt(); } finally { shutdownLatch.countDown(); } }
/** Synchronously stops corresponding services. */ private void doSuspendServices() { LOG.info("Preparing system to shutdown"); eventService.publish(asDto(new SystemStatusChangedEvent(RUNNING, PREPARING_TO_SHUTDOWN))); try { terminator.suspendAll(); statusRef.set(READY_TO_SHUTDOWN); eventService.publish( asDto(new SystemStatusChangedEvent(PREPARING_TO_SHUTDOWN, READY_TO_SHUTDOWN))); LOG.info("System is ready to shutdown"); } catch (InterruptedException x) { LOG.error("Interrupted while waiting for system service to shutdown components"); Thread.currentThread().interrupt(); } finally { shutdownLatch.countDown(); } }
@Transactional(rollbackOn = {RuntimeException.class, ServerException.class}) protected Optional<WorkspaceImpl> doRemove(String id) throws ServerException { final WorkspaceImpl workspace = managerProvider.get().find(WorkspaceImpl.class, id); if (workspace == null) { return Optional.empty(); } final EntityManager manager = managerProvider.get(); eventService .publish(new BeforeWorkspaceRemovedEvent(new WorkspaceImpl(workspace))) .propagateException(); manager.remove(workspace); manager.flush(); return Optional.of(workspace); }
@Transactional(rollbackOn = {RuntimeException.class, ServerException.class}) protected Optional<WorkspaceImpl> doRemove(String id) throws ServerException { final WorkspaceImpl workspace = managerProvider.get().find(WorkspaceImpl.class, id); if (workspace == null) { return Optional.empty(); } final EntityManager manager = managerProvider.get(); eventService .publish(new BeforeWorkspaceRemovedEvent(new WorkspaceImpl(workspace))) .propagateException(); manager.remove(workspace); manager.flush(); return Optional.of(workspace); }
@Transactional(rollbackOn = {RuntimeException.class, ServerException.class}) protected void doRemove(String id) throws ServerException { final EntityManager manager = managerProvider.get(); final StackImpl stack = manager.find(StackImpl.class, id); if (stack != null) { eventService.publish(new BeforeStackRemovedEvent(new StackImpl(stack))).propagateException(); manager.remove(stack); manager.flush(); } }
@Transactional(rollbackOn = {RuntimeException.class, ServerException.class}) protected void doRemove(String id) throws ServerException { final EntityManager manager = managerProvider.get(); final StackImpl stack = manager.find(StackImpl.class, id); if (stack != null) { eventService.publish(new BeforeStackRemovedEvent(new StackImpl(stack))).propagateException(); manager.remove(stack); manager.flush(); } }
@Override public void remove(String id) throws ServerException { requireNonNull(id, "Required non-null id"); try { Optional<WorkspaceImpl> workspaceOpt = doRemove(id); workspaceOpt.ifPresent( workspace -> eventService.publish(new WorkspaceRemovedEvent(workspace))); } catch (RuntimeException x) { throw new ServerException(x.getLocalizedMessage(), x); } }
@VisibleForTesting void doTerminate(ServiceTermination termination) throws InterruptedException { eventService.publish(new StoppingSystemServiceEvent(termination.getServiceName())); try { termination.terminate(); } catch (InterruptedException x) { LOG.error( "Interrupted while waiting for '{}' service to shutdown", termination.getServiceName()); throw x; } LOG.info("Service '{}' is shut down", termination.getServiceName()); eventService.publish(new SystemServiceStoppedEvent(termination.getServiceName())); }
@Override public void remove(String id) throws ServerException { requireNonNull(id, "Required non-null id"); try { Optional<WorkspaceImpl> workspaceOpt = doRemove(id); workspaceOpt.ifPresent( workspace -> eventService.publish(new WorkspaceRemovedEvent(workspace))); } catch (RuntimeException x) { throw new ServerException(x.getLocalizedMessage(), x); } }
@Transactional(rollbackOn = {RuntimeException.class, ApiException.class}) protected void doCreate(StackImpl stack) throws ConflictException, ServerException { if (stack.getWorkspaceConfig() != null) { stack.getWorkspaceConfig().getProjects().forEach(ProjectConfigImpl::prePersistAttributes); } EntityManager manager = managerProvider.get(); manager.persist(stack); manager.flush(); eventService.publish(new StackPersistedEvent(stack)).propagateException(); }
@Transactional(rollbackOn = {RuntimeException.class, ApiException.class}) protected void doCreate(StackImpl stack) throws ConflictException, ServerException { if (stack.getWorkspaceConfig() != null) { stack.getWorkspaceConfig().getProjects().forEach(ProjectConfigImpl::prePersistAttributes); } EntityManager manager = managerProvider.get(); manager.persist(stack); manager.flush(); eventService.publish(new StackPersistedEvent(stack)).propagateException(); }
@Transactional(rollbackOn = {RuntimeException.class, ApiException.class}) protected void doCreate(UserImpl user, boolean isTemporary) throws ConflictException, ServerException { userDao.create(user); eventService.publish(new PostUserPersistedEvent(new UserImpl(user))).propagateException(); preferencesDao.setPreferences( user.getId(), ImmutableMap.of( "temporary", Boolean.toString(isTemporary), "codenvy:created", Long.toString(currentTimeMillis()))); }
@Override public void onEvent(WorkspaceStatusEvent event) { if (event.getStatus() == WorkspaceStatus.STOPPED) { eventService.publish( asDto( new SystemServiceItemStoppedEvent( getServiceName(), event.getWorkspaceId(), currentlyStopped.incrementAndGet(), totalRunning))); } } }
@DELETE @Path("repository") public void deleteRepository(@Context UriInfo uriInfo) throws ApiException { ProjectConfig project = projectManager .get(projectPath) .orElseThrow(() -> new NotFoundException("Can't find project")); String dotGitWsPath = resolve(absolutize(projectPath), ".git"); fsManager.delete(dotGitWsPath); eventService.publish( newDto(GitRepositoryDeletedEvent.class) .withProjectName(project.getName()) .withProjectPath(projectPath)); }
private void publishWorkspaceStatusEvent( String workspaceId, WorkspaceStatus status, WorkspaceStatus previous, String errorMsg) { eventService.publish( DtoFactory.newDto(WorkspaceStatusEvent.class) .withWorkspaceId(workspaceId) .withPrevStatus(previous) .withError(errorMsg) .withStatus(status)); }
@Override public void onEvent(WorkspaceStatusEvent event) { if (event.getStatus() == WorkspaceStatus.STOPPED || event.getStatus() == WorkspaceStatus.RUNNING) { eventService.publish( asDto( new SystemServiceItemSuspendedEvent( getServiceName(), event.getWorkspaceId(), currentlyStopped.incrementAndGet(), totalRunning))); } } }
@Transactional(rollbackOn = {RuntimeException.class, ApiException.class}) protected void doRemove(String id) throws ServerException { UserImpl user; try { user = userDao.getById(id); } catch (NotFoundException ignored) { return; } preferencesDao.remove(id); eventService.publish(new BeforeUserRemovedEvent(user)).propagateException(); userDao.remove(id); }