@@ -0,0 +1,1820 @@
+package foam.nanos.notification;%0Aimport foam.core.FObject;%0Aimport foam.core.X;%0Aimport foam.dao.DAO;%0Aimport foam.dao.ProxyDAO;%0Aimport org.apache.http.client.methods.CloseableHttpResponse;%0Aimport org.apache.http.client.methods.HttpPost;%0Aimport org.apache.http.entity.StringEntity;%0Aimport org.apache.http.impl.client.CloseableHttpClient;%0Aimport org.apache.http.impl.client.HttpClients;%0A%0A%0Apublic class SendSlackNotificationDAO extends ProxyDAO %7B%0A%0A    public SendSlackNotificationDAO(DAO delegate) %7B%0A      setDelegate(delegate);%0A    %7D%0A%0A    public SendSlackNotificationDAO(X x, DAO delegate) %7B%0A      setX(x);%0A      setDelegate(delegate);%0A    %7D%0A    @Override%0A    public FObject put_(X x, FObject obj) %7B%0A      Notification notif = (Notification) obj;%0A      Boolean sendSlackMessage = notif.getSendSlackMessage();%0A      String slackWebhook = notif.getSlackWebhook();%0A      String slackMessage = notif.getSlackMessage();%0A%0A      if ( sendSlackMessage ) %7B%0A        CloseableHttpClient client = HttpClients.createDefault();%0A        HttpPost httppost = new HttpPost(slackWebhook);%0A        httppost.addHeader(%22Content-type%22, %22application/json%22);%0A        StringEntity params = new StringEntity(%22%7B%5C%22text%5C%22 : %5C%22%22 + slackMessage + %22%5C%22%7D%22, %22UTF-8%22);%0A        params.setContentType(%22application/json%22);%0A        httppost.setEntity(params);%0A        try %7B%0A            CloseableHttpResponse response =  client.execute(httppost);%0A            // TO REVIEWER - Is there a better way to handle non 200 responses from slack?%0A            if (response.getStatusLine().getStatusCode() != 200 )%7B%0A              System.err.print(%22Could not post to Slack; error code -%22 + response.getStatusLine().getStatusCode() + %22%5Cn1%22);%0A            %7D;%0A        %7D catch (Throwable t) %7B%0A          System.err.print(t);%0A        %7D%0A      %7D%0A      return super.put_(x, obj);%0A    %7D%0A%7D%0A

add DAO to send slack messages for a notification event