From 7c83746ee789a5219af641a4502a657d9563771d Mon Sep 17 00:00:00 2001 From: Jacky Date: Fri, 27 Oct 2017 16:59:55 -0400 Subject: [PATCH] deal with empty string properly --- main/src/com/google/refine/ProjectMetadata.java | 14 +++++++------- .../project/SetProjectMetaDataCommand.java | 3 ++- .../views/data-table/text-transform-dialog.html | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/main/src/com/google/refine/ProjectMetadata.java b/main/src/com/google/refine/ProjectMetadata.java index 0e747fd8a..29372b7cc 100644 --- a/main/src/com/google/refine/ProjectMetadata.java +++ b/main/src/com/google/refine/ProjectMetadata.java @@ -57,16 +57,16 @@ public class ProjectMetadata implements Jsonizable { private final Date _created; private Date _modified; private Date written = null; - private String _name; - private String _password; + private String _name = ""; + private String _password = ""; - private String _encoding; + private String _encoding = ""; private int _encodingConfidence; - private String _creator; - private String _contributors; - private String _subject; // Several refine projects may be linked - private String _description; // free form of comment + private String _creator = ""; + private String _contributors = ""; + private String _subject = ""; // Several refine projects may be linked + private String _description = ""; // free form of comment private int _rowNumber; // at the creation. Essential for cleaning old projects too heavy // import options is an array for 1-n data sources diff --git a/main/src/com/google/refine/commands/project/SetProjectMetaDataCommand.java b/main/src/com/google/refine/commands/project/SetProjectMetaDataCommand.java index 8cd2b175c..6644cf389 100644 --- a/main/src/com/google/refine/commands/project/SetProjectMetaDataCommand.java +++ b/main/src/com/google/refine/commands/project/SetProjectMetaDataCommand.java @@ -6,6 +6,7 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.commons.lang.StringUtils; import org.json.JSONException; import org.json.JSONTokener; import org.json.JSONWriter; @@ -36,7 +37,7 @@ public class SetProjectMetaDataCommand extends Command { response.setHeader("Content-Type", "application/json"); JSONWriter writer = new JSONWriter(response.getWriter()); - Object o = valueString == null ? null : new JSONTokener(valueString).nextValue(); + Object o = StringUtils.isEmpty(valueString) ? null : new JSONTokener(valueString).nextValue(); meta.setAnyField(metaName, valueString); ProjectManager.singleton.saveMetadata(meta, project.id); diff --git a/main/webapp/modules/core/scripts/views/data-table/text-transform-dialog.html b/main/webapp/modules/core/scripts/views/data-table/text-transform-dialog.html index 4544ce84f..1bab7d958 100644 --- a/main/webapp/modules/core/scripts/views/data-table/text-transform-dialog.html +++ b/main/webapp/modules/core/scripts/views/data-table/text-transform-dialog.html @@ -1,4 +1,4 @@ -
+