mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-09-10 14:11:58 +00:00
[ACS-9736] Refactoring
This commit is contained in:
@@ -826,7 +826,7 @@ public class AuditComponentImpl implements AuditComponent
|
||||
AuditApplication application,
|
||||
Map<String, Serializable> values)
|
||||
{
|
||||
Map<String, Serializable> newData = new HashMap<String, Serializable>(values.size());
|
||||
Map<String, Serializable> newData = new HashMap<>(values.size());
|
||||
|
||||
List<DataExtractorDefinition> extractors = application.getDataExtractors();
|
||||
for (DataExtractorDefinition extractorDef : extractors)
|
||||
@@ -944,7 +944,7 @@ public class AuditComponentImpl implements AuditComponent
|
||||
{
|
||||
int rootSize = applicationName.length() + 2; // Root is constructed like this -> '/' + auditedApplicationName + '/'.
|
||||
AuditRecord.Builder builder = AuditRecordUtils.generateAuditRecordBuilder(auditData, rootSize);
|
||||
builder.setAuditApplicationId(applicationName);
|
||||
builder.setAuditRecordType(applicationName);
|
||||
builder.setInTransaction(inTransaction);
|
||||
return builder.build();
|
||||
}
|
||||
|
@@ -38,9 +38,9 @@ public class AuditRecord
|
||||
|
||||
public AuditRecord(Builder builder)
|
||||
{
|
||||
this.auditApplicationId = builder.auditApplicationId;
|
||||
this.auditApplicationId = builder.auditRecordType;
|
||||
this.inTransaction = builder.inTransaction;
|
||||
this.auditData = builder.auditData;
|
||||
this.auditData = builder.auditRecordData;
|
||||
this.createdAt = ZonedDateTime.now();
|
||||
}
|
||||
|
||||
@@ -71,13 +71,13 @@ public class AuditRecord
|
||||
|
||||
public static class Builder
|
||||
{
|
||||
private String auditApplicationId;
|
||||
private String auditRecordType;
|
||||
private boolean inTransaction;
|
||||
private Map<String, Serializable> auditData;
|
||||
private Map<String, Serializable> auditRecordData;
|
||||
|
||||
public Builder setAuditApplicationId(String auditApplicationId)
|
||||
public Builder setAuditRecordType(String auditRecordType)
|
||||
{
|
||||
this.auditApplicationId = auditApplicationId;
|
||||
this.auditRecordType = auditRecordType;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -87,9 +87,9 @@ public class AuditRecord
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setAuditData(Map<String, Serializable> auditData)
|
||||
public Builder setAuditRecordData(Map<String, Serializable> auditRecordData)
|
||||
{
|
||||
this.auditData = auditData;
|
||||
this.auditRecordData = auditRecordData;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@@ -32,7 +32,7 @@ import java.util.Map;
|
||||
public class AuditRecordUtils
|
||||
{
|
||||
/**
|
||||
* Generates an {@link AuditRecord.Builder} from flat audit data. Translates `key-value` pairs into a nested JSON structure, preloading the builder with {@link AuditRecord#auditApplicationId} and {@link AuditRecord#auditData}. Keys are split by `/` to build the nested structure, with the root key used as the application ID. Each key starts with the same root constructed like this '/' + auditedApplicationName + '/'. Before split, this root is removed from the key.
|
||||
* Generates an {@link AuditRecord.Builder} from flat audit data. Translates `key-value` pairs into a nested JSON structure, preloading the builder with arguments. Keys are split by `/` to build the nested structure, with the root key used as the application ID. Each key starts with the same root constructed like this '/' + auditedApplicationName + '/'. Before split, this root is removed from the key.
|
||||
*
|
||||
* @param data
|
||||
* a map containing flat audit data as `key-value` pairs
|
||||
@@ -56,7 +56,7 @@ public class AuditRecordUtils
|
||||
}
|
||||
current.put(keys[keys.length - 1], v);
|
||||
});
|
||||
auditRecordBuilder.setAuditData(rootNode);
|
||||
auditRecordBuilder.setAuditRecordData(rootNode);
|
||||
|
||||
return auditRecordBuilder;
|
||||
}
|
||||
|
@@ -54,7 +54,7 @@ public class AuditRecordUtilsTest
|
||||
testData.put("/alfresco-access/transaction/properties/to", (Serializable) Map.of(QName.createQName("modified"), Date.from(now)));
|
||||
|
||||
var builder = AuditRecordUtils.generateAuditRecordBuilder(testData, "/alfresco-access/".length());
|
||||
builder.setAuditApplicationId("alfresco-access");
|
||||
builder.setAuditRecordType("alfresco-access");
|
||||
var auditRecord = builder.build();
|
||||
|
||||
assertNotNull(auditRecord);
|
||||
|
Reference in New Issue
Block a user