From 2c6b67f2e80533c1b33fa9270294018c92ad4a61 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Wed, 5 Dec 2012 23:47:22 +0100 Subject: [PATCH] Some checks for nulls. * src/main/java/org/glom/web/client/activity/TableSelectionActivity.java: fillView(): * src/main/java/org/glom/web/client/ui/TableSelectionViewImpl.java: setLocaleList(), setReportList()): * src/main/java/org/glom/web/server/OnlineGlomServiceImpl.java: getReportsList(): Avoid using null objects. * src/main/java/org/glom/web/server/Utils.java: transformUnknownToActualType(): Try to avoid or catch failures to parse the string as a double. --- ChangeLog | 14 ++++++++++++++ .../glom/web/client/activity/TableSelectionActivity.java | 7 ++++++- .../org/glom/web/client/ui/TableSelectionViewImpl.java | 8 ++++++++ .../java/org/glom/web/server/OnlineGlomServiceImpl.java | 6 +++++- src/main/java/org/glom/web/server/Utils.java | 10 +++++++++- 5 files changed, 42 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5f4f0fb..b0ab3cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,19 @@ 2012-12-05 Murray Cumming + Some checks for nulls. + + * src/main/java/org/glom/web/client/activity/TableSelectionActivity.java: + fillView(): + * src/main/java/org/glom/web/client/ui/TableSelectionViewImpl.java: + setLocaleList(), setReportList()): + * src/main/java/org/glom/web/server/OnlineGlomServiceImpl.java: + getReportsList(): Avoid using null objects. + * src/main/java/org/glom/web/server/Utils.java: + transformUnknownToActualType(): Try to avoid or catch + failures to parse the string as a double. + +2012-12-05 Murray Cumming + Turn the authenication popup into a real Place. * src/main/java/org/glom/web/client/place/HasTablePlace.java: diff --git a/src/main/java/org/glom/web/client/activity/TableSelectionActivity.java b/src/main/java/org/glom/web/client/activity/TableSelectionActivity.java index 936e046..c2908a1 100644 --- a/src/main/java/org/glom/web/client/activity/TableSelectionActivity.java +++ b/src/main/java/org/glom/web/client/activity/TableSelectionActivity.java @@ -19,6 +19,8 @@ package org.glom.web.client.activity; +import java.util.ArrayList; + import org.glom.web.client.ClientFactory; import org.glom.web.client.OnlineGlomServiceAsync; import org.glom.web.client.StringUtils; @@ -166,7 +168,10 @@ public class TableSelectionActivity extends AbstractActivity implements View.Pre tableSelectionView.setTableSelection(result.getTableNames(), result.getTableTitles()); if (StringUtils.isEmpty(tableName)) { - tableName = result.getTableNames().get(result.getDefaultTableIndex()); + final ArrayList tableNames = result.getTableNames(); + if(tableNames != null) { + tableName = tableNames.get(result.getDefaultTableIndex()); + } } tableSelectionView.setSelectedTableName(tableName); diff --git a/src/main/java/org/glom/web/client/ui/TableSelectionViewImpl.java b/src/main/java/org/glom/web/client/ui/TableSelectionViewImpl.java index 9cc345b..e9666fe 100644 --- a/src/main/java/org/glom/web/client/ui/TableSelectionViewImpl.java +++ b/src/main/java/org/glom/web/client/ui/TableSelectionViewImpl.java @@ -228,6 +228,11 @@ public class TableSelectionViewImpl extends Composite implements TableSelectionV @Override public void setLocaleList(final ArrayList ids, final ArrayList titles) { localesChooser.clear(); + + if(ids == null) { + return; + } + for (int i = 0; i < ids.size(); i++) { localesChooser.addItem(titles.get(i), ids.get(i)); } @@ -302,6 +307,9 @@ public class TableSelectionViewImpl extends Composite implements TableSelectionV // TODO: Think of a better UI for this. reportsChooser.addItem("-", ""); + if(reports == null) + return; + for (int i = 0; i < reports.getCount(); i++) { reportsChooser.addItem(reports.getTitle(i), reports.getName(i)); } diff --git a/src/main/java/org/glom/web/server/OnlineGlomServiceImpl.java b/src/main/java/org/glom/web/server/OnlineGlomServiceImpl.java index b6b9392..1c35de4 100644 --- a/src/main/java/org/glom/web/server/OnlineGlomServiceImpl.java +++ b/src/main/java/org/glom/web/server/OnlineGlomServiceImpl.java @@ -321,7 +321,11 @@ public class OnlineGlomServiceImpl extends RemoteServiceServlet implements Onlin @Override public Reports getReportsList(final String documentID, final String tableName, final String localeID) { final ConfiguredDocument configuredDoc = configuredDocumentSet.getDocument(documentID); - return configuredDoc.getReports(tableName, localeID); + if(configuredDoc != null) { + return configuredDoc.getReports(tableName, localeID); + } else { + return null; + } } // TODO: It would be more efficient to get the extra related (or related related) column value along with the other diff --git a/src/main/java/org/glom/web/server/Utils.java b/src/main/java/org/glom/web/server/Utils.java index 085cc67..d73402a 100644 --- a/src/main/java/org/glom/web/server/Utils.java +++ b/src/main/java/org/glom/web/server/Utils.java @@ -197,7 +197,15 @@ public class Utils { switch(actualType) { case TYPE_NUMERIC: // TODO: Is this really locale-independent? - final double number = Double.parseDouble(unknownText); + double number = 0; + if(!StringUtils.isEmpty(unknownText)) { + try { + number = Double.parseDouble(unknownText); + } catch (final NumberFormatException e) { + e.printStackTrace(); + } + } + dataItem.setNumber(number); break; case TYPE_TEXT: -- 2.1.4