View Javadoc

1   /*
2    * $Id: ValidationException.java 7976 2007-08-21 14:26:13Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.registry;
12  
13  import org.mule.config.i18n.MessageFactory;
14  import org.mule.util.SystemUtils;
15  
16  import java.util.Iterator;
17  import java.util.List;
18  
19  /**
20   * Is thrown when an object loaded from a descriptor is invalid
21   * 
22   * @author <a href="mailto:ross.mason@symphonysoft.com">Ross Mason</a>
23   * @version $Revision: 7976 $
24   */
25  public class ValidationException extends RegistryException
26  {
27      /**
28       * Serial version
29       */
30      private static final long serialVersionUID = -8798792301579785598L;
31  
32      public ValidationException(String vaildationError)
33      {
34          super(MessageFactory.createStaticMessage(vaildationError));
35      }
36  
37      public ValidationException(List vaildationErrors)
38      {
39          this(createMessage(vaildationErrors));
40      }
41  
42      private static String createMessage(List vaildationErrors)
43      {
44          // TODO i18n
45          StringBuffer buf = new StringBuffer();
46          buf.append("The following validation errors occurred");
47          for (Iterator iterator = vaildationErrors.iterator(); iterator.hasNext();)
48          {
49              String s = (String)iterator.next();
50              buf.append(SystemUtils.LINE_SEPARATOR).append(s);
51          }
52          return buf.toString();
53      }
54  }