@@ -0,0 +1,2055 @@
+package me.doubledutch.stroom.servlet;%0A%0Aimport org.apache.log4j.Logger;%0A%0Aimport java.io.IOException;%0A%0Aimport java.lang.reflect.*;%0Aimport java.io.*;%0Aimport java.util.*;%0A%0Aimport javax.servlet.ServletException;%0Aimport javax.servlet.http.HttpServlet;%0Aimport javax.servlet.http.HttpServletRequest;%0Aimport javax.servlet.http.HttpServletResponse;%0A%0Aimport me.doubledutch.stroom.streams.*;%0A%0Aimport org.json.*;%0A%0Apublic class AggregateAPIServlet extends HttpServlet%7B%0A%09private final Logger log = Logger.getLogger(%22AggregateAPI%22);%0A%0A%09private static StreamHandler streamHandler;%0A%0A%09public static void setStreamHandler(StreamHandler streamHandlerArg)%7B%0A%09%09streamHandler=streamHandlerArg;%0A%09%7D%0A%0A%09@Override%0A%09protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException %7B%0A%09%09try%7B%0A%09%09%09Writer out=response.getWriter();%0A%09%09%09response.setContentType(%22application/json%22);%0A%09%09%09String uriPath=request.getRequestURI().substring(request.getServletPath().length());%0A%09%09%09if(uriPath.startsWith(%22/%22))uriPath=uriPath.substring(1).trim();%0A%09%09%09String%5B%5D splitPath=uriPath.split(%22/%22);%0A%09%09%09if(uriPath.length()==0)%7B%0A%09%09%09%09// List aggregates%0A%09%09%09%09JSONArray result=new JSONArray();%0A%09%09%09%09/*%0A%09%09%09%09for(Stream stream:streamHandler.getStreams())%7B%0A%09%09%09%09%09if(stream.getTopic().indexOf(%22.%22)==-1)%7B%0A%09%09%09%09%09%09result.put(stream.toJSON());%0A%09%09%09%09%09%7D%0A%09%09%09%09%7D*/%0A%09%09%09%09out.write(result.toString());%0A%09%09%09%09return;%0A%09%09%09%7Delse if(splitPath.length==1)%7B%0A%09%09%09%09// Get simple aggregate or keyset of partitioned aggregate%0A%09%09%09%09String id=splitPath%5B0%5D;%0A%09%09%09%09// Stream stream=streamHandler.getOrCreateStream(topic);%0A%09%09%09%09// out.append(stream.toJSON().toString());%0A%09%09%09%7Delse if(splitPath.length==2)%7B%0A%09%09%09%09// Get partitioned aggregate by partition key%0A%09%09%09%09String id=splitPath%5B0%5D;%0A%09%09%09%09String partition=splitPath%5B1%5D;%0A%09%09%09%09%0A%09%09%09%7Delse%7B%0A%09%09%09%09// response.sendError(HttpServletResponse.SC_NOT_FOUND,%22You must specify both topic and location.%22);%0A%09%09%09%7D%0A%09%09%7Dcatch(Exception e)%7B%0A%09%09%09e.printStackTrace();%0A%09%09%09response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR ,%22Internal server error%22);%0A%09%09%7D%0A%09%09return;%0A%09%7D%0A%7D

add almost empty servlet for handling aggregate requests