syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmarte...@apache.org
Subject svn commit: r1476262 - in /syncope/branches/1_1_X: common/src/main/java/org/apache/syncope/common/types/ core/src/main/java/org/apache/syncope/core/persistence/validation/entity/ core/src/main/webapp/
Date Fri, 26 Apr 2013 16:00:50 GMT
Author: fmartelli
Date: Fri Apr 26 16:00:43 2013
New Revision: 1476262

URL: http://svn.apache.org/r1476262
Log:
SYNCOPE-336 resolved

Modified:
    syncope/branches/1_1_X/common/src/main/java/org/apache/syncope/common/types/EntityViolationType.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/AbstractValidator.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/AttrValidator.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/AttrValueValidator.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/ConnInstanceValidator.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/EntitlementValidator.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/ExternalResourceValidator.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/InvalidEntityException.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/NotificationValidator.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/PolicyValidator.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/PropagationTaskValidator.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/ReportValidator.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/SchedTaskValidator.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/SchemaValidator.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/SyncTaskValidator.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/SyncopeRoleValidator.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/SyncopeUserValidator.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/USchemaValidator.java
    syncope/branches/1_1_X/core/src/main/webapp/syncopeClientError.jsp

Modified: syncope/branches/1_1_X/common/src/main/java/org/apache/syncope/common/types/EntityViolationType.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/common/src/main/java/org/apache/syncope/common/types/EntityViolationType.java?rev=1476262&r1=1476261&r2=1476262&view=diff
==============================================================================
--- syncope/branches/1_1_X/common/src/main/java/org/apache/syncope/common/types/EntityViolationType.java
(original)
+++ syncope/branches/1_1_X/common/src/main/java/org/apache/syncope/common/types/EntityViolationType.java
Fri Apr 26 16:00:43 2013
@@ -60,14 +60,11 @@ public enum EntityViolationType {
         this.message = message;
     }
 
