1
0
Fork 0
mirror of https://bitbucket.org/akapribot/owm-japis.git synced 2025-04-24 23:07:12 -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
**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
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
@ -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
[7]: http://opensource.org/licenses/MIT
[8]: https://github.com/dvdme/forecastio-lib-java
[9]: mailto:me@aksingh.net

View file

@ -1,23 +1,79 @@
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'maven'
apply plugin: 'signing'
sourceCompatibility = 1.5
group = 'net.aksingh.owmjapis'
group = 'net.aksingh'
archivesBaseName = "owm-japis"
version = '2.5.0.3'
repositories {
mavenCentral()
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
}
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'
}
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.+'
developers {
developer {
id 'akapribot'
name 'Ashutosh Kumar Singh'
email 'me@aksingh.net'
}
}
}
}
}
}

View file

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

View file

@ -43,6 +43,24 @@ public class CurrentWeatherTest {
System.out.println("Reponse is inValid!");
} else {
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();
}
}
}