ilgrosso commented on code in PR #1457:
URL: https://github.com/apache/syncope/pull/1457#discussion_r3593080108
##########
client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/layout/UserFormLayouts.java:
##########
@@ -0,0 +1,48 @@
+package org.apache.syncope.client.enduser.layout;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.syncope.common.lib.SyncopeConstants;
+
+public class UserFormLayouts implements Serializable {
+
+ private static final long serialVersionUID = 9106933641699158419L;
+
+ private final Map<String, UserFormLayoutInfo> layouts;
+
+ public UserFormLayouts() {
Review Comment:
Is this empty constructor really needed?
##########
client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/SyncopeWebApplication.java:
##########
@@ -271,7 +273,8 @@ public ClassPathScanImplementationLookup getLookup() {
}
public UserFormLayoutInfo getCustomFormLayout() {
- return customFormLayout;
+ String userRealm =
SyncopeEnduserSession.get().getSelfTO(true).getRealm();
Review Comment:
What happens during self registration?
##########
client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/layout/UserFormLayouts.java:
##########
@@ -0,0 +1,48 @@
+package org.apache.syncope.client.enduser.layout;
Review Comment:
Missing license header (have you ever attempted to build this?)
##########
client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/layout/UserFormLayouts.java:
##########
@@ -0,0 +1,48 @@
+package org.apache.syncope.client.enduser.layout;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.syncope.common.lib.SyncopeConstants;
+
+public class UserFormLayouts implements Serializable {
+
+ private static final long serialVersionUID = 9106933641699158419L;
+
+ private final Map<String, UserFormLayoutInfo> layouts;
+
+ public UserFormLayouts() {
+ this(null);
+ }
+
+ @JsonCreator
+ public UserFormLayouts(@JsonProperty("layouts") final Map<String,
UserFormLayoutInfo> layouts) {
+ this.layouts = layouts == null ? new HashMap<>() : new
HashMap<>(layouts);
+ this.layouts.putIfAbsent(SyncopeConstants.ROOT_REALM, new
UserFormLayoutInfo());
+ }
+
+ public Map<String, UserFormLayoutInfo> getLayouts() {
+ return layouts;
+ }
+
+ public UserFormLayoutInfo getLayout(final String realm) {
+ if (StringUtils.isNotBlank(realm)) {
Review Comment:
I think that the logic here should start first looking for the given
`realm`, then attempt to remove the substring after last `/` until the root is
reached.
Please use `StringUtils#substringAfterLast` /
`StringUtils.substringBeforeLast` and similar to clean the code.
##########
client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/SyncopeWebApplication.java:
##########
@@ -92,7 +94,7 @@ public static SyncopeWebApplication get() {
protected final List<IResource> resources;
- protected UserFormLayoutInfo customFormLayout;
+ protected UserFormLayouts customFormLayout;
Review Comment:
rename the variable as `customFormLayouts`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]