syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmarte...@apache.org
Subject [07/54] [abbrv] syncope git commit: Small enhancement in ExternalResource entity validation
Date Fri, 23 Oct 2015 10:29:08 GMT
Small enhancement in ExternalResource entity validation


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

Branch: refs/heads/SYNCOPE-156
Commit: 77c2999b339ca2c3ef510578780a17a5d0c79f3e
Parents: c1bd770
Author: Francesco Chicchiriccò <ilgrosso@apache.org>
Authored: Thu Oct 15 12:26:24 2015 +0200
Committer: Francesco Chicchiriccò <ilgrosso@apache.org>
Committed: Thu Oct 15 12:26:24 2015 +0200

----------------------------------------------------------------------
 .../entity/ExternalResourceValidator.java       | 32 ++++++++++++--------
 1 file changed, 20 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/77c2999b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/ExternalResourceValidator.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/ExternalResourceValidator.java
b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/ExternalResourceValidator.java
index 7879661..fb5a0a9 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/ExternalResourceValidator.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/ExternalResourceValidator.java
@@ -32,6 +32,7 @@ import org.apache.syncope.core.persistence.api.entity.resource.MappingItem;
 import org.apache.syncope.core.persistence.api.entity.resource.Provision;
 import org.apache.syncope.core.provisioning.api.data.MappingItemTransformer;
 import org.apache.syncope.core.provisioning.api.propagation.PropagationActions;
+import org.identityconnectors.framework.common.objects.ObjectClass;
 
 public class ExternalResourceValidator extends AbstractValidator<ExternalResourceCheck,
ExternalResource> {
 
@@ -162,22 +163,29 @@ public class ExternalResourceValidator extends AbstractValidator<ExternalResourc
             }
         }
 
+        final Set<AnyType> anyTypes = new HashSet<>();
         final Set<String> objectClasses = new HashSet<>();
-        boolean validMappings = CollectionUtils.matchesAll(resource.getProvisions(),
-                new Predicate<Provision>() {
-
-                    @Override
-                    public boolean evaluate(final Provision provision) {
-                        if (provision.getObjectClass() != null) {
-                            objectClasses.add(provision.getObjectClass().getObjectClassValue());
-                        }
-                        return isValid(provision.getAnyType(), provision.getMapping(), context);
-                    }
-                });
+        boolean validMappings = CollectionUtils.matchesAll(resource.getProvisions(), new
Predicate<Provision>() {
 
+            @Override
+            public boolean evaluate(final Provision provision) {
+                anyTypes.add(provision.getAnyType());
+                if (provision.getObjectClass() != null) {
+                    objectClasses.add(provision.getObjectClass().getObjectClassValue());
+                }
+                return isValid(provision.getAnyType(), provision.getMapping(), context);
+            }
+        });
+
+        if (anyTypes.size() < resource.getProvisions().size()) {
+            context.buildConstraintViolationWithTemplate(getTemplate(EntityViolationType.InvalidResource,
+                    "Each provision requires a different " + AnyType.class.getSimpleName())).
+                    addPropertyNode("provisions").addConstraintViolation();
+            return false;
+        }
         if (objectClasses.size() < resource.getProvisions().size()) {
             context.buildConstraintViolationWithTemplate(getTemplate(EntityViolationType.InvalidResource,
-                    "Each provision requires a different ObjectClass")).
+                    "Each provision requires a different" + ObjectClass.class.getSimpleName())).
                     addPropertyNode("provisions").addConstraintViolation();
             return false;
         }


Mime
View raw message