Bug 139415 - Implement Business Object validation service
Implement Business Object validation service
Status: CLOSED CURRENTRELEASE
Product: Red Hat Network
Classification: Red Hat
Component: RHN/R&D (Show other bugs)
RHN Devel
All Linux
medium Severity medium
: ---
: ---
Assigned To: Mike McCune
Red Hat Satellite QA List
:
Depends On:
Blocks: rhnMilestone1
  Show dependency treegraph
 
Reported: 2004-11-15 16:32 EST by Mike McCune
Modified: 2007-04-18 13:15 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-12-06 01:38:13 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Mike McCune 2004-11-15 16:32:53 EST
Will reside in rhn.common.validator.

I spent some time thinking/reading about how we should provide a
mechanism for validating our business objects and came up with some
thoughts.

The brute-force method would be to put validation code directly in our
domain objects:

User {

public void setEmail(String emailIn) {
    if (emailIn == null) {
        throw new ValidationException("email must not be null");
    }

    if (!FormatHelper.isEmail(emailIn)) {
        throw new ValidationException("Not valid email format");
    }

    // perhaps some other criteria
     this.email = emailIn;
}

This approach has a lot of drawbacks.  One, it requires a lot of code
to be sprinkled throughout our domain objects.  Two, it will make it
difficult for consumers to deal with error conditions in that they
would have to catch ValidationException and interpret it, but this
would only allow for one error to be caught during a transaction.
With a web-based architecture we need to be able to perform a
transaction and return a *list* of validation errors.

This leads me to want to externalize the validation process to being
outside the domain object itself.  Instead , like we currently do with
Struts, we should validate at transaction time in one operation.  My
initial thought is to have our Manager layer perform validation at
storage time:

UserManager {

    public ValidationErrors storeUser(User usr) {
         ValidationErrors retval =
            SomeSortOfValidationService.validateObject(usr);
         if (retval != null) {
             UserFactory.commit(usr);
         }
         return retval;
    }
}

Consumers of our Manager layer (web UI and webservices) will be able
to perform operations and receive back a set of errors (or not if
everything was OK).  This will provide our goal of a re-usable
validation scheme for our business objects.

The mechanics of the ValidationService is TBD but I wanted to throw
out this approach to see what people think.

Mike

Note You need to log in before you can comment on or make changes to this bug.