package handlers.files;
import handlers.AbstractServerHandler;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import queries.Query;
import queries.QueryManager;
import static main.ServerMain.*;
import connection.ClientConnection;
public class ResultsHandler extends AbstractServerHandler
{
@SuppressWarnings("unchecked")
public void execute(ClientConnection connection, ObjectInputStream is,
ObjectOutputStream os) throws IOException, ClassNotFoundException
{
int queryId = is.readInt();
Object results = is.readObject();
QueryManager queryManager = getQueryManager();
Query query = queryManager.getQuery(queryId);
if (query == null)
{
return;
}
ClientConnection client = getConnectionManager().getClientById(
query.getQuerierId());
if (client == null)
{
return;
}
client.sendSearchResults(query.getQuerierCookie(), results);
}
}