yacy_search_server/htroot/api/config_p.java
2010-11-24 01:31:41 +00:00

52 lines
1.5 KiB
Java

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import net.yacy.cora.protocol.RequestHeader;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
public class config_p {
public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
// return variable that accumulates replacements
//plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
//change a Key
if(post != null && post.containsKey("key") && post.containsKey("value")) {
final String key = post.get("key");
final String value = post.get("value");
if(!"".equals(key)) {
env.setConfig(key, value);
}
}
final Iterator<String> keys = env.configKeys();
final List<String> list = new ArrayList<String>(250);
while (keys.hasNext()) {
list.add(keys.next());
}
Collections.sort(list);
int count=0;
for (final String key : list) {
prop.putHTML("options_" + count + "_key", key);
prop.putHTML("options_" + count + "_value", env.getConfig(key, "ERROR"));
count++;
}
prop.put("options", count);
// return rewrite properties
return prop;
}
}