From 8703c6e07e46b4bad8e0e50af41d70f976302a6d Mon Sep 17 00:00:00 2001 From: fayder Date: Fri, 1 Nov 2013 13:00:53 +0200 Subject: [PATCH 1/6] added branches description --- README.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index aa37965a..0dd230cb 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,19 @@ Get information about any country via a RESTful API http://restcountries.eu ---------- -Work in Progress +Branches --------- -- More REST search options -- Add Timezone to Available Data +##### dev +* well.. dev environment. play around in here before committing to other branches
+* using java7 and servlet api 3 + +##### master +* latest stable release +* using java7 and servlet api 3 + +##### servlet2 +* latest stable release +* using java6 and servlet api 2 Available Data --------- From a564ee91678c3c2d3ddd17ac31338cf163d5ff19 Mon Sep 17 00:00:00 2001 From: fayder Date: Fri, 1 Nov 2013 14:05:00 +0200 Subject: [PATCH 2/6] updated rest urls in dev --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0dd230cb..c8c0b578 100644 --- a/README.md +++ b/README.md @@ -37,9 +37,9 @@ Available Data REST Services --------- -- By code ISO 3166-1 alpha-2 http://restcountries.eu/rest/alpha2/NO +- By code ISO 3166-1 alpha-2 http://restcountries.eu/rest/alpha/NO -- By code ISO 3166-1 alpha-3 http://restcountries.eu/rest/alpha3/NOR +- By code ISO 3166-1 alpha-3 http://restcountries.eu/rest/alpha/NOR - By currency http://restcountries.eu/rest/currency/NOK From 01df246e60a5b4bb687ba3c7299f002eb158549a Mon Sep 17 00:00:00 2001 From: fayder Date: Fri, 1 Nov 2013 14:31:35 +0200 Subject: [PATCH 3/6] corrected 'Moscow' in countries.json --- src/main/resources/countries.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/countries.json b/src/main/resources/countries.json index 0d3c1007..97fab26d 100644 --- a/src/main/resources/countries.json +++ b/src/main/resources/countries.json @@ -179,7 +179,7 @@ {"name":"Qatar","tld":".qa","cca2":"QA","ccn3":634,"cca3":"QAT","currency":"QAR","callingcode":"974","capital":"Doha","altSpellings":"QA","relevance":0,"region":"Asia","subregion":"Western Asia"}, {"name":"R\u00e9union","tld":".re","cca2":"RE","ccn3":638,"cca3":"REU","currency":"EUR","callingcode":"262","capital":"","altSpellings":"RE,Reunion","relevance":0,"region":"Africa","subregion":"Eastern Africa"}, {"name":"Romania","tld":".ro","cca2":"RO","ccn3":642,"cca3":"ROU","currency":"RON","callingcode":"40","capital":"Bucharest","altSpellings":"RO,Rumania,Roumania,Rom\u00e2nia","relevance":0,"region":"Europe","subregion":"Eastern Europe"}, -{"name":"Russian Federation","tld":".ru","cca2":"RU","ccn3":643,"cca3":"RUS","currency":"RUB","callingcode":"7","capital":"Moskow","altSpellings":"RU,Rossiya","relevance":2.5,"region":"Europe","subregion":"Eastern Europe"}, +{"name":"Russian Federation","tld":".ru","cca2":"RU","ccn3":643,"cca3":"RUS","currency":"RUB","callingcode":"7","capital":"Moscow","altSpellings":"RU,Rossiya","relevance":2.5,"region":"Europe","subregion":"Eastern Europe"}, {"name":"Rwanda","tld":".rw","cca2":"RW","ccn3":646,"cca3":"RWA","currency":"RWF","callingcode":"250","capital":"Kigali","altSpellings":"RW","relevance":0,"region":"Africa","subregion":"Eastern Africa"}, {"name":"Saint Barth\u00e9lemy","tld":".bl","cca2":"BL","ccn3":652,"cca3":"BLM","currency":"EUR","callingcode":"590","capital":"Gustavia","altSpellings":"BL,St. Barthelemy","relevance":0,"region":"Americas","subregion":"Caribbean"}, {"name":"Saint Helena","tld":".sh","cca2":"SH","ccn3":654,"cca3":"SHN","currency":"SHP","callingcode":"290","capital":"Jamestown","altSpellings":"SH,St.","relevance":0,"region":"Africa","subregion":"Western Africa"}, From 1bcaeb4ad9e07b4761d0660de7af6ee2bc820c63 Mon Sep 17 00:00:00 2001 From: fayder Date: Fri, 1 Nov 2013 15:23:22 +0200 Subject: [PATCH 4/6] supporting deprecated api --- .../vaeke/restcountries/rest/CountryRest.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/main/java/vaeke/restcountries/rest/CountryRest.java b/src/main/java/vaeke/restcountries/rest/CountryRest.java index 0647b67f..07be58c6 100644 --- a/src/main/java/vaeke/restcountries/rest/CountryRest.java +++ b/src/main/java/vaeke/restcountries/rest/CountryRest.java @@ -69,9 +69,47 @@ public Object getByAlpha(@PathParam("alphacode") String alpha) { LOG.error(e.getMessage(), e); return Response.status(Status.INTERNAL_SERVER_ERROR).entity("500: Internal Server Error").build(); } + } + + @GET + @Path("alpha2/{alpha2code}") + @Deprecated + public Object getByAlpha2(@PathParam("alpha2code") String alpha2) { + LOG.info("Getting by alpha2 " + alpha2); + try { + List countries = getAll(); + for(Country country : countries) { + if (country.getCca2().toLowerCase().equals(alpha2.toLowerCase())) { + return country; + } + } + return Response.status(Status.NOT_FOUND).entity("404: Not Found").build(); + } catch (IOException e) { + LOG.error(e.getMessage(), e); + return Response.status(Status.INTERNAL_SERVER_ERROR).entity("500: Internal Server Error").build(); + } } + @GET + @Path("alpha3/{alpha3code}") + @Deprecated + public Object getByAlpha3(@PathParam("alpha3code") String alpha3) { + LOG.info("Getting by alpha3 " + alpha3); + try { + List countries = getAll(); + for(Country country : countries) { + if (country.getCca3().toLowerCase().equals(alpha3.toLowerCase())) { + return country; + } + } + return Response.status(Status.NOT_FOUND).entity("404: Not Found").build(); + } catch (IOException e) { + LOG.error(e.getMessage(), e); + return Response.status(Status.INTERNAL_SERVER_ERROR).entity("500: Internal Server Error").build(); + } + } + @GET @Path("currency/{currency}") public Object getByCurrency(@PathParam("currency") String currency) { From 70c66f172a38212f2c8c785dac81f933d320b337 Mon Sep 17 00:00:00 2001 From: fayder Date: Fri, 1 Nov 2013 16:34:59 +0200 Subject: [PATCH 5/6] change 'tryit' input value when clicking the examples --- src/main/webapp/js/restcountries.js | 1 + src/main/webapp/js/restcountries.min.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/webapp/js/restcountries.js b/src/main/webapp/js/restcountries.js index 111a53fb..96e5e959 100644 --- a/src/main/webapp/js/restcountries.js +++ b/src/main/webapp/js/restcountries.js @@ -33,6 +33,7 @@ $(function () { ajax($(e.target).html(), function(data) { restc.ui.jsonwell.removeClass('hidden'); restc.ui.jsonwell.html(getCodeHtml(data)); + restc.ui.inputTryit.val($(e.target).html()); $(document).scrollTop(restc.ui.searchers.get(0).clientHeight); }); }); diff --git a/src/main/webapp/js/restcountries.min.js b/src/main/webapp/js/restcountries.min.js index b1937deb..1dcc25ff 100644 --- a/src/main/webapp/js/restcountries.min.js +++ b/src/main/webapp/js/restcountries.min.js @@ -1 +1 @@ -var restc=restc||{};$(function(){"use strict";restc.ui={navbarlink:$(".rc-navbar-link"),tryit:$(".rc-a-tryit"),inputTryit:$(".rc-input-tryit"),jsonwell:$("#rc-json-well"),warning:$("#rc-warning"),errorMsg:$("#rc-error"),searchers:$("#rc-searchers"),tryityou:$(".rc-a-diy")};restc.ui.navbarlink.click(function(t){e(t.target)});restc.ui.tryityou.click(function(e){t($(e.target).parent().prev().val(),function(e){restc.ui.jsonwell.removeClass("hidden");restc.ui.jsonwell.html(n(e));$(document).scrollTop(restc.ui.searchers.get(0).clientHeight)})});restc.ui.tryit.click(function(e){t($(e.target).html(),function(e){restc.ui.jsonwell.removeClass("hidden");restc.ui.jsonwell.html(n(e));$(document).scrollTop(restc.ui.searchers.get(0).clientHeight)})});restc.ui.inputTryit.keypress(function(e){if(e.keyCode==13){$(e.target).next().get(0).firstChild.click()}});var e=function(e){restc.ui.navbarlink.parent().removeClass("active");$(e).parent().addClass("active")};var t=function(e,t){if(e.indexOf("restcountries.eu")!=7&&e.indexOf("restcountries.eu")!=11&&e.indexOf("localhost")!=7)return;$.ajax({url:e,type:"GET",dataType:"json",success:function(e,n,r){restc.ui.warning.addClass("hidden");t(e)},statusCode:{404:function(){restc.ui.warning.removeClass("hidden");restc.ui.errorMsg.addClass("hidden");restc.ui.jsonwell.addClass("hidden")},500:function(){restc.ui.warning.addClass("hidden");restc.ui.errorMsg.removeClass("hidden");restc.ui.jsonwell.addClass("hidden")}}})};var n=function(e){var t=[];t.push('
');t.push(JSON.stringify(e,null,"	"));t.push("
");return t.join("")}}) \ No newline at end of file +var restc=restc||{};$(function(){"use strict";restc.ui={navbarlink:$(".rc-navbar-link"),tryit:$(".rc-a-tryit"),inputTryit:$(".rc-input-tryit"),jsonwell:$("#rc-json-well"),warning:$("#rc-warning"),errorMsg:$("#rc-error"),searchers:$("#rc-searchers"),tryityou:$(".rc-a-diy")};restc.ui.navbarlink.click(function(t){e(t.target)});restc.ui.tryityou.click(function(e){t($(e.target).parent().prev().val(),function(e){restc.ui.jsonwell.removeClass("hidden");restc.ui.jsonwell.html(n(e));$(document).scrollTop(restc.ui.searchers.get(0).clientHeight)})});restc.ui.tryit.click(function(e){t($(e.target).html(),function(t){restc.ui.jsonwell.removeClass("hidden");restc.ui.jsonwell.html(n(t));restc.ui.inputTryit.val($(e.target).html());$(document).scrollTop(restc.ui.searchers.get(0).clientHeight)})});restc.ui.inputTryit.keypress(function(e){if(e.keyCode==13){$(e.target).next().get(0).firstChild.click()}});var e=function(e){restc.ui.navbarlink.parent().removeClass("active");$(e).parent().addClass("active")};var t=function(e,t){if(e.indexOf("restcountries.eu")!=7&&e.indexOf("restcountries.eu")!=11&&e.indexOf("localhost")!=7)return;$.ajax({url:e,type:"GET",dataType:"json",success:function(e,n,r){restc.ui.warning.addClass("hidden");t(e)},statusCode:{404:function(){restc.ui.warning.removeClass("hidden");restc.ui.errorMsg.addClass("hidden");restc.ui.jsonwell.addClass("hidden")},500:function(){restc.ui.warning.addClass("hidden");restc.ui.errorMsg.removeClass("hidden");restc.ui.jsonwell.addClass("hidden")}}})};var n=function(e){var t=[];t.push('
');t.push(JSON.stringify(e,null,"	"));t.push("
");return t.join("")}}) \ No newline at end of file From 837406787702f4b17f15b01a28aac4b6e8956426 Mon Sep 17 00:00:00 2001 From: fayder Date: Fri, 1 Nov 2013 16:35:32 +0200 Subject: [PATCH 6/6] v0.6 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 28427e98..0ada40d9 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 vaeke restcountries - 0.6 + 0.7 war restcountries REST interface to get data about countries