@Test public void testToJsonFormatLog() throws Throwable { DBAuditMetadataLogEntity amle = new DBAuditMetadataLogEntity("serviceName", "userName", "impersonator", "ipAddress", "operation", "eventTime", "operationText", "allowed", "objectType", "component", "databaseName", "tableName", "columnName", "resourcePath"); String jsonAuditLog = amle.toJsonFormatLog(); ContainerNode rootNode = AuditMetadataLogEntity.parse(jsonAuditLog); assertEntryEquals(rootNode, Constants.LOG_FIELD_SERVICE_NAME, "serviceName"); assertEntryEquals(rootNode, Constants.LOG_FIELD_USER_NAME, "userName"); assertEntryEquals(rootNode, Constants.LOG_FIELD_IMPERSONATOR, "impersonator"); assertEntryEquals(rootNode, Constants.LOG_FIELD_IP_ADDRESS, "ipAddress"); assertEntryEquals(rootNode, Constants.LOG_FIELD_OPERATION, "operation"); assertEntryEquals(rootNode, Constants.LOG_FIELD_EVENT_TIME, "eventTime"); assertEntryEquals(rootNode, Constants.LOG_FIELD_OPERATION_TEXT, "operationText"); assertEntryEquals(rootNode, Constants.LOG_FIELD_ALLOWED, "allowed"); assertEntryEquals(rootNode, Constants.LOG_FIELD_DATABASE_NAME, "databaseName"); assertEntryEquals(rootNode, Constants.LOG_FIELD_TABLE_NAME, "tableName"); assertEntryEquals(rootNode, Constants.LOG_FIELD_COLUMN_NAME, "columnName"); assertEntryEquals(rootNode, Constants.LOG_FIELD_RESOURCE_PATH, "resourcePath"); assertEntryEquals(rootNode, Constants.LOG_FIELD_OBJECT_TYPE, "objectType"); }
@Override public String toJsonFormatLog() throws Exception { StringWriter stringWriter = new StringWriter(); JsonGenerator json = null; try { json = factory.createJsonGenerator(stringWriter); json.writeStartObject(); json.writeStringField(Constants.LOG_FIELD_SERVICE_NAME, serviceName); json.writeStringField(Constants.LOG_FIELD_USER_NAME, userName); json.writeStringField(Constants.LOG_FIELD_IMPERSONATOR, impersonator); json.writeStringField(Constants.LOG_FIELD_IP_ADDRESS, ipAddress); json.writeStringField(Constants.LOG_FIELD_OPERATION, operation); json.writeStringField(Constants.LOG_FIELD_EVENT_TIME, eventTime); json.writeStringField(Constants.LOG_FIELD_OPERATION_TEXT, operationText); json.writeStringField(Constants.LOG_FIELD_ALLOWED, allowed); json.writeStringField(Constants.LOG_FIELD_DATABASE_NAME, databaseName); json.writeStringField(Constants.LOG_FIELD_TABLE_NAME, tableName); json.writeStringField(Constants.LOG_FIELD_COLUMN_NAME, columnName); json.writeStringField(Constants.LOG_FIELD_RESOURCE_PATH, resourcePath); json.writeStringField(Constants.LOG_FIELD_OBJECT_TYPE, objectType); json.writeEndObject(); json.flush(); } catch (IOException e) { String msg = "Error creating audit log in json format: " + e.getMessage(); LOGGER.error(msg, e); throw e; } finally { try { if (json != null) { json.close(); } } catch (IOException e) { throw e; } } return stringWriter.toString(); }
DBAuditMetadataLogEntity extends AuditMetadataLogEntity { @Override public String toJsonFormatLog() throws Exception { StringWriter stringWriter = new StringWriter(); JsonGenerator json = null; try { json = factory.createJsonGenerator(stringWriter); json.writeStartObject(); json.writeStringField(Constants.LOG_FIELD_SERVICE_NAME, serviceName); json.writeStringField(Constants.LOG_FIELD_USER_NAME, userName); json.writeStringField(Constants.LOG_FIELD_IMPERSONATOR, impersonator); json.writeStringField(Constants.LOG_FIELD_IP_ADDRESS, ipAddress); json.writeStringField(Constants.LOG_FIELD_OPERATION, operation); json.writeStringField(Constants.LOG_FIELD_EVENT_TIME, eventTime); json.writeStringField(Constants.LOG_FIELD_OPERATION_TEXT, operationText); json.writeStringField(Constants.LOG_FIELD_ALLOWED, allowed); json.writeStringField(Constants.LOG_FIELD_DATABASE_NAME, databaseName); json.writeStringField(Constants.LOG_FIELD_TABLE_NAME, tableName); json.writeStringField(Constants.LOG_FIELD_COLUMN_NAME, columnName); json.writeStringField(Constants.LOG_FIELD_RESOURCE_PATH, resourcePath); json.writeStringField(Constants.LOG_FIELD_OBJECT_TYPE, objectType); json.writeEndObject(); json.flush(); } catch (IOException e) { String msg = "Error creating audit log in json format: " + e.getMessage(); LOGGER.error(msg, e); throw e; } finally { try { if (json != null) { json.close(); } } catch (IOException e) { throw e; } } return stringWriter.toString(); } }
DBAuditMetadataLogEntity extends AuditMetadataLogEntity { @Override public String toJsonFormatLog() throws Exception { StringWriter stringWriter = new StringWriter(); JsonGenerator json = null; try { json = factory.createJsonGenerator(stringWriter); json.writeStartObject(); json.writeStringField(Constants.LOG_FIELD_SERVICE_NAME, serviceName); json.writeStringField(Constants.LOG_FIELD_USER_NAME, userName); json.writeStringField(Constants.LOG_FIELD_IMPERSONATOR, impersonator); json.writeStringField(Constants.LOG_FIELD_IP_ADDRESS, ipAddress); json.writeStringField(Constants.LOG_FIELD_OPERATION, operation); json.writeStringField(Constants.LOG_FIELD_EVENT_TIME, eventTime); json.writeStringField(Constants.LOG_FIELD_OPERATION_TEXT, operationText); json.writeStringField(Constants.LOG_FIELD_ALLOWED, allowed); json.writeStringField(Constants.LOG_FIELD_DATABASE_NAME, databaseName); json.writeStringField(Constants.LOG_FIELD_TABLE_NAME, tableName); json.writeStringField(Constants.LOG_FIELD_COLUMN_NAME, columnName); json.writeStringField(Constants.LOG_FIELD_RESOURCE_PATH, resourcePath); json.writeStringField(Constants.LOG_FIELD_OBJECT_TYPE, objectType); json.writeEndObject(); json.flush(); } catch (IOException e) { String msg = "Error creating audit log in json format: " + e.getMessage(); LOGGER.error(msg, e); throw e; } finally { try { if (json != null) { json.close(); } } catch (IOException e) { throw e; } } return stringWriter.toString(); } DBAuditMetadataLogEntity();  DBAuditMetadataLogEntity(String serviceName, String userName, String impersonator,
      String ipAddress, String operation, String eventTime, String operationText, String allowed,
      String objectType, String component, String databaseName, String tableName,
      String columnName, String resourcePath); }
