You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2020/10/26 12:54:14 UTC
[syncope] 02/02: [SYNCOPE-1596] Restoring read from underlying
PlainSchemaTO to properly set read-only attributes
This is an automated email from the ASF dual-hosted git repository.
ilgrosso pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/syncope.git
commit 48f89ac65431634cb0176d432daa15fbda1f8997
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Mon Oct 26 13:45:28 2020 +0100
[SYNCOPE-1596] Restoring read from underlying PlainSchemaTO to properly set read-only attributes
---
.../client/console/wizards/any/PlainAttrs.java | 6 ++-
.../client/enduser/wizards/any/PlainAttrs.java | 44 ++++++++++++----------
2 files changed, 28 insertions(+), 22 deletions(-)
diff --git a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/wizards/any/PlainAttrs.java b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/wizards/any/PlainAttrs.java
index d331e7a..b9dcda3 100644
--- a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/wizards/any/PlainAttrs.java
+++ b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/wizards/any/PlainAttrs.java
@@ -202,7 +202,8 @@ public class PlainAttrs extends AbstractAttrs<PlainSchemaTO> {
@Override
protected void populateItem(final ListItem<Attr> item) {
- setPanel(schemas, item, false);
+ PlainSchemaTO schema = schemas.get(item.getModelObject().getSchema());
+ setPanel(schemas, item, schema == null ? false : schema.isReadonly());
}
});
}
@@ -226,7 +227,8 @@ public class PlainAttrs extends AbstractAttrs<PlainSchemaTO> {
@Override
protected void populateItem(final ListItem<Attr> item) {
- setPanel(schemas, item, false);
+ PlainSchemaTO schema = schemas.get(item.getModelObject().getSchema());
+ setPanel(schemas, item, schema == null ? false : schema.isReadonly());
}
});
}
diff --git a/client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/wizards/any/PlainAttrs.java b/client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/wizards/any/PlainAttrs.java
index 5a5eeb1..7e1e66f 100644
--- a/client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/wizards/any/PlainAttrs.java
+++ b/client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/wizards/any/PlainAttrs.java
@@ -402,24 +402,26 @@ public class PlainAttrs extends AbstractAttrs<PlainSchemaTO> {
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void populateItem(final ListItem<Attr> item) {
- Attr attrTO = item.getModelObject();
+ 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()) {
+ AbstractFieldPanel<?> panel = getFieldPanel(schemas.get(attr.getSchema()));
+ if (schemas.get(attr.getSchema()).isMultivalue()) {
panel = new MultiFieldPanel.Builder<>(
new PropertyModel<>(
- attributableTO.getObject().getPlainAttr(attrTO.getSchema()), "values"))
- .build("panel", attrTO.getSchema(), FieldPanel.class.cast(panel));
+ attributableTO.getObject().getPlainAttr(attr.getSchema()), "values"))
+ .build("panel", attr.getSchema(), FieldPanel.class.cast(panel));
// SYNCOPE-1215 the entire multifield panel must be readonly, not only its field
- ((MultiFieldPanel) panel).setReadOnly(schemas.get(attrTO.getSchema()).isReadonly());
+ ((MultiFieldPanel) 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());
}
item.add(panel);
@@ -446,25 +448,27 @@ public class PlainAttrs extends AbstractAttrs<PlainSchemaTO> {
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void populateItem(final ListItem<Attr> item) {
- Attr attrTO = item.getModelObject();
+ 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()));
+ if (attr.getValues().stream().noneMatch(StringUtils::isNotBlank)) {
+ attr.getValues().clear();
+ attr.getValues().addAll(getDefaultValues(attr.getSchema()));
}
- AbstractFieldPanel<?> panel = getFieldPanel(schemas.get(attrTO.getSchema()));
- if (schemas.get(attrTO.getSchema()).isMultivalue()) {
+ AbstractFieldPanel<?> panel = getFieldPanel(schemas.get(attr.getSchema()));
+ if (schemas.get(attr.getSchema()).isMultivalue()) {
panel = new MultiFieldPanel.Builder<>(
- new PropertyModel<>(attrTO, "values")).build(
+ new PropertyModel<>(attr, "values")).build(
"panel",
- attrTO.getSchema(),
+ attr.getSchema(),
FieldPanel.class.cast(panel));
// SYNCOPE-1215 the entire multifield panel must be readonly, not only its field
- ((MultiFieldPanel) panel).setReadOnly(schemas.get(attrTO.getSchema()).isReadonly());
+ ((MultiFieldPanel) 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());
}
item.add(panel);
}