Package org.spoutcraft.launcher.exceptions

Examples of org.spoutcraft.launcher.exceptions.RestfulAPIException


    try {
      stream = RestAPI.getCachingInputStream(new URL(url), true);
      Project project = mapper.readValue(stream, Project.class);
      return project.getBuild();
    } catch (IOException e) {
      throw new RestfulAPIException("Error accessing URL [" + url + "]", e);
    } finally {
      IOUtils.closeQuietly(stream);
    }
  }
View Full Code Here


    try {
      stream = RestAPI.getCachingInputStream(new URL(url), true);
      Project project = mapper.readValue(stream, Project.class);
      return project.getMd5();
    } catch (IOException e) {
      throw new RestfulAPIException("Error accessing URL [" + url + "]", e);
    } finally {
      IOUtils.closeQuietly(stream);
    }
  }
View Full Code Here

      try {
        stream = RestAPI.getCachingInputStream(new URL(url), true);
        Project project = mapper.readValue(stream, Project.class);
        build = project.getBuild();
      } catch (IOException e) {
        throw new RestfulAPIException("Error accessing URL [" + url + "]", e);
      } finally {
        IOUtils.closeQuietly(stream);
      }
      // Check to see if stable has newer release
      if (channel == Channel.STABLE) {
        return String.valueOf(build);
      } else {
        url = RestAPI.getSpoutcraftURL(Channel.STABLE);
        try {
          stream = RestAPI.getCachingInputStream(new URL(url), true);
          Project stable = mapper.readValue(stream, Project.class);
          // Stable release is newer
          if (stable.getBuild() > build) {
            return String.valueOf(stable.getBuild());
          } else {
            return String.valueOf(build);
          }
        } catch (IOException e) {
          throw new RestfulAPIException("Error accessing URL [" + url + "]", e);
        } finally {
          IOUtils.closeQuietly(stream);
        }
      }
    } else {
      // Find the newest build for the Minecraft version
      String url = RestAPI.ALL_BUILDS_URL;
      try {
        final String mcVersion = getMinecraft().getVersion();
        stream = RestAPI.getCachingInputStream(new URL(url), true);
        ChannelData data = mapper.readValue(stream, ChannelData.class);
        HashSet<String> builds = new HashSet<String>(100);
        for (VersionData v : data.stable) {
          if (v.minecraftVersion.equals(mcVersion)) {
            builds.add(v.buildNumber);
          }
        }
        for (VersionData v : data.beta) {
          if (v.minecraftVersion.equals(mcVersion)) {
            builds.add(v.buildNumber);
          }
        }
        for (VersionData v : data.dev) {
          if (v.minecraftVersion.equals(mcVersion)) {
            builds.add(v.buildNumber);
          }
        }
        ArrayList<String> buildList = new ArrayList<String>(builds);
        Collections.sort(buildList);
        return buildList.get(buildList.size() - 1);
      } catch (IOException e) {
        throw new RestfulAPIException("Error accessing URL [" + url + "]", e);
      } finally {
        IOUtils.closeQuietly(stream);
      }
    }
  }
View Full Code Here

          i.remove();
        }
      }
      return libs;
    } catch (IOException e) {
      throw new RestfulAPIException("Error accessing URL [" + url + "]", e);
    } finally {
      IOUtils.closeQuietly(stream);
    }
  }
View Full Code Here

      Minecraft[] versions = mapper.readValue(stream, Minecraft[].class);
      List<Minecraft> list = new ArrayList<Minecraft>(Arrays.asList(versions));
      Collections.sort(list);
      return Collections.unmodifiableList(list);
    } catch (IOException e) {
      throw new RestfulAPIException("Error accessing URL [" + RestAPI.MINECRAFT_URL + "]", e);
    } finally {
      IOUtils.closeQuietly(stream);
    }
  }
View Full Code Here

        try {
          stream = RestAPI.getCachingInputStream(new URL(RestAPI.getBuildListURL(c)), true);
          ObjectMapper mapper = new ObjectMapper();
          uniqueBuilds.addAll(Arrays.asList(mapper.readValue(stream, SpoutcraftBuild[].class)));
        } catch (IOException e) {
          throw new RestfulAPIException("Error reading spoutcraft build list", e);
        } finally {
          IOUtils.closeQuietly(stream);
        }
      }
    }
View Full Code Here

TOP

Related Classes of org.spoutcraft.launcher.exceptions.RestfulAPIException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.