001/**
002 * Copyright 2005-2015 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.notes;
017
018import org.apache.log4j.Logger;
019import org.kuali.rice.kew.api.document.Document;
020import org.kuali.rice.krad.UserSession;
021
022
023/**
024 * Default implementation of the {@link CustomNoteAttribute}.
025 *
026 * @author Kuali Rice Team (rice.collab@kuali.org)
027 */
028public class CustomNoteAttributeImpl implements CustomNoteAttribute {
029
030    private Document routeHeaderVO;
031    private UserSession userSession;
032    private static final Logger LOG = Logger.getLogger(CustomNoteAttributeImpl.class);
033
034    @Override
035        public boolean isAuthorizedToAddNotes() throws Exception {
036        return true;
037    }
038
039    /**
040     * By default the individual who authored the note is the only one allowed to edit it.
041     */
042    @Override
043        public boolean isAuthorizedToEditNote(Note note) throws Exception {
044        return note.getNoteAuthorWorkflowId().equalsIgnoreCase(userSession.getPrincipalId());
045    }
046
047    @Override
048        public Document getRouteHeaderVO() {
049        return routeHeaderVO;
050    }
051
052    @Override
053        public void setRouteHeaderVO(Document routeHeaderVO) {
054        this.routeHeaderVO = routeHeaderVO;
055    }
056
057        @Override
058        public UserSession getUserSession() {
059                return userSession;
060        }
061
062        @Override
063        public void setUserSession(UserSession userSession) {
064                this.userSession = userSession;
065        }
066        
067    @Override
068    public boolean isAuthorizedToRetrieveAttachments() throws Exception {
069        LOG.info("CustomNoteAttribute override not found, defaulting attachment security result will be true.");
070        return true;
071    }
072
073}