protected void postMap(Map map) throws Exception { validateMap(map); Set<Object> commonKeys = intersection(map); if (!commonKeys.isEmpty()) { String msg = "Already existing rules: " + StringUtils.join(commonKeys.iterator(), ","); throw new RestException(msg, HttpStatus.CONFLICT); } for (Object entry : map.entrySet()) { Comparable rule = convertEntryToRule((Entry<String, String>) entry); ruleDAO.addRule(rule); } ruleDAO.storeRules(); }
protected void putMap(Map map) throws Exception { validateMap(map); Set<Object> nonExisting = nonExistingKeys(map); if (!nonExisting.isEmpty()) { String msg = "Unknown rules: " + StringUtils.join(nonExisting.iterator(), ","); throw new RestException(msg, HttpStatus.CONFLICT); } for (Object entry : map.entrySet()) { Comparable rule = convertEntryToRule((Entry<String, String>) entry); // TODO, will not work for REST ruleDAO.removeRule(rule); ruleDAO.addRule(rule); } ruleDAO.storeRules(); }