From c8076938933dfc9fda8dd300af5d5bf24a8fa555 Mon Sep 17 00:00:00 2001 From: Konstantin K Date: Mon, 1 Feb 2016 16:40:27 +0300 Subject: send notification to winmobile with avatar --- src/main/java/com/juick/PushComponent.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/main/java/com') diff --git a/src/main/java/com/juick/PushComponent.java b/src/main/java/com/juick/PushComponent.java index 4dd78286..bc2f9fb4 100644 --- a/src/main/java/com/juick/PushComponent.java +++ b/src/main/java/com/juick/PushComponent.java @@ -43,6 +43,7 @@ import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.message.BasicNameValuePair; import org.apache.http.util.EntityUtils; +import org.apache.http.util.TextUtils; import org.json.JSONObject; import javax.servlet.ServletContextEvent; @@ -254,10 +255,10 @@ public class PushComponent implements ServletContextListener, Stream.StreamListe String xml = "" + "" + "" - + "" + + "" + + "" + "" + text1 + "" + "" + text2 + "" - //+ "" // todo: user avatar + "" + "" + "" @@ -272,6 +273,8 @@ public class PushComponent implements ServletContextListener, Stream.StreamListe } } catch (IOException e) { logger.log(Level.SEVERE, "WNS: ", e); + } catch (IllegalStateException e) { + logger.log(Level.SEVERE, "WNS: ", e); } } @@ -299,7 +302,13 @@ public class PushComponent implements ServletContextListener, Stream.StreamListe } } - String getWnsAccessToken() throws IOException { + String getWnsAccessToken() throws IOException, IllegalStateException { + if(TextUtils.isEmpty(wns_application_sip)) { + throw new IllegalStateException("'wns_application_sip' is not initialized"); + } + if(TextUtils.isEmpty(wns_client_secret)) { + throw new IllegalStateException("'wns_client_secret' is not initialized"); + } HttpClient client = HttpClientBuilder.create().build(); String url = "https://login.live.com/accesstoken.srf"; List formParams = new ArrayList(); -- cgit v1.2.3