class ESUtils {

    public static void ensureIndexAndTypeForAnnotation(Annotation annotation, Boolean createIndexIfNotFound)
            throws Exception {
        String esUrl = getEsUrl();
        if(Strings.isNullOrEmpty(esUrl)){
            throw new Exception("ES host cannot be null");
        }
        String indexName = buildIndexNameFromAnnotation(annotation);

        if (!Strings.isNullOrEmpty(indexName)) {
            indexName = indexName.toLowerCase();
        } else
            throw new Exception("Index/datasource/pac_ds name cannot be null or blank");

        if (!isValidIndex(esUrl, indexName)) {
            // createIndex(esUrl, indexName);
            // DO NOT CREATE INDEX, this responsibility is delegated to pacman
            // cloud discovery, if you will create the index, parent , child
            // relation will be lost
            throw new Exception("Index is not yet ready to publish the data");
        }

        String parentType, type;
        if (!Strings.isNullOrEmpty(annotation.get(PacmanSdkConstants.TARGET_TYPE))
                && !Strings.isNullOrEmpty(annotation.get(PacmanSdkConstants.TYPE))) {
            parentType = annotation.get(PacmanSdkConstants.TARGET_TYPE);
            type = getIssueTypeFromAnnotation(annotation);
        } else
            throw new Exception("targetType name cannot be null or blank");

        if (!isValidType(esUrl, indexName, type)) {
            // createMappingWithParent(esUrl, indexName, type,parentType);do not
            // create now, this responsibility is delegated to Inventory
            // collector
            throw new Exception("Index exists but unable to find type to publish the data");
        }

    }

}