syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [2/2] syncope git commit: Removing quite useless (and much confusing) AttTO#schemaInfo
Date Fri, 21 Sep 2018 07:54:46 GMT
Removing quite useless (and much confusing) AttTO#schemaInfo


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/93e1a33e
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/93e1a33e
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/93e1a33e

Branch: refs/heads/master
Commit: 93e1a33e6511b2942b10ba3f321e516f0a2742f1
Parents: a37007e
Author: Francesco Chicchiriccò <ilgrosso@apache.org>
Authored: Fri Sep 21 09:54:22 2018 +0200
Committer: Francesco Chicchiriccò <ilgrosso@apache.org>
Committed: Fri Sep 21 09:54:35 2018 +0200

----------------------------------------------------------------------
 .../panels/ParametersDirectoryPanel.java        | 17 +++++++++---
 .../client/console/panels/TogglePanel.java      |  2 +-
 .../client/console/wizards/any/PlainAttrs.java  |  6 -----
 .../client/console/wizards/any/VirAttrs.java    | 13 ++++------
 .../syncope/common/lib/AnyOperations.java       |  3 ---
 .../apache/syncope/common/lib/to/AttrTO.java    | 23 -----------------
 .../java/data/AbstractAnyDataBinder.java        | 27 +++-----------------
 .../java/data/ConfigurationDataBinderImpl.java  |  1 -
 .../syncope/fit/core/AnyObjectITCase.java       |  2 --
 .../syncope/fit/core/ConfigurationITCase.java   |  2 --
 10 files changed, 23 insertions(+), 73 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/93e1a33e/client/console/src/main/java/org/apache/syncope/client/console/panels/ParametersDirectoryPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/ParametersDirectoryPanel.java
b/client/console/src/main/java/org/apache/syncope/client/console/panels/ParametersDirectoryPanel.java
index e2ebb57..9bce309 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/ParametersDirectoryPanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/panels/ParametersDirectoryPanel.java
@@ -41,6 +41,7 @@ import org.apache.syncope.client.console.wizards.WizardMgtPanel;
 import org.apache.syncope.common.lib.to.AttrTO;
 import org.apache.syncope.common.lib.to.PlainSchemaTO;
 import org.apache.syncope.common.lib.types.AttrSchemaType;
+import org.apache.syncope.common.lib.types.SchemaType;
 import org.apache.syncope.common.lib.types.StandardEntitlement;
 import org.apache.wicket.AttributeModifier;
 import org.apache.wicket.PageReference;
@@ -146,10 +147,18 @@ public class ParametersDirectoryPanel
             private static final long serialVersionUID = -1822504503325964706L;
 
             @Override
