Search in sources :

Example 1 with DeleteReferencesRequest

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

the class DefaultNodeManagementServiceSet method onDeleteReferences.

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