summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/util/News.java
diff options
context:
space:
mode:
authorJonathan Bauer2014-09-15 17:11:34 +0200
committerJonathan Bauer2014-09-15 17:11:34 +0200
commitcbdb0ab461b8a3b42cee70ec633248db2392f8b8 (patch)
tree0002e434dace2ca0661679a7387595f4411d4c1a /dozentenmodul/src/main/java/util/News.java
parent[client] only set news if not null (diff)
downloadtutor-module-cbdb0ab461b8a3b42cee70ec633248db2392f8b8.tar.gz
tutor-module-cbdb0ab461b8a3b42cee70ec633248db2392f8b8.tar.xz
tutor-module-cbdb0ab461b8a3b42cee70ec633248db2392f8b8.zip
[client] continue to main window even if getting the news fails
Diffstat (limited to 'dozentenmodul/src/main/java/util/News.java')
-rw-r--r--dozentenmodul/src/main/java/util/News.java41
1 files changed, 10 insertions, 31 deletions
diff --git a/dozentenmodul/src/main/java/util/News.java b/dozentenmodul/src/main/java/util/News.java
index f37f7146..22f78c92 100644
--- a/dozentenmodul/src/main/java/util/News.java
+++ b/dozentenmodul/src/main/java/util/News.java
@@ -91,33 +91,6 @@ public class News {
}
/**
- * Sets the headline of the news.
- *
- * @param s headline as String
- */
- private static void setHeadline(String s) {
- if (s != null) headline = s;
- }
-
- /**
- * Sets the content of the news.
- *
- * @param s content as String
- */
- private static void setContent(String s) {
- if (s != null) content = s;
- }
-
- /**
- * Sets the date of the news.
- *
- * @param d date as Date
- */
- private static void setDate(Date d) {
- if (d != null) date = d;
- }
-
- /**
* Private 'init' function doing the main work.
* It is called by getters if their object is null.
* Follows these steps:
@@ -171,6 +144,7 @@ public class News {
JOptionPane.showMessageDialog(null,
"Satellite antwortete auf die Anfrage der News-XML nicht!",
"Fehler", JOptionPane.ERROR_MESSAGE);
+ return;
}
InputStream is = null;
@@ -181,6 +155,7 @@ public class News {
JOptionPane.showMessageDialog(null,
"Konnte den News-URL-Stream nicht öffnen!",
"Fehler", JOptionPane.ERROR_MESSAGE);
+ return;
}
// use java's DocumentBuilder engine to parse the XML
@@ -194,6 +169,7 @@ public class News {
JOptionPane.showMessageDialog(null,
"XML-Parser falsch konfiguriert!",
"Fehler", JOptionPane.ERROR_MESSAGE);
+ return;
}
// try the parsing
@@ -204,11 +180,13 @@ public class News {
JOptionPane.showMessageDialog(null,
"Konnte die News-XML nicht parsen!",
"Fehler", JOptionPane.ERROR_MESSAGE);
+ return;
} catch (IOException e) {
JOptionPane.showMessageDialog(null,
"IO-Fehler!",
"Fehler", JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
+ return;
}
// now that we have parsed the XML, check if it is valid
@@ -242,21 +220,22 @@ public class News {
}
// set what the elements we found
- if (headlineNode != null) setHeadline(headlineNode.getNodeValue().trim());
- if (contentNode != null) setContent(contentNode.getNodeValue().trim());
+ if (headlineNode != null) headline = headlineNode.getNodeValue().trim();
+ if (contentNode != null) content = contentNode.getNodeValue().trim();
if (dateNode != null) {
// for the date we need a bit more stuff
Date tmpDate = null;
try {
- tmpDate = new Date(Long.parseLong(dateNode.getNodeValue().trim()));
+ tmpDate = new Date(Long.parseLong(dateNode.getNodeValue().trim()) * 1000);
} catch (NumberFormatException nfe) {
nfe.printStackTrace();
JOptionPane.showMessageDialog(null,
"Zeitstempel aus der XML is invalid!",
"Fehler", JOptionPane.ERROR_MESSAGE);
+ // TODO: set current date.
}
// Date creation worked, save it
- if (tmpDate != null) setDate(tmpDate);
+ if (tmpDate != null) date = tmpDate;
}
} else {
JOptionPane.showMessageDialog(null,