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.sec.document.web;
017    
018    import java.util.ArrayList;
019    import java.util.Iterator;
020    import java.util.List;
021    import java.util.Map;
022    
023    import javax.servlet.jsp.JspException;
024    import javax.servlet.jsp.PageContext;
025    import javax.servlet.jsp.tagext.Tag;
026    
027    import org.apache.struts.Globals;
028    import org.apache.struts.action.ActionMessage;
029    import org.apache.struts.action.ActionMessages;
030    import org.kuali.kfs.sec.SecConstants;
031    import org.kuali.kfs.sec.SecKeyConstants;
032    import org.kuali.kfs.sec.service.AccessSecurityService;
033    import org.kuali.kfs.sys.context.SpringContext;
034    import org.kuali.kfs.sys.document.AccountingDocument;
035    import org.kuali.kfs.sys.document.datadictionary.AccountingLineGroupDefinition;
036    import org.kuali.kfs.sys.document.web.DefaultAccountingLineGroupImpl;
037    import org.kuali.kfs.sys.document.web.RenderableAccountingLineContainer;
038    import org.kuali.kfs.sys.document.web.renderers.GroupErrorsRenderer;
039    import org.kuali.rice.kim.bo.Person;
040    import org.kuali.rice.kns.util.GlobalVariables;
041    
042    
043    /**
044     * Integrates with access security module to check security on accounting lines before rendering
045     */
046    public class CollectionSecAccountingLineGroupImpl extends SecAccountingLineGroupImpl {
047    
048        /**
049         * Constructs a SecAccountingLineGroupImpl
050         */
051        public CollectionSecAccountingLineGroupImpl() {
052            super();
053        }
054    
055        /**
056         * Adds info message if we have restricted view of any accounting lines and matches only messages for collection
057         * 
058         * @see org.kuali.kfs.sys.document.web.DefaultAccountingLineGroupImpl#renderErrors(javax.servlet.jsp.PageContext,
059         *      javax.servlet.jsp.tagext.Tag)
060         */
061        @Override
062        protected void renderErrors(PageContext pageContext, Tag parentTag) throws JspException {
063            renderSecurityMessage(pageContext, parentTag);
064    
065            GroupErrorsRenderer errorRenderer = new GroupErrorsRenderer();
066            List errors = errorRenderer.getErrorPropertyList(pageContext);
067            if (errors != null && !errors.isEmpty()) {
068                for (Iterator itr = errors.iterator(); itr.hasNext();) {
069                    String error = (String) itr.next();
070                    if (error.startsWith(collectionItemPropertyName)) {
071                        renderMessages(pageContext, parentTag, error);
072                    }
073                }
074            }
075        }
076    
077    }