@ -13,6 +13,8 @@ import net.yacy.server.serverSwitch;
public class get_list_p {
private static final BlacklistType [ ] BLACKLIST_TYPE_VALUES = BlacklistType . values ( ) ;
private static final String KEY_CURRENT_BLACKLIST = "list" ;
private static final String ITEMS = "items" ;
private static final String POSTFIX_ITEM = "_item" ;
@ -23,9 +25,14 @@ public class get_list_p {
private static final String PREFIX_TYPES = "types_" ;
private static final String POSTFIX_VALUE = "_value" ;
private static final String POSTFIX_NAME = "_name" ;
private static final String POSTFIX_COMMA = "_comma" ;
private static final String TYPES_EXT = ".BlackLists" ;
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 ) {
final serverObjects prop = new serverObjects ( ) ;
@ -34,7 +41,6 @@ public class get_list_p {
final String blackListName = ( post = = null ) ? "" : post . get ( KEY_CURRENT_BLACKLIST , "" ) ;
int count ;
if ( dirlist ! = null ) {
for ( final String element : dirlist ) {
if ( element . equals ( blackListName ) ) {
@ -44,10 +50,17 @@ public class get_list_p {
prop . put ( SHARED , ListManager . listSetContains ( BLACK_LISTS_SHARED , element ) ) ;
int j = 0 ;
for ( final BlacklistType type : B lacklistType. values ( ) ) {
for ( final BlacklistType type : B LACKLIST_TYPE_VALUES ) {
prop . putXML ( PREFIX_TYPES + j + POSTFIX_NAME , type . toString ( ) ) ;
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 ) ;
}
j + + ;
}
prop . put ( TYPES , BlacklistType . values ( ) . length ) ;
@ -56,12 +69,20 @@ public class get_list_p {
final Collection < String > list = FileUtils . getListArray ( new File ( ListManager . listsPath , element ) ) ;
count = 0 ;
int count = 0 ;
final int lastItemCount = list . size ( ) - 1 ;
for ( final String entry : list ) {
if ( entry . isEmpty ( ) ) continue ;
if ( entry . charAt ( 0 ) = = '#' ) continue ;
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 ) ;
}
count + + ;
}
prop . put ( ITEMS , count ) ;