-    public void setMessageTemplate(final String message) {
+    public void setMessage(final String message) {
         this.message = message;
     }
 
-    @Override
-    public String toString() {
-        return this == Standard
-                ? message
-                : super.toString();
+    public String getMessage() {
+        return message;
     }
 }

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/AbstractValidator.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/AbstractValidator.java?rev=1476262&r1=1476261&r2=1476262&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/AbstractValidator.java
(original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/AbstractValidator.java
Fri Apr 26 16:00:43 2013
@@ -18,6 +18,7 @@
  */
 package org.apache.syncope.core.persistence.validation.entity;
 
+import org.apache.syncope.common.types.EntityViolationType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -28,4 +29,7 @@ public abstract class AbstractValidator 
      */
     protected static final Logger LOG = LoggerFactory.getLogger(AbstractValidator.class);
 
+    protected final String getTemplate(final EntityViolationType type, final String message)
{
+        return type.name() + ";" + message;
+    }
 }

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/AttrValidator.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/AttrValidator.java?rev=1476262&r1=1476261&r2=1476262&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/AttrValidator.java
(original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/AttrValidator.java
Fri Apr 26 16:00:43 2013
@@ -20,7 +20,6 @@ package org.apache.syncope.core.persiste
 
 import javax.validation.ConstraintValidator;
 import javax.validation.ConstraintValidatorContext;
-
 import org.apache.syncope.common.types.EntityViolationType;
 import org.apache.syncope.core.persistence.beans.AbstractAttr;
 
@@ -53,9 +52,11 @@ public class AttrValidator extends Abstr
                         + ", " + "values={}", object.getValuesAsStrings());
 
                 context.disableDefaultConstraintViolation();
-                context.buildConstraintViolationWithTemplate(EntityViolationType.InvalidValueList.toString()).addNode(
-                        object + "(" + object.getSchema().getName() + ")" + "{" + object.getValuesAsStrings()
+ "}")
-                        .addConstraintViolation();
+
+                context.buildConstraintViolationWithTemplate(
+                        getTemplate(EntityViolationType.InvalidValueList,
+                        "Invalid values " + object.getValuesAsStrings())).
+                        addNode(object.getSchema().getName()).addConstraintViolation();
             }
         }
 

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/AttrValueValidator.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/AttrValueValidator.java?rev=1476262&r1=1476261&r2=1476262&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/AttrValueValidator.java
(original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/AttrValueValidator.java
Fri Apr 26 16:00:43 2013
@@ -20,7 +20,6 @@ package org.apache.syncope.core.persiste
 
 import javax.validation.ConstraintValidator;
 import javax.validation.ConstraintValidatorContext;
-
 import org.apache.syncope.common.types.EntityViolationType;
 import org.apache.syncope.core.persistence.beans.AbstractAttrUniqueValue;
 import org.apache.syncope.core.persistence.beans.AbstractAttrValue;
@@ -63,8 +62,10 @@ public class AttrValueValidator extends 
                 LOG.error("More than one non-null value for " + object);
 
                 context.disableDefaultConstraintViolation();
-                context.buildConstraintViolationWithTemplate(EntityViolationType.MoreThanOneNonNull.toString())
-                        .addNode(object.toString().replaceAll("\\n", " ")).addConstraintViolation();
+                context.buildConstraintViolationWithTemplate(
+                        getTemplate(EntityViolationType.MoreThanOneNonNull, "More than one
non-null value found")).
+                        addNode(object.getClass().getSimpleName().replaceAll("\\n", " ")).addConstraintViolation();
+
             } else if (object instanceof AbstractAttrUniqueValue) {
                 AbstractSchema uniqueValueSchema = ((AbstractAttrUniqueValue) object).getSchema();
                 AbstractSchema attrSchema = object.getAttribute().getSchema();
@@ -73,15 +74,14 @@ public class AttrValueValidator extends 
 
                 if (!isValid) {
                     LOG.error("Unique value schema for " + object.getClass().getSimpleName()
+ "[" + object.getId()
-                            + "]" + " is " + uniqueValueSchema + ", while owning " + "attribute
schema is "
-                            + attrSchema);
+                            + "]" + " is " + uniqueValueSchema + ", while owning attribute
schema is " + attrSchema);
 
                     context.disableDefaultConstraintViolation();
                     context.buildConstraintViolationWithTemplate(
-                            EntityViolationType.valueOf("Invalid" + attrSchema.getClass().getSimpleName()).toString())
-                            .addNode(
-                                    object.getClass().getSimpleName() + "[" + object.getId()
+ "].schema="
-                                            + uniqueValueSchema + " != " + attrSchema).addConstraintViolation();
+                            getTemplate(EntityViolationType.valueOf("Invalid" + attrSchema.getClass().getSimpleName()),
+                            "Unique value schema is " + uniqueValueSchema
+                            + ", while owning attribute schema is " + attrSchema)).addNode("schema").
+                            addConstraintViolation();
                 }
             }
         }

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/ConnInstanceValidator.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/ConnInstanceValidator.java?rev=1476262&r1=1476261&r2=1476262&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/ConnInstanceValidator.java
(original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/ConnInstanceValidator.java
Fri Apr 26 16:00:43 2013
@@ -42,8 +42,10 @@ public class ConnInstanceValidator exten
             LOG.error("While validating {}", connInstance.getLocation(), e);
 
             context.disableDefaultConstraintViolation();
-            context.buildConstraintViolationWithTemplate(EntityViolationType.InvalidConnInstanceLocation.toString())
-                    .addNode("location").addConstraintViolation();
+            context.buildConstraintViolationWithTemplate(
+                    getTemplate(EntityViolationType.InvalidConnInstanceLocation, e.getMessage())).
+                    addNode("location").addConstraintViolation();
+
             isValid = false;
         }
 

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/EntitlementValidator.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/EntitlementValidator.java?rev=1476262&r1=1476261&r2=1476262&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/EntitlementValidator.java
(original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/EntitlementValidator.java
Fri Apr 26 16:00:43 2013
@@ -20,10 +20,8 @@ package org.apache.syncope.core.persiste
 
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
-
 import javax.validation.ConstraintValidator;
 import javax.validation.ConstraintValidatorContext;
-
 import org.apache.syncope.common.types.EntityViolationType;
 import org.apache.syncope.core.persistence.beans.Entitlement;
 
@@ -52,11 +50,12 @@ public class EntitlementValidator extend
             }
 
             if (!isValid) {
-                LOG.error(object + " cannot have name " + "starting by ROLE_");
+                LOG.error(object + " cannot have name starting by ROLE_");
 
                 context.disableDefaultConstraintViolation();
-                context.buildConstraintViolationWithTemplate(EntityViolationType.InvalidEntitlementName.toString())
-                        .addNode(object.toString()).addConstraintViolation();
+                context.buildConstraintViolationWithTemplate(getTemplate(
+                        EntityViolationType.InvalidEntitlementName, object + " cannot have
name starting by ROLE_")).
+                        addNode("name").addConstraintViolation();
             }
         }
 

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/ExternalResourceValidator.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/ExternalResourceValidator.java?rev=1476262&r1=1476261&r2=1476262&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/ExternalResourceValidator.java
(original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/ExternalResourceValidator.java
Fri Apr 26 16:00:43 2013
@@ -20,7 +20,6 @@ package org.apache.syncope.core.persiste
 
 import javax.validation.ConstraintValidator;
 import javax.validation.ConstraintValidatorContext;
-
 import org.apache.commons.lang.StringUtils;
 import org.apache.syncope.common.types.EntityViolationType;
 import org.apache.syncope.core.persistence.beans.AbstractMapping;
@@ -37,22 +36,25 @@ public class ExternalResourceValidator e
 
     private boolean isValid(final AbstractMappingItem item, final ConstraintValidatorContext
context) {
         if (StringUtils.isBlank(item.getExtAttrName())) {
-            context.buildConstraintViolationWithTemplate(EntityViolationType.InvalidMapping.toString())
-                    .addNode(item + ".extAttrName is null").addConstraintViolation();
+            context.buildConstraintViolationWithTemplate(
+                    getTemplate(EntityViolationType.InvalidMapping, item + ".extAttrName
is null")).
+                    addNode("extAttrName").addConstraintViolation();
 
             return false;
         }
 
         if (StringUtils.isBlank(item.getIntAttrName())) {
-            context.buildConstraintViolationWithTemplate(EntityViolationType.InvalidMapping.toString())
-                    .addNode(item + ".intAttrName is null").addConstraintViolation();
+            context.buildConstraintViolationWithTemplate(
+                    getTemplate(EntityViolationType.InvalidMapping, item + ".intAttrName
is null")).
+                    addNode("intAttrName").addConstraintViolation();
 
             return false;
         }
-        
+
         if (item.getPurpose() == null) {
-            context.buildConstraintViolationWithTemplate(EntityViolationType.InvalidMapping.toString())
-                    .addNode(item + ".purpose is null").addConstraintViolation();
+            context.buildConstraintViolationWithTemplate(
+                    getTemplate(EntityViolationType.InvalidMapping, item + ".purpose is null")).
+                    addNode("purpose").addConstraintViolation();
 
             return false;
         }
@@ -72,8 +74,9 @@ public class ExternalResourceValidator e
             }
         }
         if (accountIds != 1) {
-            context.buildConstraintViolationWithTemplate(EntityViolationType.InvalidMapping.toString())
-                    .addNode(mapping + ".accountId.size==" + accountIds).addConstraintViolation();
+            context.buildConstraintViolationWithTemplate(
+                    getTemplate(EntityViolationType.InvalidMapping, "One and only one accountId
mapping is needed")).
+                    addNode("accountId.size").addConstraintViolation();
             return false;
         }
 
@@ -88,8 +91,9 @@ public class ExternalResourceValidator e
             }
         }
         if (passwords > 1) {
-            context.buildConstraintViolationWithTemplate(EntityViolationType.InvalidMapping.toString())
-                    .addNode(mapping + ".password.size==" + passwords).addConstraintViolation();
+            context.buildConstraintViolationWithTemplate(
+                    getTemplate(EntityViolationType.InvalidMapping, "One and only one password
mapping is allowed")).
+                    addNode("password.size").addConstraintViolation();
             isValid = false;
         }
 
@@ -111,8 +115,9 @@ public class ExternalResourceValidator e
             }
 
             if (actionsClass == null || !isAssignable) {
-                context.buildConstraintViolationWithTemplate(EntityViolationType.InvalidResource.toString())
-                        .addNode(resource + ".actionsClassName is not valid").addConstraintViolation();
+                context.buildConstraintViolationWithTemplate(
+                        getTemplate(EntityViolationType.InvalidResource, "Ivalid actions
class name")).
+                        addNode("actionsClassName").addConstraintViolation();
                 return false;
             }
         }

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/InvalidEntityException.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/InvalidEntityException.java?rev=1476262&r1=1476261&r2=1476262&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/InvalidEntityException.java
(original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/InvalidEntityException.java
Fri Apr 26 16:00:43 2013
@@ -22,10 +22,8 @@ import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
-
 import javax.validation.ConstraintViolation;
 import javax.validation.ValidationException;
-
 import org.apache.syncope.common.types.EntityViolationType;
 
 public class InvalidEntityException extends ValidationException {
@@ -44,15 +42,24 @@ public class InvalidEntityException exte
         this.entityClassSimpleName = entityClassSimpleName;
 
         this.violations = new HashMap<Class, Set<EntityViolationType>>();
-        EntityViolationType entityViolationType;
         for (ConstraintViolation<Object> violation : violations) {
+            int firstComma = violation.getMessageTemplate().indexOf(';');
+
+            final String key = violation.getMessageTemplate().substring(
+                    0, firstComma > 0 ? firstComma : violation.getMessageTemplate().length());
+
+            final String message = violation.getMessageTemplate().substring(firstComma >
0 ? firstComma + 1 : 0);
+
+            EntityViolationType entityViolationType;
+
             try {
-                entityViolationType = EntityViolationType.valueOf(violation.getMessageTemplate());
+                entityViolationType = EntityViolationType.valueOf(key.trim());
             } catch (IllegalArgumentException e) {
                 entityViolationType = EntityViolationType.Standard;
-                entityViolationType.setMessageTemplate(violation.getPropertyPath() + ": "
+ violation.getMessage());
             }
 
+            entityViolationType.setMessage(message.trim());
+
             if (!this.violations.containsKey(violation.getLeafBean().getClass())) {
                 this.violations.put(violation.getLeafBean().getClass(), EnumSet.noneOf(EntityViolationType.class));
             }

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/NotificationValidator.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/NotificationValidator.java?rev=1476262&r1=1476261&r2=1476262&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/NotificationValidator.java
(original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/NotificationValidator.java
Fri Apr 26 16:00:43 2013
@@ -41,21 +41,23 @@ public class NotificationValidator exten
         if (value.getEvents().isEmpty()) {
             isValid = false;
 
-            context.buildConstraintViolationWithTemplate("No events").addNode(
-                    EntityViolationType.InvalidNotification.toString()).addNode("events").addConstraintViolation();
+            context.buildConstraintViolationWithTemplate(
+                    getTemplate(EntityViolationType.InvalidNotification, "No events")).
+                    addNode("events").addConstraintViolation();
         }
         if (!value.getAbout().isValid()) {
             isValid = false;
 
-            context.buildConstraintViolationWithTemplate("Invalid about search condition").addNode(
-                    EntityViolationType.InvalidNotification.toString()).addNode("about").addConstraintViolation();
+            context.buildConstraintViolationWithTemplate(
+                    getTemplate(EntityViolationType.InvalidNotification, "Invalid about search
condition")).
+                    addNode("about").addConstraintViolation();
         }
         if (value.getRecipients() != null) {
             if (!value.getRecipients().isValid() && !value.isSelfAsRecipient()) {
                 isValid = false;
 
-                context.buildConstraintViolationWithTemplate("Invalid recipients search condition").addNode(
-                        EntityViolationType.InvalidNotification.toString()).
+                context.buildConstraintViolationWithTemplate(
+                        getTemplate(EntityViolationType.InvalidNotification, "Invalid recipients
search condition")).
                         addNode("recipients").addConstraintViolation();
             }
         }

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/PolicyValidator.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/PolicyValidator.java?rev=1476262&r1=1476261&r2=1476262&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/PolicyValidator.java
(original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/PolicyValidator.java
Fri Apr 26 16:00:43 2013
@@ -20,7 +20,6 @@ package org.apache.syncope.core.persiste
 
 import javax.validation.ConstraintValidator;
 import javax.validation.ConstraintValidatorContext;
-
 import org.apache.syncope.common.types.AccountPolicySpec;
 import org.apache.syncope.common.types.EntityViolationType;
 import org.apache.syncope.common.types.PasswordPolicySpec;
@@ -50,8 +49,9 @@ public class PolicyValidator extends Abs
                 || ((object instanceof AccountPolicy && !(object.getSpecification()
instanceof AccountPolicySpec)))
                 || ((object instanceof SyncPolicy && !(object.getSpecification()
instanceof SyncPolicySpec))))) {
 
-            context.buildConstraintViolationWithTemplate("Invalid policy specification").
-                    addNode(EntityViolationType.valueOf("Invalid" + object.getClass().getSimpleName()).name()).
+            context.buildConstraintViolationWithTemplate(
+                    getTemplate(EntityViolationType.valueOf("Invalid" + object.getClass().getSimpleName()),
+                    "Invalid policy specification")).addNode("specification").
                     addConstraintViolation();
 
             return false;
@@ -63,8 +63,9 @@ public class PolicyValidator extends Abs
                 final PasswordPolicy passwordPolicy = policyDAO.getGlobalPasswordPolicy();
 
                 if (passwordPolicy != null && !passwordPolicy.getId().equals(object.getId()))
{
-                    context.buildConstraintViolationWithTemplate("Password policy already
exists").addNode(
-                            EntityViolationType.InvalidPasswordPolicy.name()).addConstraintViolation();
+                    context.buildConstraintViolationWithTemplate(
+                            getTemplate(EntityViolationType.InvalidPasswordPolicy, "Password
policy already exists")).
+                            addNode(object.getClass().getSimpleName()).addConstraintViolation();
 
                     return false;
                 }
@@ -75,8 +76,9 @@ public class PolicyValidator extends Abs
                 final AccountPolicy accountPolicy = policyDAO.getGlobalAccountPolicy();
 
                 if (accountPolicy != null && !accountPolicy.getId().equals(object.getId()))
{
-                    context.buildConstraintViolationWithTemplate("Global Account policy already
exists").addNode(
-                            EntityViolationType.InvalidAccountPolicy.name()).addConstraintViolation();
+                    context.buildConstraintViolationWithTemplate(getTemplate(
+                            EntityViolationType.InvalidAccountPolicy, "Global Account policy
already exists")).
+                            addNode(object.getClass().getSimpleName()).addConstraintViolation();
 
                     return false;
                 }
@@ -87,8 +89,9 @@ public class PolicyValidator extends Abs
                 final SyncPolicy syncPolicy = policyDAO.getGlobalSyncPolicy();
 
                 if (syncPolicy != null && !syncPolicy.getId().equals(object.getId()))
{
-                    context.buildConstraintViolationWithTemplate("Global Sync policy already
exists").addNode(
-                            EntityViolationType.InvalidSyncPolicy.name()).addConstraintViolation();
+                    context.buildConstraintViolationWithTemplate(getTemplate(
+                            EntityViolationType.InvalidSyncPolicy, "Global Sync policy already
exists")).
+                            addNode(object.getClass().getSimpleName()).addConstraintViolation();
 
                     return false;
                 }

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/PropagationTaskValidator.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/PropagationTaskValidator.java?rev=1476262&r1=1476261&r2=1476262&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/PropagationTaskValidator.java
(original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/PropagationTaskValidator.java
Fri Apr 26 16:00:43 2013
@@ -62,8 +62,9 @@ public class PropagationTaskValidator ex
 
             if (!isValid) {
                 context.disableDefaultConstraintViolation();
-                context.buildConstraintViolationWithTemplate(EntityViolationType.InvalidPropagationTask.toString())
-                        .addConstraintViolation();
+                context.buildConstraintViolationWithTemplate(
+                        getTemplate(EntityViolationType.InvalidPropagationTask, "Invalid
task")).
+                        addNode(task.getClass().getSimpleName()).addConstraintViolation();
             }
         }
 

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/ReportValidator.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/ReportValidator.java?rev=1476262&r1=1476261&r2=1476262&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/ReportValidator.java
(original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/ReportValidator.java
Fri Apr 26 16:00:43 2013
@@ -50,8 +50,9 @@ public class ReportValidator extends Abs
                 isValid = false;
 
                 context.disableDefaultConstraintViolation();
-                context.buildConstraintViolationWithTemplate(EntityViolationType.InvalidReport.name()).addNode(
-                        object + ".cronExpression==" + object.getCronExpression()).addConstraintViolation();
+                context.buildConstraintViolationWithTemplate(
+                        getTemplate(EntityViolationType.InvalidReport, "Invalid cron expression")).
+                        addNode("cronExpression").addConstraintViolation();
             }
         }
 
@@ -64,8 +65,9 @@ public class ReportValidator extends Abs
             isValid = false;
 
             context.disableDefaultConstraintViolation();
-            context.buildConstraintViolationWithTemplate(EntityViolationType.InvalidReport.name()).addNode(
-                    object + ".reportletConfs with duplicate names").addConstraintViolation();
+            context.buildConstraintViolationWithTemplate(
+                    getTemplate(EntityViolationType.InvalidReport, "Reportlet name must be
unique")).
+                    addNode("reportletConfs").addConstraintViolation();
         }
 
         return isValid;

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/SchedTaskValidator.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/SchedTaskValidator.java?rev=1476262&r1=1476261&r2=1476262&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/SchedTaskValidator.java
(original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/SchedTaskValidator.java
Fri Apr 26 16:00:43 2013
@@ -51,8 +51,9 @@ public class SchedTaskValidator extends 
             isValid = false;
 
             context.disableDefaultConstraintViolation();
-            context.buildConstraintViolationWithTemplate(EntityViolationType.InvalidSchedTask.toString()).addNode(
-                    object + ".jobClassName is not valid").addConstraintViolation();
+            context.buildConstraintViolationWithTemplate(
+                    getTemplate(EntityViolationType.InvalidSchedTask, "Invalid job class
name")).
+                    addNode("jobClassName").addConstraintViolation();
         }
 
         if (isValid && object.getCronExpression() != null) {
@@ -63,8 +64,9 @@ public class SchedTaskValidator extends 
                 isValid = false;
 
                 context.disableDefaultConstraintViolation();
-                context.buildConstraintViolationWithTemplate(EntityViolationType.InvalidSchedTask.toString()).addNode(
-                        object + ".cronExpression==" + object.getCronExpression()).addConstraintViolation();
+                context.buildConstraintViolationWithTemplate(
+                        getTemplate(EntityViolationType.InvalidSchedTask, "Invalid cron expression")).
+                        addNode("cronExpression").addConstraintViolation();
             }
         }
 

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/SchemaValidator.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/SchemaValidator.java?rev=1476262&r1=1476261&r2=1476262&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/SchemaValidator.java
(original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/SchemaValidator.java
Fri Apr 26 16:00:43 2013
@@ -57,8 +57,7 @@ public class SchemaValidator extends Abs
                 if (!isValid) {
                     violation = EntityViolationType.MultivalueAndUniqueConstraint;
 
-                    throw new Exception(object + " cannot be multivalue and have "
-                            + "unique constraint at the same time");
+                    throw new Exception(object + " cannot be multivalue and have unique constraint
at the same time");
                 }
             }
 
@@ -67,8 +66,8 @@ public class SchemaValidator extends Abs
             LOG.error("Error saving schema", e);
 
             context.disableDefaultConstraintViolation();
-            context.buildConstraintViolationWithTemplate(violation.toString()).addNode(object.toString())
-                    .addConstraintViolation();
+            context.buildConstraintViolationWithTemplate(getTemplate(violation, e.getMessage())).
+                    addNode(object.getClass().getSimpleName()).addConstraintViolation();
 
             return false;
         }

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/SyncTaskValidator.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/SyncTaskValidator.java?rev=1476262&r1=1476261&r2=1476262&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/SyncTaskValidator.java
(original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/SyncTaskValidator.java
Fri Apr 26 16:00:43 2013
@@ -56,8 +56,9 @@ public class SyncTaskValidator extends A
                     LOG.error("Resource is null");
 
                     context.disableDefaultConstraintViolation();
-                    context.buildConstraintViolationWithTemplate(EntityViolationType.InvalidSyncTask.toString())
-                            .addNode(object + ".resource is NULL").addConstraintViolation();
+                    context.buildConstraintViolationWithTemplate(
+                            getTemplate(EntityViolationType.InvalidSyncTask, "Resource cannot
be null")).
+                            addNode("resource").addConstraintViolation();
                 }
 
                 if (StringUtils.isNotBlank(object.getActionsClassName())) {
@@ -75,8 +76,9 @@ public class SyncTaskValidator extends A
                         isValid = false;
 
                         context.disableDefaultConstraintViolation();
-                        context.buildConstraintViolationWithTemplate(EntityViolationType.InvalidSyncTask.toString())
-                                .addNode(object + ".actionsClassName is not valid").addConstraintViolation();
+                        context.buildConstraintViolationWithTemplate(
+                                getTemplate(EntityViolationType.InvalidSyncTask, "Invalid
class name")).
+                                addNode("actionsClassName").addConstraintViolation();
                     }
                 }
             }

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/SyncopeRoleValidator.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/SyncopeRoleValidator.java?rev=1476262&r1=1476261&r2=1476262&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/SyncopeRoleValidator.java
(original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/SyncopeRoleValidator.java
Fri Apr 26 16:00:43 2013
@@ -20,7 +20,6 @@ package org.apache.syncope.core.persiste
 
 import javax.validation.ConstraintValidator;
 import javax.validation.ConstraintValidatorContext;
-
 import org.apache.syncope.common.types.EntityViolationType;
 import org.apache.syncope.core.persistence.beans.role.SyncopeRole;
 
@@ -40,8 +39,10 @@ public class SyncopeRoleValidator extend
         if (object.getUserOwner() != null && object.getRoleOwner() != null) {
             isValid = false;
 
-            context.buildConstraintViolationWithTemplate("A role must either be owned by
an user or a role, not both").
-                    addNode(EntityViolationType.InvalidRoleOwner.toString()).addConstraintViolation();
+            context.buildConstraintViolationWithTemplate(
+                    getTemplate(EntityViolationType.InvalidRoleOwner,
+                    "A role must either be owned by an user or a role, not both")).
+                    addNode("owner").addConstraintViolation();
         }
 
         return isValid;

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/SyncopeUserValidator.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/SyncopeUserValidator.java?rev=1476262&r1=1476261&r2=1476262&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/SyncopeUserValidator.java
(original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/SyncopeUserValidator.java
Fri Apr 26 16:00:43 2013
@@ -92,8 +92,9 @@ public class SyncopeUserValidator extend
             } catch (Exception e) {
                 LOG.debug("Invalid password");
 
-                context.buildConstraintViolationWithTemplate(e.getMessage()).addNode(
-                        EntityViolationType.InvalidPassword.toString()).addConstraintViolation();
+                context.buildConstraintViolationWithTemplate(
+                        getTemplate(EntityViolationType.InvalidPassword, e.getMessage())).
+                        addNode("password").addConstraintViolation();
 
                 return false;
             } finally {
@@ -120,8 +121,9 @@ public class SyncopeUserValidator extend
         } catch (Exception e) {
             LOG.debug("Invalid username");
 
-            context.buildConstraintViolationWithTemplate(e.getMessage()).addNode(
-                    EntityViolationType.InvalidUsername.toString()).addConstraintViolation();
+            context.buildConstraintViolationWithTemplate(
+                    getTemplate(EntityViolationType.InvalidUsername, e.getMessage()))
+                    .addNode("username").addConstraintViolation();
 
             return false;
         }

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/USchemaValidator.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/USchemaValidator.java?rev=1476262&r1=1476261&r2=1476262&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/USchemaValidator.java
(original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/USchemaValidator.java
Fri Apr 26 16:00:43 2013
@@ -33,8 +33,8 @@ import org.apache.syncope.core.persisten
 public class USchemaValidator extends AbstractValidator implements ConstraintValidator<USchemaCheck,
Object> {
 
     @Transient
-    private static List<String> PERMITTED_USCHEMA_NAMES = Arrays.asList(new String[]
{ "failedLogins", "username",
-            "password", "lastLoginDate", "creationDate", "changePwdDate" });
+    private static List<String> PERMITTED_USCHEMA_NAMES = Arrays.asList(new String[]{"failedLogins",
"username",
+                "password", "lastLoginDate", "creationDate", "changePwdDate"});
 
     @Override
     public void initialize(final USchemaCheck constraintAnnotation) {
@@ -72,8 +72,10 @@ public class USchemaValidator extends Ab
             LOG.error("Error saving schema", e);
 
             context.disableDefaultConstraintViolation();
-            context.buildConstraintViolationWithTemplate(violation.toString()).addNode(object.toString())
-                    .addConstraintViolation();
+
+            context.buildConstraintViolationWithTemplate(
+                    getTemplate(violation, e.getMessage())).
+                    addNode(object.getClass().getSimpleName()).addConstraintViolation();
 
             return false;
         }

Modified: syncope/branches/1_1_X/core/src/main/webapp/syncopeClientError.jsp
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/webapp/syncopeClientError.jsp?rev=1476262&r1=1476261&r2=1476262&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/webapp/syncopeClientError.jsp (original)
+++ syncope/branches/1_1_X/core/src/main/webapp/syncopeClientError.jsp Fri Apr 26 16:00:43
2013
@@ -60,7 +60,7 @@ under the License.
 
             for (EntityViolationType violationType : violation.getValue()) {
                 response.addHeader(exType.getElementHeaderName(),
-                        violation.getClass().getSimpleName() + ": " + violationType);
+                        violationType.name() + ": " + violationType.getMessage());
             }
         }
 



Mime
View raw message