/**
* {@inheritDoc}
*/
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
Sone currentSone = getCurrentSone(request.getToadletContext());
Profile profile = currentSone.getProfile();
String fieldId = request.getHttpRequest().getParam("field");
Field field = profile.getFieldById(fieldId);
if (field == null) {
return createErrorJsonObject("invalid-field-id");
}
String direction = request.getHttpRequest().getParam("direction");
try {
if ("up".equals(direction)) {
profile.moveFieldUp(field);
} else if ("down".equals(direction)) {
profile.moveFieldDown(field);
} else {
return createErrorJsonObject("invalid-direction");
}
} catch (IllegalArgumentException iae1) {
return createErrorJsonObject("not-possible");
}
currentSone.setProfile(profile);
webInterface.getCore().touchConfiguration();
return createSuccessJsonObject();
}