@@ -0,0 +1,2619 @@
+/*%0ACopyright 2011 Selenium committers%0ACopyright 2011 Software Freedom Conservancy%0A%0ALicensed under the Apache License, Version 2.0 (the %22License%22);%0Ayou may not use this file except in compliance with the License.%0AYou may obtain a copy of the License at%0A%0A     http://www.apache.org/licenses/LICENSE-2.0%0A%0AUnless required by applicable law or agreed to in writing, software%0Adistributed under the License is distributed on an %22AS IS%22 BASIS,%0AWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0ASee the License for the specific language governing permissions and%0Alimitations under the License.%0A*/%0A%0Apackage org.openqa.grid.common;%0A%0Aimport com.google.gson.JsonObject;%0Aimport com.google.gson.JsonParser;%0Aimport com.google.gson.JsonSyntaxException;%0A%0Aimport org.openqa.grid.common.exception.GridConfigurationException;%0A%0Aimport java.io.BufferedReader;%0Aimport java.io.FileInputStream;%0Aimport java.io.FileNotFoundException;%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.io.InputStreamReader;%0A%0Apublic class JSONConfigurationUtils %7B%0A%0A  /**%0A   * load a JSON file from the resource or file system.%0A   * %0A   * @param resource%0A   * @return A JsonObject representing the passed resource argument.%0A   */%0A  public static JsonObject loadJSON(String resource) %7B%0A    String propertyFileLocatorString = JSONConfigurationUtils.class.getPackage().getName().replace('.', '/') + '/' + resource;%0A    InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(%0A        propertyFileLocatorString);%0A%0A    if (in == null) %7B%0A      try %7B%0A        in = new FileInputStream(resource);%0A      %7D catch (FileNotFoundException e) %7B%0A        // ignore%0A      %7D%0A    %7D%0A%0A    if (in == null) %7B%0A      throw new RuntimeException(resource + %22 is not a valid resource.%22);%0A    %7D%0A%0A    StringBuilder b = new StringBuilder();%0A    InputStreamReader inputreader = new InputStreamReader(in);%0A    BufferedReader buffreader = new BufferedReader(inputreader);%0A    String line;%0A%0A    try %7B%0A      while ((line = buffreader.readLine()) != null) %7B%0A        b.append(line);%0A      %7D%0A    %7D catch (IOException e) %7B%0A      throw new GridConfigurationException(%22Cannot read file %22 + resource + %22 , %22 + e.getMessage(), e);%0A    %7D finally %7B%0A      try %7B%0A        buffreader.close();%0A        inputreader.close();%0A        in.close();%0A      %7D catch (IOException e) %7B%0A        e.printStackTrace();%0A      %7D%0A    %7D%0A%0A    try %7B%0A      return new JsonParser().parse(b.toString()).getAsJsonObject();%0A    %7D catch (JsonSyntaxException e) %7B%0A      throw new GridConfigurationException(%22Wrong format for the JSON input : %22 + e.getMessage(), e);%0A    %7D%0A  %7D%0A%7D

Fix missing class