private void removeOrphanedServices(AuthzSubject overlord) {
   final Collection<Service> services = serviceManager.getOrphanedServices();
   if (!services.isEmpty()) {
     log.info("cleaning up " + services.size() + " orphaned services");
   }
   for (Service service : services) {
     try {
       service = serviceManager.getServiceById(service.getId());
       serviceManager.removeService(overlord, service);
     } 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 removeServices(AuthzSubject subject, Collection<Service> services) {
   final StopWatch watch = new StopWatch();
   watch.markTimeBegin("removeServices");
   final List<Service> svcs = new ArrayList<Service>(services);
   // 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(services). Not sure why.
   for (int i = 0; i < svcs.size(); i++) {
     try {
       final Service service = svcs.get(i);
       appdefBoss.removeService(subject, service.getId());
     } catch (Exception e) {
       log.error("Unable to remove service: " + e, e);
     }
   }
   watch.markTimeEnd("removeServices");
   if (log.isDebugEnabled()) {
     log.debug("Removed " + services.size() + " services");
   }
 }