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 2012/10/15 17:12:49 UTC

svn commit: r1398326 - in /incubator/syncope/trunk: client/src/main/java/org/apache/syncope/client/to/ console/src/main/java/org/apache/syncope/console/pages/panels/ console/src/main/resources/org/apache/syncope/console/pages/ console/src/main/resource...

Author: ilgrosso
Date: Mon Oct 15 15:12:48 2012
New Revision: 1398326

URL: http://svn.apache.org/viewvc?rev=1398326&view=rev
Log:
[SYNCOPE-222] Extending AbstractAttributableDataBinder for checking mandatory conditions on derived and external attributes

Modified:
    incubator/syncope/trunk/client/src/main/java/org/apache/syncope/client/to/ResourceTO.java
    incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/ResourceDetailsPanel.java
    incubator/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/ResourceModalPage.properties
    incubator/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/ResourceModalPage_it.properties
    incubator/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/panels/ResourceDetailsPanel.html
    incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractAttr.java
    incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractAttributable.java
    incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/ExternalResource.java
    incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/SchemaMapping.java
    incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/membership/MVirAttr.java
    incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RVirAttr.java
    incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/UVirAttr.java
    incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/DerSchemaDAOImpl.java
    incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/SchemaDAOImpl.java
    incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/VirSchemaDAOImpl.java
    incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/DerivedSchemaController.java
    incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/VirtualSchemaController.java
    incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/AbstractAttributableDataBinder.java
    incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/ResourceDataBinder.java
    incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/SchemaDataBinder.java
    incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java
    incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/util/AttributableUtil.java
    incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/util/JexlUtil.java
    incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/persistence/relationships/ResourceTest.java
    incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java
    incubator/syncope/trunk/core/src/test/resources/content.xml

Modified: incubator/syncope/trunk/client/src/main/java/org/apache/syncope/client/to/ResourceTO.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/client/src/main/java/org/apache/syncope/client/to/ResourceTO.java?rev=1398326&r1=1398325&r2=1398326&view=diff
==============================================================================
--- incubator/syncope/trunk/client/src/main/java/org/apache/syncope/client/to/ResourceTO.java (original)
+++ incubator/syncope/trunk/client/src/main/java/org/apache/syncope/client/to/ResourceTO.java Mon Oct 15 15:12:48 2012
@@ -54,10 +54,7 @@ public class ResourceTO extends Abstract
 
     private PropagationMode propagationMode;
 
-    /**
-     * Force mandatory constraint.
-     */
-    private boolean forceMandatoryConstraint;
+    private boolean enforceMandatoryCondition;
 
     private TraceLevel createTraceLevel;
 
@@ -89,12 +86,12 @@ public class ResourceTO extends Abstract
         syncTraceLevel = TraceLevel.ALL;
     }
 
