Search in sources :

Example 6 with WonMessageDirection

use of won.protocol.message.WonMessageDirection in project webofneeds by researchstudio-sat.

the class LockMessageParentWonMessageProcessor method process.

@Override
public void process(Exchange exchange) throws Exception {
    WonMessage message = getMessageRequired(exchange);
    WonMessageDirection direction = getDirectionRequired(exchange);
    logger.debug("trying to lock parent of {} message {} {}", new Object[] { message.getMessageType(), message.getMessageURI(), direction });
    try {
        lockParent(message, getDirectionRequired(exchange));
    } catch (Exception e) {
        URI messageUri;
        try {
            messageUri = message.getMessageURI();
        } catch (Exception e1) {
            logger.error("Error getting messageURI from WonMessage", e);
            messageUri = null;
        }
        logger.error("Error locking parent of WonMessage with uri {}", messageUri, e);
    }
}
Also used : WonMessage(won.protocol.message.WonMessage) WonMessageDirection(won.protocol.message.WonMessageDirection) URI(java.net.URI)

Example 7 with WonMessageDirection

use of won.protocol.message.WonMessageDirection in project webofneeds by researchstudio-sat.

the class ParentFinder method process.

@Override
public void process(Exchange exchange) throws Exception {
    if (WonCamelHelper.getParentURI(exchange).isPresent()) {
        // we're done - we found the parent before
        return;
    }
    WonMessageDirection direction = WonCamelHelper.getDirectionRequired(exchange);
    WonMessage msg = WonCamelHelper.getMessageRequired(exchange);
    Optional<URI> parentURI = Optional.empty();
    parentURI = messageService.getParentofMessage(msg, direction);
    parentURI.ifPresent(uri -> WonCamelHelper.putParentURI(exchange, uri));
}
Also used : WonMessage(won.protocol.message.WonMessage) WonMessageDirection(won.protocol.message.WonMessageDirection) URI(java.net.URI)

Example 8 with WonMessageDirection

use of won.protocol.message.WonMessageDirection in project webofneeds by researchstudio-sat.

the class SocketTypeSlipComputer method evaluate.

@Override
public <T> T evaluate(final Exchange exchange, final Class<T> type) {
    WonMessage message = WonCamelHelper.getMessageRequired(exchange);
    assert message != null : "wonMessage header must not be null";
    // exchange.getIn().setHeader();
    WonMessageType messageType = WonCamelHelper.getMessageTypeRequired(exchange);
    assert messageType != null : "messageType header must not be null";
    WonMessageDirection direction = WonCamelHelper.getDirectionRequired(exchange);
    if (direction.isFromSystem()) {
        direction = WonMessageDirection.FROM_OWNER;
    }
    assert direction != null : "direction header must not be null";
    URI socketType = WonCamelHelper.getSocketTypeURIRequired(exchange);
    String slip = "bean:" + computeSocketSlip(messageType.getURI(), socketType, direction.getURI()) + "?method=process";
    return type.cast(slip);
}
Also used : WonMessage(won.protocol.message.WonMessage) WonMessageType(won.protocol.message.WonMessageType) WonMessageDirection(won.protocol.message.WonMessageDirection) URI(java.net.URI)

Example 9 with WonMessageDirection

use of won.protocol.message.WonMessageDirection in project webofneeds by researchstudio-sat.

the class UriAlreadyUsedCheckingWonMessageProcessor method process.

@Override
public void process(Exchange exchange) throws Exception {
    StopWatch sw = new StopWatch();
    sw.start();
    WonMessage message = WonCamelHelper.getMessageRequired(exchange);
    WonMessageDirection direction = WonCamelHelper.getDirectionRequired(exchange);
    Optional<URI> parentUri = WonCamelHelper.getParentURI(exchange);
    if (!parentUri.isPresent()) {
        parentUri = messageService.getParentofMessage(message, direction);
    }
    if (parentUri.isPresent()) {
        checkEventURI(message, parentUri.get());
    }
    checkAtomURI(message);
    sw.stop();
    logger.debug(LogMarkers.TIMING, "URI in use check for message {} took {} milllis", message.getMessageURIRequired(), sw.getLastTaskTimeMillis());
}
Also used : WonMessage(won.protocol.message.WonMessage) WonMessageDirection(won.protocol.message.WonMessageDirection) URI(java.net.URI) StopWatch(org.springframework.util.StopWatch)

Example 10 with WonMessageDirection

use of won.protocol.message.WonMessageDirection in project webofneeds by researchstudio-sat.

the class WonCamelHelper method getDirection.

// // direction
public static Optional<WonMessageDirection> getDirection(Exchange exchange) {
    Objects.requireNonNull(exchange);
    URI uri = (URI) exchange.getIn().getHeader(WonCamelConstants.DIRECTION_HEADER);
    if (uri == null) {
        return Optional.empty();
    }
    WonMessageDirection direction = WonMessageDirection.getWonMessageDirection(uri);
    return Optional.ofNullable(direction);
}
Also used : URI(java.net.URI) WonMessageDirection(won.protocol.message.WonMessageDirection)

Aggregations

WonMessageDirection (won.protocol.message.WonMessageDirection)11 URI (java.net.URI)10 WonMessage (won.protocol.message.WonMessage)8 Connection (won.protocol.model.Connection)3 StopWatch (org.springframework.util.StopWatch)2 Socket (won.protocol.model.Socket)2 StringWriter (java.io.StringWriter)1 Optional (java.util.Optional)1 Graph (org.apache.jena.graph.Graph)1 WonAclEvaluator (won.auth.WonAclEvaluator)1 AclEvalResult (won.auth.model.AclEvalResult)1 OperationRequest (won.auth.model.OperationRequest)1 ForbiddenMessageException (won.protocol.exception.ForbiddenMessageException)1 IllegalMessageSignerException (won.protocol.exception.IllegalMessageSignerException)1 NoSuchSocketException (won.protocol.exception.NoSuchSocketException)1 WonMessageNotWellFormedException (won.protocol.exception.WonMessageNotWellFormedException)1 WonMessageProcessingException (won.protocol.exception.WonMessageProcessingException)1 WonProtocolException (won.protocol.exception.WonProtocolException)1 EnvelopePropertyCheckResult (won.protocol.message.WonMessage.EnvelopePropertyCheckResult)1 WonMessageType (won.protocol.message.WonMessageType)1