aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
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>();