1 16 package org.pentaho.core.audit; 17 18 import java.math.BigDecimal ; 19 20 import org.pentaho.core.runtime.IRuntimeContext; 21 import org.pentaho.core.session.IPentahoSession; 22 import org.pentaho.messages.Messages; 23 import org.pentaho.util.logging.ILogger; 24 import org.pentaho.util.logging.Logger; 25 26 public class AuditHelper { 27 28 public static void audit(IRuntimeContext runtimeContext, IPentahoSession session, String messageType, String message, String value, BigDecimal duration, ILogger logger) { 29 try { 30 31 String instanceId = (runtimeContext == null) ? "" : runtimeContext.getInstanceId(); String userId = session.getName(); 33 String actionName = (runtimeContext == null) ? null : runtimeContext.getActionName(); 34 String objectType = runtimeContext.getCurrentComponentName(); 35 String processId = (runtimeContext == null) ? null : runtimeContext.getProcessId(); 36 37 audit(instanceId, userId, actionName, objectType, processId, messageType, message, value, duration, logger); 38 39 } catch (Exception e) { 40 if (logger != null) { 41 logger.error(Messages.getErrorString("AUDITHELPER.ERROR_0001_AUDIT_ENTRY_ERROR"), e); } else { 43 Logger.error(AuditHelper.class.getName(), Messages.getErrorString("AUDITHELPER.ERROR_0001_AUDIT_ENTRY_ERROR"), e); } 45 } 46 } 47 48 public static void audit(String instanceId, String userId, String actionName, String objectType, String processId, String messageType, String message, String value, BigDecimal duration, ILogger logger) { 49 try { 50 51 if ((processId == null) || (instanceId == null) || (actionName == null) || actionName.equals("")) { if (processId == null) { 53 processId = ""; } 56 if (instanceId == null) { 57 instanceId = ""; } 60 if (actionName == null) { 61 actionName = ""; } 64 } 65 AuditEntry.auditJobDuration(processId, instanceId, actionName, objectType, userId, messageType, message, value, duration); 66 } catch (Exception e) { 67 if (logger != null) { 68 logger.error(Messages.getErrorString("AUDITHELPER.ERROR_0001_AUDIT_ENTRY_ERROR"), e); } else { 70 Logger.error(AuditHelper.class.getName(), Messages.getErrorString("AUDITHELPER.ERROR_0001_AUDIT_ENTRY_ERROR"), e); } 72 } 73 } 74 75 } 76 | Popular Tags |