@POST
@Path("add")
@Consumes(FudgeRest.MEDIA)
public void add(final FudgeMsg request) {
final FudgeDeserializer fdc = new FudgeDeserializer(getFudgeContext());
final Integer ttl = request.getInt(TTL_FIELD);
final List<FudgeField> fields = request.getAllByName(RULE_FIELD);
if (fields.size() > 1) {
final Collection<FunctionBlacklistRule> rules = new ArrayList<FunctionBlacklistRule>(fields.size());
for (FudgeField field : fields) {
rules.add(fdc.fieldValueToObject(FunctionBlacklistRule.class, field));
}
if (ttl != null) {
getUnderlying().addBlacklistRules(rules, ttl);
} else {
getUnderlying().addBlacklistRules(rules);
}
} else if (!fields.isEmpty()) {
final FunctionBlacklistRule rule = fdc.fieldValueToObject(FunctionBlacklistRule.class, fields.get(0));
if (ttl != null) {
getUnderlying().addBlacklistRule(rule, ttl);
} else {
getUnderlying().addBlacklistRule(rule);
}