001    /**
002     * Copyright 2005-2013 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.rice.kew.notes;
017    
018    import org.kuali.rice.kew.api.document.Document;
019    import org.kuali.rice.krad.UserSession;
020    
021    
022    /**
023     * The default implementation of a CustomNoteAttribute in core workflow.  This can be overriden
024     * in the institution plugin extension.
025     */
026    public class WorkflowNoteAttributeImpl implements CustomNoteAttribute {
027    
028        private Document routeHeaderVO;
029    
030        private UserSession userSession;
031    
032        @Override
033            public boolean isAuthorizedToAddNotes() throws Exception {
034            return true;
035        }
036    
037        /**
038         * By default the individual who authored the note is the only one allowed to edit it.
039         */
040        @Override
041            public boolean isAuthorizedToEditNote(Note note) throws Exception {
042            return note.getNoteAuthorWorkflowId().equalsIgnoreCase(userSession.getPrincipalId());
043        }
044    
045        @Override
046            public Document getRouteHeaderVO() {
047            return routeHeaderVO;
048        }
049    
050        @Override
051            public void setRouteHeaderVO(Document routeHeaderVO) {
052            this.routeHeaderVO = routeHeaderVO;
053        }
054    
055            @Override
056            public UserSession getUserSession() {
057                    return userSession;
058            }
059    
060            @Override
061            public void setUserSession(UserSession userSession) {
062                    this.userSession = userSession;
063            }
064            
065       @Override
066        public boolean isAuthorizedToRetrieveAttachments() throws Exception {
067            return true;
068        }
069    }