package pt.webdetails.cdv;

import java.util.Date;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONObject;

import pt.webdetails.cpf.JsonRequestHandler;
import pt.webdetails.cpf.messaging.PluginEvent;

public class PushWarningsHandler extends JsonRequestHandler {

  private static Log logger = LogFactory.getLog(PushWarningsHandler.class); 
  
  @Override
  public JSONObject call(JSONObject request) throws Exception {
//    
//    logger.info("EVENT received:" + request.toString(4));
    
    PluginEvent event = new PluginEvent(request);
    
    logger.info("[" + event.getPlugin() + ":" + event.getEventType() + "] " +
                "[" + new Date() + "]" + "[" + new Date(event.getTimeStamp()) + "] \n" + 
                event.getEvent().toString(4));
    return request;
  }

//  @Override
//  public void call(OutputStream out, IParameterProvider pathParams, IParameterProvider requestParams) {
//    try {
//      IOUtils.write("ok", out);
//    } catch (IOException e) {
//      LogFactory.getLog(this.getClass()).error(e);
//    }
//  }

}

@@ -204,16 +204,49 @@
 andler;%0A
+import pt.webdetails.cpf.Result;%0A
 import p
@@ -285,16 +285,16 @@
 nEvent;%0A
-
 %0Apublic 
@@ -429,16 +429,19 @@
 s); %0A  %0A
+  %0A
   @Overr
@@ -512,80 +512,20 @@
 n %7B%0A
-//    %0A//    logger.info(%22EVENT received:%22 + request.toString(4));%0A    %0A
+%0A    try%7B%0A  
     
@@ -574,17 +574,21 @@
 t);%0A    
-%0A
+  %0A  
     logg
@@ -677,32 +677,9 @@
     
-%22%5B%22 + new Date() + %22%5D%22 +
+ 
  %22%5B%22
@@ -740,16 +740,18 @@
         
+  
 event.ge
@@ -781,23 +781,142 @@
     
+  
 return 
-request;
+Result.getOK(%22warning received%22).toJSON();%0A    %7D catch (Exception e)%7B%0A      return Result.getFromException(e).toJSON();%0A    %7D
 %0A  %7D

use result