/** * Fetches elements like {@link #iterate(PageSupplier, int)} method does using default page size * which is equal to {@value #DEFAULT_PAGE_SIZE}. */ public static <E, X extends Exception> Iterable<E> iterate(PageSupplier<E, X> supplier) throws X { return iterate(supplier, DEFAULT_PAGE_SIZE); }
@Override public void onCascadeEvent(BeforeAccountRemovedEvent event) throws Exception { for (WorkspaceImpl workspace : iterate( (maxItems, skipCount) -> workspaceManager.getByNamespace( event.getAccount().getName(), false, maxItems, skipCount))) { workspaceManager.removeWorkspace(workspace.getId()); } } }
@VisibleForTesting void removeTemporaryWs() throws ServerException { for (WorkspaceImpl workspace : Pages.iterate( (maxItems, skipCount) -> workspaceDao.getWorkspaces(true, maxItems, skipCount))) { WorkspaceStatus status = runtimes.getStatus(workspace.getId()); if (status == WorkspaceStatus.STOPPED) { try { workspaceDao.remove(workspace.getId()); } catch (ServerException e) { LOG.error( "Unable to cleanup temporary workspace {}. Reason is {}", workspace.getId(), e.getMessage()); } } } } }
@Override public void onCascadeEvent(BeforeAccountRemovedEvent event) throws Exception { for (WorkspaceImpl workspace : iterate( (maxItems, skipCount) -> workspaceManager.getByNamespace( event.getAccount().getName(), false, maxItems, skipCount))) { workspaceManager.removeWorkspace(workspace.getId()); } } }