001    /*
002     * Copyright 2011 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     */
016    package org.kuali.kfs.module.bc.exception;
017    
018    import org.kuali.kfs.module.bc.BCKeyConstants;
019    import org.kuali.rice.kns.exception.AuthorizationException;
020    import org.kuali.rice.kns.util.RiceKeyConstants;
021    
022    /**
023     * Handles special Budget Construction Document exception processing to display the reason behind the authorization exception
024     * and to also display a link allowing the user to get back to the BC document selection screen.
025     * 
026     */
027    public class BudgetConstructionDocumentAuthorizationException extends AuthorizationException {
028        
029        private boolean isPickListMode;
030    
031        /**
032         * Constructs a BudgetConstructionDocumentAuthorizationException.java.
033         * @param userId
034         * @param action
035         * @param documentId
036         */
037        public BudgetConstructionDocumentAuthorizationException(String userId, String action, String documentId, String reason, boolean isPickListMode) {
038    
039            super(userId, action, documentId.toString() + ": " + reason, "user '" + userId + "' is not authorized to " + action + " document '" + documentId + ": " + reason + "'", null);
040            this.isPickListMode = isPickListMode;
041        }
042    
043        /**
044         * @see org.kuali.rice.kns.exception.AuthorizationException#getErrorMessageKey()
045         */
046        @Override
047        public String getErrorMessageKey() {
048    
049            if (isPickListMode){
050                return RiceKeyConstants.AUTHORIZATION_ERROR_DOCUMENT;
051            } else {
052                return BCKeyConstants.ERROR_BUDGET_AUTHORIZATION_DOCUMENT;
053            }
054        }
055    
056    }