Search in sources :

Example 1 with AddReferencesResponse

use of org.eclipse.milo.opcua.stack.core.types.structured.AddReferencesResponse in project milo by eclipse.

the class DefaultNodeManagementServiceSet method onAddReferences.

@Override
public void onAddReferences(ServiceRequest service) {
    OpcUaServer server = service.attr(ServiceAttributes.SERVER_KEY).get();
    Session session = service.attr(ServiceAttributes.SESSION_KEY).get();
    AddReferencesRequest request = (AddReferencesRequest) service.getRequest();
    List<AddReferencesItem> referencesToAdd = l(request.getReferencesToAdd());
    if (referencesToAdd.isEmpty()) {
        service.setServiceFault(StatusCodes.Bad_NothingToDo);
        return;
    }
    if (referencesToAdd.size() > server.getConfig().getLimits().getMaxNodesPerNodeManagement().longValue()) {
        service.setServiceFault(StatusCodes.Bad_TooManyOperations);
        return;
    }
    AddReferencesContext context = new AddReferencesContext(server, session, new DiagnosticsContext<>());
    server.getAddressSpaceManager().addReferences(context, referencesToAdd);
    context.getFuture().thenAccept(results -> {
        ResponseHeader header = service.createResponseHeader();
        AddReferencesResponse response = new AddReferencesResponse(header, a(results, StatusCode.class), new DiagnosticInfo[0]);
        service.setResponse(response);
    });
}
Also used : OpcUaServer(org.eclipse.milo.opcua.sdk.server.OpcUaServer) AddReferencesItem(org.eclipse.milo.opcua.stack.core.types.structured.AddReferencesItem) AddReferencesContext(org.eclipse.milo.opcua.sdk.server.api.services.NodeManagementServices.AddReferencesContext) ResponseHeader(org.eclipse.milo.opcua.stack.core.types.structured.ResponseHeader) AddReferencesResponse(org.eclipse.milo.opcua.stack.core.types.structured.AddReferencesResponse) AddReferencesRequest(org.eclipse.milo.opcua.stack.core.types.structured.AddReferencesRequest) StatusCode(org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode) Session(org.eclipse.milo.opcua.sdk.server.Session)

Aggregations

OpcUaServer (org.eclipse.milo.opcua.sdk.server.OpcUaServer)1 Session (org.eclipse.milo.opcua.sdk.server.Session)1 AddReferencesContext (org.eclipse.milo.opcua.sdk.server.api.services.NodeManagementServices.AddReferencesContext)1 StatusCode (org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode)1 AddReferencesItem (org.eclipse.milo.opcua.stack.core.types.structured.AddReferencesItem)1 AddReferencesRequest (org.eclipse.milo.opcua.stack.core.types.structured.AddReferencesRequest)1 AddReferencesResponse (org.eclipse.milo.opcua.stack.core.types.structured.AddReferencesResponse)1 ResponseHeader (org.eclipse.milo.opcua.stack.core.types.structured.ResponseHeader)1