protected <T> Map<String, T> initParams(Class<T> klass, String extraParams, Pattern pattern) throws ValidationException { if (extraParams == null || extraParams.isEmpty()) { // not using return null; } StringTokenizer stk = new StringTokenizer(extraParams, "|"); Map<String, T> result = new TreeMap<String, T>(); while (stk.hasMoreTokens()) { String entry = stk.nextToken(); Matcher matcher = pattern.matcher(entry); if (!matcher.matches()) { throw new ValidationException("could not parse for extra params " + extraParams + " for type " + klass.getName()); } String paramName = matcher.group(1); String paramValueStr = matcher.group(2); T paramValue = ConverterUtil.convert(klass, paramValueStr); if (log.isDebugEnabled()) { log.debug("detected extra param : <type:" + klass + ", name:" + paramName + ", value:" + paramValue + ">"); } result.put(paramName, paramValue); } return result; } }
log.warn("Error during validation on " + beanClass + " for reason : " + eee.getMessage(), eee);
if (log.isWarnEnabled()) { log.warn("Error during validation on " + type + " for reason : " + eee.getMessage(), eee);
protected <T> Map<String, T> initParams(Class<T> klass, String extraParams, Pattern pattern) throws ValidationException { if (extraParams == null || extraParams.isEmpty()) { // not using return null; } StringTokenizer stk = new StringTokenizer(extraParams, "|"); Map<String, T> result = new java.util.TreeMap<String, T>(); while (stk.hasMoreTokens()) { String entry = stk.nextToken(); Matcher matcher = pattern.matcher(entry); if (!matcher.matches()) { throw new ValidationException("could not parse for extra params " + extraParams + " for type " + klass.getName()); } String paramName = matcher.group(1); String paramValueStr = matcher.group(2); T paramValue = ConverterUtil.convert(klass, paramValueStr); if (log.isDebugEnabled()) { log.debug("detected extra param : <type:" + klass + ", name:" + paramName + ", value:" + paramValue + ">"); } result.put(paramName, paramValue); } return result; } }
} catch (Exception e) { throw new ValidationException( "Can not evaluate boolean expression [" + skip + "] for reason " + e.getMessage());
} catch (Exception e) { throw new ValidationException( "Can not evaluate boolean expression [" + skip + "] for reason " + e.getMessage());
/** * @param object the incoming object containing the collection to test * @return the collection of the incoming object given by the fieldName property * @throws ValidationException if any pb to retreave the collection */ protected Collection<?> getCollection(Object object) throws ValidationException { String fieldName = getCollectionFieldName(); if (fieldName == null || fieldName.trim().isEmpty()) { // on travaille directement sur le fieldName fieldName = getFieldName(); } Object obj = null; // obtain the collection to test try { obj = getFieldValue(fieldName, object); } catch (ValidationException e) { throw e; } catch (Exception e) { // let this pass, but it will be logged right below } if (obj == null) { // la collection est nulle, donc on renvoie une collection vide return Collections.emptyList(); } if (!Collection.class.isInstance(obj)) { throw new ValidationException("field " + fieldName + " is not a collection type! (" + obj.getClass() + ")"); } return (Collection<?>) obj; }
/** * @param object the incoming object containing the collection to test * @return the collection of the incoming object given by the fieldName property * @throws ValidationException if any pb to retreave the collection */ protected Collection<?> getCollection(Object object) throws ValidationException { String fieldName = getCollectionFieldName(); if (fieldName == null || fieldName.trim().isEmpty()) { // on travaille directement sur le fieldName fieldName = getFieldName(); } Object obj = null; // obtain the collection to test try { obj = getFieldValue(fieldName, object); } catch (ValidationException e) { throw e; } catch (Exception e) { // let this pass, but it will be logged right below } if (obj == null) { // la collection est nulle, donc on renvoie une collection vide return java.util.Collections.EMPTY_LIST; } if (!Collection.class.isInstance(obj)) { throw new ValidationException("field " + fieldName + " is not a collection type! (" + obj.getClass() + ")"); } return (Collection<?>) obj; }
throw new ValidationException("field " + fieldName + " is not a collection type! (" + obj.getClass() + ')');
/** * @param object the incoming object containing the collection to test * @return the collection of the incoming object given by the fieldName property * @throws ValidationException if any pb to retreave the collection */ protected Collection<?> getCollection(Object object) throws ValidationException { String fieldName = getCollectionFieldName(); if (fieldName == null || fieldName.trim().isEmpty()) { // on travaille directement sur le fieldName fieldName = getFieldName(); } Object obj = null; // obtain the collection to test try { obj = getFieldValue(fieldName, object); } catch (ValidationException e) { throw e; } catch (Exception e) { // let this pass, but it will be logged right below } if (obj == null) { // la collection est nulle, donc on renvoie une collection vide return java.util.Collections.EMPTY_LIST; } if (!Collection.class.isInstance(obj)) { throw new ValidationException("field " + fieldName + " is not a collection type! (" + obj.getClass() + ")"); } return (Collection<?>) obj; }
throw new ValidationException("no unique keys defined");
throw new ValidationException("no unique keys defined");
@Override public void validate(Object object) throws ValidationException { if (mode == null) { throw new ValidationException("no mode defined!"); throw new ValidationException("can only use expressionForFirst in mode ALL but was " + mode); throw new ValidationException("can only use expressionForLast in mode ALL but was " + mode); case UNIQUE_KEY: if (keys == null || keys.length == 0) { throw new ValidationException("no unique keys defined");
@Override public void validateWhenNotSkip(Object object) throws ValidationException { if (mode == null) { throw new ValidationException("no mode defined!"); throw new ValidationException("can only use expressionForFirst in " + "mode ALL but was " + mode); throw new ValidationException("can only use expressionForLast in " + "mode ALL but was " + mode); case UNIQUE_KEY: if (keys == null || keys.length == 0) { throw new ValidationException("no unique keys defined");