Search in sources :

Example 16 with Audit

use of org.alfresco.repo.audit.model._3.Audit in project atlasmap by atlasmap.

the class AtlasServiceTest method printAudit.

protected String printAudit(Audits audits) {
    StringBuilder buf = new StringBuilder("Audits: ");
    for (Audit a : audits.getAudit()) {
        buf.append('[');
        buf.append(a.getStatus());
        buf.append(", message=");
        buf.append(a.getMessage());
        buf.append("], ");
    }
    return buf.toString();
}
Also used : Audit(io.atlasmap.v2.Audit)

Example 17 with Audit

use of org.alfresco.repo.audit.model._3.Audit in project atlasmap by atlasmap.

the class BaseDefaultAtlasContextTest method printAudit.

protected String printAudit(Audits audits) {
    StringBuilder buf = new StringBuilder("Audits: ");
    for (Audit a : audits.getAudit()) {
        buf.append('[');
        buf.append(a.getStatus());
        buf.append(", message=");
        buf.append(a.getMessage());
        buf.append("], ");
    }
    return buf.toString();
}
Also used : Audit(io.atlasmap.v2.Audit)

Example 18 with Audit

use of org.alfresco.repo.audit.model._3.Audit in project atlasmap by atlasmap.

the class AtlasUtil method createAudit.

/**
 * Creates the Audit.
 * @param status audit status
 * @param docId Document ID
 * @param docName Document name
 * @param path field path
 * @param value value
 * @param message message
 * @return audit
 */
public static Audit createAudit(AuditStatus status, String docId, String docName, String path, String value, String message) {
    Audit audit = new Audit();
    audit.setDocId(docId);
    audit.setDocName(docName);
    audit.setMessage(message);
    audit.setPath(path);
    audit.setStatus(status);
    audit.setValue(value);
    return audit;
}
Also used : Audit(io.atlasmap.v2.Audit)

Example 19 with Audit

use of org.alfresco.repo.audit.model._3.Audit in project atlasmap by atlasmap.

the class AtlasUtil method addAudits.

/**
 * Adds the list of Audit into the session.
 * @param session session
 * @param field field
 * @param audits a list of audit
 */
public static void addAudits(AtlasInternalSession session, Field field, List<Audit> audits) {
    String docId = field.getDocId();
    String docName = getDocumentNameById(session, docId);
    for (Audit audit : audits) {
        audit.setDocId(docId);
        audit.setDocName(docName);
        session.getAudits().getAudit().add(audit);
    }
}
Also used : Audit(io.atlasmap.v2.Audit)

Example 20 with Audit

use of org.alfresco.repo.audit.model._3.Audit in project alfresco-repository by Alfresco.

the class AuditApplication method buildAuditPaths.

/**
 * Recursive method to build generator and extractor mappings
 */
private void buildAuditPaths(AuditPath auditPath, String currentPath, Set<String> existingPaths, Map<String, DataGenerator> upperGeneratorsByPath) {
    // Clone the upper maps to prevent pollution
    upperGeneratorsByPath = new HashMap<String, DataGenerator>(upperGeneratorsByPath);
    // Append the current audit path to the current path
    if (currentPath == null) {
        currentPath = AuditApplication.buildPath(auditPath.getKey());
    } else {
        currentPath = AuditApplication.buildPath(currentPath, auditPath.getKey());
    }
    // Make sure we have not processed it before
    if (!existingPaths.add(currentPath)) {
        generateException(currentPath, "The audit path already exists.");
    }
    // Get the data extractors declared for this key
    for (RecordValue element : auditPath.getRecordValue()) {
        String key = element.getKey();
        String extractorPath = AuditApplication.buildPath(currentPath, key);
        if (!existingPaths.add(extractorPath)) {
            generateException(extractorPath, "The audit path already exists.");
        }
        String extractorName = element.getDataExtractor();
        DataExtractor extractor = dataExtractorsByName.get(extractorName);
        if (extractor == null) {
            generateException(extractorPath, "No data extractor exists for name: " + extractorName);
        }
        // The extractor may pull data from somewhere else
        String sourcePath = element.getDataSource();
        if (sourcePath == null) {
            sourcePath = currentPath;
        }
        // The extractor may be triggered by data from elsewhere
        String dataTrigger = element.getDataTrigger();
        if (dataTrigger == null) {
            dataTrigger = currentPath;
        }
        // Store the extractor definition
        DataExtractorDefinition extractorDef = new DataExtractorDefinition(dataTrigger, sourcePath, extractorPath, extractor);
        dataExtractors.add(extractorDef);
    }
    // Get the data generators declared for this key
    for (GenerateValue element : auditPath.getGenerateValue()) {
        String key = element.getKey();
        String generatorPath = AuditApplication.buildPath(currentPath, key);
        if (!existingPaths.add(generatorPath)) {
            generateException(generatorPath, "The audit path already exists.");
        }
        String generatorName = element.getDataGenerator();
        DataGenerator generator = dataGeneratorsByName.get(generatorName);
        if (generator == null) {
            generateException(generatorPath, "No data generator exists for name: " + generatorName);
        }
        // All generators that occur earlier in the path will also be applicable here
        upperGeneratorsByPath.put(generatorPath, generator);
    }
    // All the generators apply to the current path
    dataGenerators.put(currentPath, upperGeneratorsByPath);
    // Find all sub audit paths and recurse
    for (AuditPath element : auditPath.getAuditPath()) {
        buildAuditPaths(element, currentPath, existingPaths, upperGeneratorsByPath);
    }
}
Also used : GenerateValue(org.alfresco.repo.audit.model._3.GenerateValue) DataGenerator(org.alfresco.repo.audit.generator.DataGenerator) RecordValue(org.alfresco.repo.audit.model._3.RecordValue) DataExtractor(org.alfresco.repo.audit.extractor.DataExtractor) AuditPath(org.alfresco.repo.audit.model._3.AuditPath)

Aggregations

Audit (io.atlasmap.v2.Audit)19 Test (org.junit.jupiter.api.Test)7 AtlasSession (io.atlasmap.api.AtlasSession)4 AtlasContext (io.atlasmap.api.AtlasContext)3 AtlasMappingBaseTest (io.atlasmap.itests.reference.AtlasMappingBaseTest)3 BaseContact (io.atlasmap.java.test.BaseContact)3 File (java.io.File)3 AtlasException (io.atlasmap.api.AtlasException)1 TargetContact (io.atlasmap.java.test.TargetContact)1 AtlasJsonTestUnrootedMapper (io.atlasmap.json.test.AtlasJsonTestUnrootedMapper)1 Action (io.atlasmap.v2.Action)1 AtlasMapping (io.atlasmap.v2.AtlasMapping)1 Audits (io.atlasmap.v2.Audits)1 BaseMapping (io.atlasmap.v2.BaseMapping)1 Field (io.atlasmap.v2.Field)1 Mapping (io.atlasmap.v2.Mapping)1 ProcessMappingRequest (io.atlasmap.v2.ProcessMappingRequest)1 ProcessMappingResponse (io.atlasmap.v2.ProcessMappingResponse)1 BufferedInputStream (java.io.BufferedInputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1