2006-10-15 23:41:47 +02:00
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.List;
|
|
|
|
|
2009-10-11 23:29:18 +02:00
|
|
|
import de.anomic.http.server.RequestHeader;
|
2006-10-15 23:41:47 +02:00
|
|
|
import de.anomic.server.serverObjects;
|
|
|
|
import de.anomic.server.serverSwitch;
|
|
|
|
|
|
|
|
public class config_p {
|
|
|
|
|
|
|
|
|
2009-07-19 22:37:44 +02:00
|
|
|
public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
|
2006-10-15 23:41:47 +02:00
|
|
|
// return variable that accumulates replacements
|
|
|
|
//plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
|
2008-08-02 14:12:04 +02:00
|
|
|
final serverObjects prop = new serverObjects();
|
2006-10-15 23:41:47 +02:00
|
|
|
String key;
|
|
|
|
|
|
|
|
//change a Key
|
|
|
|
if(post != null && post.containsKey("key") && post.containsKey("value")){
|
2008-06-06 18:01:27 +02:00
|
|
|
key=post.get("key");
|
|
|
|
final String value=post.get("value");
|
2006-10-15 23:41:47 +02:00
|
|
|
if(!key.equals("")){
|
|
|
|
env.setConfig(key, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-29 17:41:09 +01:00
|
|
|
Iterator<String> keys = env.configKeys();
|
2006-10-15 23:41:47 +02:00
|
|
|
|
2008-08-02 14:12:04 +02:00
|
|
|
final List<String> list = new ArrayList<String>(250);
|
2006-10-15 23:41:47 +02:00
|
|
|
while(keys.hasNext()){
|
|
|
|
list.add(keys.next());
|
|
|
|
}
|
|
|
|
Collections.sort(list);
|
|
|
|
keys = list.iterator();
|
|
|
|
|
|
|
|
int count=0;
|
|
|
|
while(keys.hasNext()){
|
2008-06-06 18:01:27 +02:00
|
|
|
key = keys.next();
|
2007-10-24 23:38:19 +02:00
|
|
|
prop.putHTML("options_"+count+"_key", key);
|
|
|
|
prop.putHTML("options_"+count+"_value", env.getConfig(key, "ERROR"));
|
2006-10-15 23:41:47 +02:00
|
|
|
count++;
|
|
|
|
}
|
|
|
|
prop.put("options", count);
|
|
|
|
|
|
|
|
// return rewrite properties
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|