package de.tblsoft.solr.http;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.regex.Pattern;

/**
 * Created by tblsoft on 18.03.16.
 */
public class ElasticHelper {


    public static String getIndexUrl(String url) throws URISyntaxException {
        URI uri = new URI(url);
        String[] parts = uri.getPath().split(Pattern.quote("/"));
        if(parts.length < 2) {
            throw new URISyntaxException(url, "The url " + url + " must contain at least one path part.");
        }
        String path = parts[1];
        uri = uri.resolve("/" + path);
        return uri.toString();
    }
    
    public static String getMappingUrl(String url) throws URISyntaxException {
    	if(!url.endsWith("/")) {
    		url = url + "/";
    	}
    	return url + "_mapping";
    }



}

@@ -261,24 +261,124 @@
 Exception %7B%0A
+        if(url==null) %7B%0A            throw new URISyntaxException(%22%22, %22The url is null.%22);%0A        %7D%0A
         URI 

handle null url in Elastic Helper