aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-02-01 17:11:49 +0300
committerGravatar Vitaly Takmazov2016-02-01 17:11:49 +0300
commitcdfb7ce31855c0c27c6672f9dc36b1e8a0941ac0 (patch)
tree993f727765edce333a272f33bdb27244305834f3
parent474323453f1b881273f618555845e07ace830bd2 (diff)
parentc8076938933dfc9fda8dd300af5d5bf24a8fa555 (diff)
Merge remote-tracking branch 'bitbucket/develop' into develop
-rw-r--r--src/main/java/com/juick/PushComponent.java15
1 files changed, 12 insertions, 3 deletions
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 = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+ "<toast>"
+ "<visual>"
- + "<binding template=\"ToastText02\">"
+ + "<binding template=\"ToastImageAndText02\">"
+ + "<image id=\"1\" src=\"http://i.juick.com/as/" + jmsg.getUser().getUID() + ".png\" />"
+ "<text id=\"1\">" + text1 + "</text>"
+ "<text id=\"2\">" + text2 + "</text>"
- //+ "<image id=\"3\" src=\"http://i.juick.com/as/" + jmsg.User.UID + ".png\" />" // todo: user avatar
+ "</binding>"
+ "</visual>"
+ "<commands>"
@@ -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<NameValuePair> formParams = new ArrayList<NameValuePair>();