@RequestMapping( value = "/rules", method = RequestMethod.POST, consumes = { MediaType.TEXT_XML_VALUE, MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE, MediaTypeExtensions.TEXT_JSON_VALUE } ) @ResponseStatus(HttpStatus.CREATED) public ResponseEntity<Long> insert(@RequestBody(required = true) JaxbRule rule) { long priority = rule.getPriority() == null ? 0 : rule.getPriority().longValue(); if (adminService.getRuleByPriority(priority) != null) { adminService.shift(priority, 1); } Long id = adminService.insert(rule.toRule()); if (rule.getLimits() != null && rule.getAccess().equals("LIMIT")) { adminService.setLimits(id, rule.getLimits().toRuleLimits(null)); } if (rule.getLayerDetails() != null && !rule.getAccess().equals("LIMIT")) { adminService.setDetails(id, rule.getLayerDetails().toLayerDetails(null)); } return new ResponseEntity<Long>(id, HttpStatus.CREATED); }
@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())); } }
@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); } }
rule.setAccess("ALLOW"); rule.setLayerDetails(new JaxbRule.LayerDetails()); rule.getLayerDetails().setAllowedArea(GML3MockData.multiPolygon()); rule.getLayerDetails().getAllowedStyles().add("style1"); rule.getLayerDetails().getAllowedStyles().add("style2"); JaxbRule.LayerAttribute att = new JaxbRule.LayerAttribute(); att.setName("layerAttribute1"); att.setAccessType("READONLY"); att.setDataType("dataType"); rule.getLayerDetails().getAttributes().add(att); att = new JaxbRule.LayerAttribute(); att.setName("layerAttribute2"); att.setAccessType("READONLY"); att.setDataType("dataType2"); rule.getLayerDetails().getAttributes().add(att); rule.getLayerDetails().setCatalogMode("MIXED"); rule.getLayerDetails().setCqlFilterRead("myFilterRead"); rule.getLayerDetails().setCqlFilterWrite("myFilterWrite"); rule.getLayerDetails().setDefaultStyle("myDefaultStyle"); rule.getLayerDetails().setLayerType("VECTOR"); try { assertEquals( new WKTReader().read(rule.getLayerDetails().getAllowedArea()), realRule.getLayerDetails().getArea()); } catch (ParseException e) { rule.getLayerDetails().getCatalogMode(), realRule.getLayerDetails().getCatalogMode().toString());