001/**
002 * Copyright 2005-2018 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.kew.api.exception;
017
018import org.kuali.rice.core.api.util.xml.XmlException;
019
020/**
021 * This error is thrown whenever a child document type is trying to be processed before its 
022 * parent document type has been parsed; this provides a means for delaying the processing
023 * of child doc types until their parents are parsed.
024 * 
025 * @author Kuali Rice Team (rice.collab@kuali.org)
026 *
027 */
028public class InvalidParentDocTypeException extends XmlException {
029        
030        /** The name of the parent document that still needs to be parsed. */
031        private final String parentName;
032        /** The name of the child document that was expecting the parentName document to exist. */
033        private final String childName;
034        
035        /**
036         * Constructs an InvalidParentDocTypeException, given a document type parent name and a child name.
037         * 
038         * @param docParent The name of the unprocessed document type parent.
039         * @param docChild The name of the unprocessed document type child.
040         */
041        public InvalidParentDocTypeException(String docParent, String docChild) {
042                super("parent: " + docParent + " child: " + docChild);
043                parentName = docParent;
044                childName = docChild;
045        }
046        
047        /**
048         * Constructs an InvalidParentDocTypeException, given a document type parent name, a child name, and an error message.
049         * 
050         * @param docParent The name of the unprocessed document type parent.
051         * @param docChild The name of the unprocessed document type child.
052         * @param message The error message.
053         */
054        public InvalidParentDocTypeException(String docParent, String docChild, String message) {
055                super(message);
056                parentName = docParent;
057                childName = docChild;
058        }
059
060        /**
061         * Constructs an InvalidParentDocTypeException, given a document type parent name, a child name, an error message, and a cause.
062         * 
063         * @param docParent The name of the unprocessed document type parent.
064         * @param docChild The name of the unprocessed document type child.
065         * @param message The error message.
066         * @param throwable The cause.
067         */
068        public InvalidParentDocTypeException(String docParent, String docChild, String message, Throwable throwable) {
069                super(message, throwable);
070                parentName = docParent;
071                childName = docChild;
072        }
073
074        /**
075         * Constructs an InvalidParentDocTypeException, given a document type parent name, a child name, and a cause.
076         * 
077         * @param docParent The name of the unprocessed document type parent.
078         * @param docChild The name of the unprocessed document type child.
079         * @param throwable The cause.
080         */
081        public InvalidParentDocTypeException(String docParent, String docChild, Throwable throwable) {
082                super(throwable);
083                parentName = docParent;
084                childName = docChild;
085        }
086        
087        /**
088         * Retrieves the name of the parent document type that has not been processed yet.
089         * 
090         * @return The name of the unprocessed document type parent, which may or may not be null.
091         */
092        public String getParentName() {
093                return parentName;
094        }
095        
096        /**
097         * Retrieves the name of the child document type that depends on the given parent.
098         * 
099         * @return The name of the unprocessed document type child, which may or may not be null.
100         */
101        public String getChildName() {
102                return childName;
103        }
104}