// Path: src/main/java/net/itimothy/elasticsearch/restapispec/model/RestApiSpecData.java
// public class RestApiSpecData extends HashMap<String, Api> {
// }


import com.google.gson.Gson;
import net.itimothy.elasticsearch.restapispec.model.Api;
import net.itimothy.elasticsearch.restapispec.model.RestApiSpecData;
import org.apache.commons.io.IOUtils;
import org.elasticsearch.Version;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.net.URL;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.*;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
package net.itimothy.elasticsearch.restapispec;



public class OfficialRestApiSpecDataProvider {

    // TODO: caching

    public Map<String, Api> getData(Version version) {
        final HashMap<String, Api> data = new HashMap<>();

        try {
            final Gson gson = new Gson();
            final String path = String.format(
                "rest-api-spec/%s.%s",
                version.major,
                version.minor
            );
            for (InputStream stream : getFiles(path)) {
                final String json = IOUtils.toString(stream, "UTF-8");
                try {
                    AccessController.doPrivileged(
                        new PrivilegedAction<Void>() {
                            public Void run() {
// Path: src/main/java/net/itimothy/elasticsearch/restapispec/model/RestApiSpecData.java
// public class RestApiSpecData extends HashMap<String, Api> {
// }


// Path: src/main/java/net/itimothy/elasticsearch/restapispec/OfficialRestApiSpecDataProvider.java
import com.google.gson.Gson;
import net.itimothy.elasticsearch.restapispec.model.Api;
import net.itimothy.elasticsearch.restapispec.model.RestApiSpecData;
import org.apache.commons.io.IOUtils;
import org.elasticsearch.Version;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.net.URL;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.*;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

package net.itimothy.elasticsearch.restapispec;



public class OfficialRestApiSpecDataProvider {

    // TODO: caching

    public Map<String, Api> getData(Version version) {
        final HashMap<String, Api> data = new HashMap<>();

        try {
            final Gson gson = new Gson();
            final String path = String.format(
                "rest-api-spec/%s.%s",
                version.major,
                version.minor
            );
            for (InputStream stream : getFiles(path)) {
                final String json = IOUtils.toString(stream, "UTF-8");
                try {
                    AccessController.doPrivileged(
                        new PrivilegedAction<Void>() {
                            public Void run() {
                                RestApiSpecData restApiSpecData = gson.fromJson(json, RestApiSpecData.class);