*
*/
public class GetDocument extends RPCDefaultMessage {
public Hashtable execute(Hashtable message) throws Exception {
SymbolSerializer symbolSerializer = null;
if(!message.containsKey(COLLECTION)) {
throw new Exception(MISSING_COLLECTION_PARAM);
}
if(!message.containsKey(NAME)) {
throw new Exception(MISSING_NAME_PARAM);
}
Collection col = getCollection( (String) message.get(COLLECTION) );
Document doc = col.getDocument( (String) message.get(NAME) );
if ( doc == null ) {
throw new Exception( API_NAME + ": Document not found " +
(String) message.get(NAME) );
}
Hashtable result = new Hashtable();
if (message.containsKey(COMPRESSED)) {
try {
symbolSerializer = new SymbolSerializer(col.getSymbols());
}
catch ( Exception e ) {
// It's ok (in theory) for a Collection to have no symbol table
}
long timestamp = 1;
/* Time stamp is an optimization and 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();*/
if ( /*( timestamp != -1) &&*/ ( symbolSerializer != null ) ) {
result.put(RESULT,
symbolSerializer.convertFromDocument(doc, timestamp));
}
else {
result.put(RESULT, TextWriter.toString( doc ));
}
}