public void remove(Collection<ShortRule> selected) { // local rules.removeAll(selected); // db for (ShortRule rule : selected) { adminService().delete(rule.getId()); } }
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 void onDrop( AjaxRequestTarget target, Transfer transfer, Location location) { if (location == null || !(location.getComponent().getDefaultModel().getObject() instanceof ShortRule)) { return; } ShortRule movedRule = transfer.getData(); ShortRule targetRule = (ShortRule) location.getComponent().getDefaultModel().getObject(); if (movedRule.getId().equals(targetRule.getId())) { return; } if (movedRule.getPriority() < targetRule.getPriority()) { movedRule.setPriority(targetRule.getPriority() + 1); } else { movedRule.setPriority(targetRule.getPriority()); } rulesModel.save(movedRule); doReturn(GeofenceServerPage.class); } }.dropCenter("tr"));
@RequestMapping(value = "/rules/id/{id}", method = RequestMethod.POST) public @ResponseStatus(HttpStatus.OK) void update( @PathVariable("id") Long id, @RequestBody JaxbRule rule) { if (rule.getPriority() != null) { ShortRule priorityRule = adminService.getRuleByPriority(rule.getPriority().longValue()); if (priorityRule != null && priorityRule.getId() != id) { adminService.shift(rule.getPriority().longValue(), 1); } } Rule theRule = adminService.get(id); adminService.update(rule.toRule(theRule)); if (rule.getLimits() != null) { adminService.setLimits(id, rule.getLimits().toRuleLimits(theRule.getRuleLimits())); } if (rule.getLayerDetails() != null) { adminService.setDetails( id, rule.getLayerDetails().toLayerDetails(theRule.getLayerDetails())); } }
/** * 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; }
@RequestMapping(value = "/rules/id/{id}", method = RequestMethod.PUT) public @ResponseStatus(HttpStatus.OK) void clearAndUpdate( @PathVariable("id") Long id, @RequestBody JaxbRule rule) { if (rule.getPriority() != null) { ShortRule priorityRule = adminService.getRuleByPriority(rule.getPriority().longValue()); if (priorityRule != null && priorityRule.getId() != id) { adminService.shift(rule.getPriority().longValue(), 1); } } Rule theRule = new Rule(); theRule.setId(id); adminService.update(rule.toRule(theRule)); if (rule.getLimits() != null) { adminService.setLimits(id, rule.getLimits().toRuleLimits(null)); } else { adminService.setLimits(id, null); } if (rule.getLayerDetails() != null) { adminService.setDetails(id, rule.getLayerDetails().toLayerDetails(null)); } else { adminService.setDetails(id, null); } }
public void save(ShortRule rule) { if (rule.getId() == null) { shiftIfNecessary(rule.getPriority(), rule); // local int i = 0; while (i < rules.size() && rules.get(i).getPriority() < rule.getPriority()) { i++; } rules.add(i, rule); // db Rule bigRule = new Rule(); syncRule(rule, bigRule); rule.setId(adminService().insert(bigRule)); } else { // db Rule bigRule = adminService().get(rule.getId()); if (bigRule.getPriority() != rule.getPriority()) { shiftIfNecessary(rule.getPriority(), rule); } syncRule(rule, bigRule); adminService().update(bigRule); } }
if (ruleFormData.rule.getAccess().equals(GrantType.LIMIT)) { rules.save( ruleFormData.rule.getId(), parseAllowedArea(ruleFormData.allowedArea), ruleFormData.catalogMode); ruleFormData.layerDetails.defaultStyle); layerDetails.setType((ruleFormData.layerDetails.layerType)); rules.save(ruleFormData.rule.getId(), layerDetails); } else { rules.save(ruleFormData.rule.getId(), (LayerDetails) null);
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); } }
final RuleLimits ruleLimits = rules.getRulesLimits(rule.getId()); if (ruleLimits != null) { ruleFormData.allowedArea = getAllowedAreaAsString(ruleLimits.getAllowedArea()); ruleFormData.catalogMode = ruleLimits.getCatalogMode(); final LayerDetails layerDetails = rules.getDetails(rule.getId()); if (layerDetails != null) { ruleFormData.layerDetailsCheck = true;
@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); }