mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-20 22:18:43 +00:00
Merged dev into integration/sprint-35
This commit is contained in:
@ -91,20 +91,6 @@ public class DMLAuditAction extends AbstractQActionFunction<DMLAuditInput, DMLAu
|
||||
long start = System.currentTimeMillis();
|
||||
DMLType dmlType = getDMLType(tableActionInput);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// currently, the table's primary key must be integer... so, log (once) and return early if not that //
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
QFieldMetaData field = table.getField(table.getPrimaryKeyField());
|
||||
if(!QFieldType.INTEGER.equals(field.getType()))
|
||||
{
|
||||
if(!loggedUnauditableTableNames.contains(table.getName()))
|
||||
{
|
||||
LOG.info("Cannot audit table without integer as its primary key", logPair("tableName", table.getName()));
|
||||
loggedUnauditableTableNames.add(table.getName());
|
||||
}
|
||||
return (output);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
List<QRecord> recordList = CollectionUtils.nonNullList(input.getRecordList()).stream()
|
||||
@ -119,6 +105,21 @@ public class DMLAuditAction extends AbstractQActionFunction<DMLAuditInput, DMLAu
|
||||
return (output);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// currently, the table's primary key must be integer... so, log (once) and return early if not that //
|
||||
// (or, if no primary key!) //
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
QFieldMetaData field = table.getFields().get(table.getPrimaryKeyField());
|
||||
if(field == null || !QFieldType.INTEGER.equals(field.getType()))
|
||||
{
|
||||
if(!loggedUnauditableTableNames.contains(table.getName()))
|
||||
{
|
||||
LOG.info("Cannot audit table without integer as its primary key", logPair("tableName", table.getName()));
|
||||
loggedUnauditableTableNames.add(table.getName());
|
||||
}
|
||||
return (output);
|
||||
}
|
||||
|
||||
String contextSuffix = getContentSuffix(input);
|
||||
|
||||
AuditInput auditInput = new AuditInput();
|
||||
|
@ -186,7 +186,7 @@ public class QRecord implements Serializable
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// we know entry is serializable at this point, based on type param's bound //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
LOG.info("Non-primitive serializable value in QRecord - calling SerializationUtils.clone...", logPair("key", entry.getKey()), logPair("type", value.getClass()));
|
||||
LOG.debug("Non-primitive serializable value in QRecord - calling SerializationUtils.clone...", logPair("key", entry.getKey()), logPair("type", value.getClass()));
|
||||
clone.put(entry.getKey(), (V) SerializationUtils.clone(entry.getValue()));
|
||||
}
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ public class Auth0AuthenticationModule implements QAuthenticationModuleInterface
|
||||
// process a sessionUUID - looks up userSession record - cannot create token this way. //
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
String sessionUUID = context.get(SESSION_UUID_KEY);
|
||||
LOG.info("Creating session from sessionUUID (userSession)", logPair("sessionUUID", maskForLog(sessionUUID)));
|
||||
LOG.debug("Creating session from sessionUUID (userSession)", logPair("sessionUUID", maskForLog(sessionUUID)));
|
||||
if(sessionUUID != null)
|
||||
{
|
||||
accessToken = getAccessTokenFromSessionUUID(metaData, sessionUUID);
|
||||
|
@ -276,6 +276,7 @@ public abstract class AbstractTableSyncTransformStep extends AbstractTransformSt
|
||||
|
||||
if(sourceKeyValue == null || "".equals(sourceKeyValue))
|
||||
{
|
||||
LOG.debug("Skipping record without a value in the sourceKeyField", logPair("keyField", sourceTableKeyField));
|
||||
errorMissingKeyField.incrementCountAndAddPrimaryKey(sourcePrimaryKey);
|
||||
|
||||
try
|
||||
|
@ -176,6 +176,19 @@ public class StringUtils
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** safely appends a string to another, changing empty string if either value is null
|
||||
**
|
||||
*******************************************************************************/
|
||||
public static String safeAppend(String input, String contentToAppend)
|
||||
{
|
||||
input = input != null ? input : "";
|
||||
contentToAppend = contentToAppend != null ? contentToAppend : "";
|
||||
return input + contentToAppend;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** returns input if not null, or nullOutput if input == null (as in SQL NVL)
|
||||
**
|
||||
|
@ -400,4 +400,49 @@ class DMLAuditActionTest extends BaseTest
|
||||
QContext.popAction();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
@Test
|
||||
void testTableWithoutIntegerPrimaryKey() throws QException
|
||||
{
|
||||
QInstance qInstance = QContext.getQInstance();
|
||||
new AuditsMetaDataProvider().defineAll(qInstance, TestUtils.MEMORY_BACKEND_NAME, null);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// we used to throw if table had no primary key. first, assert that we do not throw in that case //
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
QContext.getQInstance().addTable(
|
||||
new QTableMetaData()
|
||||
.withName("nullPkey")
|
||||
.withField(new QFieldMetaData("foo", QFieldType.STRING))
|
||||
.withAuditRules(new QAuditRules().withAuditLevel(AuditLevel.FIELD)));
|
||||
|
||||
new DMLAuditAction().execute(new DMLAuditInput()
|
||||
.withTableActionInput(new InsertInput("nullPkey"))
|
||||
.withRecordList(List.of(new QRecord())));
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// next, make sure we don't throw (and don't record anything) if table's pkey isn't integer //
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
QContext.getQInstance().addTable(
|
||||
new QTableMetaData()
|
||||
.withName("stringPkey")
|
||||
.withField(new QFieldMetaData("idString", QFieldType.STRING))
|
||||
.withPrimaryKeyField("idString")
|
||||
.withAuditRules(new QAuditRules().withAuditLevel(AuditLevel.FIELD)));
|
||||
|
||||
new DMLAuditAction().execute(new DMLAuditInput()
|
||||
.withTableActionInput(new InsertInput("stringPkey"))
|
||||
.withRecordList(List.of(new QRecord())));
|
||||
|
||||
//////////////////////////////////
|
||||
// make sure no audits happened //
|
||||
//////////////////////////////////
|
||||
List<QRecord> auditList = TestUtils.queryTable("audit");
|
||||
assertTrue(auditList.isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -78,6 +78,20 @@ class StringUtilsTest extends BaseTest
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
@Test
|
||||
void test_safeAppend()
|
||||
{
|
||||
assertEquals("Foo", StringUtils.safeAppend("Foo", null));
|
||||
assertEquals("Foo", StringUtils.safeAppend(null, "Foo"));
|
||||
assertEquals("FooBar", StringUtils.safeAppend("Foo", "Bar"));
|
||||
assertEquals("", StringUtils.safeAppend(null, null));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
|
Reference in New Issue
Block a user