You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by an...@apache.org on 2019/06/04 09:08:23 UTC

[syncope] 02/02: default form layout info loaded by java object and not static string

This is an automated email from the ASF dual-hosted git repository.

andreapatricelli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/syncope.git

commit a123eda1dc15f1d20000087e3121ac28bd048328
Author: Andrea Patricelli <an...@apache.org>
AuthorDate: Tue Jun 4 11:07:59 2019 +0200

    default form layout info loaded by java object and not static string
---
 .../apache/syncope/client/ui/commons/Constants.java    |  7 -------
 .../client/enduser/layout/FormLayoutInfoUtils.java     | 18 +++++++++++++++++-
 .../org/apache/syncope/client/enduser/pages/Self.java  |  2 +-
 3 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/client/idrepo/common-ui/src/main/java/org/apache/syncope/client/ui/commons/Constants.java b/client/idrepo/common-ui/src/main/java/org/apache/syncope/client/ui/commons/Constants.java
index 1254ed0..579db02 100644
--- a/client/idrepo/common-ui/src/main/java/org/apache/syncope/client/ui/commons/Constants.java
+++ b/client/idrepo/common-ui/src/main/java/org/apache/syncope/client/ui/commons/Constants.java
@@ -103,13 +103,6 @@ public final class Constants {
 
     public static final String NOTIFICATION_LEVEL_PARAM = "notificationLevel";
 
-    public static final String DEFAULT_USER_FORM_LAYOUT_INFO = "{\n"
-            + "    \"formClass\" : \"org.apache.syncope.client.enduser.wizards.any.UserWizardBuilder\",\n"
-            + "    \"auxClasses\" : true,\n" + "    \"groups\" : true,\n" + "    \"plainAttrs\" : true,\n"
-            + "    \"derAttrs\" : true,\n" + "    \"virAttrs\" : true,\n" + "    \"resources\" : true,\n"
-            + "    \"whichPlainAttrs\" : {},\n" + "    \"whichDerAttrs\" : {},\n" + "    \"whichVirAttrs\" : {},\n"
-            + "    \"passwordManagement\" : true\n" + "  }";
-
     public static Component getJEXLPopover(final Component caller, final TooltipConfig.Placement placement) {
         return getJEXLPopover(caller, placement, caller.getString("jexl_ex1"), caller.getString("jexl_ex2"));
     }
diff --git a/client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/layout/FormLayoutInfoUtils.java b/client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/layout/FormLayoutInfoUtils.java
index f5517bb..283f0a0 100644
--- a/client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/layout/FormLayoutInfoUtils.java
+++ b/client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/layout/FormLayoutInfoUtils.java
@@ -36,7 +36,23 @@ import org.apache.wicket.PageReference;
  */
 public final class FormLayoutInfoUtils {
 
-    private static final ObjectMapper MAPPER = new ObjectMapper();
+    private static final ObjectMapper MAPPER;
+
+    private static final String DEFAULT_USER_FORM_LAYOUT_INFO;
+
+    static {
+        MAPPER = new ObjectMapper();
+        try {
+            DEFAULT_USER_FORM_LAYOUT_INFO = MAPPER.writeValueAsString(new UserFormLayoutInfo());
+        } catch (IOException e) {
+            throw new IllegalArgumentException("While generating default enduser layout info for "
+                    + SyncopeEnduserSession.get().getSelfTO().getUsername(), e);
+        }
+    }
+
+    public static String getDefaultValue() {
+        return DEFAULT_USER_FORM_LAYOUT_INFO;
+    }
 
     public static UserFormLayoutInfo fromJsonString(final String content) {
         try {
diff --git a/client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/pages/Self.java b/client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/pages/Self.java
index ca78a4d..bebdcfe 100644
--- a/client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/pages/Self.java
+++ b/client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/pages/Self.java
@@ -98,7 +98,7 @@ public class Self extends BaseEnduserWebPage implements IEventSource {
         final String formLayoutConfParam = confParamOps.get(
                 SyncopeEnduserSession.get().getDomain(),
                 "enduser.form.layout.info",
-                Constants.DEFAULT_USER_FORM_LAYOUT_INFO,
+                FormLayoutInfoUtils.getDefaultValue(),
                 String.class);
         userWizardBuilder = new UserWizardBuilder(
                 null,