Search in sources :

Example 1 with AuditException

use of org.pentaho.platform.api.engine.AuditException in project pentaho-platform by pentaho.

the class AuditSQLEntry method auditAll.

/*
   * private void setInteger(PreparedStatement stmt, int num, Integer val) throws SQLException{ if (val != null) {
   * stmt.setInt(num, val.intValue()); } else { stmt.setNull(num, Types.INTEGER); } }
   */
public void auditAll(final String jobId, final String instId, final String objId, final String objType, final String actor, final String messageType, final String messageName, final String messageTxtValue, final BigDecimal messageNumValue, final double duration) throws AuditException {
    Connection con = null;
    try {
        con = AuditSQLEntry.audc.getAuditConnection();
        try {
            PreparedStatement stmt = con.prepareStatement(AuditSQLEntry.INSERT_STMT);
            try {
                setString(stmt, 1, jobId);
                setString(stmt, 2, instId);
                setString(stmt, 3, objId);
                setString(stmt, 4, objType);
                setString(stmt, 5, actor);
                setString(stmt, 6, messageType);
                setString(stmt, 7, messageName);
                setObject(stmt, 8, messageTxtValue);
                setBigDec(stmt, 9, messageNumValue);
                setBigDec(stmt, 10, new BigDecimal(duration));
                stmt.setTimestamp(11, new Timestamp(System.currentTimeMillis()));
                stmt.executeUpdate();
            } catch (SQLException ex) {
                Logger.error(this.getClass().getName(), ex.getMessage(), ex);
                try {
                    con.rollback();
                } catch (Exception rollbackExc) {
                    throw new AuditException(rollbackExc);
                }
                throw new AuditException(ex);
            } finally {
                stmt.close();
            }
        } finally {
            con.close();
        }
    } catch (SQLException ex) {
        throw new AuditException(ex);
    }
}
Also used : SQLException(java.sql.SQLException) Connection(java.sql.Connection) AuditException(org.pentaho.platform.api.engine.AuditException) PreparedStatement(java.sql.PreparedStatement) Timestamp(java.sql.Timestamp) BigDecimal(java.math.BigDecimal) SQLException(java.sql.SQLException) AuditException(org.pentaho.platform.api.engine.AuditException)

Example 2 with AuditException

use of org.pentaho.platform.api.engine.AuditException in project pentaho-platform by pentaho.

the class AuditFileEntry method auditAll.

public synchronized void auditAll(final String jobId, final String instId, final String objId, final String objType, final String actor, final String messageType, final String messageName, final String messageTxtValue, final BigDecimal messageNumValue, final double duration) throws AuditException {
    if (AuditFileEntry.auditFile == null) {
        return;
    }
    try {
        BufferedWriter fw = new BufferedWriter(new FileWriter(AuditFileEntry.auditFile, true));
        try {
            Date dt = new Date();
            fw.write(AuditFileEntry.auditDateFormat.format(dt));
            fw.write(AuditFileEntry.ID_SEPARATOR);
            fw.write(getWritable(jobId));
            fw.write(AuditFileEntry.ID_SEPARATOR);
            fw.write(getWritable(instId));
            fw.write(AuditFileEntry.ID_SEPARATOR);
            fw.write(getWritable(objId));
            fw.write(AuditFileEntry.ID_SEPARATOR);
            fw.write(getWritable(objType));
            fw.write(AuditFileEntry.ID_SEPARATOR);
            fw.write(getWritable(actor));
            fw.write(AuditFileEntry.ID_SEPARATOR);
            fw.write(getWritable(messageType));
            fw.write(AuditFileEntry.ID_SEPARATOR);
            fw.write(getWritable(messageName));
            fw.write(AuditFileEntry.ID_SEPARATOR);
            fw.write(getWritable(messageTxtValue));
            fw.write(AuditFileEntry.ID_SEPARATOR);
            fw.write(getWritable(messageNumValue));
            fw.write(AuditFileEntry.ID_SEPARATOR);
            fw.write(getWritable(duration));
            fw.newLine();
        } finally {
            fw.flush();
            fw.close();
        }
    } catch (IOException ex) {
        throw new AuditException(ex);
    }
}
Also used : FileWriter(java.io.FileWriter) AuditException(org.pentaho.platform.api.engine.AuditException) IOException(java.io.IOException) Date(java.util.Date) BufferedWriter(java.io.BufferedWriter)

