001/** 002 * Copyright 2005-2016 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.krad.kim; 017 018 019import org.kuali.rice.kim.api.KimConstants; 020import org.kuali.rice.kim.api.permission.Permission; 021import org.kuali.rice.kim.impl.permission.PermissionBo; 022import org.kuali.rice.krad.kim.DocumentTypePermissionTypeServiceImpl; 023 024import java.util.ArrayList; 025import java.util.List; 026import java.util.Map; 027 028/** 029 * @author Kuali Rice Team (rice.collab@kuali.org) 030 */ 031public class DocumentTypeAndRelationshipToNoteAuthorPermissionTypeService 032 extends DocumentTypePermissionTypeServiceImpl { 033 034 @Override 035 protected List<Permission> performPermissionMatches( 036 Map<String, String> requestedDetails, 037 List<Permission> permissionsList) { 038 039 List<Permission> matchingPermissions = new ArrayList<Permission>(); 040 if (requestedDetails == null) { 041 return matchingPermissions; // empty list 042 } 043 044 // loop over the permissions, checking the non-document-related ones 045 for (Permission permission : permissionsList) { 046 PermissionBo bo = PermissionBo.from(permission); 047 if (Boolean.parseBoolean(requestedDetails 048 .get(KimConstants.AttributeConstants.CREATED_BY_SELF))) { 049 if(Boolean.parseBoolean(bo.getDetails().get( 050 KimConstants.AttributeConstants.CREATED_BY_SELF_ONLY))){ 051 matchingPermissions.add(permission); 052 } 053 054 }else{ 055 if (!Boolean.parseBoolean(bo.getDetails().get( 056 KimConstants.AttributeConstants.CREATED_BY_SELF_ONLY))) { 057 matchingPermissions.add(permission); 058 } 059 } 060 061 } 062 063 matchingPermissions = super.performPermissionMatches(requestedDetails, matchingPermissions); 064 return matchingPermissions; 065 } 066}