aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2015-02-24 16:23:45 +0100
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2015-02-24 16:23:45 +0100
commitb3b6404c36ba320baa27cc6980511f94395d50e9 (patch)
treefc36b06019ce4174dca13c6abd22c5eeb7e74724
parent6e1aad3596c6a2897aec2a8bbe183cea694cb93e (diff)
downloadpdf-as-4-b3b6404c36ba320baa27cc6980511f94395d50e9.tar.gz
pdf-as-4-b3b6404c36ba320baa27cc6980511f94395d50e9.tar.bz2
pdf-as-4-b3b6404c36ba320baa27cc6980511f94395d50e9.zip
Fixed possible Null pointer error, Added source entry to csv file
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/stats/StatisticFrontend.java72
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/stats/impl/StatisticFileBackend.java1
2 files changed, 39 insertions, 34 deletions
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/stats/StatisticFrontend.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/stats/StatisticFrontend.java
index 3c59a7cc..f006be54 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/stats/StatisticFrontend.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/stats/StatisticFrontend.java
@@ -39,36 +39,41 @@ public class StatisticFrontend implements StatisticBackend {
while (statisticIterator.hasNext()) {
StatisticBackend statisticBackend = statisticIterator.next();
-
- if(enabledBackends == null || enabledBackends.contains(statisticBackend
- .getName())) {
+
+ if (enabledBackends == null
+ || enabledBackends.contains(statisticBackend.getName())) {
logger.info("adding Statistic Logger {} [{}]", statisticBackend
.getName(), statisticBackend.getClass().getName());
-
- statisticBackends.add(statisticBackend);
+
+ statisticBackends.add(statisticBackend);
} else {
- logger.info("skipping Statistic Logger {} [{}]", statisticBackend
- .getName(), statisticBackend.getClass().getName());
+ logger.info("skipping Statistic Logger {} [{}]",
+ statisticBackend.getName(), statisticBackend.getClass()
+ .getName());
}
}
-
-
- Iterator<String> enabledBackendsIterator = enabledBackends
- .iterator();
- while (enabledBackendsIterator.hasNext()) {
- String enabledBackend = enabledBackendsIterator.next();
- statisticIterator = statisticBackends.iterator();
- boolean found = false;
- while (statisticIterator.hasNext()) {
- StatisticBackend statisticBackend = statisticIterator.next();
- if(statisticBackend.getName().equals(enabledBackend)) {
- found = true;
- break;
+
+ if (enabledBackends != null) {
+ Iterator<String> enabledBackendsIterator = enabledBackends
+ .iterator();
+ while (enabledBackendsIterator.hasNext()) {
+ String enabledBackend = enabledBackendsIterator.next();
+ statisticIterator = statisticBackends.iterator();
+ boolean found = false;
+ while (statisticIterator.hasNext()) {
+ StatisticBackend statisticBackend = statisticIterator
+ .next();
+ if (statisticBackend.getName().equals(enabledBackend)) {
+ found = true;
+ break;
+ }
+ }
+
+ if (!found) {
+ logger.warn(
+ "Failed to load statistic backend {}. Not in classpath?",
+ enabledBackend);
}
- }
-
- if(!found) {
- logger.warn("Failed to load statistic backend {}. Not in classpath?", enabledBackend);
}
}
}
@@ -80,29 +85,28 @@ public class StatisticFrontend implements StatisticBackend {
return _instance;
}
-
@Override
public String getName() {
return StatisticFrontend.class.getSimpleName();
}
-
@Override
public void storeEvent(StatisticEvent statisticEvent) {
-
- if(statisticEvent == null) {
+
+ if (statisticEvent == null) {
logger.warn("Tried to log null as statisticEvent!");
return;
}
-
- if(statisticEvent.isLogged()) {
+
+ if (statisticEvent.isLogged()) {
logger.warn("Tried to relog statisticEvent!");
return;
}
-
- Iterator<StatisticBackend> statisticBackendIterator = statisticBackends.iterator();
-
- while(statisticBackendIterator.hasNext()) {
+
+ Iterator<StatisticBackend> statisticBackendIterator = statisticBackends
+ .iterator();
+
+ while (statisticBackendIterator.hasNext()) {
StatisticBackend statisticBackend = statisticBackendIterator.next();
statisticBackend.storeEvent(statisticEvent);
}
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/stats/impl/StatisticFileBackend.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/stats/impl/StatisticFileBackend.java
index 531c47bf..997bcfdd 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/stats/impl/StatisticFileBackend.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/stats/impl/StatisticFileBackend.java
@@ -30,6 +30,7 @@ public class StatisticFileBackend implements StatisticBackend {
addCSVValue(String.valueOf(statisticEvent.getTimestamp()), sb);
addCSVValue(statisticEvent.getOperation().getName(), sb);
addCSVValue(statisticEvent.getDevice(), sb);
+ addCSVValue(statisticEvent.getSource().getName(), sb);
addCSVValue(statisticEvent.getProfileId(), sb);
addCSVValue(String.valueOf(statisticEvent.getFilesize()), sb);
addCSVValue(statisticEvent.getUserAgent(), sb);