public void removeAllRules() throws NotFoundServiceEx { List<ShortRule> list = ruleAdminService.getAll(); for (ShortRule item : list) { LOGGER.warn("Removing " + item); boolean ret = ruleAdminService.delete(item.getId()); if ( !ret ) { LOGGER.error("Could not remove " + item); } } long count = ruleAdminService.getCountAll(); if ( count > 0 ) { LOGGER.error("Items not removed"); } }
public GeofenceRulesModel() { rules = adminService().getAll(); setSort("priority", SortOrder.ASCENDING); }
/** * Helper method that checks if the rule already exists and create a new one by returning its * ID. */ protected long prepareGeoFenceTestRules(JaxbRule rule) { if (adminService.getCountAll() > 0) { for (ShortRule r : adminService.getAll()) { controller.delete(r.getId()); } } long id = controller.insert(rule).getBody(); return id; }
public void saveAllRules(List<RuleModel> rules) throws ApplicationException { for (ShortRule rule : geofenceRemoteService.getRuleAdminService() .getAll()) { try { geofenceRemoteService.getRuleAdminService() .delete(rule.getId()); } catch (NotFoundServiceEx e) { logger.error(e.getMessage(), e); throw new ApplicationException(e.getMessage(), e); } } for (RuleModel localRule : rules) { IPAddressRange addressRange = validateSourceRange(localRule.getSourceIPRange()); Rule rule = new Rule( localRule.getPriority(), "*".equals(localRule.getUsername()) ? null : localRule.getUsername(), "*".equals(localRule.getRolename()) ? null : localRule.getRolename(), getInstance(localRule.getInstance()), addressRange, "*".equals(localRule.getService()) ? null : localRule.getService(), "*".equals(localRule.getRequest()) ? null : localRule.getRequest(), "*".equals(localRule.getWorkspace()) ? null : localRule.getWorkspace(), "*".equals(localRule.getLayer()) ? null : localRule.getLayer(), getAccessType(localRule.getGrant())); geofenceRemoteService.getRuleAdminService().insert(rule); } }
@Before public void initGeoFenceControllers() { controller = (RulesRestController) applicationContext.getBean("rulesRestController"); adminService = (RuleAdminService) applicationContext.getBean("ruleAdminService"); if (adminService.getCountAll() > 0) { for (ShortRule r : adminService.getAll()) { adminService.delete(r.getId()); } } Rule citeRule = new Rule(0, "cite", null, null, null, "wms", null, "cite", null, GrantType.ALLOW); Rule sfRule = new Rule(1, "cite", null, null, null, "wms", null, "sf", null, GrantType.ALLOW); adminService.insert(citeRule); adminService.insert(sfRule); }