1 16 17 package org.pentaho.plugin.misc; 18 19 import java.util.Date ; 20 import org.apache.commons.logging.Log; 21 import org.apache.commons.logging.LogFactory; 22 import org.pentaho.messages.Messages; 23 import org.pentaho.plugin.ComponentBase; 24 25 31 public class ReceiptAuditComponent extends ComponentBase { 32 33 private static final long serialVersionUID = -7641957638192444235L; 34 35 private static final String MESSAGE = "message"; 37 private static final String DT = "dt"; 39 public Log getLogger() { 40 return LogFactory.getLog(ReceiptAuditComponent.class); 41 } 42 43 public static String RECEIPT_AUDIT = Messages.getString("ReceiptAuditComponent.CODE_AUDIT_CONTENT_RECEIVED"); 45 protected boolean validateSystemSettings() { 46 return true; 48 } 49 50 protected boolean validateAction() { 51 52 if (!isDefinedInput(MESSAGE)) { 54 error(Messages.getErrorString("ReceiptAuditComponent.ERROR_0001_MESSAGE_NOT_SPECIFIED")); return false; 56 } 57 58 if (!isDefinedInput(DT)) { 60 error(Messages.getErrorString("ReceiptAuditComponent.ERROR_0002_TIMESTAMP_NOT_SPECIFIED")); return false; 62 } 63 64 return true; 65 } 66 67 public void done() { 68 } 69 70 protected boolean executeAction() { 71 72 String message = getInputStringValue(MESSAGE); 73 String dtString = getInputStringValue(DT); 74 75 long dt = new Long (dtString).longValue(); 76 long now = new Date ().getTime(); 77 int duration = (int) ((now - dt) / 1000); 78 79 audit(RECEIPT_AUDIT, message, "", duration); 81 return false; 82 } 83 84 89 public boolean init() { 90 return true; 91 } 92 93 } 94 | Popular Tags |