DBAuditMetadataLogEntity extends AuditMetadataLogEntity { @Override public String toJsonFormatLog() throws Exception { StringWriter stringWriter = new StringWriter(); JsonGenerator json = null; try { json = factory.createJsonGenerator(stringWriter); json.writeStartObject(); json.writeStringField(Constants.LOG_FIELD_SERVICE_NAME, serviceName); json.writeStringField(Constants.LOG_FIELD_USER_NAME, userName); json.writeStringField(Constants.LOG_FIELD_IMPERSONATOR, impersonator); json.writeStringField(Constants.LOG_FIELD_IP_ADDRESS, ipAddress); json.writeStringField(Constants.LOG_FIELD_OPERATION, operation); json.writeStringField(Constants.LOG_FIELD_EVENT_TIME, eventTime); json.writeStringField(Constants.LOG_FIELD_OPERATION_TEXT, operationText); json.writeStringField(Constants.LOG_FIELD_ALLOWED, allowed); json.writeStringField(Constants.LOG_FIELD_DATABASE_NAME, databaseName); json.writeStringField(Constants.LOG_FIELD_TABLE_NAME, tableName); json.writeStringField(Constants.LOG_FIELD_COLUMN_NAME, columnName); json.writeStringField(Constants.LOG_FIELD_RESOURCE_PATH, resourcePath); json.writeStringField(Constants.LOG_FIELD_OBJECT_TYPE, objectType); json.writeEndObject(); json.flush(); } catch (IOException e) { String msg = "Error creating audit log in json format: " + e.getMessage(); LOGGER.error(msg, e); throw e; } finally { try { if (json != null) { json.close(); } } catch (IOException e) { throw e; } } return stringWriter.toString(); } DBAuditMetadataLogEntity();  DBAuditMetadataLogEntity(String serviceName, String userName, String impersonator,
      String ipAddress, String operation, String eventTime, String operationText, String allowed,
      String objectType, String component, String databaseName, String tableName,
      String columnName, String resourcePath); String getDatabaseName(); void setDatabaseName(String databaseName); String getTableName(); void setTableName(String tableName); String getColumnName(); void setColumnName(String columnName); String getResourcePath(); void setResourcePath(String resourcePath); @Override String toJsonFormatLog(); }
