ref #5969: check if there is a NC preference in db if not use the local NC preference
authorKatja Luther <k.luther@bgbm.org>
Thu, 15 Sep 2016 11:18:42 +0000 (13:18 +0200)
committerKatja Luther <k.luther@bgbm.org>
Thu, 15 Sep 2016 11:18:42 +0000 (13:18 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PreferencesUtil.java

index d6a8f6bf71a0e092cb73595ff550e783dac2e12b..00bbfff9643a3ed14a5f8ae878f4de1f5581c96e 100644 (file)
@@ -116,9 +116,13 @@ public class PreferencesUtil implements IPreferenceKeys {
                CdmPreference preference = null;
                if (preferredCode == null){
                        preference = controller.getPreferenceService().find(key);
-                       int index = StringUtils.lastIndexOf(preference.getValue(), ".");
-                       UUID uuid = UUID.fromString(preference.getValue().substring(index +1, preference.getValue().length()));
-                       preferredCode = NomenclaturalCode.getByUuid(uuid);
+                       if (preference == null){
+                               return;
+                       } else{
+                               int index = StringUtils.lastIndexOf(preference.getValue(), ".");
+                               UUID uuid = UUID.fromString(preference.getValue().substring(index +1, preference.getValue().length()));
+                               preferredCode = NomenclaturalCode.getByUuid(uuid);
+                       }
                } else{
                        preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode, preferredCode.getKey());
                        controller.getPreferenceService().set(preference);