if (!message.containsKey(NAME)) {
throw new Exception(MISSING_NAME_PARAM);
}
Collection col = getCollection((String) message.get(COLLECTION));
Entry obj = col.getEntry(message.get(NAME));
Map result = new HashMap(3);
if (obj == null) {
// Return empty result
} else if (obj.getEntryType() == Entry.BINARY) {
// Binary resource
result.put(RESULT, obj.getValue());
} else if (message.containsKey(COMPRESSED)) {
// Compressed XML resource
SymbolSerializer symbolSerializer = new SymbolSerializer(col.getSymbols());
long timestamp = 1;
/* TODO: Timestamp optimization.
Longs are causing problems with XML-RPC
so we'll try to get everything working without them.
if (!message.containsKey(TIMESTAMP)) {
throw new Exception(MISSING_TIMESTAMP_PARAM);
}
int timestamp = ((Integer) message.get("timestamp")).intValue();
*/
// Document might be compressed (with bytes) or not. In a latter case, convert to string.
Document doc = (Document) obj.getValue();
if (/*( timestamp != -1) &&*/ ((CompressedDocument) doc).getDataBytes() != null) {
result.put(RESULT, symbolSerializer.convertFromDocument(doc, timestamp));
} else {
result.put(RESULT, TextWriter.toString(doc));
}
} else {
// XML resource
Document doc = (Document) obj.getValue();
result.put(RESULT, TextWriter.toString(doc));
}
return result;
}