Example 3 with AuditException

use of org.pentaho.platform.api.engine.AuditException in project pentaho-platform by pentaho.

the class MultipleComponentIT method testMiscExceptionClasses.

/*
   * public void testCrosstab() { startTest(); IRuntimeContext context = run("test", "rules", "CrossTabTest.xaction");
   * //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertEquals(
   * Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS,
   * context.getStatus()); //$NON-NLS-1$ IActionParameter rtn = context.getOutputParameter("rule-result"); //$NON-NLS-1$
   * assertNotNull(rtn); IPentahoResultSet resultset = (IPentahoResultSet) rtn.getValue();
   * assertEquals(resultset.getRowCount(), 7); Object[][] colHeaders = resultset.getMetaData().getColumnHeaders();
   * assertEquals(colHeaders[0][0], "DEPARTMENT"); //$NON-NLS-1$ assertEquals(colHeaders[0][1], "Central"); //$NON-NLS-1$
   * assertEquals(colHeaders[0][2], "Western"); //$NON-NLS-1$ assertEquals(colHeaders[0][3], "Southern"); //$NON-NLS-1$
   * assertEquals(colHeaders[0][4], "Eastern"); //$NON-NLS-1$
   * 
   * finishTest(); }
   */
public void testMiscExceptionClasses() {
    // Making sure we create an instance of all the Hitachi Vantara
    // Exception classes.
    startTest();
    Exception ex = new RepositoryException();
    // $NON-NLS-1$
    Exception ex2 = new RepositoryException("Ignored");
    Exception ex3 = new RepositoryException(ex2);
    // $NON-NLS-1$
    Exception ex4 = new RepositoryException("Ignored", ex3);
    Exception ex5 = new AuditException();
    // $NON-NLS-1$
    Exception ex6 = new AuditException("Ignored");
    // $NON-NLS-1$
    Exception ex7 = new AuditException("Ignored", ex);
    Exception ex8 = new AuditException(ex4);
    // $NON-NLS-1$
    ex = new ContentException("Ignored");
    // $NON-NLS-1$
    ex = new ContentException("Ignored", ex5);
    ex = new ContentException(ex6);
    ex = new InvalidParameterException();
    ex = new SQLResultSetException();
    ex = new PentahoChainedException();
    // $NON-NLS-1$
    ex = new PentahoChainedException("Ignored");
    // $NON-NLS-1$
    ex = new PentahoChainedException("Ignored", ex7);
    ex = new PentahoChainedException(ex8);
    finishTest();
}
Also used : InvalidParameterException(org.pentaho.platform.api.engine.InvalidParameterException) SQLResultSetException(org.pentaho.platform.plugin.services.connections.sql.SQLResultSetException) PentahoChainedException(org.pentaho.platform.api.util.PentahoChainedException) AuditException(org.pentaho.platform.api.engine.AuditException) ContentException(org.pentaho.platform.api.repository.ContentException) RepositoryException(org.pentaho.platform.api.repository.RepositoryException) SQLResultSetException(org.pentaho.platform.plugin.services.connections.sql.SQLResultSetException) InvalidParameterException(org.pentaho.platform.api.engine.InvalidParameterException) AuditException(org.pentaho.platform.api.engine.AuditException) ContentException(org.pentaho.platform.api.repository.ContentException) PentahoChainedException(org.pentaho.platform.api.util.PentahoChainedException) RepositoryException(org.pentaho.platform.api.repository.RepositoryException)

Aggregations

AuditException (org.pentaho.platform.api.engine.AuditException)3 BufferedWriter (java.io.BufferedWriter)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 BigDecimal (java.math.BigDecimal)1 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 SQLException (java.sql.SQLException)1 Timestamp (java.sql.Timestamp)1 Date (java.util.Date)1 InvalidParameterException (org.pentaho.platform.api.engine.InvalidParameterException)1 ContentException (org.pentaho.platform.api.repository.ContentException)1 RepositoryException (org.pentaho.platform.api.repository.RepositoryException)1 PentahoChainedException (org.pentaho.platform.api.util.PentahoChainedException)1 SQLResultSetException (org.pentaho.platform.plugin.services.connections.sql.SQLResultSetException)1