Improved blacklist XML/JSON API.

pull/1/head
Marc Nause 11 years ago
parent 830057d788
commit 4723329e29

@ -30,8 +30,6 @@ public class get_list_p {
private static final String BLACK_LISTS_SHARED = "BlackLists.Shared";
private static final int lastTypeIndex = BLACKLIST_TYPE_VALUES.length - 1;
private static final String EMPTY_STRING = "";
private static final String COMMA_STRING = ",";
public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, final serverObjects post, @SuppressWarnings("unused") final serverSwitch env) {
@ -55,11 +53,7 @@ public class get_list_p {
prop.put(PREFIX_TYPES + j + POSTFIX_VALUE,
ListManager.listSetContains(type + TYPES_EXT, element));
if (j < lastTypeIndex) {
prop.put(PREFIX_TYPES + j + POSTFIX_COMMA, COMMA_STRING);
} else {
prop.put(PREFIX_TYPES + j + POSTFIX_COMMA, EMPTY_STRING);
}
prop.put(PREFIX_TYPES + j + POSTFIX_COMMA, j < lastTypeIndex);
j++;
}
@ -77,11 +71,7 @@ public class get_list_p {
prop.putXML(PREFIX_ITEMS + count + POSTFIX_ITEM, entry);
if (count < lastItemCount) {
prop.put(PREFIX_ITEMS + count + POSTFIX_COMMA, COMMA_STRING);
} else {
prop.put(PREFIX_ITEMS + count + POSTFIX_COMMA, EMPTY_STRING);
}
prop.put(PREFIX_ITEMS + count + POSTFIX_COMMA, count < lastItemCount);
count++;
}

@ -1,9 +1,13 @@
{
"name": "#[name]#",
"shared": "#[shared]#",
"types": [#{types}#{"#[name]#": "#[value]#"}#[comma]# #{/types}#]
"name":"#[name]#",
"shared":#(shared)#false::true#(/shared)#,
"types": {
#{types}#
"#[name]#":#(value)#false::true#(/value)##(comma)#::,#(/comma)#
#{/types}#
},
"items":
[
#{items}#"#[item]#"#[comma]#
#{items}#"#[item]#"#(comma)#::,#(/comma)#
#{/items}#]
}

@ -1,6 +1,6 @@
<?xml version="1.0"?>
<list name="#[name]#" shared="#[shared]#" #{types}#
#[name]#="#[value]#"#{/types}#>
<list name="#[name]#" shared="#(shared)#false::true#(/shared)#" #{types}#
#[name]#="#(value)#false::true#(/value)#"#{/types}#>
<items>
#{items}#
<item>#[item]#</item>

@ -26,8 +26,6 @@ public class get_metadata_p {
private static final String BLACK_LISTS_SHARED = "BlackLists.Shared";
private static final int lastTypeIndex = BLACKLIST_TYPE_VALUES.length - 1;
private static final String EMPTY_STRING = "";
private static final String COMMA_STRING = ",";
public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, @SuppressWarnings("unused") final serverObjects post, @SuppressWarnings("unused") final serverSwitch env) {
@ -49,21 +47,13 @@ public class get_metadata_p {
prop.put(PREFIX_LISTS + blacklistCount + INFIX_TYPES + j + POSTFIX_VALUE,
ListManager.listSetContains(type + TYPES_EXT, element));
if (j < lastTypeIndex) {
prop.put(PREFIX_LISTS + blacklistCount + INFIX_TYPES + j + POSTFIX_COMMA, COMMA_STRING);
} else {
prop.put(PREFIX_LISTS + blacklistCount + INFIX_TYPES + j + POSTFIX_COMMA, EMPTY_STRING);
}
prop.put(PREFIX_LISTS + blacklistCount + INFIX_TYPES + j + POSTFIX_COMMA, j < lastTypeIndex);
j++;
}
prop.put(PREFIX_LISTS + blacklistCount + POSTFIX_TYPES, BLACKLIST_TYPE_VALUES.length);
if (blacklistCount < lastBlacklistCount) {
prop.put(PREFIX_LISTS + blacklistCount + POSTFIX_COMMA, COMMA_STRING);
} else {
prop.put(PREFIX_LISTS + blacklistCount + POSTFIX_COMMA, EMPTY_STRING);
}
prop.put(PREFIX_LISTS + blacklistCount + POSTFIX_COMMA, blacklistCount < lastBlacklistCount);
blacklistCount++;
}

@ -1,8 +1,12 @@
[
#{lists}#{
"name": "#[name]#",
"shared": "#[shared]#",
"types": [#{types}#{"#[name]#": "#[value]#"}#[comma]# #{/types}#]
}#[comma]#
"name":"#[name]#",
"shared":#(shared)#false::true#(/shared)#,
"types": {
#{types}#
"#[name]#":#(value)#false::true#(/value)##(comma)#::,#(/comma)#
#{/types}#
}
}#(comma)#::,#(/comma)#
#{/lists}#
]

@ -1,6 +1,6 @@
<?xml version='1.0' encoding="UTF-8" standalone='yes'?>
<blacklists>
#{lists}#<list name="#[name]#" shared="#[shared]#" #{types}#
#[name]#="#[value]#"#{/types}# />
#{lists}#<list name="#[name]#" shared="#(shared)#false::true#(/shared)#" #{types}#
#[name]#="#(value)#false::true#(/value)#"#{/types}# />
#{/lists}#
</blacklists>
Loading…
Cancel
Save