View Javadoc

1   /**
2    * Copyright 2005-2006 the original author or authors.
3    *
4    * Licensed under the Gnu General Pubic License, Version 2.0 (the
5    * "License"); you may not use this file except in compliance with
6    * the License. You may obtain a copy of the License at
7    *
8    *      http://www.opensource.org/licenses/gpl-license.php
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13   * See the Gnu General Public License for more details.
14   */
15  package org.figure8.join.core;
16  
17  /**
18   * Extension of Exception thrown during a save or update operation on an
19   * {@link EntityObject} when a same or analogous entity already exists.
20   * @author <a href="mailto:laurent.broudoux@free.fr">Laurent Broudoux</a>
21   * @version $Revision: 1.2 $
22   */
23  public class DuplicateEntityException extends Exception{
24  
25     // Attributes ---------------------------------------------------------------
26  
27     /** Original EntityObject that has cause the duplicate exception to occur. */
28     private EntityObject original;
29  
30  
31     // Constructors -------------------------------------------------------------
32  
33     /**
34      * Creates a new instance of DuplicateEntityException.
35      * @param msg Message for this exception
36      * @param original Orignal entity that has cause duplication to occur
37      */
38     public DuplicateEntityException(String msg, EntityObject original){
39        super(msg);
40        this.original = original;
41     }
42  
43     /**
44      * Creates a new instance of DuplicateEntityException.
45      * @param cause Root throwable for this exception
46      * @param original Orignal entity that has cause duplication to occur
47      */
48     public DuplicateEntityException(Throwable cause, EntityObject original){
49        super(cause);
50        this.original = original;
51     }
52  
53     /**
54      * Creates a new instance of DuplicateEntityException.
55      * @param msg Message for this exception
56      * @param cause Root throwable for this exception
57      * @param original Orignal entity that has cause duplication to occur
58      */
59     public DuplicateEntityException(String msg, Throwable cause, EntityObject original){
60        super(msg, cause);
61        this.original = original;
62     }
63  
64  
65     // Public -------------------------------------------------------------------
66  
67     /** @return The original EntityObject that has cause this exception to occur */
68     public EntityObject getOriginalEntity(){
69        return original;
70     }
71  }