2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.netconf.persist.impl;
11 import org.opendaylight.controller.netconf.client.NetconfClient;
12 import org.opendaylight.controller.netconf.client.NetconfClientDispatcher;
13 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
18 public final class Util {
19 private static final Logger logger = LoggerFactory.getLogger(Util.class);
22 public static boolean isSubset(NetconfClient netconfClient, Set<String> expectedCaps) {
23 return isSubset(netconfClient.getCapabilities(), expectedCaps);
27 private static boolean isSubset(Set<String> currentCapabilities, Set<String> expectedCaps) {
28 for (String exCap : expectedCaps) {
29 if (currentCapabilities.contains(exCap) == false)
35 public static void closeClientAndDispatcher(NetconfClient client) {
36 NetconfClientDispatcher dispatcher = client.getNetconfClientDispatcher();
37 Exception fromClient = null;
40 } catch (Exception e) {
45 } catch (Exception e) {
46 if (fromClient != null) {
47 e.addSuppressed(fromClient);
49 throw new RuntimeException("Error closing temporary client ", e);