@Test public void testUpdateLoadBalancerWithValidAccessList() throws Exception { when(objectMessage.getObject()).thenReturn(lb); when(loadBalancerService.getWithUserPages(LOAD_BALANCER_ID, ACCOUNT_ID)).thenReturn(lb); when(accessListService.diffRequestAccessListWithDomainAccessList(lb, lb)).thenReturn(accessLists); when(config.getString(Matchers.<ConfigurationKey>any())).thenReturn("REST"); updateAccessListListener.doOnMessage(objectMessage); verify(reverseProxyLoadBalancerStmService).updateAccessList(lb); verify(loadBalancerService).setStatus(lb, LoadBalancerStatus.ACTIVE); verify(notificationService).saveAccessListEvent(USERNAME, ACCOUNT_ID, LOAD_BALANCER_ID, ACCESS_LIST_ID, EntryHelper.UPDATE_ACCESS_LIST_TITLE, EntryHelper.createAccessListSummary(accessList), EventType.UPDATE_ACCESS_LIST, CategoryType.UPDATE, EventSeverity.INFO); }
@Override public void doOnMessage(Message message) throws Exception { LOG.debug("Entering " + getClass()); LOG.debug(message); LoadBalancer queueLb = getLoadbalancerFromMessage(message); LoadBalancer dbLoadBalancer; try { dbLoadBalancer = loadBalancerService.getWithUserPages(queueLb.getId(), queueLb.getAccountId()); } catch (EntityNotFoundException enfe) { String alertDescription = String.format("Load balancer '%d' not found in database.", queueLb.getId()); LOG.error(alertDescription, enfe); notificationService.saveAlert(queueLb.getAccountId(), queueLb.getId(), enfe, DATABASE_FAILURE.name(), alertDescription); sendErrorToEventResource(queueLb, queueLb.getAccessLists()); return; } try { if (isRestAdapter()) { LOG.debug(String.format("Update access list for load balancer '%d' in STM...", dbLoadBalancer.getId())); reverseProxyLoadBalancerStmService.updateAccessList(dbLoadBalancer); LOG.debug(String.format("Successfully updated access list in Zeus for load balancer '%d'.", dbLoadBalancer.getId())); } else { LOG.debug(String.format("Update access list for load balancer '%d' in ZXTM...", dbLoadBalancer.getId())); reverseProxyLoadBalancerService.updateAccessList(dbLoadBalancer); LOG.debug(String.format("Successfully updated access list in Zeus for load balancer '%d'.", dbLoadBalancer.getId())); } } catch (Exception e) { loadBalancerService.setStatus(dbLoadBalancer, LoadBalancerStatus.ERROR); String alertDescription = String.format("Error updating access list for load balancer '%d' in Zeus.", dbLoadBalancer.getId()); LOG.error(alertDescription, e); notificationService.saveAlert(dbLoadBalancer.getAccountId(), dbLoadBalancer.getId(), e, ZEUS_FAILURE.name(), alertDescription); sendErrorToEventResource(queueLb, queueLb.getAccessLists()); return; } loadBalancerService.setStatus(dbLoadBalancer, LoadBalancerStatus.ACTIVE); for (AccessList al : accessListService.diffRequestAccessListWithDomainAccessList(queueLb, dbLoadBalancer)) { notificationService.saveAccessListEvent(queueLb.getUserName(), dbLoadBalancer.getAccountId(), dbLoadBalancer.getId(), al.getId(), UPDATE_ACCESS_LIST_TITLE, EntryHelper.createAccessListSummary(al), UPDATE_ACCESS_LIST, UPDATE, INFO); } LOG.info(String.format("Update access list operation complete for load balancer '%d'.", dbLoadBalancer.getId())); }
UpdateAccessListListener extends BaseListener { @Override public void doOnMessage(Message message) throws Exception { LOG.debug("Entering " + getClass()); LOG.debug(message); LoadBalancer queueLb = getLoadbalancerFromMessage(message); LoadBalancer dbLoadBalancer; try { dbLoadBalancer = loadBalancerService.getWithUserPages(queueLb.getId(), queueLb.getAccountId()); } catch (EntityNotFoundException enfe) { String alertDescription = String.format("Load balancer '%d' not found in database.", queueLb.getId()); LOG.error(alertDescription, enfe); notificationService.saveAlert(queueLb.getAccountId(), queueLb.getId(), enfe, DATABASE_FAILURE.name(), alertDescription); sendErrorToEventResource(queueLb, queueLb.getAccessLists()); return; } try { if (isRestAdapter()) { LOG.debug(String.format("Update access list for load balancer '%d' in STM...", dbLoadBalancer.getId())); reverseProxyLoadBalancerStmService.updateAccessList(dbLoadBalancer); LOG.debug(String.format("Successfully updated access list in Zeus for load balancer '%d'.", dbLoadBalancer.getId())); } else { LOG.debug(String.format("Update access list for load balancer '%d' in ZXTM...", dbLoadBalancer.getId())); reverseProxyLoadBalancerService.updateAccessList(dbLoadBalancer); LOG.debug(String.format("Successfully updated access list in Zeus for load balancer '%d'.", dbLoadBalancer.getId())); } } catch (Exception e) { loadBalancerService.setStatus(dbLoadBalancer, LoadBalancerStatus.ERROR); String alertDescription = String.format("Error updating access list for load balancer '%d' in Zeus.", dbLoadBalancer.getId()); LOG.error(alertDescription, e); notificationService.saveAlert(dbLoadBalancer.getAccountId(), dbLoadBalancer.getId(), e, ZEUS_FAILURE.name(), alertDescription); sendErrorToEventResource(queueLb, queueLb.getAccessLists()); return; } loadBalancerService.setStatus(dbLoadBalancer, LoadBalancerStatus.ACTIVE); for (AccessList al : accessListService.diffRequestAccessListWithDomainAccessList(queueLb, dbLoadBalancer)) { notificationService.saveAccessListEvent(queueLb.getUserName(), dbLoadBalancer.getAccountId(), dbLoadBalancer.getId(), al.getId(), UPDATE_ACCESS_LIST_TITLE, EntryHelper.createAccessListSummary(al), UPDATE_ACCESS_LIST, UPDATE, INFO); } LOG.info(String.format("Update access list operation complete for load balancer '%d'.", dbLoadBalancer.getId())); } }
UpdateAccessListListener extends BaseListener { @Override public void doOnMessage(Message message) throws Exception { LOG.debug("Entering " + getClass()); LOG.debug(message); LoadBalancer queueLb = getLoadbalancerFromMessage(message); LoadBalancer dbLoadBalancer; try { dbLoadBalancer = loadBalancerService.getWithUserPages(queueLb.getId(), queueLb.getAccountId()); } catch (EntityNotFoundException enfe) { String alertDescription = String.format("Load balancer '%d' not found in database.", queueLb.getId()); LOG.error(alertDescription, enfe); notificationService.saveAlert(queueLb.getAccountId(), queueLb.getId(), enfe, DATABASE_FAILURE.name(), alertDescription); sendErrorToEventResource(queueLb, queueLb.getAccessLists()); return; } try { if (isRestAdapter()) { LOG.debug(String.format("Update access list for load balancer '%d' in STM...", dbLoadBalancer.getId())); reverseProxyLoadBalancerStmService.updateAccessList(dbLoadBalancer); LOG.debug(String.format("Successfully updated access list in Zeus for load balancer '%d'.", dbLoadBalancer.getId())); } else { LOG.debug(String.format("Update access list for load balancer '%d' in ZXTM...", dbLoadBalancer.getId())); reverseProxyLoadBalancerService.updateAccessList(dbLoadBalancer); LOG.debug(String.format("Successfully updated access list in Zeus for load balancer '%d'.", dbLoadBalancer.getId())); } } catch (Exception e) { loadBalancerService.setStatus(dbLoadBalancer, LoadBalancerStatus.ERROR); String alertDescription = String.format("Error updating access list for load balancer '%d' in Zeus.", dbLoadBalancer.getId()); LOG.error(alertDescription, e); notificationService.saveAlert(dbLoadBalancer.getAccountId(), dbLoadBalancer.getId(), e, ZEUS_FAILURE.name(), alertDescription); sendErrorToEventResource(queueLb, queueLb.getAccessLists()); return; } loadBalancerService.setStatus(dbLoadBalancer, LoadBalancerStatus.ACTIVE); for (AccessList al : accessListService.diffRequestAccessListWithDomainAccessList(queueLb, dbLoadBalancer)) { notificationService.saveAccessListEvent(queueLb.getUserName(), dbLoadBalancer.getAccountId(), dbLoadBalancer.getId(), al.getId(), UPDATE_ACCESS_LIST_TITLE, EntryHelper.createAccessListSummary(al), UPDATE_ACCESS_LIST, UPDATE, INFO); } LOG.info(String.format("Update access list operation complete for load balancer '%d'.", dbLoadBalancer.getId())); }  }
UpdateAccessListListener extends BaseListener { @Override public void doOnMessage(Message message) throws Exception { LOG.debug("Entering " + getClass()); LOG.debug(message); LoadBalancer queueLb = getLoadbalancerFromMessage(message); LoadBalancer dbLoadBalancer; try { dbLoadBalancer = loadBalancerService.getWithUserPages(queueLb.getId(), queueLb.getAccountId()); } catch (EntityNotFoundException enfe) { String alertDescription = String.format("Load balancer '%d' not found in database.", queueLb.getId()); LOG.error(alertDescription, enfe); notificationService.saveAlert(queueLb.getAccountId(), queueLb.getId(), enfe, DATABASE_FAILURE.name(), alertDescription); sendErrorToEventResource(queueLb, queueLb.getAccessLists()); return; } try { if (isRestAdapter()) { LOG.debug(String.format("Update access list for load balancer '%d' in STM...", dbLoadBalancer.getId())); reverseProxyLoadBalancerStmService.updateAccessList(dbLoadBalancer); LOG.debug(String.format("Successfully updated access list in Zeus for load balancer '%d'.", dbLoadBalancer.getId())); } else { LOG.debug(String.format("Update access list for load balancer '%d' in ZXTM...", dbLoadBalancer.getId())); reverseProxyLoadBalancerService.updateAccessList(dbLoadBalancer); LOG.debug(String.format("Successfully updated access list in Zeus for load balancer '%d'.", dbLoadBalancer.getId())); } } catch (Exception e) { loadBalancerService.setStatus(dbLoadBalancer, LoadBalancerStatus.ERROR); String alertDescription = String.format("Error updating access list for load balancer '%d' in Zeus.", dbLoadBalancer.getId()); LOG.error(alertDescription, e); notificationService.saveAlert(dbLoadBalancer.getAccountId(), dbLoadBalancer.getId(), e, ZEUS_FAILURE.name(), alertDescription); sendErrorToEventResource(queueLb, queueLb.getAccessLists()); return; } loadBalancerService.setStatus(dbLoadBalancer, LoadBalancerStatus.ACTIVE); for (AccessList al : accessListService.diffRequestAccessListWithDomainAccessList(queueLb, dbLoadBalancer)) { notificationService.saveAccessListEvent(queueLb.getUserName(), dbLoadBalancer.getAccountId(), dbLoadBalancer.getId(), al.getId(), UPDATE_ACCESS_LIST_TITLE, EntryHelper.createAccessListSummary(al), UPDATE_ACCESS_LIST, UPDATE, INFO); } LOG.info(String.format("Update access list operation complete for load balancer '%d'.", dbLoadBalancer.getId())); }  @Override void doOnMessage(Message message); }
UpdateAccessListListener extends BaseListener { @Override public void doOnMessage(Message message) throws Exception { LOG.debug("Entering " + getClass()); LOG.debug(message); LoadBalancer queueLb = getLoadbalancerFromMessage(message); LoadBalancer dbLoadBalancer; try { dbLoadBalancer = loadBalancerService.getWithUserPages(queueLb.getId(), queueLb.getAccountId()); } catch (EntityNotFoundException enfe) { String alertDescription = String.format("Load balancer '%d' not found in database.", queueLb.getId()); LOG.error(alertDescription, enfe); notificationService.saveAlert(queueLb.getAccountId(), queueLb.getId(), enfe, DATABASE_FAILURE.name(), alertDescription); sendErrorToEventResource(queueLb, queueLb.getAccessLists()); return; } try { if (isRestAdapter()) { LOG.debug(String.format("Update access list for load balancer '%d' in STM...", dbLoadBalancer.getId())); reverseProxyLoadBalancerStmService.updateAccessList(dbLoadBalancer); LOG.debug(String.format("Successfully updated access list in Zeus for load balancer '%d'.", dbLoadBalancer.getId())); } else { LOG.debug(String.format("Update access list for load balancer '%d' in ZXTM...", dbLoadBalancer.getId())); reverseProxyLoadBalancerService.updateAccessList(dbLoadBalancer); LOG.debug(String.format("Successfully updated access list in Zeus for load balancer '%d'.", dbLoadBalancer.getId())); } } catch (Exception e) { loadBalancerService.setStatus(dbLoadBalancer, LoadBalancerStatus.ERROR); String alertDescription = String.format("Error updating access list for load balancer '%d' in Zeus.", dbLoadBalancer.getId()); LOG.error(alertDescription, e); notificationService.saveAlert(dbLoadBalancer.getAccountId(), dbLoadBalancer.getId(), e, ZEUS_FAILURE.name(), alertDescription); sendErrorToEventResource(queueLb, queueLb.getAccessLists()); return; } loadBalancerService.setStatus(dbLoadBalancer, LoadBalancerStatus.ACTIVE); for (AccessList al : accessListService.diffRequestAccessListWithDomainAccessList(queueLb, dbLoadBalancer)) { notificationService.saveAccessListEvent(queueLb.getUserName(), dbLoadBalancer.getAccountId(), dbLoadBalancer.getId(), al.getId(), UPDATE_ACCESS_LIST_TITLE, EntryHelper.createAccessListSummary(al), UPDATE_ACCESS_LIST, UPDATE, INFO); } LOG.info(String.format("Update access list operation complete for load balancer '%d'.", dbLoadBalancer.getId())); }  @Override void doOnMessage(Message message);  }