Merge "Bug 1386: Avoid commit deadlock"
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / cluster / datastore / node / utils / PathUtils.java
1 /*
2  *
3  *  Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
4  *
5  *  This program and the accompanying materials are made available under the
6  *  terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  *  and is available at http://www.eclipse.org/legal/epl-v10.html
8  *
9  */
10
11 package org.opendaylight.controller.cluster.datastore.node.utils;
12
13 public class PathUtils {
14     public static String getParentPath(String currentElementPath){
15         String parentPath = "";
16
17         if(currentElementPath != null){
18             String[] parentPaths = currentElementPath.split("/");
19             if(parentPaths.length > 2){
20                 for(int i=0;i<parentPaths.length-1;i++){
21                     if(parentPaths[i].length() > 0){
22                         parentPath += "/" + parentPaths[i];
23                     }
24                 }
25             }
26         }
27         return parentPath;
28     }
29 }