use of org.eclipse.milo.opcua.stack.core.types.structured.BrowseResponse in project milo by eclipse.
the class DefaultViewServiceSet method onBrowse.
@Override
public void onBrowse(ServiceRequest service) {
browseCounter.record(service);
BrowseRequest request = (BrowseRequest) service.getRequest();
DiagnosticsContext<BrowseDescription> diagnosticsContext = new DiagnosticsContext<>();
OpcUaServer server = service.attr(ServiceAttributes.SERVER_KEY).get();
Session session = service.attr(ServiceAttributes.SESSION_KEY).get();
List<BrowseDescription> nodesToBrowse = l(request.getNodesToBrowse());
if (nodesToBrowse.isEmpty()) {
service.setServiceFault(StatusCodes.Bad_NothingToDo);
return;
}
if (nodesToBrowse.size() > server.getConfig().getLimits().getMaxNodesPerBrowse().intValue()) {
service.setServiceFault(StatusCodes.Bad_TooManyOperations);
return;
}
Stream<CompletableFuture<BrowseResult>> futures = nodesToBrowse.stream().map(browseDescription -> browseHelper.browse(() -> Optional.of(session), server, request.getView(), request.getRequestedMaxReferencesPerNode(), browseDescription));
FutureUtils.sequence(futures).thenAccept(results -> {
ResponseHeader header = service.createResponseHeader();
DiagnosticInfo[] diagnosticInfos = diagnosticsContext.getDiagnosticInfos(nodesToBrowse);
BrowseResponse response = new BrowseResponse(header, a(results, BrowseResult.class), diagnosticInfos);
service.setResponse(response);
});
}
Aggregations