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);
}
}
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));
}
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);
}
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());
}
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);
}
Aggregations