-            public void populateItem(final Item<ICellPopulator<AttrTO>> item,
-                    final String componentId, final IModel<AttrTO> rowModel) {
-                PlainSchemaTO modelSchemaTO = (PlainSchemaTO) rowModel.getObject().getSchemaInfo();
-                AttrSchemaType type = modelSchemaTO.getType();
+            public void populateItem(
+                    final Item<ICellPopulator<AttrTO>> item,
+                    final String componentId,
+                    final IModel<AttrTO> rowModel) {
+
+                PlainSchemaTO schema = null;
+                try {
+                    schema = schemaRestClient.read(SchemaType.PLAIN, rowModel.getObject().getSchema());
+                } catch (Exception e) {
+                    LOG.error("Could not read conf schema {}", rowModel.getObject().getSchema(),
e);
+                }
+                AttrSchemaType type = schema == null ? null : schema.getType();
                 if (type == AttrSchemaType.Binary || type == AttrSchemaType.Encrypted) {
                     item.add(new Label(componentId, type.name()).
                             add(new AttributeModifier("style", "font-style:italic")));

http://git-wip-us.apache.org/repos/asf/syncope/blob/93e1a33e/client/console/src/main/java/org/apache/syncope/client/console/panels/TogglePanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/TogglePanel.java
b/client/console/src/main/java/org/apache/syncope/client/console/panels/TogglePanel.java
index 862747a..e9f8029 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/TogglePanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/panels/TogglePanel.java
@@ -193,7 +193,7 @@ public abstract class TogglePanel<T extends Serializable> extends
WizardMgtPanel
         } else if (modelObject instanceof ReportTO) {
             key = ((ReportTO) modelObject).getKey();
         } else if (modelObject instanceof AttrTO) {
-            key = ((AttrTO) modelObject).getSchemaInfo().getKey();
+            key = ((AttrTO) modelObject).getSchema();
         } else if (modelObject instanceof PolicyTO) {
             key = ((PolicyTO) modelObject).getKey();
         } else if (modelObject instanceof SecurityQuestionTO) {

http://git-wip-us.apache.org/repos/asf/syncope/blob/93e1a33e/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/PlainAttrs.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/PlainAttrs.java
b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/PlainAttrs.java
index 722adc9..7357313 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/PlainAttrs.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/PlainAttrs.java
@@ -174,9 +174,6 @@ public class PlainAttrs extends AbstractAttrs<PlainSchemaTO> {
             attrTO.setSchema(schema.getKey());
             if (attrMap.get(schema.getKey()) == null || attrMap.get(schema.getKey()).getValues().isEmpty())
{
                 attrTO.getValues().add("");
-
-                // is important to set the schema info only after values setting
-                attrTO.setSchemaInfo(schema);
             } else {
                 attrTO = attrMap.get(schema.getKey());
             }
@@ -205,9 +202,6 @@ public class PlainAttrs extends AbstractAttrs<PlainSchemaTO> {
                     attrTO.setSchema(schema.getKey());
                     if (attrMap.get(schema.getKey()) == null || attrMap.get(schema.getKey()).getValues().isEmpty())
{
                         attrTO.getValues().add(StringUtils.EMPTY);
-
-                        // is important to set the schema info only after values setting
-                        attrTO.setSchemaInfo(schema);
                     } else {
                         attrTO.getValues().addAll(attrMap.get(schema.getKey()).getValues());
                     }

http://git-wip-us.apache.org/repos/asf/syncope/blob/93e1a33e/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/VirAttrs.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/VirAttrs.java
b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/VirAttrs.java
index d2ceaef..ef20e54 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/VirAttrs.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/VirAttrs.java
@@ -188,26 +188,23 @@ public class VirAttrs extends AbstractAttrs<VirSchemaTO> {
                 @SuppressWarnings("unchecked")
                 protected void populateItem(final ListItem<AttrTO> item) {
                     AttrTO attrTO = item.getModelObject();
+                    VirSchemaTO virSchemaTO = schemas.get(attrTO.getSchema());
 
                     AbstractFieldPanel<?> panel = new AjaxTextFieldPanel(
                             "panel",
-                            schemas.get(attrTO.getSchema()).getLabel(SyncopeConsoleSession.get().getLocale()),
+                            virSchemaTO.getLabel(SyncopeConsoleSession.get().getLocale()),
                             new Model<>(),
                             false);
 
-                    boolean readonly = attrTO.getSchemaInfo() == null
-                            ? false
-                            : VirSchemaTO.class.cast(attrTO.getSchemaInfo()).isReadonly();
-
                     if (mode == AjaxWizard.Mode.TEMPLATE) {
-                        AjaxTextFieldPanel.class.cast(panel).enableJexlHelp().setEnabled(!readonly);
+                        AjaxTextFieldPanel.class.cast(panel).enableJexlHelp().setEnabled(!virSchemaTO.isReadonly());
                     } else {
                         panel = new MultiFieldPanel.Builder<>(
                                 new PropertyModel<List<String>>(attrTO, "values")).build(
                                 "panel",
-                                schemas.get(attrTO.getSchema()).getLabel(SyncopeConsoleSession.get().getLocale()),
+                                virSchemaTO.getLabel(SyncopeConsoleSession.get().getLocale()),
                                 AjaxTextFieldPanel.class.cast(panel));
-                        panel.setEnabled(!readonly);
+                        panel.setEnabled(!virSchemaTO.isReadonly());
                     }
 
                     item.add(panel);

http://git-wip-us.apache.org/repos/asf/syncope/blob/93e1a33e/common/lib/src/main/java/org/apache/syncope/common/lib/AnyOperations.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/AnyOperations.java b/common/lib/src/main/java/org/apache/syncope/common/lib/AnyOperations.java
index 966b1f3..0e1b688 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/AnyOperations.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/AnyOperations.java
@@ -407,9 +407,6 @@ public final class AnyOperations {
                 LOG.warn("Invalid {} specified: {}", AttrPatch.class.getName(), patch);
             } else {
                 AttrTO removed = rwattrs.remove(patch.getAttrTO().getSchema());
-                if (removed != null && removed.getSchemaInfo() != null) {
-                    patch.getAttrTO().setSchemaInfo(removed.getSchemaInfo());
-                }
                 if (patch.getOperation() == PatchOperation.ADD_REPLACE && !patch.getAttrTO().getValues().isEmpty())
{
                     rwattrs.put(patch.getAttrTO().getSchema(), patch.getAttrTO());
                 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/93e1a33e/common/lib/src/main/java/org/apache/syncope/common/lib/to/AttrTO.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/AttrTO.java b/common/lib/src/main/java/org/apache/syncope/common/lib/to/AttrTO.java
index f44258c..b06b6b4 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/to/AttrTO.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/AttrTO.java
@@ -20,7 +20,6 @@ package org.apache.syncope.common.lib.to;
 
 import org.apache.syncope.common.lib.AbstractBaseBean;
 import com.fasterxml.jackson.annotation.JsonProperty;
-import io.swagger.v3.oas.annotations.media.Schema;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -46,11 +45,6 @@ public class AttrTO extends AbstractBaseBean {
             return this;
         }
 
-        public Builder schemaInfo(final SchemaTO schemaInfo) {
-            instance.schemaInfo = schemaInfo;
-            return this;
-        }
-
         public Builder value(final String value) {
             instance.getValues().add(value);
             return this;
@@ -72,11 +66,6 @@ public class AttrTO extends AbstractBaseBean {
     }
 
     /**
-     * (Optional) schema information for this attribute.
-     */
-    private SchemaTO schemaInfo;
-
-    /**
      * Name of the schema that this attribute is referring to.
      */
     private String schema;
@@ -87,18 +76,6 @@ public class AttrTO extends AbstractBaseBean {
     private final List<String> values = new ArrayList<>();
 
     /**
-     * @return schema information for this attribute; may be {@code NULL}
-     */
-    @Schema(accessMode = Schema.AccessMode.READ_ONLY)
-    public SchemaTO getSchemaInfo() {
-        return schemaInfo;
-    }
-
-    public void setSchemaInfo(final SchemaTO schemaInfo) {
-        this.schemaInfo = schemaInfo;
-    }
-
-    /**
      * @return the name of the schema that this attribute is referring to
      */
     @JsonProperty(required = true)

http://git-wip-us.apache.org/repos/asf/syncope/blob/93e1a33e/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AbstractAnyDataBinder.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AbstractAnyDataBinder.java
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AbstractAnyDataBinder.java
index 28f44af..5c134df 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AbstractAnyDataBinder.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AbstractAnyDataBinder.java
@@ -77,7 +77,6 @@ import org.apache.syncope.core.provisioning.api.IntAttrName;
 import org.apache.syncope.core.provisioning.api.MappingManager;
 import org.apache.syncope.core.provisioning.api.PropagationByResource;
 import org.apache.syncope.core.provisioning.api.VirAttrHandler;
-import org.apache.syncope.core.provisioning.api.data.SchemaDataBinder;
 import org.apache.syncope.core.provisioning.java.IntAttrNameParser;
 import org.apache.syncope.core.provisioning.java.jexl.JexlUtils;
 import org.apache.syncope.core.provisioning.java.utils.MappingUtils;
@@ -90,9 +89,6 @@ abstract class AbstractAnyDataBinder {
     protected static final Logger LOG = LoggerFactory.getLogger(AbstractAnyDataBinder.class);
 
     @Autowired
-    protected SchemaDataBinder schemaDataBinder;
-
-    @Autowired
     protected RealmDAO realmDAO;
 
     @Autowired
@@ -559,29 +555,17 @@ abstract class AbstractAnyDataBinder {
         anyTO.getAuxClasses().addAll(auxClasses.stream().map(Entity::getKey).collect(Collectors.toList()));
 
         plainAttrs.forEach(plainAttr -> {
-            AttrTO.Builder attrTOBuilder = new AttrTO.Builder().
+            anyTO.getPlainAttrs().add(new AttrTO.Builder().
                     schema(plainAttr.getSchema().getKey()).
-                    values(plainAttr.getValuesAsStrings());
-            if (details) {
-                attrTOBuilder.schemaInfo(schemaDataBinder.getPlainSchemaTO(plainAttr.getSchema().getKey()));
-            }
-            anyTO.getPlainAttrs().add(attrTOBuilder.build());
+                    values(plainAttr.getValuesAsStrings()).build());
         });
 
         derAttrs.forEach((schema, value) -> {
-            AttrTO.Builder attrTOBuilder = new AttrTO.Builder().schema(schema.getKey()).value(value);
-            if (details) {
-                attrTOBuilder.schemaInfo(schemaDataBinder.getDerSchemaTO(schema.getKey()));
-            }
-            anyTO.getDerAttrs().add(attrTOBuilder.build());
+            anyTO.getDerAttrs().add(new AttrTO.Builder().schema(schema.getKey()).value(value).build());
         });
 
         virAttrs.forEach((schema, values) -> {
-            AttrTO.Builder attrTOBuilder = new AttrTO.Builder().schema(schema.getKey()).values(values);
-            if (details) {
-                attrTOBuilder.schemaInfo(schemaDataBinder.getVirSchemaTO(schema.getKey()));
-            }
-            anyTO.getVirAttrs().add(attrTOBuilder.build());
+            anyTO.getVirAttrs().add(new AttrTO.Builder().schema(schema.getKey()).values(values).build());
         });
 
         anyTO.getResources().addAll(resources.stream().map(Entity::getKey).collect(Collectors.toSet()));
@@ -607,7 +591,6 @@ abstract class AbstractAnyDataBinder {
             membershipTO.getPlainAttrs().add(new AttrTO.Builder().
                     schema(plainAttr.getSchema().getKey()).
                     values(plainAttr.getValuesAsStrings()).
-                    schemaInfo(schemaDataBinder.getPlainSchemaTO(plainAttr.getSchema().getKey())).
                     build());
         });
 
@@ -615,7 +598,6 @@ abstract class AbstractAnyDataBinder {
             membershipTO.getDerAttrs().add(new AttrTO.Builder().
                     schema(schema.getKey()).
                     value(value).
-                    schemaInfo(schemaDataBinder.getDerSchemaTO(schema.getKey())).
                     build());
         });
 
@@ -623,7 +605,6 @@ abstract class AbstractAnyDataBinder {
             membershipTO.getVirAttrs().add(new AttrTO.Builder().
                     schema(schema.getKey()).
                     values(values).
-                    schemaInfo(schemaDataBinder.getVirSchemaTO(schema.getKey())).
                     build());
         });
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/93e1a33e/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/ConfigurationDataBinderImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/ConfigurationDataBinderImpl.java
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/ConfigurationDataBinderImpl.java
index e71c54f..f207ae6 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/ConfigurationDataBinderImpl.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/ConfigurationDataBinderImpl.java
@@ -54,7 +54,6 @@ public class ConfigurationDataBinderImpl extends AbstractAnyDataBinder implement
     @Override
     public AttrTO getAttrTO(final CPlainAttr attr) {
         return new AttrTO.Builder().
-                schemaInfo(schemaDataBinder.getPlainSchemaTO(attr.getSchema().getKey())).
                 schema(attr.getSchema().getKey()).
                 values(attr.getValuesAsStrings()).
                 build();

http://git-wip-us.apache.org/repos/asf/syncope/blob/93e1a33e/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AnyObjectITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AnyObjectITCase.java
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AnyObjectITCase.java
index e97ebd8..36cd40f 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AnyObjectITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AnyObjectITCase.java
@@ -178,8 +178,6 @@ public class AnyObjectITCase extends AbstractITCase {
         anyObjectService.update(anyObjectTO.getKey(), SchemaType.PLAIN, updated);
 
         AttrTO location = anyObjectService.read(anyObjectTO.getKey(), SchemaType.PLAIN, "location");
-        // need to remove schemaInfo which is included when reading the any object
-        location.setSchemaInfo(null);
         assertEquals(updated, location);
     }
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/93e1a33e/fit/core-reference/src/test/java/org/apache/syncope/fit/core/ConfigurationITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/ConfigurationITCase.java
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/ConfigurationITCase.java
index e94e3d7..c6a3438 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/ConfigurationITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/ConfigurationITCase.java
@@ -58,7 +58,6 @@ public class ConfigurationITCase extends AbstractITCase {
         configurationService.set(conf);
 
         AttrTO actual = configurationService.get(conf.getSchema());
-        actual.setSchemaInfo(null);
         assertEquals(actual, conf);
     }
 
@@ -82,7 +81,6 @@ public class ConfigurationITCase extends AbstractITCase {
         configurationService.set(conf);
 
         AttrTO actual = configurationService.get(conf.getSchema());
-        actual.setSchemaInfo(null);
         assertEquals(actual, conf);
     }
 


Mime
View raw message