use of org.eclipse.milo.opcua.stack.core.types.structured.AddNodesItem in project milo by eclipse.
the class DefaultNodeManagementServiceSet method onAddNodes.
@Override
public void onAddNodes(ServiceRequest service) {
OpcUaServer server = service.attr(ServiceAttributes.SERVER_KEY).get();
Session session = service.attr(ServiceAttributes.SESSION_KEY).get();
AddNodesRequest request = (AddNodesRequest) service.getRequest();
List<AddNodesItem> nodesToAdd = l(request.getNodesToAdd());
if (nodesToAdd.isEmpty()) {
service.setServiceFault(StatusCodes.Bad_NothingToDo);
return;
}
if (nodesToAdd.size() > server.getConfig().getLimits().getMaxNodesPerNodeManagement().longValue()) {
service.setServiceFault(StatusCodes.Bad_TooManyOperations);
return;
}
AddNodesContext context = new AddNodesContext(server, session, new DiagnosticsContext<>());
server.getAddressSpaceManager().addNodes(context, nodesToAdd);
context.getFuture().thenAccept(results -> {
ResponseHeader header = service.createResponseHeader();
AddNodesResponse response = new AddNodesResponse(header, a(results, AddNodesResult.class), new DiagnosticInfo[0]);
service.setResponse(response);
});
}
Aggregations