From 51691fc06d8419ea9b77e52302fb7a9c14b517a6 Mon Sep 17 00:00:00 2001 From: Jacky Date: Sat, 4 Nov 2017 19:07:09 -0400 Subject: [PATCH] handle the empty user metadata --- .../commands/workspace/GetAllProjectMetadataCommand.java | 8 +++++--- main/src/com/google/refine/io/FileProjectManager.java | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/main/src/com/google/refine/commands/workspace/GetAllProjectMetadataCommand.java b/main/src/com/google/refine/commands/workspace/GetAllProjectMetadataCommand.java index 6d75510da..018cbb7cb 100644 --- a/main/src/com/google/refine/commands/workspace/GetAllProjectMetadataCommand.java +++ b/main/src/com/google/refine/commands/workspace/GetAllProjectMetadataCommand.java @@ -76,10 +76,12 @@ public class GetAllProjectMetadataCommand extends Command { } writer.endObject(); - writer.key("customMetaDataColumns"); - JSONArray customMetaDataColumns = new JSONArray( - (String)ProjectManager.singleton.getPreferenceStore().get("userMetaData")); + String userMeta = (String)ProjectManager.singleton.getPreferenceStore().get("userMetaData"); + if (userMeta != null) { + writer.key("customMetaDataColumns"); + JSONArray customMetaDataColumns = new JSONArray(userMeta); writer.value(customMetaDataColumns); + } writer.endObject(); } catch (JSONException e) { diff --git a/main/src/com/google/refine/io/FileProjectManager.java b/main/src/com/google/refine/io/FileProjectManager.java index 0afd7997b..beccf4c5a 100644 --- a/main/src/com/google/refine/io/FileProjectManager.java +++ b/main/src/com/google/refine/io/FileProjectManager.java @@ -413,7 +413,10 @@ public class FileProjectManager extends ProjectManager { JSONArray jsonObjArray = metadata.getUserMetadata(); try { - userMetadataPreference = new JSONArray((String)_preferenceStore.get(PreferenceStore.USER_METADATA_KEY)); + String userMeta = (String)_preferenceStore.get(PreferenceStore.USER_METADATA_KEY); + if (userMeta == null) + return; + userMetadataPreference = new JSONArray(userMeta); } catch (JSONException e1) { logger.error(ExceptionUtils.getFullStackTrace(e1)); }