DBAuditMetadataLogEntity extends AuditMetadataLogEntity { @Override public String toJsonFormatLog() throws Exception { StringWriter stringWriter = new StringWriter(); JsonGenerator json = null; try { json = factory.createJsonGenerator(stringWriter); json.writeStartObject(); json.writeStringField(Constants.LOG_FIELD_SERVICE_NAME, serviceName); json.writeStringField(Constants.LOG_FIELD_USER_NAME, userName); json.writeStringField(Constants.LOG_FIELD_IMPERSONATOR, impersonator); json.writeStringField(Constants.LOG_FIELD_IP_ADDRESS, ipAddress); json.writeStringField(Constants.LOG_FIELD_OPERATION, operation); json.writeStringField(Constants.LOG_FIELD_EVENT_TIME, eventTime); json.writeStringField(Constants.LOG_FIELD_OPERATION_TEXT, operationText); json.writeStringField(Constants.LOG_FIELD_ALLOWED, allowed); json.writeStringField(Constants.LOG_FIELD_DATABASE_NAME, databaseName); json.writeStringField(Constants.LOG_FIELD_TABLE_NAME, tableName); json.writeStringField(Constants.LOG_FIELD_COLUMN_NAME, columnName); json.writeStringField(Constants.LOG_FIELD_RESOURCE_PATH, resourcePath); json.writeStringField(Constants.LOG_FIELD_OBJECT_TYPE, objectType); json.writeEndObject(); json.flush(); } catch (IOException e) { String msg = "Error creating audit log in json format: " + e.getMessage(); LOGGER.error(msg, e); throw e; } finally { try { if (json != null) { json.close(); } } catch (IOException e) { throw e; } } return stringWriter.toString(); } DBAuditMetadataLogEntity();  DBAuditMetadataLogEntity(String serviceName, String userName, String impersonator,
      String ipAddress, String operation, String eventTime, String operationText, String allowed,
      String objectType, String component, String databaseName, String tableName,
      String columnName, String resourcePath); String getDatabaseName(); void setDatabaseName(String databaseName); String getTableName(); void setTableName(String tableName); String getColumnName(); void setColumnName(String columnName); String getResourcePath(); void setResourcePath(String resourcePath); @Override String toJsonFormatLog();  }