This is an automated email from the ASF dual-hosted git repository.
ilgrosso pushed a commit to branch 3_0_X
in repository https://gitbox.apache.org/repos/asf/syncope.git
The following commit(s) were added to refs/heads/3_0_X by this push:
new 3f1346e2cd [SYNCOPE-1820] Ensure to get label if available for
multivalue attributes on Console and Enduser
3f1346e2cd is described below
commit 3f1346e2cdbd315a0ee58873c3b1cc2595875d35
Author: Francesco Chicchiriccò <[email protected]>
AuthorDate: Thu May 9 17:17:51 2024 +0200
[SYNCOPE-1820] Ensure to get label if available for multivalue attributes
on Console and Enduser
---
.../wizards/any/AbstractAttrsWizardStep.java | 11 +++++-----
.../client/enduser/panels/any/AbstractAttrs.java | 16 +++++++-------
.../client/enduser/panels/any/PlainAttrs.java | 25 ++++++++++++----------
3 files changed, 27 insertions(+), 25 deletions(-)
diff --git
a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/wizards/any/AbstractAttrsWizardStep.java
b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/wizards/any/AbstractAttrsWizardStep.java
index 7764fdc28c..6e795a7987 100644
---
a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/wizards/any/AbstractAttrsWizardStep.java
+++
b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/wizards/any/AbstractAttrsWizardStep.java
@@ -403,19 +403,18 @@ public abstract class AbstractAttrsWizardStep<S extends
SchemaTO> extends Wizard
final boolean setReadOnly) {
Attr attr = item.getModelObject();
- final boolean isMultivalue = mode != AjaxWizard.Mode.TEMPLATE
- && schemas.get(attr.getSchema()).isMultivalue();
+ PlainSchemaTO schema = schemas.get(attr.getSchema());
- AbstractFieldPanel<?> panel =
getFieldPanel(schemas.get(attr.getSchema()));
- if (isMultivalue) {
+ AbstractFieldPanel<?> panel = getFieldPanel(schema);
+ if (mode != AjaxWizard.Mode.TEMPLATE && schema.isMultivalue()) {
// SYNCOPE-1476 set form as multipart to properly manage
membership attributes
panel = new MultiFieldPanel.Builder<>(
new PropertyModel<>(attr, "values")).build(
"panel",
- attr.getSchema(),
+
schema.getLabel(SyncopeConsoleSession.get().getLocale()),
FieldPanel.class.cast(panel)).setFormAsMultipart(true);
// SYNCOPE-1215 the entire multifield panel must be readonly,
not only its field
-
MultiFieldPanel.class.cast(panel).setReadOnly(schemas.get(attr.getSchema()).isReadonly());
+
MultiFieldPanel.class.cast(panel).setReadOnly(schema.isReadonly());
MultiFieldPanel.class.cast(panel).setFormReadOnly(setReadOnly);
} else {
FieldPanel.class.cast(panel).setNewModel(attr.getValues()).setReadOnly(setReadOnly);
diff --git
a/client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/panels/any/AbstractAttrs.java
b/client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/panels/any/AbstractAttrs.java
index f7cf9fcd21..d67c18922e 100644
---
a/client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/panels/any/AbstractAttrs.java
+++
b/client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/panels/any/AbstractAttrs.java
@@ -25,8 +25,8 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
-import org.apache.cxf.common.util.StringUtils;
import org.apache.syncope.client.enduser.layout.CustomizationOption;
import org.apache.syncope.client.enduser.rest.SchemaRestClient;
import org.apache.syncope.client.enduser.rest.SyncopeRestClient;
@@ -129,8 +129,8 @@ public abstract class AbstractAttrs<S extends SchemaTO>
extends Panel {
protected boolean renderAsReadonly(final String schema, final String
groupName) {
// whether to render the attribute as readonly or not, without
considering schema readonly property
- String schemaName =
(org.apache.commons.lang3.StringUtils.isBlank(groupName)
- ? org.apache.commons.lang3.StringUtils.EMPTY
+ String schemaName = (StringUtils.isBlank(groupName)
+ ? StringUtils.EMPTY
: groupName + '#')
+ schema;
return whichAttrs.get(schemaName) == null ? false :
whichAttrs.get(schemaName).isReadonly();
@@ -141,8 +141,8 @@ public abstract class AbstractAttrs<S extends SchemaTO>
extends Panel {
}
protected List<String> getDefaultValues(final String schema, final String
groupName) {
- String schemaName =
(org.apache.commons.lang3.StringUtils.isBlank(groupName)
- ? org.apache.commons.lang3.StringUtils.EMPTY
+ String schemaName = (StringUtils.isBlank(groupName)
+ ? StringUtils.EMPTY
: groupName + '#')
+ schema;
return whichAttrs.get(schemaName) == null
@@ -181,7 +181,7 @@ public abstract class AbstractAttrs<S extends SchemaTO>
extends Panel {
if (filterSchemas()) {
// 1. remove attributes not selected for display
allSchemas.removeAll(allSchemas.stream().
- filter(schemaTO ->
org.apache.commons.lang3.StringUtils.isBlank(groupName)
+ filter(schemaTO -> StringUtils.isBlank(groupName)
? !whichAttrs.containsKey(schemaTO.getKey())
: !whichAttrs.containsKey(groupName + '#' +
schemaTO.getKey())).collect(Collectors.toSet()));
}
@@ -237,10 +237,10 @@ public abstract class AbstractAttrs<S extends SchemaTO>
extends Panel {
@Override
public int compare(final Attr left, final Attr right) {
- if (left == null || StringUtils.isEmpty(left.getSchema())) {
+ if (left == null || StringUtils.isBlank(left.getSchema())) {
return -1;
}
- if (right == null || StringUtils.isEmpty(right.getSchema())) {
+ if (right == null || StringUtils.isBlank(right.getSchema())) {
return 1;
} else if (AbstractAttrs.this.filterSchemas()) {
int leftIndex = new
ArrayList<>(AbstractAttrs.this.whichAttrs.keySet()).indexOf(left.getSchema());
diff --git
a/client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/panels/any/PlainAttrs.java
b/client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/panels/any/PlainAttrs.java
index ecc6cdd405..1575a903f5 100644
---
a/client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/panels/any/PlainAttrs.java
+++
b/client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/panels/any/PlainAttrs.java
@@ -354,23 +354,26 @@ public class PlainAttrs extends
AbstractAttrs<PlainSchemaTO> {
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void populateItem(final ListItem<Attr> item) {
- Attr attrTO = item.getModelObject();
- PlainSchemaTO schema = schemas.get(attrTO.getSchema());
+ Attr attr = item.getModelObject();
+ PlainSchemaTO schema = schemas.get(attr.getSchema());
// set default values, if any
- if
(attrTO.getValues().stream().noneMatch(StringUtils::isNotBlank)) {
- attrTO.getValues().clear();
-
attrTO.getValues().addAll(getDefaultValues(attrTO.getSchema(), groupName));
+ if
(attr.getValues().stream().noneMatch(StringUtils::isNotBlank)) {
+ attr.getValues().clear();
+
attr.getValues().addAll(getDefaultValues(attr.getSchema(), groupName));
}
- AbstractFieldPanel<?> panel =
getFieldPanel(schemas.get(attrTO.getSchema()));
- if (schemas.get(attrTO.getSchema()).isMultivalue()) {
- panel = new MultiFieldPanel.Builder<>(new
PropertyModel<>(attrTO, "values")).
- build("panel", attrTO.getSchema(),
FieldPanel.class.cast(panel));
+ AbstractFieldPanel<?> panel =
getFieldPanel(schemas.get(attr.getSchema()));
+ if (schemas.get(attr.getSchema()).isMultivalue()) {
+ panel = new MultiFieldPanel.Builder<>(
+ new PropertyModel<>(attr, "values")).build(
+ "panel",
+
schemas.get(attr.getSchema()).getLabel(SyncopeEnduserSession.get().getLocale()),
+ FieldPanel.class.cast(panel));
// SYNCOPE-1215 the entire multifield panel must be
readonly, not only its field
- ((MultiFieldPanel) panel).setReadOnly(schema == null ?
false : schema.isReadonly());
+ panel.setReadOnly(schema == null ? false :
schema.isReadonly());
} else {
-
FieldPanel.class.cast(panel).setNewModel(attrTO.getValues()).
+
FieldPanel.class.cast(panel).setNewModel(attr.getValues()).
setReadOnly(schema == null ? false :
schema.isReadonly());
}