2 * Copyright (c) 2014 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
8 package org.opendaylight.controller.sal.connect.netconf;
11 import java.text.ParseException;
12 import java.text.SimpleDateFormat;
13 import java.util.Date;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
20 public class InventoryUtils {
21 private static final Logger LOG = LoggerFactory.getLogger(InventoryUtils.class);
22 private static final URI INVENTORY_NAMESPACE = URI.create("urn:opendaylight:inventory");
23 private static final URI NETCONF_INVENTORY_NAMESPACE = URI.create("urn:opendaylight:netconf-node-inventory");
24 private static final Date INVENTORY_REVISION = dateFromString("2013-08-19");
25 private static final Date NETCONF_INVENTORY_REVISION = dateFromString("2014-01-08");
26 public static final QName INVENTORY_NODES = new QName(INVENTORY_NAMESPACE, INVENTORY_REVISION, "nodes");
27 public static final QName INVENTORY_NODE = new QName(INVENTORY_NAMESPACE, INVENTORY_REVISION, "node");
28 public static final QName INVENTORY_ID = new QName(INVENTORY_NAMESPACE, INVENTORY_REVISION, "id");
29 public static final QName INVENTORY_CONNECTED = new QName(NETCONF_INVENTORY_NAMESPACE, NETCONF_INVENTORY_REVISION,
31 public static final QName NETCONF_INVENTORY_INITIAL_CAPABILITY = new QName(NETCONF_INVENTORY_NAMESPACE,
32 NETCONF_INVENTORY_REVISION, "initial-capability");
34 public static final InstanceIdentifier INVENTORY_PATH = InstanceIdentifier.builder().node(INVENTORY_NODES)
36 public static final QName NETCONF_INVENTORY_MOUNT = null;
38 private InventoryUtils() {
39 throw new UnsupportedOperationException("Utility class cannot be instantiated");
43 * Converts date in string format yyyy-MM-dd to java.util.Date.
45 * @return java.util.Date conformant to string formatted date yyyy-MM-dd.
47 private static Date dateFromString(final String date) {
48 // We do not reuse the formatter because it's not thread-safe
49 SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
51 return formatter.parse(date);
52 } catch (ParseException e) {
53 LOG.error("Failed to parse date {}", date, e);