aboutsummaryrefslogtreecommitdiff
path: root/src/net/cbaines/suca/SotonCalendarFetcher.java
diff options
context:
space:
mode:
authorChristopher Baines <cbaines8@gmail.com>2012-03-23 19:46:14 +0000
committerChristopher Baines <cbaines8@gmail.com>2012-03-23 19:46:14 +0000
commit1749f7edc11b9961b15e790c7d296bacd8d68ff5 (patch)
treec754defaef9eb9baf3bbc015c0da1c93a2e6937e /src/net/cbaines/suca/SotonCalendarFetcher.java
parente8f29f14141e7cdec43f32c8176471e352ce1d8b (diff)
downloadsouthampton-university-calendar-applet-1749f7edc11b9961b15e790c7d296bacd8d68ff5.tar
southampton-university-calendar-applet-1749f7edc11b9961b15e790c7d296bacd8d68ff5.tar.gz
Updated and now in one case will work, needs more UI work.
Diffstat (limited to 'src/net/cbaines/suca/SotonCalendarFetcher.java')
-rw-r--r--src/net/cbaines/suca/SotonCalendarFetcher.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/net/cbaines/suca/SotonCalendarFetcher.java b/src/net/cbaines/suca/SotonCalendarFetcher.java
index 633b898..40a85ff 100644
--- a/src/net/cbaines/suca/SotonCalendarFetcher.java
+++ b/src/net/cbaines/suca/SotonCalendarFetcher.java
@@ -6,6 +6,8 @@ import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
+import javax.security.auth.login.LoginException;
+
import org.apache.commons.io.IOUtils;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
@@ -28,7 +30,7 @@ public class SotonCalendarFetcher {
this.password = password;
}
- public String fetchAndParseTimetable() {
+ public String fetchAndParseTimetable() throws LoginException {
DefaultHttpClient httpclient = new DefaultHttpClient();
try {
HttpGet httpget = new HttpGet(
@@ -153,7 +155,13 @@ public class SotonCalendarFetcher {
response = httpclient.execute(httpost);
entity = response.getEntity();
- return IOUtils.toString(entity.getContent());
+ String responseString = IOUtils.toString(entity.getContent());
+
+ if (responseString.contains("Failed Login")) {
+ throw new LoginException("Login failed");
+ } else {
+ return responseString;
+ }
} catch (IllegalStateException e) {
// TODO Auto-generated catch block