X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Futils%2FInstanceIdentifierUtils.java;h=20268a67449d2ff1bcddeef240b91ef4f287a774;hb=eb887b1c2c8cd2768f8b4c2ed2b5054f97798466;hp=fafeba50b57d7459ce9a6d04691c8d020a572f5b;hpb=dc25ccb46759cd69b37f590bd38ad57348a97456;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/InstanceIdentifierUtils.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/InstanceIdentifierUtils.java index fafeba50b5..20268a6744 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/InstanceIdentifierUtils.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/InstanceIdentifierUtils.java @@ -1,7 +1,10 @@ package org.opendaylight.controller.cluster.datastore.utils; import org.opendaylight.controller.cluster.datastore.node.utils.NodeIdentifierFactory; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.List; @@ -10,33 +13,60 @@ import java.util.List; * @author: syedbahm */ public class InstanceIdentifierUtils { - public static String getParentPath(String currentElementPath) { - String parentPath = ""; - - if (currentElementPath != null) { - String[] parentPaths = currentElementPath.split("/"); - if (parentPaths.length > 2) { - for (int i = 0; i < parentPaths.length - 1; i++) { - if (parentPaths[i].length() > 0) { - parentPath += "/" + parentPaths[i]; - } + + protected static final Logger logger = LoggerFactory + .getLogger(InstanceIdentifierUtils.class); + + public static String getParentPath(String currentElementPath) { + String parentPath = ""; + + if (currentElementPath != null) { + String[] parentPaths = currentElementPath.split("/"); + if (parentPaths.length > 2) { + for (int i = 0; i < parentPaths.length - 1; i++) { + if (parentPaths[i].length() > 0) { + parentPath += "/" + parentPaths[i]; + } + } + } + } + return parentPath; + } + + @Deprecated + public static YangInstanceIdentifier from(String path) { + String[] ids = path.split("/"); + + List pathArguments = + new ArrayList<>(); + for (String nodeId : ids) { + if (!"".equals(nodeId)) { + pathArguments + .add(NodeIdentifierFactory.getArgument(nodeId)); + } } - } + final YangInstanceIdentifier instanceIdentifier = + YangInstanceIdentifier.create(pathArguments); + return instanceIdentifier; } - return parentPath; - } - public static InstanceIdentifier from(String path) { - String[] ids = path.split("/"); + /** + * @deprecated Use {@link org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils} instead + * @param path + * @return + */ + @Deprecated + public static NormalizedNodeMessages.InstanceIdentifier toSerializable(YangInstanceIdentifier path){ + return org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils.toSerializable(path); + } - List pathArguments = new ArrayList<>(); - for (String nodeId : ids) { - if (!"".equals(nodeId)) { - pathArguments.add(NodeIdentifierFactory.getArgument(nodeId)); - } + /** + * @deprecated Use {@link org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils} instead + * @param path + * @return + */ + @Deprecated + public static YangInstanceIdentifier fromSerializable(NormalizedNodeMessages.InstanceIdentifier path){ + return org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils.fromSerializable(path); } - final InstanceIdentifier instanceIdentifier = - new InstanceIdentifier(pathArguments); - return instanceIdentifier; - } }