private String getCommonAncestorPath(String rootPath1, String rootPath2) {

        if (rootPath1 == null) {
            return rootPath2;
        }
        if (rootPath2 == null) {
            return rootPath1;
        }
        rootPath1 = CmsStringUtil.joinPaths("/", rootPath1, "/");
        rootPath2 = CmsStringUtil.joinPaths("/", rootPath2, "/");
        int minLength = Math.min(rootPath1.length(), rootPath2.length());
        int i;
        for (i = 0; i < minLength; i++) {
            char char1 = rootPath1.charAt(i);
            char char2 = rootPath2.charAt(i);
            if (char1 != char2) {
                break;
            }
        }
        String result = rootPath1.substring(0, i);
        if ("/".equals(result)) {
            return result;
        }
        int slashIndex = result.lastIndexOf('/');
        result = result.substring(0, slashIndex);
        return result;
    }
private String getCommonAncestorPath ( String rootPath1 , String rootPath2 ) { if ( rootPath1 == null ) { return rootPath2 ; } if ( rootPath2 == null ) { return rootPath1 ; } rootPath1 = CmsStringUtil . joinPaths ( "/" , rootPath1 , "/" ) ; rootPath2 = CmsStringUtil . joinPaths ( "/" , rootPath2 , "/" ) ; int minLength = Math . min ( rootPath1 . length ( ) , rootPath2 . length ( ) ) ; int i ; for ( i = 0 ; i < minLength ; i ++ ) { char char1 = rootPath1 . charAt ( i ) ; char char2 = rootPath2 . charAt ( i ) ; if ( char1 != char2 ) { break ; } } String result = rootPath1 . substring ( 0 , i ) ; if ( "/" . equals ( result ) ) { return result ; } int slashIndex = result . lastIndexOf ( '/' ) ; result = result . substring ( 0 , slashIndex ) ; return result ; }
Gets the common ancestor of two paths.<p>

@param rootPath1 the first path
@param rootPath2 the second path

@return the common ancestor path