1
0
Fork 0
mirror of https://bitbucket.org/ethauvin/owm-japis.git synced 2025-04-25 09:47:11 -07:00

2.5.0.3 is now there on Maven repo. Hurray!

This commit is contained in:
Ashutosh Kumar Singh 2015-01-10 15:48:13 +05:30
parent a573686f24
commit b7562181ae
4 changed files with 103 additions and 23 deletions

View file

@ -198,7 +198,7 @@ Kindly post bugs or feature requests at [OWM JAPIs Bugs/Requests][3] and I will
##Developer ##Developer
**Ashutosh Kumar Singh** | [AKSingh.net][4] | me@aksingh.net **Ashutosh Kumar Singh** | [AKSingh.net][4] | [me@aksingh.net][9]
@ -218,9 +218,9 @@ for reporting bugs, and even finding and sharing possible solutions for them.
##License ##License
Copyright (c) 2013-2014 Ashutosh Kumar Singh <me@aksingh.net> Copyright (c) 2013-2014 Ashutosh Kumar Singh `<me@aksingh.net>`
Released under the terms of [MIT license][7]. It's open source and developer-friendly. Released under the terms of the [MIT license][7]. It's open source and developer-friendly.
[1]: http://go.aksingh.net/owm-japis-downloads [1]: http://go.aksingh.net/owm-japis-downloads
@ -231,3 +231,4 @@ Released under the terms of [MIT license][7]. It's open source and developer-fri
[6]: http://www.json.org/java/index.html [6]: http://www.json.org/java/index.html
[7]: http://opensource.org/licenses/MIT [7]: http://opensource.org/licenses/MIT
[8]: https://github.com/dvdme/forecastio-lib-java [8]: https://github.com/dvdme/forecastio-lib-java
[9]: mailto:me@aksingh.net

View file

@ -1,23 +1,79 @@
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'maven-publish' apply plugin: 'maven'
apply plugin: 'signing'
sourceCompatibility = 1.5 sourceCompatibility = 1.5
group = 'net.aksingh.owmjapis' group = 'net.aksingh'
archivesBaseName = "owm-japis"
version = '2.5.0.3' version = '2.5.0.3'
repositories { repositories {
mavenCentral() mavenCentral()
} }
publishing { dependencies {
publications { testCompile group: 'junit', name: 'junit', version: '4.12'
mavenJava(MavenPublication) { }
from components.java
task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives javadocJar, sourcesJar
}
signing {
sign configurations.archives
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
pom.project {
name 'OWM JAPIs'
packaging 'jar'
description 'Java Wrapper Library for OpenWeatherMap.org Web APIs'
url 'http://code.aksingh.net/owm-japis'
scm {
connection 'scm:svn:http://foo.googlecode.com/svn/trunk/'
developerConnection 'scm:svn:https://foo.googlecode.com/svn/trunk/'
url 'http://foo.googlecode.com/svn/trunk/'
}
licenses {
license {
name 'The MIT License (MIT)'
url 'http://opensource.org/licenses/MIT'
}
}
developers {
developer {
id 'akapribot'
name 'Ashutosh Kumar Singh'
email 'me@aksingh.net'
}
}
}
} }
} }
} }
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.+'
}

View file

@ -33,6 +33,8 @@ import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
import java.util.zip.Inflater;
import java.util.zip.InflaterInputStream;
/** /**
* <p> * <p>
@ -614,21 +616,23 @@ public class OpenWeatherMap {
connection.setUseCaches(false); connection.setUseCaches(false);
connection.setDoInput(true); connection.setDoInput(true);
connection.setDoOutput(false); connection.setDoOutput(false);
connection.setRequestProperty("Accept-Encoding", "gzip"); connection.setRequestProperty("Accept-Encoding", "gzip, deflate");
connection.connect(); connection.connect();
if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) { if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
String encoding = connection.getContentEncoding();
try { try {
if (connection.getRequestProperty("Accept-Encoding") != null) { if (encoding != null && encoding.equalsIgnoreCase("gzip")) {
reader = new BufferedReader(new InputStreamReader(new GZIPInputStream(connection.getInputStream()))); reader = new BufferedReader(new InputStreamReader(new GZIPInputStream(connection.getInputStream())));
while ((s = reader.readLine()) != null) { } else if (encoding != null && encoding.equalsIgnoreCase("deflate")) {
response = s; reader = new BufferedReader(new InputStreamReader(new InflaterInputStream(connection.getInputStream(), new Inflater(true))));
}
} else { } else {
reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
while ((s = reader.readLine()) != null) { }
response = s;
} while ((s = reader.readLine()) != null) {
response = s;
} }
} catch (IOException e) { } catch (IOException e) {
System.err.println("Error: " + e.getMessage()); System.err.println("Error: " + e.getMessage());
@ -644,8 +648,9 @@ public class OpenWeatherMap {
} else { // if HttpURLConnection is not okay } else { // if HttpURLConnection is not okay
try { try {
reader = new BufferedReader(new InputStreamReader(connection.getErrorStream())); reader = new BufferedReader(new InputStreamReader(connection.getErrorStream()));
while ((s = reader.readLine()) != null) while ((s = reader.readLine()) != null) {
response = s; response = s;
}
} catch (IOException e) { } catch (IOException e) {
System.err.println("Error: " + e.getMessage()); System.err.println("Error: " + e.getMessage());
} finally { } finally {

View file

@ -43,6 +43,24 @@ public class CurrentWeatherTest {
System.out.println("Reponse is inValid!"); System.out.println("Reponse is inValid!");
} else { } else {
System.out.println("Reponse is Valid!"); System.out.println("Reponse is Valid!");
System.out.println();
if (cw.hasBaseStation()) {
System.out.println("Base station: " + cw.getBaseStation());
}
if (cw.hasDateTime()) {
System.out.println("Date time: " + cw.getDateTime());
}
System.out.println();
if (cw.hasCityCode()) {
System.out.println("City code: " + cw.getCityCode());
}
if (cw.hasCityName()) {
System.out.println("City name: " + cw.getCityName());
}
System.out.println();
} }
} }
} }