001/*
002 *  Copyright 2021 Anyware Services
003 *
004 *  Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0
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.ametys.cms.workflow;
017
018import org.ametys.cms.repository.Content;
019import org.ametys.runtime.authentication.AccessDeniedException;
020import org.ametys.runtime.model.ModelItem;
021
022/**
023 * Exception representing an error while editing a content.
024 */
025public class EditContentAccessDeniedException extends AccessDeniedException
026{
027    private Content _content;
028    private ModelItem _modelItem;
029    
030    /**
031     * Constructs a new {@link EditContentAccessDeniedException}. Message is automatically built.
032     * @param content the content on which the exception occurs
033     * @param modelItem the model item on which the exception occurs
034     */
035    public EditContentAccessDeniedException(Content content, ModelItem modelItem)
036    {
037        super("The current user has no right to edit attribute " + modelItem.getPath() + " on the content " + content.toString());
038        _content = content;
039        _modelItem = modelItem;
040    }
041    
042    /**
043     * Get the content which the exception appears on.
044     * @return the content
045     */
046    public Content getContent()
047    {
048        return _content;
049    }
050    
051    /**
052     * Get the model item which the exception appears on.
053     * @return the model item
054     */
055    public ModelItem getModelItem()
056    {
057        return _modelItem;
058    }
059}