shale-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Tsay (JIRA)" <>
Subject [jira] Created: (SHALE-489) Default validator configuration should not override user specified configuration
Date Sun, 20 Apr 2008 08:40:05 GMT
Default validator  configuration should not override user specified configuration

                 Key: SHALE-489
             Project: Shale
          Issue Type: Improvement
          Components: Validator
    Affects Versions: 1.0.4
         Environment: Any
            Reporter: Jeff Tsay
            Priority: Minor

It seems strange the way that configuration rules are loaded. If the 
default configuration file is not found, the validator lifecycle 
listener will add the default configuration file to the end of a url 
list. However, since the list is processed in forward order, that means 
if you leave out the default configuration file, any settings you have 
in your own file will be overwritten by the default. That means you need 
to explicitly put the default configuration file in your 
org.apache.shale.validator.VALIDATOR_RULES list before your own files. 
Since I think it makes more sense to have your specified configuration 
files override the default settings, I propose the following change in 

 private ValidatorResources validatorResources(ServletContext context)
      throws IOException, SAXException {

        // Process the explicitly configured resources (if any)
       // jtsay
        // Since we want to add to the beginning later, use a linked list
        // ArrayList urls = new ArrayList()
         LinkedList urls = new LinkedList();


       // Process the default configuration resources (if not already 
        if (!didDefault) {
            try {
                url = context.getResource(Globals.DEFAULT_VALIDATOR_RULES);
            } catch (MalformedURLException e) {
                throw new IllegalArgumentException("MalformedURLException:"
                        + " The URL '" + Globals.DEFAULT_VALIDATOR_RULES
                        + "' specified as a validator rules resource is 
            if (url == null) {
                url = 
            if (url == null) {
                throw new 
           // jtsay
            // Add to beginning of list so that explicit resources override
            // default, not the other way around.

Also below, there is some code to iterate over all elements in the list. Since the list is
now a LinkedList it is not efficient to iterate using an array index. So the replaced code
should like this:

       int i = 0;
        for (Iterator it = urls.iterator(); it.hasNext(); i++) {
          array[i] = ((URL);

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message