-    public boolean isForceMandatoryConstraint() {
-        return forceMandatoryConstraint;
+    public boolean isEnforceMandatoryCondition() {
+        return enforceMandatoryCondition;
     }
 
-    public void setForceMandatoryConstraint(boolean forceMandatoryConstraint) {
-        this.forceMandatoryConstraint = forceMandatoryConstraint;
+    public void setEnforceMandatoryCondition(boolean enforceMandatoryCondition) {
+        this.enforceMandatoryCondition = enforceMandatoryCondition;
     }
 
     public Long getConnectorId() {

Modified: incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/ResourceDetailsPanel.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/ResourceDetailsPanel.java?rev=1398326&r1=1398325&r2=1398326&view=diff
==============================================================================
--- incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/ResourceDetailsPanel.java (original)
+++ incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/ResourceDetailsPanel.java Mon Oct 15 15:12:48 2012
@@ -20,6 +20,16 @@ package org.apache.syncope.console.pages
 
 import java.util.Arrays;
 import java.util.List;
+import org.apache.syncope.client.to.ConnInstanceTO;
+import org.apache.syncope.client.to.ResourceTO;
+import org.apache.syncope.console.pages.ResourceModalPage.ResourceEvent;
+import org.apache.syncope.console.rest.ConnectorRestClient;
+import org.apache.syncope.console.wicket.markup.html.form.AjaxCheckBoxPanel;
+import org.apache.syncope.console.wicket.markup.html.form.AjaxDropDownChoicePanel;
+import org.apache.syncope.console.wicket.markup.html.form.AjaxNumberFieldPanel;
+import org.apache.syncope.console.wicket.markup.html.form.AjaxTextFieldPanel;
+import org.apache.syncope.types.PropagationMode;
+import org.apache.syncope.types.TraceLevel;
 import org.apache.wicket.ajax.AjaxRequestTarget;
 import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
 import org.apache.wicket.event.Broadcast;
@@ -33,16 +43,6 @@ import org.apache.wicket.model.ResourceM
 import org.apache.wicket.spring.injection.annot.SpringBean;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.apache.syncope.client.to.ConnInstanceTO;
-import org.apache.syncope.client.to.ResourceTO;
-import org.apache.syncope.console.pages.ResourceModalPage.ResourceEvent;
-import org.apache.syncope.console.rest.ConnectorRestClient;
-import org.apache.syncope.console.wicket.markup.html.form.AjaxCheckBoxPanel;
-import org.apache.syncope.console.wicket.markup.html.form.AjaxDropDownChoicePanel;
-import org.apache.syncope.console.wicket.markup.html.form.AjaxNumberFieldPanel;
-import org.apache.syncope.console.wicket.markup.html.form.AjaxTextFieldPanel;
-import org.apache.syncope.types.PropagationMode;
-import org.apache.syncope.types.TraceLevel;
 
 public class ResourceDetailsPanel extends Panel {
 
@@ -82,10 +82,10 @@ public class ResourceDetailsPanel extend
         resourceName.addRequiredLabel();
         add(resourceName);
 
-        final AjaxCheckBoxPanel forceMandatoryConstraint = new AjaxCheckBoxPanel("forceMandatoryConstraint",
-                new ResourceModel("forceMandatoryConstraint", "forceMandatoryConstraint").getObject(),
-                new PropertyModel<Boolean>(resourceTO, "forceMandatoryConstraint"));
-        add(forceMandatoryConstraint);
+        final AjaxCheckBoxPanel enforceMandatoryCondition = new AjaxCheckBoxPanel("enforceMandatoryCondition",
+                new ResourceModel("enforceMandatoryCondition", "enforceMandatoryCondition").getObject(),
+                new PropertyModel<Boolean>(resourceTO, "enforceMandatoryCondition"));
+        add(enforceMandatoryCondition);
 
         final AjaxCheckBoxPanel propagationPrimary = new AjaxCheckBoxPanel("propagationPrimary", new ResourceModel(
                 "propagationPrimary", "propagationPrimary").getObject(), new PropertyModel<Boolean>(resourceTO,

Modified: incubator/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/ResourceModalPage.properties
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/ResourceModalPage.properties?rev=1398326&r1=1398325&r2=1398326&view=diff
==============================================================================
--- incubator/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/ResourceModalPage.properties (original)
+++ incubator/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/ResourceModalPage.properties Mon Oct 15 15:12:48 2012
@@ -36,7 +36,7 @@ mappingUserSchema=Mapping User Schema
 mappingRoleSchema=Mapping Role Schema
 delete=Delete
 intAttrNames=Internal Attributes
-forceMandatoryConstraint=Enforce mandatory constraints
+enforceMandatoryCondition=Enforce mandatory condition
 fieldName=Field name
 
 accountIdValidation=There must be exactly one AccountId

Modified: incubator/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/ResourceModalPage_it.properties
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/ResourceModalPage_it.properties?rev=1398326&r1=1398325&r2=1398326&view=diff
==============================================================================
--- incubator/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/ResourceModalPage_it.properties (original)
+++ incubator/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/ResourceModalPage_it.properties Mon Oct 15 15:12:48 2012
@@ -37,7 +37,7 @@ mappingUserSchema=Mapping User Schema
 mappingRoleSchema=Mapping Role Schema
 delete=Rimuovi
 intAttrNames=Attributi interni
-forceMandatoryConstraint=Forza mandatory constraint
+enforceMandatoryCondition=Abilita mandatory condition
 fieldName=Nome campo
 
 accountIdValidation=Deve essere definito esattamente un AccountId

Modified: incubator/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/panels/ResourceDetailsPanel.html
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/panels/ResourceDetailsPanel.html?rev=1398326&r1=1398325&r2=1398326&view=diff
==============================================================================
--- incubator/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/panels/ResourceDetailsPanel.html (original)
+++ incubator/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/panels/ResourceDetailsPanel.html Mon Oct 15 15:12:48 2012
@@ -35,10 +35,10 @@
 
             <div class="tablerow">
                 <div class="tablecolumn_label medium_fixedsize">
-                    <label for="forceMandatoryConstraint"><wicket:message key="forceMandatoryConstraint"/></label>
+                    <label for="enforceMandatoryCondition"><wicket:message key="enforceMandatoryCondition"/></label>
                 </div>
                 <div class="tablecolumn_field medium_dynamicsize">
-                    <span wicket:id="forceMandatoryConstraint">[forceMandatoryConstraint]</span>
+                    <span wicket:id="enforceMandatoryCondition">[enforceMandatoryCondition]</span>
                 </div>
             </div>
 

Modified: incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractAttr.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractAttr.java?rev=1398326&r1=1398325&r2=1398326&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractAttr.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractAttr.java Mon Oct 15 15:12:48 2012
@@ -39,10 +39,10 @@ public abstract class AbstractAttr exten
 
         T attrValue;
         if (getSchema().isUniqueConstraint()) {
-            attrValue = (T) attributableUtil.newAttributeUniqueValue();
+            attrValue = (T) attributableUtil.newAttrUniqueValue();
             ((AbstractAttrUniqueValue) attrValue).setSchema(getSchema());
         } else {
-            attrValue = (T) attributableUtil.newAttributeValue();
+            attrValue = (T) attributableUtil.newAttrValue();
         }
 
         attrValue.setAttribute(this);

Modified: incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractAttributable.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractAttributable.java?rev=1398326&r1=1398325&r2=1398326&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractAttributable.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractAttributable.java Mon Oct 15 15:12:48 2012
@@ -31,9 +31,8 @@ public abstract class AbstractAttributab
 
     public <T extends AbstractAttr> T getAttribute(final String schemaName) {
         T result = null;
-        T attribute;
         for (Iterator<? extends AbstractAttr> itor = getAttributes().iterator(); result == null && itor.hasNext();) {
-            attribute = (T) itor.next();
+            final T attribute = (T) itor.next();
             if (attribute.getSchema() != null && schemaName.equals(attribute.getSchema().getName())) {
                 result = attribute;
             }
@@ -42,13 +41,11 @@ public abstract class AbstractAttributab
     }
 
     public <T extends AbstractDerAttr> T getDerivedAttribute(final String derivedSchemaName) {
-
         T result = null;
-        T derivedAttribute;
         for (Iterator<? extends AbstractDerAttr> itor = getDerivedAttributes().iterator(); result == null
                 && itor.hasNext();) {
 
-            derivedAttribute = (T) itor.next();
+            final T derivedAttribute = (T) itor.next();
             if (derivedAttribute.getDerivedSchema() != null
                     && derivedSchemaName.equals(derivedAttribute.getDerivedSchema().getName())) {
 
@@ -60,14 +57,11 @@ public abstract class AbstractAttributab
     }
 
     public <T extends AbstractVirAttr> T getVirtualAttribute(final String virtualSchemaName) {
-
         T result = null;
-        T virtualAttribute;
         for (Iterator<? extends AbstractVirAttr> itor = getVirtualAttributes().iterator(); result == null
                 && itor.hasNext();) {
 
-            virtualAttribute = (T) itor.next();
-
+            final T virtualAttribute = (T) itor.next();
             if (virtualAttribute.getVirtualSchema() != null
                     && virtualSchemaName.equals(virtualAttribute.getVirtualSchema().getName())) {
 

Modified: incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/ExternalResource.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/ExternalResource.java?rev=1398326&r1=1398325&r2=1398326&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/ExternalResource.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/ExternalResource.java Mon Oct 15 15:12:48 2012
@@ -69,19 +69,17 @@ public class ExternalResource extends Ab
     @Basic
     @Min(0)
     @Max(1)
-    private Integer forceMandatoryConstraint;
+    private Integer enforceMandatoryCondition;
 
     /**
      * The resource type is identified by the associated connector.
      */
-    @ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.MERGE })
+    @ManyToOne(fetch = FetchType.EAGER, cascade = {CascadeType.MERGE})
     @NotNull
     private ConnInstance connector;
 
     /**
      * Attribute mappings.
-     *
-     * List type cannot be used. Please, take a look at https://hibernate.onjira.com/browse/HHH-1718
      */
     @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER, mappedBy = "resource")
     @Valid
@@ -155,7 +153,7 @@ public class ExternalResource extends Ab
     public ExternalResource() {
         super();
 
-        forceMandatoryConstraint = getBooleanAsInteger(false);
+        enforceMandatoryCondition = getBooleanAsInteger(false);
         mappings = new HashSet<SchemaMapping>();
         propagationPrimary = 0;
         propagationPriority = 0;
@@ -167,12 +165,12 @@ public class ExternalResource extends Ab
         syncTraceLevel = TraceLevel.FAILURES;
     }
 
-    public boolean isForceMandatoryConstraint() {
-        return isBooleanAsInteger(forceMandatoryConstraint);
+    public boolean isEnforceMandatoryCondition() {
+        return isBooleanAsInteger(enforceMandatoryCondition);
     }
 
-    public void setForceMandatoryConstraint(boolean forceMandatoryConstraint) {
-        this.forceMandatoryConstraint = getBooleanAsInteger(forceMandatoryConstraint);
+    public void setEnforceMandatoryCondition(boolean enforceMandatoryCondition) {
+        this.enforceMandatoryCondition = getBooleanAsInteger(enforceMandatoryCondition);
     }
 
     public ConnInstance getConnector() {
@@ -214,7 +212,6 @@ public class ExternalResource extends Ab
     }
 
     public Set<SchemaMapping> getMappings(final String intAttrName, final IntMappingType intMappingType) {
-
         Set<SchemaMapping> result = new HashSet<SchemaMapping>();
         for (SchemaMapping mapping : mappings) {
             if (intAttrName.equals(mapping.getIntAttrName()) && mapping.getIntMappingType() == intMappingType) {
@@ -225,7 +222,7 @@ public class ExternalResource extends Ab
         return result;
     }
 
-    public boolean removeMapping(SchemaMapping mapping) {
+    public boolean removeMapping(final SchemaMapping mapping) {
         return mappings.remove(mapping);
     }
 
@@ -248,7 +245,7 @@ public class ExternalResource extends Ab
         return accountLink;
     }
 
-    public void setAccountLink(String accountLink) {
+    public void setAccountLink(final String accountLink) {
         this.accountLink = accountLink;
     }
 
@@ -256,7 +253,7 @@ public class ExternalResource extends Ab
         return name;
     }
 
-    public void setName(String name) {
+    public void setName(final String name) {
         this.name = name;
     }
 
@@ -264,7 +261,7 @@ public class ExternalResource extends Ab
         return createTraceLevel;
     }
 
-    public void setCreateTraceLevel(TraceLevel createTraceLevel) {
+    public void setCreateTraceLevel(final TraceLevel createTraceLevel) {
         this.createTraceLevel = createTraceLevel;
     }
 
@@ -272,7 +269,7 @@ public class ExternalResource extends Ab
         return deleteTraceLevel;
     }
 
-    public void setDeleteTraceLevel(TraceLevel deleteTraceLevel) {
+    public void setDeleteTraceLevel(final TraceLevel deleteTraceLevel) {
         this.deleteTraceLevel = deleteTraceLevel;
     }
 
@@ -280,7 +277,7 @@ public class ExternalResource extends Ab
         return updateTraceLevel;
     }
 
-    public void setUpdateTraceLevel(TraceLevel updateTraceLevel) {
+    public void setUpdateTraceLevel(final TraceLevel updateTraceLevel) {
         this.updateTraceLevel = updateTraceLevel;
     }
 
@@ -288,7 +285,7 @@ public class ExternalResource extends Ab
         return syncTraceLevel;
     }
 
-    public void setSyncTraceLevel(TraceLevel syncTraceLevel) {
+    public void setSyncTraceLevel(final TraceLevel syncTraceLevel) {
         this.syncTraceLevel = syncTraceLevel;
     }
 
@@ -296,7 +293,7 @@ public class ExternalResource extends Ab
         return accountPolicy;
     }
 
-    public void setAccountPolicy(AccountPolicy accountPolicy) {
+    public void setAccountPolicy(final AccountPolicy accountPolicy) {
         this.accountPolicy = accountPolicy;
     }
 
@@ -304,7 +301,7 @@ public class ExternalResource extends Ab
         return passwordPolicy;
     }
 
-    public void setPasswordPolicy(PasswordPolicy passwordPolicy) {
+    public void setPasswordPolicy(final PasswordPolicy passwordPolicy) {
         this.passwordPolicy = passwordPolicy;
     }
 
@@ -312,12 +309,11 @@ public class ExternalResource extends Ab
         return syncPolicy;
     }
 
-    public void setSyncPolicy(SyncPolicy syncPolicy) {
+    public void setSyncPolicy(final SyncPolicy syncPolicy) {
         this.syncPolicy = syncPolicy;
     }
 
     public void setConnectorConfigurationProperties(final Set<ConnConfProperty> properties) {
-
         // create new set to make sure it's a serializable set implementation.
         xmlConfiguration = XMLSerializer.serialize(new HashSet<ConnConfProperty>(properties));
     }
@@ -327,7 +323,7 @@ public class ExternalResource extends Ab
 
         Set<ConnConfProperty> deserializedSet;
         if (StringUtils.isNotBlank(xmlConfiguration)) {
-            deserializedSet = XMLSerializer.<HashSet<ConnConfProperty>> deserialize(xmlConfiguration);
+            deserializedSet = XMLSerializer.<HashSet<ConnConfProperty>>deserialize(xmlConfiguration);
             if (deserializedSet != null) {
                 result = deserializedSet;
             }
@@ -343,7 +339,7 @@ public class ExternalResource extends Ab
     public SyncToken getSyncToken() {
         return serializedSyncToken == null
                 ? null
-                : XMLSerializer.<SyncToken> deserialize(serializedSyncToken);
+                : XMLSerializer.<SyncToken>deserialize(serializedSyncToken);
     }
 
     public void setSerializedSyncToken(final String serializedSyncToken) {

Modified: incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/SchemaMapping.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/SchemaMapping.java?rev=1398326&r1=1398325&r2=1398326&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/SchemaMapping.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/SchemaMapping.java Mon Oct 15 15:12:48 2012
@@ -18,12 +18,11 @@
  */
 package org.apache.syncope.core.persistence.beans;
 
-import static javax.persistence.EnumType.STRING;
-
 import javax.persistence.Basic;
 import javax.persistence.Cacheable;
 import javax.persistence.Column;
 import javax.persistence.Entity;
+import javax.persistence.EnumType;
 import javax.persistence.Enumerated;
 import javax.persistence.Id;
 import javax.persistence.ManyToOne;
@@ -47,7 +46,7 @@ public class SchemaMapping extends Abstr
     private String intAttrName;
 
     @Column(nullable = false)
-    @Enumerated(STRING)
+    @Enumerated(EnumType.STRING)
     private IntMappingType intMappingType;
 
     /**

Modified: incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/membership/MVirAttr.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/membership/MVirAttr.java?rev=1398326&r1=1398325&r2=1398326&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/membership/MVirAttr.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/membership/MVirAttr.java Mon Oct 15 15:12:48 2012
@@ -31,8 +31,10 @@ import org.apache.syncope.core.persisten
 public class MVirAttr extends AbstractVirAttr {
 
     private static final long serialVersionUID = 7774760571251641332L;
+
     @ManyToOne
     private Membership owner;
+
     @ManyToOne(fetch = FetchType.EAGER)
     private MVirSchema virtualSchema;
 
@@ -42,7 +44,7 @@ public class MVirAttr extends AbstractVi
     }
 
     @Override
-    public <T extends AbstractAttributable> void setOwner(T owner) {
+    public <T extends AbstractAttributable> void setOwner(final T owner) {
         if (!(owner instanceof Membership)) {
             throw new ClassCastException("expected type Membership, found: " + owner.getClass().getName());
         }
@@ -56,7 +58,7 @@ public class MVirAttr extends AbstractVi
     }
 
     @Override
-    public <T extends AbstractVirSchema> void setVirtualSchema(T virtualSchema) {
+    public <T extends AbstractVirSchema> void setVirtualSchema(final T virtualSchema) {
         if (!(virtualSchema instanceof MVirSchema)) {
             throw new ClassCastException("expected type MVirSchema, found: " + virtualSchema.getClass().getName());
         }

Modified: incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RVirAttr.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RVirAttr.java?rev=1398326&r1=1398325&r2=1398326&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RVirAttr.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RVirAttr.java Mon Oct 15 15:12:48 2012
@@ -31,8 +31,10 @@ import org.apache.syncope.core.persisten
 public class RVirAttr extends AbstractVirAttr {
 
     private static final long serialVersionUID = -1747430556914428649L;
+
     @ManyToOne
     private SyncopeRole owner;
+
     @ManyToOne(fetch = FetchType.EAGER)
     private RVirSchema virtualSchema;
 
@@ -42,7 +44,7 @@ public class RVirAttr extends AbstractVi
     }
 
     @Override
-    public <T extends AbstractAttributable> void setOwner(T owner) {
+    public <T extends AbstractAttributable> void setOwner(final T owner) {
         if (!(owner instanceof SyncopeRole)) {
             throw new ClassCastException("expected type SyncopeRole, found: " + owner.getClass().getName());
         }
@@ -55,7 +57,7 @@ public class RVirAttr extends AbstractVi
     }
 
     @Override
-    public <T extends AbstractVirSchema> void setVirtualSchema(T virtualSchema) {
+    public <T extends AbstractVirSchema> void setVirtualSchema(final T virtualSchema) {
         if (!(virtualSchema instanceof RVirSchema)) {
             throw new ClassCastException("expected type RVirSchema, found: " + virtualSchema.getClass().getName());
         }

Modified: incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/UVirAttr.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/UVirAttr.java?rev=1398326&r1=1398325&r2=1398326&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/UVirAttr.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/UVirAttr.java Mon Oct 15 15:12:48 2012
@@ -31,8 +31,10 @@ import org.apache.syncope.core.persisten
 public class UVirAttr extends AbstractVirAttr {
 
     private static final long serialVersionUID = 2943450934283989741L;
+
     @ManyToOne
     private SyncopeUser owner;
+
     @ManyToOne(fetch = FetchType.EAGER)
     private UVirSchema virtualSchema;
 
@@ -42,7 +44,7 @@ public class UVirAttr extends AbstractVi
     }
 
     @Override
-    public <T extends AbstractAttributable> void setOwner(T owner) {
+    public <T extends AbstractAttributable> void setOwner(final T owner) {
         if (!(owner instanceof SyncopeUser)) {
             throw new ClassCastException("expected type SyncopeUser, found: " + owner.getClass().getName());
         }
@@ -55,7 +57,7 @@ public class UVirAttr extends AbstractVi
     }
 
     @Override
-    public <T extends AbstractVirSchema> void setVirtualSchema(T virtualSchema) {
+    public <T extends AbstractVirSchema> void setVirtualSchema(final T virtualSchema) {
         if (!(virtualSchema instanceof UVirSchema)) {
             throw new ClassCastException("expected type UVirSchema, found: " + virtualSchema.getClass().getName());
         }

Modified: incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/DerSchemaDAOImpl.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/DerSchemaDAOImpl.java?rev=1398326&r1=1398325&r2=1398326&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/DerSchemaDAOImpl.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/DerSchemaDAOImpl.java Mon Oct 15 15:12:48 2012
@@ -61,14 +61,14 @@ public class DerSchemaDAOImpl extends Ab
     @Override
     public void delete(final String name, final AttributableUtil attributableUtil) {
 
-        final AbstractDerSchema derivedSchema = find(name, attributableUtil.derivedSchemaClass());
+        final AbstractDerSchema derivedSchema = find(name, attributableUtil.derSchemaClass());
 
         if (derivedSchema == null) {
             return;
         }
 
         List<? extends AbstractDerAttr> attributes = getAttributes(derivedSchema, attributableUtil
-                .derivedAttributeClass());
+                .derAttrClass());
 
         final Set<Long> derivedAttributeIds = new HashSet<Long>(attributes.size());
 
@@ -83,7 +83,7 @@ public class DerSchemaDAOImpl extends Ab
             derivedAttributeDAO.delete(derivedAttributeId, attributeClass);
         }
 
-        resourceDAO.deleteMappings(name, attributableUtil.derivedIntMappingType());
+        resourceDAO.deleteMappings(name, attributableUtil.derIntMappingType());
 
         entityManager.remove(derivedSchema);
     }

Modified: incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/SchemaDAOImpl.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/SchemaDAOImpl.java?rev=1398326&r1=1398325&r2=1398326&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/SchemaDAOImpl.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/SchemaDAOImpl.java Mon Oct 15 15:12:48 2012
@@ -77,14 +77,14 @@ public class SchemaDAOImpl extends Abstr
             return;
         }
 
-        List<? extends AbstractAttr> attributes = getAttributes(schema, attributableUtil.attributeClass());
+        List<? extends AbstractAttr> attributes = getAttributes(schema, attributableUtil.attrClass());
 
         Set<Long> attributeIds = new HashSet<Long>(attributes.size());
         for (AbstractAttr attribute : attributes) {
             attributeIds.add(attribute.getId());
         }
         for (Long attributeId : attributeIds) {
-            attributeDAO.delete(attributeId, attributableUtil.attributeClass());
+            attributeDAO.delete(attributeId, attributableUtil.attrClass());
         }
 
         resourceDAO.deleteMappings(name, attributableUtil.intMappingType());

Modified: incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/VirSchemaDAOImpl.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/VirSchemaDAOImpl.java?rev=1398326&r1=1398325&r2=1398326&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/VirSchemaDAOImpl.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/VirSchemaDAOImpl.java Mon Oct 15 15:12:48 2012
@@ -61,29 +61,28 @@ public class VirSchemaDAOImpl extends Ab
     @Override
     public void delete(final String name, final AttributableUtil attributableUtil) {
 
-        final AbstractVirSchema virtualSchema = find(name, attributableUtil.virtualSchemaClass());
+        final AbstractVirSchema virtualSchema = find(name, attributableUtil.virSchemaClass());
 
         if (virtualSchema == null) {
             return;
         }
 
-        List<? extends AbstractVirAttr> attributes = getAttributes(virtualSchema, attributableUtil
-                .virtualAttributeClass());
+        List<? extends AbstractVirAttr> attributes = getAttributes(virtualSchema, attributableUtil.virAttrClass());
 
-        final Set<Long> virtualAttributeIds = new HashSet<Long>(attributes.size());
+        final Set<Long> virAttrIds = new HashSet<Long>(attributes.size());
 
         Class attributeClass = null;
 
         for (AbstractVirAttr attribute : attributes) {
-            virtualAttributeIds.add(attribute.getId());
+            virAttrIds.add(attribute.getId());
             attributeClass = attribute.getClass();
         }
 
-        for (Long virtualAttributeId : virtualAttributeIds) {
+        for (Long virtualAttributeId : virAttrIds) {
             virtualAttributeDAO.delete(virtualAttributeId, attributeClass);
         }
 
-        resourceDAO.deleteMappings(name, attributableUtil.virtualIntMappingType());
+        resourceDAO.deleteMappings(name, attributableUtil.virIntMappingType());
 
         entityManager.remove(virtualSchema);
     }

Modified: incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/DerivedSchemaController.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/DerivedSchemaController.java?rev=1398326&r1=1398325&r2=1398326&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/DerivedSchemaController.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/DerivedSchemaController.java Mon Oct 15 15:12:48 2012
@@ -59,7 +59,7 @@ public class DerivedSchemaController ext
             throws SyncopeClientCompositeErrorException {
 
         AbstractDerSchema derivedSchema = derivedSchemaDAO.save(
-                derivedSchemaDataBinder.create(derivedSchemaTO, getAttributableUtil(kind).newDerivedSchema()));
+                derivedSchemaDataBinder.create(derivedSchemaTO, getAttributableUtil(kind).newDerSchema()));
 
         auditManager.audit(Category.schema, SchemaSubCategory.createDerived, Result.success,
                 "Successfully created derived schema: " + kind + "/" + derivedSchema.getName());
@@ -73,7 +73,7 @@ public class DerivedSchemaController ext
     public DerivedSchemaTO delete(@PathVariable("kind") final String kind,
             @PathVariable("schema") final String derivedSchemaName) throws NotFoundException {
 
-        Class reference = getAttributableUtil(kind).derivedSchemaClass();
+        Class reference = getAttributableUtil(kind).derSchemaClass();
         AbstractDerSchema derivedSchema = derivedSchemaDAO.find(derivedSchemaName, reference);
         if (derivedSchema == null) {
             throw new NotFoundException("Derived schema '" + derivedSchemaName + "'");
@@ -91,7 +91,7 @@ public class DerivedSchemaController ext
 
     @RequestMapping(method = RequestMethod.GET, value = "/{kind}/list")
     public List<DerivedSchemaTO> list(@PathVariable("kind") final String kind) {
-        Class reference = getAttributableUtil(kind).derivedSchemaClass();
+        Class reference = getAttributableUtil(kind).derSchemaClass();
         List<AbstractDerSchema> derivedAttributeSchemas = derivedSchemaDAO.findAll(reference);
 
         List<DerivedSchemaTO> derivedSchemaTOs = new ArrayList<DerivedSchemaTO>(derivedAttributeSchemas.size());
@@ -110,7 +110,7 @@ public class DerivedSchemaController ext
     public DerivedSchemaTO read(@PathVariable("kind") final String kind,
             @PathVariable("derivedSchema") final String derivedSchemaName) throws NotFoundException {
 
-        Class reference = getAttributableUtil(kind).derivedSchemaClass();
+        Class reference = getAttributableUtil(kind).derSchemaClass();
         AbstractDerSchema derivedSchema = derivedSchemaDAO.find(derivedSchemaName, reference);
         if (derivedSchema == null) {
             throw new NotFoundException("Derived schema '" + derivedSchemaName + "'");
@@ -127,7 +127,7 @@ public class DerivedSchemaController ext
     public DerivedSchemaTO update(@RequestBody final DerivedSchemaTO derivedSchemaTO,
             @PathVariable("kind") final String kind) throws NotFoundException {
 
-        Class reference = getAttributableUtil(kind).derivedSchemaClass();
+        Class reference = getAttributableUtil(kind).derSchemaClass();
         AbstractDerSchema derivedSchema = derivedSchemaDAO.find(derivedSchemaTO.getName(), reference);
         if (derivedSchema == null) {
             throw new NotFoundException("Derived schema '" + derivedSchemaTO.getName() + "'");

Modified: incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/VirtualSchemaController.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/VirtualSchemaController.java?rev=1398326&r1=1398325&r2=1398326&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/VirtualSchemaController.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/VirtualSchemaController.java Mon Oct 15 15:12:48 2012
@@ -59,7 +59,7 @@ public class VirtualSchemaController ext
             throws SyncopeClientCompositeErrorException {
 
         AbstractVirSchema virtualSchema = virtualSchemaDAO.save(virtualSchemaDataBinder.create(
-                virtualSchemaTO, getAttributableUtil(kind).newVirtualSchema(),
+                virtualSchemaTO, getAttributableUtil(kind).newVirSchema(),
                 getAttributableUtil(kind).schemaClass()));
 
         auditManager.audit(Category.schema, SchemaSubCategory.createVirtual, Result.success,
@@ -74,7 +74,7 @@ public class VirtualSchemaController ext
     public VirtualSchemaTO delete(@PathVariable("kind") final String kind,
             @PathVariable("schema") final String virtualSchemaName) throws NotFoundException {
 
-        Class reference = getAttributableUtil(kind).virtualSchemaClass();
+        Class reference = getAttributableUtil(kind).virSchemaClass();
         AbstractVirSchema virtualSchema = virtualSchemaDAO.find(virtualSchemaName, reference);
         if (virtualSchema == null) {
             throw new NotFoundException("Virtual schema '" + virtualSchemaName + "'");
@@ -90,7 +90,7 @@ public class VirtualSchemaController ext
 
     @RequestMapping(method = RequestMethod.GET, value = "/{kind}/list")
     public List<VirtualSchemaTO> list(@PathVariable("kind") final String kind) {
-        Class reference = getAttributableUtil(kind).virtualSchemaClass();
+        Class reference = getAttributableUtil(kind).virSchemaClass();
         List<AbstractVirSchema> virtualAttributeSchemas = virtualSchemaDAO.findAll(reference);
 
         List<VirtualSchemaTO> virtualSchemaTOs = new ArrayList<VirtualSchemaTO>(virtualAttributeSchemas.size());
@@ -109,7 +109,7 @@ public class VirtualSchemaController ext
     public VirtualSchemaTO read(@PathVariable("kind") final String kind,
             @PathVariable("virtualSchema") final String virtualSchemaName) throws NotFoundException {
 
-        Class reference = getAttributableUtil(kind).virtualSchemaClass();
+        Class reference = getAttributableUtil(kind).virSchemaClass();
         AbstractVirSchema virtualSchema = virtualSchemaDAO.find(virtualSchemaName, reference);
         if (virtualSchema == null) {
             throw new NotFoundException("Virtual schema '" + virtualSchemaName + "'");
@@ -126,7 +126,7 @@ public class VirtualSchemaController ext
     public VirtualSchemaTO update(@RequestBody final VirtualSchemaTO virtualSchemaTO,
             @PathVariable("kind") final String kind) throws SyncopeClientCompositeErrorException, NotFoundException {
 
-        Class reference = getAttributableUtil(kind).virtualSchemaClass();
+        Class reference = getAttributableUtil(kind).virSchemaClass();
         AbstractVirSchema virtualSchema = virtualSchemaDAO.find(virtualSchemaTO.getName(), reference);
         if (virtualSchema == null) {
             throw new NotFoundException("Virtual schema is null");

Modified: incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/AbstractAttributableDataBinder.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/AbstractAttributableDataBinder.java?rev=1398326&r1=1398325&r2=1398326&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/AbstractAttributableDataBinder.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/AbstractAttributableDataBinder.java Mon Oct 15 15:12:48 2012
@@ -65,6 +65,7 @@ import org.apache.syncope.core.propagati
 import org.apache.syncope.core.util.AttributableUtil;
 import org.apache.syncope.core.util.JexlUtil;
 import org.apache.syncope.types.AttributableType;
+import org.apache.syncope.types.IntMappingType;
 import org.apache.syncope.types.PropagationOperation;
 import org.apache.syncope.types.SyncopeClientExceptionType;
 
@@ -85,13 +86,13 @@ public abstract class AbstractAttributab
     protected SchemaDAO schemaDAO;
 
     @Autowired
-    protected DerSchemaDAO derivedSchemaDAO;
+    protected DerSchemaDAO derSchemaDAO;
 
     @Autowired
-    protected VirSchemaDAO virtualSchemaDAO;
+    protected VirSchemaDAO virSchemaDAO;
 
     @Autowired
-    protected AttrDAO attributeDAO;
+    protected AttrDAO attrDAO;
 
     @Autowired
     protected DerAttrDAO derAttrDAO;
@@ -141,7 +142,7 @@ public abstract class AbstractAttributab
 
         T derivedSchema = null;
         if (StringUtils.isNotBlank(derSchemaName)) {
-            derivedSchema = derivedSchemaDAO.find(derSchemaName, reference);
+            derivedSchema = derSchemaDAO.find(derSchemaName, reference);
             if (derivedSchema == null) {
                 LOG.debug("Ignoring invalid derived schema {}", derSchemaName);
             }
@@ -154,7 +155,7 @@ public abstract class AbstractAttributab
 
         T virtualSchema = null;
         if (StringUtils.isNotBlank(virSchemaName)) {
-            virtualSchema = virtualSchemaDAO.find(virSchemaName, reference);
+            virtualSchema = virSchemaDAO.find(virSchemaName, reference);
 
             if (virtualSchema == null) {
                 LOG.debug("Ignoring invalid virtual schema {}", virSchemaName);
@@ -202,42 +203,39 @@ public abstract class AbstractAttributab
     }
 
     private boolean evaluateMandatoryCondition(final String mandatoryCondition,
-            final List<? extends AbstractAttr> attributes) {
+            final AbstractAttributable attributable) {
 
         JexlContext jexlContext = new MapContext();
-        jexlUtil.addAttrsToContext(attributes, jexlContext);
+        jexlUtil.addAttrsToContext(attributable.getAttributes(), jexlContext);
+        jexlUtil.addDerAttrsToContext(attributable.getDerivedAttributes(), attributable.getAttributes(), jexlContext);
+        jexlUtil.addVirAttrsToContext(attributable.getVirtualAttributes(), jexlContext);
 
         return Boolean.parseBoolean(jexlUtil.evaluate(mandatoryCondition, jexlContext));
     }
 
-    private boolean evaluateMandatoryCondition(final ExternalResource resource,
-            final List<? extends AbstractAttr> attributes, final String intAttrName,
-            final AttributableUtil attributableUtil) {
+    private boolean evaluateMandatoryCondition(final ExternalResource resource, final AbstractAttributable attributable,
+            final String intAttrName, final IntMappingType intMappingType) {
 
         boolean result = false;
 
-        for (Iterator<SchemaMapping> itor = resource.getMappings(intAttrName, attributableUtil.intMappingType()).
-                iterator(); itor.hasNext() && !result;) {
-
-            SchemaMapping mapping = itor.next();
-            result |= evaluateMandatoryCondition(mapping.getMandatoryCondition(), attributes);
+        final Set<SchemaMapping> mappings = resource.getMappings(intAttrName, intMappingType);
+        for (Iterator<SchemaMapping> itor = mappings.iterator(); itor.hasNext() && !result;) {
+            final SchemaMapping mapping = itor.next();
+            result |= evaluateMandatoryCondition(mapping.getMandatoryCondition(), attributable);
         }
 
         return result;
     }
 
-    private boolean evaluateMandatoryCondition(final Collection<ExternalResource> resources,
-            final List<? extends AbstractAttr> attributes, final String intAttrName,
-            final AttributableUtil attributableUtil) {
+    private boolean evaluateMandatoryCondition(final AbstractAttributable attributable, final String intAttrName,
+            final IntMappingType intMappingType) {
 
         boolean result = false;
 
-        ExternalResource resource;
-        for (Iterator<ExternalResource> itor = resources.iterator(); itor.hasNext() && !result;) {
-
-            resource = itor.next();
-            if (resource.isForceMandatoryConstraint()) {
-                result |= evaluateMandatoryCondition(resource, attributes, intAttrName, attributableUtil);
+        for (Iterator<ExternalResource> itor = attributable.getResources().iterator(); itor.hasNext() && !result;) {
+            final ExternalResource resource = itor.next();
+            if (resource.isEnforceMandatoryCondition()) {
+                result |= evaluateMandatoryCondition(resource, attributable, intAttrName, intMappingType);
             }
         }
 
@@ -247,28 +245,45 @@ public abstract class AbstractAttributab
     private SyncopeClientException checkMandatory(final AttributableUtil attributableUtil,
             final AbstractAttributable attributable) {
 
-        SyncopeClientException requiredValuesMissing = new SyncopeClientException(
+        SyncopeClientException reqValMissing = new SyncopeClientException(
                 SyncopeClientExceptionType.RequiredValuesMissing);
 
         LOG.debug("Check mandatory constraint among resources {}", attributable.getResources());
-        // Check if there is some mandatory schema defined for which no value
-        // has been provided
-        List<AbstractSchema> allSchemas = schemaDAO.findAll(attributableUtil.schemaClass());
 
-        for (AbstractSchema schema : allSchemas) {
+        // Check if there is some mandatory schema defined for which no value has been provided
+        for (AbstractSchema schema : schemaDAO.findAll(attributableUtil.schemaClass())) {
             if (attributable.getAttribute(schema.getName()) == null
                     && !schema.isReadonly()
-                    && (evaluateMandatoryCondition(schema.getMandatoryCondition(), attributable.getAttributes()) || evaluateMandatoryCondition(
-                    attributable.getResources(), attributable.getAttributes(), schema.getName(),
-                    attributableUtil))) {
+                    && (evaluateMandatoryCondition(schema.getMandatoryCondition(), attributable)
+                    || evaluateMandatoryCondition(attributable, schema.getName(), attributableUtil.intMappingType()))) {
 
                 LOG.error("Mandatory schema " + schema.getName() + " not provided with values");
-                
-                requiredValuesMissing.addElement(schema.getName());
+
+                reqValMissing.addElement(schema.getName());
             }
         }
+        for (AbstractDerSchema derSchema : derSchemaDAO.findAll(attributableUtil.derSchemaClass())) {
+            if (attributable.getDerivedAttribute(derSchema.getName()) == null
+                    && evaluateMandatoryCondition(
+                    attributable, derSchema.getName(), attributableUtil.derIntMappingType())) {
+
+                LOG.error("Mandatory derived schema " + derSchema.getName() + " does not evaluate to any value");
 
-        return requiredValuesMissing;
+                reqValMissing.addElement(derSchema.getName());
+            }
+        }
+        for (AbstractVirSchema virSchema : virSchemaDAO.findAll(attributableUtil.virSchemaClass())) {
+            if (attributable.getAttribute(virSchema.getName()) == null
+                    && evaluateMandatoryCondition(
+                    attributable, virSchema.getName(), attributableUtil.virIntMappingType())) {
+
+                LOG.error("Mandatory virtual schema " + virSchema.getName() + " not provided with values");
+
+                reqValMissing.addElement(virSchema.getName());
+            }
+        }
+
+        return reqValMissing;
     }
 
     public PropagationByResource fillVirtual(final AbstractAttributable attributable,
@@ -279,32 +294,29 @@ public abstract class AbstractAttributab
 
         // 1. virtual attributes to be removed
         for (String vAttrToBeRemoved : vAttrsToBeRemoved) {
-            AbstractVirSchema virtualSchema = getVirtualSchema(vAttrToBeRemoved, attributableUtil.virtualSchemaClass());
+            AbstractVirSchema virtualSchema = getVirtualSchema(vAttrToBeRemoved, attributableUtil.virSchemaClass());
 
             if (virtualSchema != null) {
-                AbstractVirAttr virtualAttribute = attributable.getVirtualAttribute(virtualSchema.getName());
+                AbstractVirAttr virAttr = attributable.getVirtualAttribute(virtualSchema.getName());
 
-                if (virtualAttribute == null) {
+                if (virAttr == null) {
                     LOG.debug("No virtual attribute found for schema {}", virtualSchema.getName());
                 } else {
-                    attributable.removeVirtualAttribute(virtualAttribute);
-                    virAttrDAO.delete(virtualAttribute);
+                    attributable.removeVirtualAttribute(virAttr);
+                    virAttrDAO.delete(virAttr);
                 }
 
                 for (SchemaMapping mapping : resourceDAO.findAllMappings()) {
                     if (virtualSchema.getName().equals(mapping.getIntAttrName())
-                            && mapping.getIntMappingType() == attributableUtil.virtualIntMappingType()
+                            && mapping.getIntMappingType() == attributableUtil.virIntMappingType()
                             && mapping.getResource() != null
                             && attributable.getResources().contains(mapping.getResource())) {
 
                         propByRes.add(PropagationOperation.UPDATE, mapping.getResource().getName());
 
-                        // TODO: must be avoided to use virtual attribute as AccountId
-                        if (mapping.isAccountid() && virtualAttribute != null
-                                && !virtualAttribute.getValues().isEmpty()) {
-
-                            propByRes.addOldAccountId(mapping.getResource().getName(), virtualAttribute.getValues().get(
-                                    0));
+                        // TODO: using virtual attribute as AccountId must be avoided
+                        if (mapping.isAccountid() && virAttr != null && !virAttr.getValues().isEmpty()) {
+                            propByRes.addOldAccountId(mapping.getResource().getName(), virAttr.getValues().get(0));
                         }
                     }
                 }
@@ -315,13 +327,13 @@ public abstract class AbstractAttributab
 
         // 2. virtual attributes to be updated
         for (AttributeMod vAttrToBeUpdated : vAttrsToBeUpdated) {
-            AbstractVirSchema virtualSchema = getVirtualSchema(vAttrToBeUpdated.getSchema(), attributableUtil.
-                    virtualSchemaClass());
+            AbstractVirSchema virtualSchema = getVirtualSchema(vAttrToBeUpdated.getSchema(),
+                    attributableUtil.virSchemaClass());
 
             if (virtualSchema != null) {
                 for (SchemaMapping mapping : resourceDAO.findAllMappings()) {
                     if (virtualSchema.getName().equals(mapping.getIntAttrName())
-                            && mapping.getIntMappingType() == attributableUtil.virtualIntMappingType()
+                            && mapping.getIntMappingType() == attributableUtil.virIntMappingType()
                             && mapping.getResource() != null
                             && attributable.getResources().contains(mapping.getResource())) {
 
@@ -332,7 +344,7 @@ public abstract class AbstractAttributab
                 AbstractVirAttr virtualAttribute = attributable.getVirtualAttribute(virtualSchema.getName());
 
                 if (virtualAttribute == null) {
-                    virtualAttribute = attributableUtil.newVirtualAttribute();
+                    virtualAttribute = attributableUtil.newVirAttr();
                     virtualAttribute.setVirtualSchema(virtualSchema);
                     attributable.addVirtualAttribute(virtualAttribute);
                 }
@@ -415,7 +427,7 @@ public abstract class AbstractAttributab
                     if (!schema.isUniqueConstraint() || (!attribute.getUniqueValue().getStringValue().equals(newValue))) {
 
                         attributable.removeAttribute(attribute);
-                        attributeDAO.delete(attribute.getId(), attributableUtil.attributeClass());
+                        attrDAO.delete(attribute.getId(), attributableUtil.attrClass());
                     }
                 }
 
@@ -459,7 +471,7 @@ public abstract class AbstractAttributab
 
                 attribute = attributable.getAttribute(schema.getName());
                 if (attribute == null) {
-                    attribute = attributableUtil.newAttribute();
+                    attribute = attributableUtil.newAttr();
                     attribute.setSchema(schema);
                     attribute.setOwner(attributable);
 
@@ -485,7 +497,7 @@ public abstract class AbstractAttributab
                     }
                 }
                 for (Long attributeValueId : valuesToBeRemoved) {
-                    attributeValueDAO.delete(attributeValueId, attributableUtil.attributeValueClass());
+                    attributeValueDAO.delete(attributeValueId, attributableUtil.attrValueClass());
                 }
 
                 // 1.2 add values
@@ -500,7 +512,7 @@ public abstract class AbstractAttributab
 
                 // if no values are in, the attribute can be safely removed
                 if (attribute.getValuesAsStrings().isEmpty()) {
-                    attributeDAO.delete(attribute);
+                    attrDAO.delete(attribute);
                 }
             }
         }
@@ -514,7 +526,7 @@ public abstract class AbstractAttributab
         // 5. derived attributes to be removed
         for (String derivedAttributeToBeRemoved : attributableMod.getDerivedAttributesToBeRemoved()) {
 
-            derivedSchema = getDerivedSchema(derivedAttributeToBeRemoved, attributableUtil.derivedSchemaClass());
+            derivedSchema = getDerivedSchema(derivedAttributeToBeRemoved, attributableUtil.derSchemaClass());
 
             if (derivedSchema != null) {
                 derivedAttribute = attributable.getDerivedAttribute(derivedSchema.getName());
@@ -527,7 +539,7 @@ public abstract class AbstractAttributab
 
                 for (SchemaMapping mapping : resourceDAO.findAllMappings()) {
                     if (derivedSchema.getName().equals(mapping.getIntAttrName())
-                            && mapping.getIntMappingType() == attributableUtil.derivedIntMappingType()
+                            && mapping.getIntMappingType() == attributableUtil.derIntMappingType()
                             && mapping.getResource() != null
                             && attributable.getResources().contains(mapping.getResource())) {
 
@@ -549,12 +561,12 @@ public abstract class AbstractAttributab
         // 6. derived attributes to be added
         for (String derivedAttributeToBeAdded : attributableMod.getDerivedAttributesToBeAdded()) {
 
-            derivedSchema = getDerivedSchema(derivedAttributeToBeAdded, attributableUtil.derivedSchemaClass());
+            derivedSchema = getDerivedSchema(derivedAttributeToBeAdded, attributableUtil.derSchemaClass());
 
             if (derivedSchema != null) {
                 for (SchemaMapping mapping : resourceDAO.findAllMappings()) {
                     if (derivedSchema.getName().equals(mapping.getIntAttrName())
-                            && mapping.getIntMappingType() == attributableUtil.derivedIntMappingType()
+                            && mapping.getIntMappingType() == attributableUtil.derIntMappingType()
                             && mapping.getResource() != null
                             && attributable.getResources().contains(mapping.getResource())) {
 
@@ -562,7 +574,7 @@ public abstract class AbstractAttributab
                     }
                 }
 
-                derivedAttribute = attributableUtil.newDerivedAttribute();
+                derivedAttribute = attributableUtil.newDerAttr();
                 derivedAttribute.setDerivedSchema(derivedSchema);
                 derivedAttribute.setOwner(attributable);
                 attributable.addDerivedAttribute(derivedAttribute);
@@ -606,11 +618,11 @@ public abstract class AbstractAttributab
             AbstractVirAttr virtualAttribute = attributable.getVirtualAttribute(attributeTO.getSchema());
 
             if (virtualAttribute == null) {
-                AbstractVirSchema virtualSchema = getVirtualSchema(attributeTO.getSchema(), attributableUtil.
-                        virtualSchemaClass());
+                AbstractVirSchema virtualSchema = getVirtualSchema(attributeTO.getSchema(),
+                        attributableUtil.virSchemaClass());
 
                 if (virtualSchema != null) {
-                    virtualAttribute = attributableUtil.newVirtualAttribute();
+                    virtualAttribute = attributableUtil.newVirAttr();
                     virtualAttribute.setVirtualSchema(virtualSchema);
                     virtualAttribute.setOwner(attributable);
                     attributable.addVirtualAttribute(virtualAttribute);
@@ -643,7 +655,7 @@ public abstract class AbstractAttributab
                 if (schema != null) {
                     attribute = attributable.getAttribute(schema.getName());
                     if (attribute == null) {
-                        attribute = attributableUtil.newAttribute();
+                        attribute = attributableUtil.newAttr();
                         attribute.setSchema(schema);
                     }
 
@@ -666,10 +678,10 @@ public abstract class AbstractAttributab
         AbstractDerAttr derivedAttribute;
         for (AttributeTO attributeTO : attributableTO.getDerivedAttributes()) {
 
-            derivedSchema = getDerivedSchema(attributeTO.getSchema(), attributableUtil.derivedSchemaClass());
+            derivedSchema = getDerivedSchema(attributeTO.getSchema(), attributableUtil.derSchemaClass());
 
             if (derivedSchema != null) {
-                derivedAttribute = attributableUtil.newDerivedAttribute();
+                derivedAttribute = attributableUtil.newDerAttr();
                 derivedAttribute.setDerivedSchema(derivedSchema);
                 derivedAttribute.setOwner(attributable);
                 attributable.addDerivedAttribute(derivedAttribute);
@@ -680,10 +692,10 @@ public abstract class AbstractAttributab
         if (AttributableType.USER == attributableUtil.getType()) {
             for (AttributeTO vattrTO : attributableTO.getVirtualAttributes()) {
                 AbstractVirSchema uVirSchema = getVirtualSchema(vattrTO.getSchema(),
-                        attributableUtil.virtualSchemaClass());
+                        attributableUtil.virSchemaClass());
 
                 if (uVirSchema != null) {
-                    AbstractVirAttr vattr = attributableUtil.newVirtualAttribute();
+                    AbstractVirAttr vattr = attributableUtil.newVirAttr();
                     vattr.setVirtualSchema(uVirSchema);
                     vattr.setOwner(attributable);
                     attributable.addVirtualAttribute(vattr);
@@ -702,7 +714,7 @@ public abstract class AbstractAttributab
                 attributable.addResource(resource);
             }
         }
-        
+
         SyncopeClientException requiredValuesMissing = checkMandatory(attributableUtil, attributable);
         if (!requiredValuesMissing.isEmpty()) {
             compositeErrorException.addException(requiredValuesMissing);

Modified: incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/ResourceDataBinder.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/ResourceDataBinder.java?rev=1398326&r1=1398325&r2=1398326&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/ResourceDataBinder.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/ResourceDataBinder.java Mon Oct 15 15:12:48 2012
@@ -95,7 +95,7 @@ public class ResourceDataBinder {
             }
         }
 
-        resource.setForceMandatoryConstraint(resourceTO.isForceMandatoryConstraint());
+        resource.setEnforceMandatoryCondition(resourceTO.isEnforceMandatoryCondition());
 
         resource.setPropagationPrimary(resourceTO.isPropagationPrimary());
 
@@ -165,7 +165,7 @@ public class ResourceDataBinder {
 
         resourceTO.setAccountLink(resource.getAccountLink());
 
-        resourceTO.setForceMandatoryConstraint(resource.isForceMandatoryConstraint());
+        resourceTO.setEnforceMandatoryCondition(resource.isEnforceMandatoryCondition());
 
         resourceTO.setPropagationPrimary(resource.isPropagationPrimary());
 

Modified: incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/SchemaDataBinder.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/SchemaDataBinder.java?rev=1398326&r1=1398325&r2=1398326&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/SchemaDataBinder.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/SchemaDataBinder.java Mon Oct 15 15:12:48 2012
@@ -80,7 +80,7 @@ public class SchemaDataBinder {
 
         SyncopeClientCompositeErrorException scce = new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
 
-        List<AbstractAttr> attrs = schemaDAO.getAttributes(schema, attributableUtil.attributeClass());
+        List<AbstractAttr> attrs = schemaDAO.getAttributes(schema, attributableUtil.attrClass());
         if (!attrs.isEmpty()) {
             if (schema.getType() != schemaTO.getType()) {
                 SyncopeClientException e = new SyncopeClientException(SyncopeClientExceptionType.valueOf("Invalid"

Modified: incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java?rev=1398326&r1=1398325&r2=1398326&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java Mon Oct 15 15:12:48 2012
@@ -321,7 +321,7 @@ public class UserDataBinder extends Abst
                         attributeIds.add(attribute.getId());
                     }
                     for (Long attributeId : attributeIds) {
-                        attributeDAO.delete(attributeId, MAttr.class);
+                        attrDAO.delete(attributeId, MAttr.class);
                     }
                     attributeIds.clear();
 

Modified: incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/util/AttributableUtil.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/util/AttributableUtil.java?rev=1398326&r1=1398325&r2=1398326&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/util/AttributableUtil.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/util/AttributableUtil.java Mon Oct 15 15:12:48 2012
@@ -91,7 +91,7 @@ public class AttributableUtil {
         return result;
     }
 
-    public IntMappingType derivedIntMappingType() {
+    public IntMappingType derIntMappingType() {
         IntMappingType result;
 
         switch (type) {
@@ -110,7 +110,7 @@ public class AttributableUtil {
         return result;
     }
 
-    public IntMappingType virtualIntMappingType() {
+    public IntMappingType virIntMappingType() {
         IntMappingType result;
 
         switch (type) {
@@ -165,7 +165,7 @@ public class AttributableUtil {
         return result;
     }
 
-    public <T extends AbstractDerSchema> Class<T> derivedSchemaClass() {
+    public <T extends AbstractDerSchema> Class<T> derSchemaClass() {
         Class result = null;
 
         switch (type) {
@@ -183,7 +183,7 @@ public class AttributableUtil {
         return result;
     }
 
-    public <T extends AbstractVirSchema> Class<T> virtualSchemaClass() {
+    public <T extends AbstractVirSchema> Class<T> virSchemaClass() {
         Class result = null;
 
         switch (type) {
@@ -201,7 +201,7 @@ public class AttributableUtil {
         return result;
     }
 
-    public <T extends AbstractDerSchema> T newDerivedSchema() {
+    public <T extends AbstractDerSchema> T newDerSchema() {
         T result = null;
 
         switch (type) {
@@ -219,7 +219,7 @@ public class AttributableUtil {
         return result;
     }
 
-    public <T extends AbstractAttr> Class<T> attributeClass() {
+    public <T extends AbstractAttr> Class<T> attrClass() {
         Class result = null;
 
         switch (type) {
@@ -237,7 +237,7 @@ public class AttributableUtil {
         return result;
     }
 
-    public <T extends AbstractAttr> T newAttribute() {
+    public <T extends AbstractAttr> T newAttr() {
         T result = null;
 
         switch (type) {
@@ -255,7 +255,7 @@ public class AttributableUtil {
         return result;
     }
 
-    public <T extends AbstractDerAttr> Class<T> derivedAttributeClass() {
+    public <T extends AbstractDerAttr> Class<T> derAttrClass() {
         Class result = null;
 
         switch (type) {
@@ -273,7 +273,7 @@ public class AttributableUtil {
         return result;
     }
 
-    public <T extends AbstractVirAttr> Class<T> virtualAttributeClass() {
+    public <T extends AbstractVirAttr> Class<T> virAttrClass() {
         Class result = null;
 
         switch (type) {
@@ -291,7 +291,7 @@ public class AttributableUtil {
         return result;
     }
 
-    public <T extends AbstractDerAttr> T newDerivedAttribute() {
+    public <T extends AbstractDerAttr> T newDerAttr() {
         T result = null;
 
         switch (type) {
@@ -309,7 +309,7 @@ public class AttributableUtil {
         return result;
     }
 
-    public <T extends AbstractVirAttr> T newVirtualAttribute() {
+    public <T extends AbstractVirAttr> T newVirAttr() {
         T result = null;
 
         switch (type) {
@@ -327,7 +327,7 @@ public class AttributableUtil {
         return result;
     }
 
-    public <T extends AbstractVirSchema> T newVirtualSchema() {
+    public <T extends AbstractVirSchema> T newVirSchema() {
         T result = null;
 
         switch (type) {
@@ -345,7 +345,7 @@ public class AttributableUtil {
         return result;
     }
 
-    public <T extends AbstractAttrValue> Class<T> attributeValueClass() {
+    public <T extends AbstractAttrValue> Class<T> attrValueClass() {
         Class result = null;
 
         switch (type) {
@@ -363,7 +363,7 @@ public class AttributableUtil {
         return result;
     }
 
-    public <T extends AbstractAttrValue> T newAttributeValue() {
+    public <T extends AbstractAttrValue> T newAttrValue() {
         T result = null;
 
         switch (type) {
@@ -381,7 +381,7 @@ public class AttributableUtil {
         return result;
     }
 
-    public <T extends AbstractAttrValue> T newAttributeUniqueValue() {
+    public <T extends AbstractAttrValue> T newAttrUniqueValue() {
         T result = null;
 
         switch (type) {

Modified: incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/util/JexlUtil.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/util/JexlUtil.java?rev=1398326&r1=1398325&r2=1398326&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/util/JexlUtil.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/util/JexlUtil.java Mon Oct 15 15:12:48 2012
@@ -34,6 +34,7 @@ import org.apache.syncope.client.to.Attr
 import org.apache.syncope.core.persistence.beans.AbstractAttr;
 import org.apache.syncope.core.persistence.beans.AbstractBaseBean;
 import org.apache.syncope.core.persistence.beans.AbstractDerAttr;
+import org.apache.syncope.core.persistence.beans.AbstractVirAttr;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -128,15 +129,15 @@ public class JexlUtil {
                 ? new MapContext()
                 : jexlContext;
 
-        for (AbstractAttr attribute : attributes) {
-            List<String> attributeValues = attribute.getValuesAsStrings();
+        for (AbstractAttr attr : attributes) {
+            List<String> attributeValues = attr.getValuesAsStrings();
             String expressionValue = attributeValues.isEmpty()
                     ? ""
                     : attributeValues.get(0);
 
-            LOG.debug("Add attribute {} with value {}", attribute.getSchema().getName(), expressionValue);
+            LOG.debug("Add attribute {} with value {}", attr.getSchema().getName(), expressionValue);
 
-            context.set(attribute.getSchema().getName(), expressionValue);
+            context.set(attr.getSchema().getName(), expressionValue);
         }
 
         return context;
@@ -163,40 +164,61 @@ public class JexlUtil {
         return context;
     }
 
+    public JexlContext addVirAttrsToContext(final Collection<? extends AbstractVirAttr> virAttrs,
+            final JexlContext jexlContext) {
+
+        JexlContext context = jexlContext == null
+                ? new MapContext()
+                : jexlContext;
+
+        for (AbstractVirAttr virAttr : virAttrs) {
+            List<String> attributeValues = virAttr.getValues();
+            String expressionValue = attributeValues.isEmpty()
+                    ? ""
+                    : attributeValues.get(0);
+
+            LOG.debug("Add virtual attribute {} with value {}", virAttr.getVirtualSchema().getName(), expressionValue);
+
+            context.set(virAttr.getVirtualSchema().getName(), expressionValue);
+        }
+
+        return context;
+    }
+
     public String evaluate(final String expression, final AbstractAttributableTO attributableTO) {
         final JexlContext context = new MapContext();
 
         addFieldsToContext(attributableTO, context);
 
-        for (AttributeTO attribute : attributableTO.getAttributes()) {
-            List<String> attributeValues = attribute.getValues();
-            String expressionValue = attributeValues.isEmpty()
+        for (AttributeTO attr : attributableTO.getAttributes()) {
+            List<String> values = attr.getValues();
+            String expressionValue = values.isEmpty()
                     ? ""
-                    : attributeValues.get(0);
+                    : values.get(0);
 
-            LOG.debug("Add attribute {} with value {}", attribute.getSchema(), expressionValue);
+            LOG.debug("Add attribute {} with value {}", attr.getSchema(), expressionValue);
 
-            context.set(attribute.getSchema(), expressionValue);
+            context.set(attr.getSchema(), expressionValue);
         }
-        for (AttributeTO attribute : attributableTO.getDerivedAttributes()) {
-            List<String> attributeValues = attribute.getValues();
-            String expressionValue = attributeValues.isEmpty()
+        for (AttributeTO derAttr : attributableTO.getDerivedAttributes()) {
+            List<String> values = derAttr.getValues();
+            String expressionValue = values.isEmpty()
                     ? ""
-                    : attributeValues.get(0);
+                    : values.get(0);
 
-            LOG.debug("Add derived attribute {} with value {}", attribute.getSchema(), expressionValue);
+            LOG.debug("Add derived attribute {} with value {}", derAttr.getSchema(), expressionValue);
 
-            context.set(attribute.getSchema(), expressionValue);
+            context.set(derAttr.getSchema(), expressionValue);
         }
-        for (AttributeTO attribute : attributableTO.getVirtualAttributes()) {
-            List<String> attributeValues = attribute.getValues();
-            String expressionValue = attributeValues.isEmpty()
+        for (AttributeTO virAttr : attributableTO.getVirtualAttributes()) {
+            List<String> values = virAttr.getValues();
+            String expressionValue = values.isEmpty()
                     ? ""
-                    : attributeValues.get(0);
+                    : values.get(0);
 
-            LOG.debug("Add virtual attribute {} with value {}", attribute.getSchema(), expressionValue);
+            LOG.debug("Add virtual attribute {} with value {}", virAttr.getSchema(), expressionValue);
 
-            context.set(attribute.getSchema(), expressionValue);
+            context.set(virAttr.getSchema(), expressionValue);
         }
 
         // Evaluate expression using the context prepared before

Modified: incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/persistence/relationships/ResourceTest.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/persistence/relationships/ResourceTest.java?rev=1398326&r1=1398325&r2=1398326&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/persistence/relationships/ResourceTest.java (original)
+++ incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/persistence/relationships/ResourceTest.java Mon Oct 15 15:12:48 2012
@@ -123,7 +123,7 @@ public class ResourceTest extends Abstra
         resourceTO.setConnectorId(100L);
         resourceTO.setMappings(schemaMappingTOs);
         resourceTO.setPropagationMode(PropagationMode.ONE_PHASE);
-        resourceTO.setForceMandatoryConstraint(true);
+        resourceTO.setEnforceMandatoryCondition(true);
 
         ExternalResource resource = resourceDataBinder.create(resourceTO);
         resource = resourceDAO.save(resource);

Modified: incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java?rev=1398326&r1=1398325&r2=1398326&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java (original)
+++ incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java Mon Oct 15 15:12:48 2012
@@ -311,7 +311,7 @@ public class UserTestITCase extends Abst
     }
 
     @Test
-    public void testMandatoryContraintsUserCreation() {
+    public void testEnforceMandatoryCondition() {
         UserTO userTO = getSampleTO("issue183@apache.org");
         userTO.addResource("ws-target-resource-2");
         userTO.setPassword("newPassword");
@@ -340,6 +340,37 @@ public class UserTestITCase extends Abst
     }
 
     @Test
+    public void testEnforceMandatoryConditionOnDerived() {
+        ResourceTO resourceTO = restTemplate.getForObject(BASE_URL + "/resource/read/{resourceName}.json",
+                ResourceTO.class, "resource-csv");
+        assertNotNull(resourceTO);
+        resourceTO.setName("resource-csv-enforcing");
+        resourceTO.setEnforceMandatoryCondition(true);
+        resourceTO = restTemplate.postForObject(BASE_URL + "resource/create.json", resourceTO, ResourceTO.class);
+        assertNotNull(resourceTO);
+
+        UserTO userTO = getSampleTO("syncope222@apache.org");
+        userTO.addResource(resourceTO.getName());
+        userTO.setPassword("newPassword");
+
+        SyncopeClientException sce = null;
+        try {
+            userTO = restTemplate.postForObject(BASE_URL + "user/create", userTO, UserTO.class);
+        } catch (SyncopeClientCompositeErrorException scce) {
+            sce = scce.getException(SyncopeClientExceptionType.RequiredValuesMissing);
+        }
+        assertNotNull(sce);
+
+        AttributeTO derAttTO = new AttributeTO();
+        derAttTO.setSchema("csvuserid");
+        userTO.addDerivedAttribute(derAttTO);
+
+        userTO = restTemplate.postForObject(BASE_URL + "user/create", userTO, UserTO.class);
+        assertNotNull(userTO);
+        assertEquals(Collections.singleton("resource-csv-enforcing"), userTO.getResources());
+    }
+
+    @Test
     public void issue147() {
         // 1. create an user without role nor resources
         UserTO userTO = getSampleTO("issue147@tirasa.net");
@@ -553,7 +584,8 @@ public class UserTestITCase extends Abst
         assertEquals(maxTaskExecutions, taskTO.getExecutions().size());
 
         // 3. verify password
-        Boolean verify = restTemplate.getForObject(BASE_URL + "user/verifyPassword/{username}.json?password=password123",
+        Boolean verify = restTemplate.
+                getForObject(BASE_URL + "user/verifyPassword/{username}.json?password=password123",
                 Boolean.class, newUserTO.getUsername());
         assertTrue(verify);
 
@@ -869,7 +901,8 @@ public class UserTestITCase extends Abst
             assertNotNull(user);
         }
 
-        users = Arrays.asList(restTemplate.getForObject(BASE_URL + "user/list/{page}/{size}.json", UserTO[].class, 2, 2));
+        users = Arrays.
+                asList(restTemplate.getForObject(BASE_URL + "user/list/{page}/{size}.json", UserTO[].class, 2, 2));
 
         assertNotNull(users);
         assertFalse(users.isEmpty());

Modified: incubator/syncope/trunk/core/src/test/resources/content.xml
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/test/resources/content.xml?rev=1398326&r1=1398325&r2=1398326&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/test/resources/content.xml (original)
+++ incubator/syncope/trunk/core/src/test/resources/content.xml Mon Oct 15 15:12:48 2012
@@ -309,38 +309,38 @@ under the License.
   <ConnInstance_capabilities ConnInstance_id="106" capabilities="SEARCH"/>
   <ConnInstance_capabilities ConnInstance_id="106" capabilities="SYNC"/>
     
-  <ExternalResource name="ws-target-resource-1" connector_id="100" forceMandatoryConstraint="0" propagationMode="TWO_PHASES"
+  <ExternalResource name="ws-target-resource-1" connector_id="100" enforceMandatoryCondition="0" propagationMode="TWO_PHASES"
                     propagationPriority="0" propagationPrimary="1" createTraceLevel="ALL" deleteTraceLevel="ALL" updateTraceLevel="ALL" syncTraceLevel="ALL"/>
-  <ExternalResource name="ws-target-resource-2" connector_id="100" forceMandatoryConstraint="1" propagationMode="TWO_PHASES"
+  <ExternalResource name="ws-target-resource-2" connector_id="100" enforceMandatoryCondition="1" propagationMode="TWO_PHASES"
                     propagationPriority="0" propagationPrimary="1" createTraceLevel="FAILURES" deleteTraceLevel="NONE" updateTraceLevel="ALL" syncTraceLevel="ALL"/>
-  <ExternalResource name="ws-target-resource-list-mappings-1" connector_id="100" forceMandatoryConstraint="0" propagationMode="TWO_PHASES"
+  <ExternalResource name="ws-target-resource-list-mappings-1" connector_id="100" enforceMandatoryCondition="0" propagationMode="TWO_PHASES"
                     propagationPriority="0" propagationPrimary="0" createTraceLevel="ALL" deleteTraceLevel="ALL" updateTraceLevel="ALL" syncTraceLevel="ALL"/>
-  <ExternalResource name="ws-target-resource-list-mappings-2" connector_id="100" forceMandatoryConstraint="1" propagationMode="TWO_PHASES"
+  <ExternalResource name="ws-target-resource-list-mappings-2" connector_id="100" enforceMandatoryCondition="1" propagationMode="TWO_PHASES"
                     propagationPriority="0" propagationPrimary="0" createTraceLevel="ALL" deleteTraceLevel="ALL" updateTraceLevel="ALL" syncTraceLevel="ALL"/>
-  <ExternalResource name="ws-target-resource-delete" connector_id="102" forceMandatoryConstraint="0" propagationMode="TWO_PHASES"
+  <ExternalResource name="ws-target-resource-delete" connector_id="102" enforceMandatoryCondition="0" propagationMode="TWO_PHASES"
                     propagationPriority="2" propagationPrimary="0" createTraceLevel="ALL" deleteTraceLevel="ALL" updateTraceLevel="ALL" syncTraceLevel="ALL"/>
-  <ExternalResource name="ws-target-resource-update" connector_id="100" forceMandatoryConstraint="1" propagationMode="TWO_PHASES"
+  <ExternalResource name="ws-target-resource-update" connector_id="100" enforceMandatoryCondition="1" propagationMode="TWO_PHASES"
                     propagationPriority="0" propagationPrimary="0" createTraceLevel="ALL" deleteTraceLevel="ALL" updateTraceLevel="ALL" syncTraceLevel="ALL"/>
-  <ExternalResource name="resource-testdb" connector_id="101" forceMandatoryConstraint="1" propagationMode="ONE_PHASE"
+  <ExternalResource name="resource-testdb" connector_id="101" enforceMandatoryCondition="1" propagationMode="ONE_PHASE"
                     propagationPriority="0" propagationPrimary="0" createTraceLevel="ALL" deleteTraceLevel="ALL" updateTraceLevel="ALL" syncTraceLevel="ALL"/>
-  <ExternalResource name="resource-testdb2" connector_id="106" forceMandatoryConstraint="1" propagationMode="ONE_PHASE"
+  <ExternalResource name="resource-testdb2" connector_id="106" enforceMandatoryCondition="1" propagationMode="ONE_PHASE"
                     propagationPriority="0" propagationPrimary="0" createTraceLevel="ALL" deleteTraceLevel="ALL" updateTraceLevel="ALL" syncTraceLevel="ALL"/>
-  <ExternalResource name="resource-csv" connector_id="104" forceMandatoryConstraint="0" propagationMode="ONE_PHASE" syncPolicy_id="3"
+  <ExternalResource name="resource-csv" connector_id="104" enforceMandatoryCondition="0" propagationMode="ONE_PHASE" syncPolicy_id="3"
                     propagationPriority="0" propagationPrimary="0" createTraceLevel="ALL" deleteTraceLevel="ALL" updateTraceLevel="ALL" syncTraceLevel="ALL"/>
-  <ExternalResource name="ws-target-resource-update-resetsynctoken" connector_id="100" forceMandatoryConstraint="1" propagationMode="TWO_PHASES"
+  <ExternalResource name="ws-target-resource-update-resetsynctoken" connector_id="100" enforceMandatoryCondition="1" propagationMode="TWO_PHASES"
                     propagationPriority="0" propagationPrimary="0" createTraceLevel="ALL" deleteTraceLevel="ALL" updateTraceLevel="ALL" syncTraceLevel="ALL" serializedSyncToken="%3Corg.identityconnectors.framework.common.objects.SyncToken%2F%3E"/>
-  <ExternalResource name="resource-ldap" connector_id="105" forceMandatoryConstraint="1" propagationMode="ONE_PHASE"
+  <ExternalResource name="resource-ldap" connector_id="105" enforceMandatoryCondition="1" propagationMode="ONE_PHASE"
                     propagationPriority="0" propagationPrimary="1" createTraceLevel="ALL" deleteTraceLevel="ALL" updateTraceLevel="ALL" syncTraceLevel="ALL"
                     accountlink="&apos;uid=&apos; + username + &apos;,ou=people,o=isp&apos;"/>
-  <ExternalResource name="ws-target-resource-nopropagation" connector_id="103" forceMandatoryConstraint="1" propagationMode="TWO_PHASES"
+  <ExternalResource name="ws-target-resource-nopropagation" connector_id="103" enforceMandatoryCondition="1" propagationMode="TWO_PHASES"
                     propagationPriority="0" propagationPrimary="0" createTraceLevel="ALL" deleteTraceLevel="ALL" updateTraceLevel="ALL" syncTraceLevel="ALL" passwordPolicy_id="4"/>
   
   <!-- The following three resources has been added to verify the issue SYNCOPE-68 -->
-  <ExternalResource name="ws-target-resource-nopropagation2" connector_id="103" forceMandatoryConstraint="1" propagationMode="TWO_PHASES"
+  <ExternalResource name="ws-target-resource-nopropagation2" connector_id="103" enforceMandatoryCondition="1" propagationMode="TWO_PHASES"
                     propagationPriority="0" propagationPrimary="0" createTraceLevel="ALL" deleteTraceLevel="ALL" updateTraceLevel="ALL" syncTraceLevel="ALL" />
-  <ExternalResource name="ws-target-resource-nopropagation3" connector_id="103" forceMandatoryConstraint="1" propagationMode="TWO_PHASES"
+  <ExternalResource name="ws-target-resource-nopropagation3" connector_id="103" enforceMandatoryCondition="1" propagationMode="TWO_PHASES"
                     propagationPriority="0" propagationPrimary="0" createTraceLevel="ALL" deleteTraceLevel="ALL" updateTraceLevel="ALL" syncTraceLevel="ALL" />
-  <ExternalResource name="ws-target-resource-nopropagation4" connector_id="103" forceMandatoryConstraint="1" propagationMode="TWO_PHASES"
+  <ExternalResource name="ws-target-resource-nopropagation4" connector_id="103" enforceMandatoryCondition="1" propagationMode="TWO_PHASES"
                     propagationPriority="0" propagationPrimary="0" createTraceLevel="ALL" deleteTraceLevel="ALL" updateTraceLevel="ALL" syncTraceLevel="ALL" />
                     
   <SyncopeUser_ExternalResource user_id="3" resource_name="ws-target-resource-delete" />