fixed xml output for table retrieval

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@8065 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 13 years ago
parent d449547023
commit c461c1eebf

@ -26,7 +26,6 @@ import net.yacy.cora.protocol.RequestHeader;
import net.yacy.kelondro.blob.Tables; import net.yacy.kelondro.blob.Tables;
import net.yacy.kelondro.logging.Log; import net.yacy.kelondro.logging.Log;
import net.yacy.search.Switchboard; import net.yacy.search.Switchboard;
import de.anomic.server.serverObjects; import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch; import de.anomic.server.serverSwitch;
@ -35,28 +34,33 @@ public class table_p {
public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) { public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
final Switchboard sb = (Switchboard) env; final Switchboard sb = (Switchboard) env;
final serverObjects prop = new serverObjects(); final serverObjects prop = new serverObjects();
final String EXT = header.get("EXT", "");
final boolean html = EXT.equals("html");
final boolean xml = EXT.equals("xml");
String table = (post == null) ? null : post.get("table", null); String table = (post == null) ? null : post.get("table", null);
if (table != null && !sb.tables.hasHeap(table)) table = null; if (table != null && !sb.tables.hasHeap(table)) table = null;
prop.put("showtable", 0); prop.put("showtable", 0);
if (table == null) return prop; if (table == null) return prop;
boolean showpk = post.containsKey("pk"); final boolean showpk = post.containsKey("pk");
String selectKey = post.containsKey("selectKey") ? post.get("selectKey") : null; final String selectKey = post.containsKey("selectKey") ? post.get("selectKey") : null;
String selectValue = (selectKey != null && post.containsKey("selectValue")) ? post.get("selectValue") : null; final String selectValue = (selectKey != null && post.containsKey("selectValue")) ? post.get("selectValue") : null;
ArrayList<String> columns = null; ArrayList<String> columns = null;
try { try {
columns = sb.tables.columns(table); columns = sb.tables.columns(table);
} catch (IOException e) { } catch (final IOException e) {
Log.logException(e); Log.logException(e);
columns = new ArrayList<String>(); columns = new ArrayList<String>();
} }
// if a row attribute is given // if a row attribute is given
// then order the columns according to the given order // then order the columns according to the given order
String[] row = post.get("row", "").split(","); final String[] row = post.get("row", "").split(",");
for (int i = 0; i < row.length; i++) { for (int i = 0; i < row.length; i++) {
if (columns.contains(row[i])) { if (columns.contains(row[i])) {
columns.remove(row[i]); columns.remove(row[i]);
@ -79,7 +83,7 @@ public class table_p {
int maxCount; int maxCount;
try { try {
maxCount = Math.min(1000, sb.tables.size(table)); maxCount = Math.min(1000, sb.tables.size(table));
} catch (IOException e) { } catch (final IOException e) {
Log.logException(e); Log.logException(e);
maxCount = 0; maxCount = 0;
} }
@ -105,14 +109,20 @@ public class table_p {
} else { } else {
cellValue = ""; cellValue = "";
} }
if (html) {
prop.putHTML("showtable_list_" + count + "_columns_" + i + "_column", cellName); prop.putHTML("showtable_list_" + count + "_columns_" + i + "_column", cellName);
prop.putHTML("showtable_list_" + count + "_columns_" + i + "_cell", cellValue); prop.putHTML("showtable_list_" + count + "_columns_" + i + "_cell", cellValue);
} }
if (xml) {
prop.putXML("showtable_list_" + count + "_columns_" + i + "_column", cellName);
prop.putXML("showtable_list_" + count + "_columns_" + i + "_cell", cellValue);
}
}
prop.put("showtable_list_" + count + "_columns", columns.size()); prop.put("showtable_list_" + count + "_columns", columns.size());
count++; count++;
} }
} catch (IOException e) { } catch (final IOException e) {
Log.logException(e); Log.logException(e);
} }
prop.put("showtable_list", count); prop.put("showtable_list", count);

Loading…
Cancel
Save