001/*
002 *  Licensed to the Apache Software Foundation (ASF) under one
003 *  or more contributor license agreements.  See the NOTICE file
004 *  distributed with this work for additional information
005 *  regarding copyright ownership.  The ASF licenses this file
006 *  to you under the Apache License, Version 2.0 (the
007 *  "License"); you may not use this file except in compliance
008 *  with the License.  You may obtain a copy of the License at
009 *  
010 *    http://www.apache.org/licenses/LICENSE-2.0
011 *  
012 *  Unless required by applicable law or agreed to in writing,
013 *  software distributed under the License is distributed on an
014 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 *  KIND, either express or implied.  See the License for the
016 *  specific language governing permissions and limitations
017 *  under the License. 
018 *  
019 */
020package org.apache.directory.shared.ldap.model.exception;
021
022
023import org.apache.directory.shared.ldap.model.schema.SchemaManager;
024import org.apache.directory.shared.ldap.model.schema.SchemaObject;
025
026
027/**
028 * A subclass of {@link LdapException} which is used to report issues 
029 * during the integrity check of the schema by the {@link SchemaManager}.
030 * 
031 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
032 */
033public class LdapSchemaException extends LdapException
034{
035    /** The serial version UUID */
036    static final long serialVersionUID = 1L;
037
038    /** The code of the exception */
039    private LdapSchemaExceptionCodes code;
040
041    /** The 'source' schema object */
042    private SchemaObject sourceObject;
043
044    /** The 'other' schema object */
045    private SchemaObject otherObject;
046
047    /** The related ID (name or OID) of the exception */
048    private String relatedId;
049
050
051    /**
052     * Creates a new instance of LdapSchemaException.
053     */
054    public LdapSchemaException()
055    {
056        super();
057    }
058
059
060    /**
061     * Creates a new instance of LdapSchemaException.
062     *
063     * @param code
064     *      The code of the exception
065     */
066    public LdapSchemaException( LdapSchemaExceptionCodes code )
067    {
068        super();
069        this.code = code;
070    }
071
072
073    /**
074     * Creates a new instance of LdapSchemaException.
075     *
076     * @param explanation
077     *      The message associated with the exception
078     */
079    public LdapSchemaException( String explanation )
080    {
081        super( explanation );
082    }
083
084
085    /**
086     * Creates a new instance of LdapSchemaException.
087     *
088     * @param code The code of the exception
089     * @param explanation The message associated with the exception
090     */
091    public LdapSchemaException( LdapSchemaExceptionCodes code, String explanation )
092    {
093        super( explanation );
094        this.code = code;
095    }
096
097
098    /**
099     *
100     * @param code The code of the exception
101     * @param cause The root cause for this exception
102     */
103    public LdapSchemaException( LdapSchemaExceptionCodes code, Throwable cause )
104    {
105        super(cause);
106        this.code = code;
107    }
108
109    
110    /**
111     * Creates a new instance of LdapSchemaException.
112     *
113     * @param code The code of the exception
114     * @param explanation The message associated with the exception
115     * @param cause The root cause for this exception
116     */
117    public LdapSchemaException( LdapSchemaExceptionCodes code, String explanation, Throwable cause )
118    {
119        super( explanation, cause );
120        this.code = code;
121    }
122
123    
124    /**
125     * Gets the code of the exception.
126     *
127     * @return
128     *      the code of the exception
129     */
130    public LdapSchemaExceptionCodes getCode()
131    {
132        return code;
133    }
134
135
136    /**
137     * Sets the code of the exception.
138     *
139     * @param code
140     *      the code of the exception
141     */
142    public void setCode( LdapSchemaExceptionCodes code )
143    {
144        this.code = code;
145    }
146
147
148    /**
149     * Gets the 'source' schema object.
150     *
151     * @return
152     *      the 'source' schema object
153     */
154    public SchemaObject getSourceObject()
155    {
156        return sourceObject;
157    }
158
159
160    /**
161     * Sets the 'source' schema object.
162     *
163     * @param source
164     *      the 'source' schema object
165     */
166    public void setSourceObject( SchemaObject source )
167    {
168        this.sourceObject = source;
169    }
170
171
172    /**
173     * Gets the 'other' schema object.
174     *
175     * @return
176     *      the 'other' schema object
177     */
178    public SchemaObject getOtherObject()
179    {
180        return otherObject;
181    }
182
183
184    /**
185     * Sets the 'other' schema object.
186     *
187     * @param other
188     *      the 'other' schema object
189     */
190    public void setOtherObject( SchemaObject other )
191    {
192        this.otherObject = other;
193    }
194
195
196    /**
197     * Gets the related ID (name or OID) of the exception.
198     *
199     * @return
200     *      the related ID (name or OID)
201     */
202    public String getRelatedId()
203    {
204        return relatedId;
205    }
206
207
208    /**
209     * Sets the related ID (name or OID) of the exception.
210     *
211     * @param relatedId
212     *      the related ID (name or OID)
213     */
214    public void setRelatedId( String relatedId )
215    {
216        this.relatedId = relatedId;
217    }
218}