private void removeOrphanedServers(AuthzSubject overlord) { final Collection<Server> servers = serverManager.getOrphanedServers(); if (!servers.isEmpty()) { log.info("cleaning up " + servers.size() + " orphaned servers"); } for (Server server : servers) { try { server = serverManager.getServerById(server.getId()); serverManager.removeServer(overlord, server); } catch (ObjectNotFoundException e) { log.warn(e); log.debug(e, e); } catch (PermissionException e) { log.warn(e); log.debug(e, e); } catch (VetoException e) { log.warn(e); log.debug(e, e); } } }
private final void removeServers(AuthzSubject subject, Collection<Server> servers) { final StopWatch watch = new StopWatch(); watch.markTimeBegin("removeServers"); final List<Server> svrs = new ArrayList<Server>(servers); // can't use iterator for loop here. Since we are modifying the // internal hibernate collection, which this collection is based on, // it will throw a ConcurrentModificationException // This occurs even if you disassociate the Collection by trying // something like new ArrayList(servers). Not sure why. for (int i = 0; i < svrs.size(); i++) { try { final Server server = svrs.get(i); // removeServices(subject, server.getServices()); appdefBoss.removeServer(subject, server.getId()); } catch (Exception e) { log.error("Unable to remove server: " + e, e); } } watch.markTimeEnd("removeServers"); if (log.isDebugEnabled()) { log.debug("Removed " + servers.size() + " services"); } }