- private static TreeSet<NetconfOperationFilter> getAllNetconfFilters(Set<NetconfOperationFilter> defaultFilters,
- NetconfOperationServiceSnapshot netconfOperationServiceSnapshot) {
- TreeSet<NetconfOperationFilter> result = new TreeSet<>(defaultFilters);
- for (NetconfOperationService netconfOperationService : netconfOperationServiceSnapshot.getServices()) {
- final Set<NetconfOperationFilter> filtersFromService = netconfOperationService.getFilters();
- for (NetconfOperationFilter filter : filtersFromService) {
- Preconditions.checkState(result.contains(filter) == false, "Filter %s already present", filter);
- result.add(filter);
+ @Override
+ public synchronized Document onNetconfMessage(Document message,
+ NetconfServerSession session) throws NetconfDocumentedException {
+ Preconditions.checkNotNull(allNetconfOperations, "Operation router was not initialized properly");
+
+ NetconfOperationExecution netconfOperationExecution;
+
+ String messageAsString = "";
+ try {
+ messageAsString = XmlUtil.toString(message);
+ netconfOperationExecution = getNetconfOperationWithHighestPriority(message, session);
+ } catch (IllegalArgumentException | IllegalStateException e) {
+ logger.warn("Unable to handle rpc {} on session {}", messageAsString, session, e);
+
+ String errorMessage = String.format("Unable to handle rpc %s on session %s", messageAsString, session);
+ Map<String, String> errorInfo = Maps.newHashMap();
+
+ NetconfDocumentedException.ErrorTag tag;
+ if (e instanceof IllegalArgumentException) {
+ errorInfo.put(NetconfDocumentedException.ErrorTag.operation_not_supported.toString(), e.getMessage());
+ tag = NetconfDocumentedException.ErrorTag.operation_not_supported;
+ } else {
+ errorInfo.put(NetconfDocumentedException.ErrorTag.operation_failed.toString(), e.getMessage());
+ tag = NetconfDocumentedException.ErrorTag.operation_failed;