Index: unk/greenstone3-extensions/gsdl-as/src/org/greenstone/gsdlas/AlertingServiceServlet.java
===================================================================
--- /trunk/greenstone3-extensions/gsdl-as/src/org/greenstone/gsdlas/AlertingServiceServlet.java	(revision 8630)
+++ 	(revision )
@@ -1,221 +1,0 @@
-/*
- * Created on Oct 26, 2004
- * Copyright (C) Andrea Schweer, 2004
- *
- * This file is part of the Greenstone Alerting Service.
- * Refer to the COPYING file in the base directory of this package
- * for licensing information.
- */
-package org.greenstone.gsdlas;
-
-import java.io.*;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.*;
-import java.util.logging.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.*;
-
-import org.greenstone.gsdlas.profiles.*;
-import org.greenstone.gsdlas.profiles.ParseException;
-import org.greenstone.gsdlas.profiles.Subscription;
-
-/**
- * @author schweer
- * 
- * TODO javadocs
- */
-public class AlertingServiceServlet extends HttpServlet {
-
-    private Logger logger;
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see javax.servlet.GenericServlet#init()
-     */
-    public void init() throws ServletException {
-        super.init();
-        logger = Logger.getLogger("org.greenstone.gsdlas");
-        try {
-            FileHandler handler = new FileHandler(
-                    "/research/schweer/gsdl3/comms/jakarta/tomcat/logs/alerting",
-                    true);
-            handler.setFormatter(new SimpleFormatter());
-            logger.addHandler(handler);
-        } catch (SecurityException e) {
-        } catch (IOException e) {
-        }
-        logger.setLevel(Level.ALL);
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest,
-     *      javax.servlet.http.HttpServletResponse)
-     */
-    protected void doPost(HttpServletRequest req, HttpServletResponse res)
-            throws ServletException, IOException {
-
-        String action = req.getQueryString();
-        logger.info("action is " + action);
-        if (action != null && action.equals("receive")) {
-            receiveEvent(req, res);
-        } else if (action != null && action.equals("subscribe")) {
-            createSubscription(req, res);
-        } else if (action != null && action.equals("list")) {
-            listSubscriptions(req, res);
-        } else {
-            res.setContentType("text/plain");
-            PrintWriter toClient = res.getWriter();
-
-            BufferedReader fromClient = req.getReader();
-            String line;
-
-            while ((line = fromClient.readLine()) != null) {
-                toClient.println(line);
-            }
-            toClient.close();
-        }
-    }
-
-    
-    
-    /**
-     * @param req
-     * @param res
-     * @throws IOException
-     */
-    private void listSubscriptions(HttpServletRequest req, HttpServletResponse res) throws IOException {
-        res.setContentType("text/plain");
-        PrintWriter toClient = res.getWriter();
-
-        BufferedReader fromClient = req.getReader();
-        String line;
-
-        toClient.println(ProfileStore.getInstance());
-        
-        toClient.close();
-    }
-
-    protected void doGet(HttpServletRequest arg0, HttpServletResponse arg1)
-            throws ServletException, IOException {
-        doPost(arg0, arg1);
-    }
-    /**
-     * @param req
-     * @param res
-     * @throws IOException
-     */
-    private void createSubscription(HttpServletRequest req,
-            HttpServletResponse res) throws IOException {
-        Map valueMap = readAttributeValueMap(req.getReader());
-        if (valueMap.size() == 0) {
-            return;
-        }
-        try {
-            // TODO pass user information to profile store
-            Subscription sub = new Subscription(valueMap);
-            // TODO this should probably be somewhere else
-            for (Iterator iter = sub.getPredicates().iterator(); iter.hasNext();) {
-                Predicate predicate = (Predicate) iter.next();
-                if (predicate != null) {
-                    predicate.addSubscription(sub);
-                }
-            }
-            ProfileStore.getInstance().addSubscription(sub);
-        } catch (ParseException e) {
-            res.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
-        }
-    }
-
-    /**
-     * @param req
-     * @param res
-     * @throws IOException
-     */
-    private void receiveEvent(HttpServletRequest req, HttpServletResponse res)
-            throws IOException {
-        res.setContentType("text/plain");
-        PrintWriter toClient = res.getWriter();
-
-        Map event = readAttributeValueMap(req.getReader());
-
-        for (Iterator iter = event.keySet().iterator(); iter.hasNext();) {
-            String key = (String) iter.next();
-            toClient.println(key + "=" + event.get(key));
-        }
-
-        GreenstoneCommunicator gsComm = null;
-        try {
-            gsComm = new GreenstoneCommunicator(new URL((String) event.get("host_url")));
-        } catch (MalformedURLException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        } catch (Exception e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        }
-        Set matchedSubscriptions = ProfileStore.getInstance().filter(event, gsComm);
-        boolean matchedAnything = false;
-        for (Iterator iter = matchedSubscriptions.iterator(); iter.hasNext();) {
-            Subscription sub = (Subscription) iter.next();
-            toClient.println("event matches subscription " + sub);
-            matchedAnything = true;
-        }
-        if (!matchedAnything) {
-            toClient.println("No matching subscriptions");
-        }
-        toClient.close();
-    }
-
-    /**
-     * @param reader
-     * @return
-     * @throws IOException
-     */
-    private Map readAttributeValueMap(BufferedReader reader)
-            throws IOException {
-        Map map = new TreeMap();
-        String line = reader.readLine();
-        if (line == null) return map;
-        String[] lines = line.split("&");
-        
-        Pattern p = Pattern.compile("^([^=]+)=([^=]+)$");
-        
-        for (int i = 0; i < lines.length; i++) {
-            String thisLine = lines[i];
-            Matcher m = p.matcher(thisLine);
-            if (m.matches()) {
-                String key = m.group(1); 
-                String value = m.group(2); 
-                map.put(key, value);
-            }
-        }
-            
-        return map;
-    }
-    
-    /**
-     * @param event
-     * @param subscriptions the set of subscriptions matched by the event.
-     */
-    private void sendNotifications(Map event, Set subscriptions) {
-        for (Iterator iter = subscriptions.iterator(); iter.hasNext();) {
-            Subscription sub = (Subscription) iter.next();
-            synchronized (logger) {
-                logger.info("Subscription " + sub + " is matched by ");
-                for (Iterator iterator = event.keySet().iterator(); iterator
-                        .hasNext();) {
-                    String key = (String) iterator.next();
-                    logger.info(key + "=" + event.get(key));
-                }
-                logger.info(" ");
-            }
-        }
-    }
-}
Index: unk/gsdl3/extensions/gsdl-as/src/org/greenstone/gsdlas/AlertingServiceServlet.java
===================================================================
--- /trunk/gsdl3/extensions/gsdl-as/src/org/greenstone/gsdlas/AlertingServiceServlet.java	(revision 8630)
+++ 	(revision )
@@ -1,221 +1,0 @@
-/*
- * Created on Oct 26, 2004
- * Copyright (C) Andrea Schweer, 2004
- *
- * This file is part of the Greenstone Alerting Service.
- * Refer to the COPYING file in the base directory of this package
- * for licensing information.
- */
-package org.greenstone.gsdlas;
-
-import java.io.*;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.*;
-import java.util.logging.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.*;
-
-import org.greenstone.gsdlas.profiles.*;
-import org.greenstone.gsdlas.profiles.ParseException;
-import org.greenstone.gsdlas.profiles.Subscription;
-
-/**
- * @author schweer
- * 
- * TODO javadocs
- */
-public class AlertingServiceServlet extends HttpServlet {
-
-    private Logger logger;
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see javax.servlet.GenericServlet#init()
-     */
-    public void init() throws ServletException {
-        super.init();
-        logger = Logger.getLogger("org.greenstone.gsdlas");
-        try {
-            FileHandler handler = new FileHandler(
-                    "/research/schweer/gsdl3/comms/jakarta/tomcat/logs/alerting",
-                    true);
-            handler.setFormatter(new SimpleFormatter());
-            logger.addHandler(handler);
-        } catch (SecurityException e) {
-        } catch (IOException e) {
-        }
-        logger.setLevel(Level.ALL);
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest,
-     *      javax.servlet.http.HttpServletResponse)
-     */
-    protected void doPost(HttpServletRequest req, HttpServletResponse res)
-            throws ServletException, IOException {
-
-        String action = req.getQueryString();
-        logger.info("action is " + action);
-        if (action != null && action.equals("receive")) {
-            receiveEvent(req, res);
-        } else if (action != null && action.equals("subscribe")) {
-            createSubscription(req, res);
-        } else if (action != null && action.equals("list")) {
-            listSubscriptions(req, res);
-        } else {
-            res.setContentType("text/plain");
-            PrintWriter toClient = res.getWriter();
-
-            BufferedReader fromClient = req.getReader();
-            String line;
-
-            while ((line = fromClient.readLine()) != null) {
-                toClient.println(line);
-            }
-            toClient.close();
-        }
-    }
-
-    
-    
-    /**
-     * @param req
-     * @param res
-     * @throws IOException
-     */
-    private void listSubscriptions(HttpServletRequest req, HttpServletResponse res) throws IOException {
-        res.setContentType("text/plain");
-        PrintWriter toClient = res.getWriter();
-
-        BufferedReader fromClient = req.getReader();
-        String line;
-
-        toClient.println(ProfileStore.getInstance());
-        
-        toClient.close();
-    }
-
-    protected void doGet(HttpServletRequest arg0, HttpServletResponse arg1)
-            throws ServletException, IOException {
-        doPost(arg0, arg1);
-    }
-    /**
-     * @param req
-     * @param res
-     * @throws IOException
-     */
-    private void createSubscription(HttpServletRequest req,
-            HttpServletResponse res) throws IOException {
-        Map valueMap = readAttributeValueMap(req.getReader());
-        if (valueMap.size() == 0) {
-            return;
-        }
-        try {
-            // TODO pass user information to profile store
-            Subscription sub = new Subscription(valueMap);
-            // TODO this should probably be somewhere else
-            for (Iterator iter = sub.getPredicates().iterator(); iter.hasNext();) {
-                Predicate predicate = (Predicate) iter.next();
-                if (predicate != null) {
-                    predicate.addSubscription(sub);
-                }
-            }
-            ProfileStore.getInstance().addSubscription(sub);
-        } catch (ParseException e) {
-            res.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
-        }
-    }
-
-    /**
-     * @param req
-     * @param res
-     * @throws IOException
-     */
-    private void receiveEvent(HttpServletRequest req, HttpServletResponse res)
-            throws IOException {
-        res.setContentType("text/plain");
-        PrintWriter toClient = res.getWriter();
-
-        Map event = readAttributeValueMap(req.getReader());
-
-        for (Iterator iter = event.keySet().iterator(); iter.hasNext();) {
-            String key = (String) iter.next();
-            toClient.println(key + "=" + event.get(key));
-        }
-
-        GreenstoneCommunicator gsComm = null;
-        try {
-            gsComm = new GreenstoneCommunicator(new URL((String) event.get("host_url")));
-        } catch (MalformedURLException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        } catch (Exception e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        }
-        Set matchedSubscriptions = ProfileStore.getInstance().filter(event, gsComm);
-        boolean matchedAnything = false;
-        for (Iterator iter = matchedSubscriptions.iterator(); iter.hasNext();) {
-            Subscription sub = (Subscription) iter.next();
-            toClient.println("event matches subscription " + sub);
-            matchedAnything = true;
-        }
-        if (!matchedAnything) {
-            toClient.println("No matching subscriptions");
-        }
-        toClient.close();
-    }
-
-    /**
-     * @param reader
-     * @return
-     * @throws IOException
-     */
-    private Map readAttributeValueMap(BufferedReader reader)
-            throws IOException {
-        Map map = new TreeMap();
-        String line = reader.readLine();
-        if (line == null) return map;
-        String[] lines = line.split("&");
-        
-        Pattern p = Pattern.compile("^([^=]+)=([^=]+)$");
-        
-        for (int i = 0; i < lines.length; i++) {
-            String thisLine = lines[i];
-            Matcher m = p.matcher(thisLine);
-            if (m.matches()) {
-                String key = m.group(1); 
-                String value = m.group(2); 
-                map.put(key, value);
-            }
-        }
-            
-        return map;
-    }
-    
-    /**
-     * @param event
-     * @param subscriptions the set of subscriptions matched by the event.
-     */
-    private void sendNotifications(Map event, Set subscriptions) {
-        for (Iterator iter = subscriptions.iterator(); iter.hasNext();) {
-            Subscription sub = (Subscription) iter.next();
-            synchronized (logger) {
-                logger.info("Subscription " + sub + " is matched by ");
-                for (Iterator iterator = event.keySet().iterator(); iterator
-                        .hasNext();) {
-                    String key = (String) iterator.next();
-                    logger.info(key + "=" + event.get(key));
-                }
-                logger.info(" ");
-            }
-        }
-    }
-}
Index: unk/gsdl3/packages/gsdl-as/src/org/greenstone/gsdlas/AlertingServiceServlet.java
===================================================================
--- /trunk/gsdl3/packages/gsdl-as/src/org/greenstone/gsdlas/AlertingServiceServlet.java	(revision 8630)
+++ 	(revision )
@@ -1,221 +1,0 @@
-/*
- * Created on Oct 26, 2004
- * Copyright (C) Andrea Schweer, 2004
- *
- * This file is part of the Greenstone Alerting Service.
- * Refer to the COPYING file in the base directory of this package
- * for licensing information.
- */
-package org.greenstone.gsdlas;
-
-import java.io.*;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.*;
-import java.util.logging.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.*;
-
-import org.greenstone.gsdlas.profiles.*;
-import org.greenstone.gsdlas.profiles.ParseException;
-import org.greenstone.gsdlas.profiles.Subscription;
-
-/**
- * @author schweer
- * 
- * TODO javadocs
- */
-public class AlertingServiceServlet extends HttpServlet {
-
-    private Logger logger;
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see javax.servlet.GenericServlet#init()
-     */
-    public void init() throws ServletException {
-        super.init();
-        logger = Logger.getLogger("org.greenstone.gsdlas");
-        try {
-            FileHandler handler = new FileHandler(
-                    "/research/schweer/gsdl3/comms/jakarta/tomcat/logs/alerting",
-                    true);
-            handler.setFormatter(new SimpleFormatter());
-            logger.addHandler(handler);
-        } catch (SecurityException e) {
-        } catch (IOException e) {
-        }
-        logger.setLevel(Level.ALL);
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest,
-     *      javax.servlet.http.HttpServletResponse)
-     */
-    protected void doPost(HttpServletRequest req, HttpServletResponse res)
-            throws ServletException, IOException {
-
-        String action = req.getQueryString();
-        logger.info("action is " + action);
-        if (action != null && action.equals("receive")) {
-            receiveEvent(req, res);
-        } else if (action != null && action.equals("subscribe")) {
-            createSubscription(req, res);
-        } else if (action != null && action.equals("list")) {
-            listSubscriptions(req, res);
-        } else {
-            res.setContentType("text/plain");
-            PrintWriter toClient = res.getWriter();
-
-            BufferedReader fromClient = req.getReader();
-            String line;
-
-            while ((line = fromClient.readLine()) != null) {
-                toClient.println(line);
-            }
-            toClient.close();
-        }
-    }
-
-    
-    
-    /**
-     * @param req
-     * @param res
-     * @throws IOException
-     */
-    private void listSubscriptions(HttpServletRequest req, HttpServletResponse res) throws IOException {
-        res.setContentType("text/plain");
-        PrintWriter toClient = res.getWriter();
-
-        BufferedReader fromClient = req.getReader();
-        String line;
-
-        toClient.println(ProfileStore.getInstance());
-        
-        toClient.close();
-    }
-
-    protected void doGet(HttpServletRequest arg0, HttpServletResponse arg1)
-            throws ServletException, IOException {
-        doPost(arg0, arg1);
-    }
-    /**
-     * @param req
-     * @param res
-     * @throws IOException
-     */
-    private void createSubscription(HttpServletRequest req,
-            HttpServletResponse res) throws IOException {
-        Map valueMap = readAttributeValueMap(req.getReader());
-        if (valueMap.size() == 0) {
-            return;
-        }
-        try {
-            // TODO pass user information to profile store
-            Subscription sub = new Subscription(valueMap);
-            // TODO this should probably be somewhere else
-            for (Iterator iter = sub.getPredicates().iterator(); iter.hasNext();) {
-                Predicate predicate = (Predicate) iter.next();
-                if (predicate != null) {
-                    predicate.addSubscription(sub);
-                }
-            }
-            ProfileStore.getInstance().addSubscription(sub);
-        } catch (ParseException e) {
-            res.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
-        }
-    }
-
-    /**
-     * @param req
-     * @param res
-     * @throws IOException
-     */
-    private void receiveEvent(HttpServletRequest req, HttpServletResponse res)
-            throws IOException {
-        res.setContentType("text/plain");
-        PrintWriter toClient = res.getWriter();
-
-        Map event = readAttributeValueMap(req.getReader());
-
-        for (Iterator iter = event.keySet().iterator(); iter.hasNext();) {
-            String key = (String) iter.next();
-            toClient.println(key + "=" + event.get(key));
-        }
-
-        GreenstoneCommunicator gsComm = null;
-        try {
-            gsComm = new GreenstoneCommunicator(new URL((String) event.get("host_url")));
-        } catch (MalformedURLException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        } catch (Exception e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        }
-        Set matchedSubscriptions = ProfileStore.getInstance().filter(event, gsComm);
-        boolean matchedAnything = false;
-        for (Iterator iter = matchedSubscriptions.iterator(); iter.hasNext();) {
-            Subscription sub = (Subscription) iter.next();
-            toClient.println("event matches subscription " + sub);
-            matchedAnything = true;
-        }
-        if (!matchedAnything) {
-            toClient.println("No matching subscriptions");
-        }
-        toClient.close();
-    }
-
-    /**
-     * @param reader
-     * @return
-     * @throws IOException
-     */
-    private Map readAttributeValueMap(BufferedReader reader)
-            throws IOException {
-        Map map = new TreeMap();
-        String line = reader.readLine();
-        if (line == null) return map;
-        String[] lines = line.split("&");
-        
-        Pattern p = Pattern.compile("^([^=]+)=([^=]+)$");
-        
-        for (int i = 0; i < lines.length; i++) {
-            String thisLine = lines[i];
-            Matcher m = p.matcher(thisLine);
-            if (m.matches()) {
-                String key = m.group(1); 
-                String value = m.group(2); 
-                map.put(key, value);
-            }
-        }
-            
-        return map;
-    }
-    
-    /**
-     * @param event
-     * @param subscriptions the set of subscriptions matched by the event.
-     */
-    private void sendNotifications(Map event, Set subscriptions) {
-        for (Iterator iter = subscriptions.iterator(); iter.hasNext();) {
-            Subscription sub = (Subscription) iter.next();
-            synchronized (logger) {
-                logger.info("Subscription " + sub + " is matched by ");
-                for (Iterator iterator = event.keySet().iterator(); iterator
-                        .hasNext();) {
-                    String key = (String) iterator.next();
-                    logger.info(key + "=" + event.get(key));
-                }
-                logger.info(" ");
-            }
-        }
-    }
-}
