aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
authorGravatar Konstantin K2016-02-01 16:40:27 +0300
committerGravatar Konstantin K2016-02-01 16:40:27 +0300
commitc8076938933dfc9fda8dd300af5d5bf24a8fa555 (patch)
tree6d605f0b2fcb25055d9a4f1ba172f4b925e61cf3 /src/main/java/com
parentb9d7b0f0379d0e824bf23a98421a32b585a48ed7 (diff)
send notification to winmobile with avatar
Diffstat (limited to 'src/main/java/com')
-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>();