@Override public void onCascadeEvent(BeforeWorkspaceRemovedEvent event) throws Exception { signatureKeyDao.remove(event.getWorkspace().getId()); } }
@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 onCascadeEvent(BeforeStackRemovedEvent event) throws Exception { removeStackPermissions(event.getStack().getId(), PAGE_SIZE); }
@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, 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(); }
@Override public void onEvent(RuntimeAbnormalStoppingEvent event) { RuntimeIdentity identity = event.getIdentity(); String workspaceId = identity.getWorkspaceId(); WorkspaceStatus previousStatus; try (Unlocker ignored = lockService.writeLock(workspaceId)) { previousStatus = statuses.replace(workspaceId, STOPPING); } if (previousStatus == null) { LOG.error( "Runtime '{}:{}:{}' became abnormally stopping but it was not considered as active before", workspaceId, identity.getEnvName(), identity.getOwnerId()); } LOG.info( "Runtime '{}:{}:{}' is stopping abnormally. Reason: {}", workspaceId, identity.getEnvName(), identity.getOwnerId(), event.getReason()); publishWorkspaceStatusEvent( workspaceId, STOPPING, previousStatus, "Workspace is going to be STOPPED. Reason: " + event.getReason()); } }
@Override public void onEvent(RuntimeAbnormalStoppedEvent event) { RuntimeIdentity identity = event.getIdentity(); String workspaceId = identity.getWorkspaceId(); identity.getEnvName(), identity.getOwnerId(), event.getReason()); STOPPED, previousStatus, "Workspace is stopped. Reason: " + event.getReason()); setAbnormalStopAttributes(workspaceId, event.getReason());
@Override public void onCascadeEvent(StackPersistedEvent event) throws Exception { final Subject subject = EnvironmentContext.getCurrent().getSubject(); if (!subject.isAnonymous()) { permissionsManager.storePermission( new StackPermissionsImpl( subject.getUserId(), event.getStack().getId(), StackDomain.getActions())); } }
@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 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, 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(); }
@Override public void onCascadeEvent(BeforeWorkspaceRemovedEvent event) throws Exception { removeWorkers(event.getWorkspace().getId(), PAGE_SIZE); }