Search in sources :

Example 1 with DeleteNodesResponse

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

the class DefaultNodeManagementServiceSet method onDeleteNodes.

@Override
public void onDeleteNodes(ServiceRequest service) {
    OpcUaServer server = service.attr(ServiceAttributes.SERVER_KEY).get();
    Session session = service.attr(ServiceAttributes.SESSION_KEY).get();
    DeleteNodesRequest request = (DeleteNodesRequest) service.getRequest();
    List<DeleteNodesItem> nodesToDelete = l(request.getNodesToDelete());
    if (nodesToDelete.isEmpty()) {
        service.setServiceFault(StatusCodes.Bad_NothingToDo);
        return;
    }
    if (nodesToDelete.size() > server.getConfig().getLimits().getMaxNodesPerNodeManagement().longValue()) {
        service.setServiceFault(StatusCodes.Bad_TooManyOperations);
        return;
    }
    DeleteNodesContext context = new DeleteNodesContext(server, session, new DiagnosticsContext<>());
    server.getAddressSpaceManager().deleteNodes(context, nodesToDelete);
    context.getFuture().thenAccept(results -> {
        ResponseHeader header = service.createResponseHeader();
        DeleteNodesResponse response = new DeleteNodesResponse(header, a(results, StatusCode.class), new DiagnosticInfo[0]);
        service.setResponse(response);
    });
}
Also used : DeleteNodesRequest(org.eclipse.milo.opcua.stack.core.types.structured.DeleteNodesRequest) OpcUaServer(org.eclipse.milo.opcua.sdk.server.OpcUaServer) ResponseHeader(org.eclipse.milo.opcua.stack.core.types.structured.ResponseHeader) DeleteNodesResponse(org.eclipse.milo.opcua.stack.core.types.structured.DeleteNodesResponse) DeleteNodesItem(org.eclipse.milo.opcua.stack.core.types.structured.DeleteNodesItem) DeleteNodesContext(org.eclipse.milo.opcua.sdk.server.api.services.NodeManagementServices.DeleteNodesContext) 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 DeleteNodesContext (org.eclipse.milo.opcua.sdk.server.api.services.NodeManagementServices.DeleteNodesContext)1 StatusCode (org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode)1 DeleteNodesItem (org.eclipse.milo.opcua.stack.core.types.structured.DeleteNodesItem)1 DeleteNodesRequest (org.eclipse.milo.opcua.stack.core.types.structured.DeleteNodesRequest)1 DeleteNodesResponse (org.eclipse.milo.opcua.stack.core.types.structured.DeleteNodesResponse)1 ResponseHeader (org.eclipse.milo.opcua.stack.core.types.structured.ResponseHeader)1