Search in sources :

Example 6 with Audit

use of io.atlasmap.v2.Audit in project atlasmap by atlasmap.

the class BaseDefaultAtlasContextTest method printAudit.

protected String printAudit(AtlasSession session) {
    StringBuilder buf = new StringBuilder("Audits: ");
    for (Audit a : session.getAudits().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 7 with Audit

use of io.atlasmap.v2.Audit in project atlasmap by atlasmap.

the class TestHelper method printAudit.

public static String printAudit(AtlasSession session) {
    StringBuilder buf = new StringBuilder("Audits: ");
    for (Audit a : session.getAudits().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 8 with Audit

use of io.atlasmap.v2.Audit in project atlasmap by atlasmap.

the class AtlasEndpoint method onExchange.

@Override
protected void onExchange(Exchange exchange) throws Exception {
    Message incomingMessage = exchange.getIn();
    String newResourceUri = incomingMessage.getHeader(AtlasConstants.ATLAS_RESOURCE_URI, String.class);
    if (newResourceUri != null) {
        incomingMessage.removeHeader(AtlasConstants.ATLAS_RESOURCE_URI);
        log.debug("{} set to {} creating new endpoint to handle exchange", AtlasConstants.ATLAS_RESOURCE_URI, newResourceUri);
        AtlasEndpoint newEndpoint = findOrCreateEndpoint(getEndpointUri(), newResourceUri);
        newEndpoint.onExchange(exchange);
        return;
    }
    AtlasSession atlasSession = getOrCreateAtlasContext(incomingMessage).createSession();
    populateSourceDocuments(exchange, atlasSession);
    getAtlasContext().process(atlasSession);
    List<Audit> errors = new ArrayList<>();
    for (Audit audit : atlasSession.getAudits().getAudit()) {
        switch(audit.getStatus()) {
            case ERROR:
                errors.add(audit);
                break;
            case WARN:
                LOG.warn("{}: docId='{}', path='{}'", audit.getMessage(), audit.getDocId(), audit.getPath());
                break;
            default:
                LOG.info("{}: docId='{}', path='{}'", audit.getMessage(), audit.getDocId(), audit.getPath());
        }
    }
    if (!errors.isEmpty()) {
        StringBuilder buf = new StringBuilder("Errors: ");
        errors.stream().forEach(a -> buf.append(String.format("[%s: docId='%s', path='%s'], ", a.getMessage(), a.getDocId(), a.getPath())));
        throw new AtlasException(buf.toString());
    }
    populateTargetDocuments(atlasSession, exchange);
}
Also used : Audit(io.atlasmap.v2.Audit) Message(org.apache.camel.Message) ArrayList(java.util.ArrayList) AtlasException(io.atlasmap.api.AtlasException) AtlasSession(io.atlasmap.api.AtlasSession)

Example 9 with Audit

use of io.atlasmap.v2.Audit in project atlasmap by atlasmap.

the class AtlasUtil method addAudit.

public static void addAudit(AtlasSession session, String docId, String message, String path, AuditStatus status, String value) {
    Audit audit = new Audit();
    audit.setDocId(docId);
    audit.setMessage(message);
    audit.setPath(path);
    audit.setStatus(status);
    audit.setValue(value);
    session.getAudits().getAudit().add(audit);
}
Also used : Audit(io.atlasmap.v2.Audit)

Aggregations

Audit (io.atlasmap.v2.Audit)9 Test (org.junit.Test)3 AtlasException (io.atlasmap.api.AtlasException)1 AtlasSession (io.atlasmap.api.AtlasSession)1 Audits (io.atlasmap.v2.Audits)1 ArrayList (java.util.ArrayList)1 Message (org.apache.camel.Message)1