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.kim.api.role; 017 018import org.apache.commons.lang.StringUtils; 019import org.kuali.rice.core.api.exception.RiceIllegalArgumentException; 020import org.kuali.rice.core.api.uif.RemotableAttributeError; 021import org.kuali.rice.kim.api.type.KimAttributeField; 022import org.kuali.rice.kim.framework.role.RoleTypeService; 023 024import java.util.ArrayList; 025import java.util.Collections; 026import java.util.List; 027import java.util.Map; 028 029public abstract class PassThruRoleTypeServiceBase implements RoleTypeService { 030 031 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(PassThruRoleTypeServiceBase.class); 032 033 public static final String UNMATCHABLE_QUALIFICATION = "!~!~!~!~!~"; 034 035 @Override 036 public abstract Map<String, String> convertQualificationForMemberRoles(String namespaceCode, String roleName, String memberRoleNamespaceCode, String memberRoleName, Map<String, String> qualification); 037 038 @Override 039 public List<RoleMembership> getMatchingRoleMemberships(Map<String, String> qualification, 040 List<RoleMembership> roleMemberList) { 041 042 if (qualification == null) { 043 throw new RiceIllegalArgumentException("qualification was null"); 044 } 045 046 if (roleMemberList == null) { 047 throw new RiceIllegalArgumentException("roleMemberList was null"); 048 } 049 return Collections.unmodifiableList(new ArrayList<RoleMembership>(roleMemberList)); 050 } 051 052 @Override 053 public boolean doesRoleQualifierMatchQualification(Map<String, String> qualification, Map<String, String> roleQualifier) { 054 if (qualification == null) { 055 throw new RiceIllegalArgumentException("qualification was null"); 056 } 057 058 if (roleQualifier == null) { 059 throw new RiceIllegalArgumentException("roleQualifier was null"); 060 } 061 062 return true; 063 } 064 065 @Override 066 public boolean hasDerivedRole(String principalId, List<String> groupIds, String namespaceCode, String roleName, Map<String, String> qualification) { 067 if (StringUtils.isBlank(principalId)) { 068 throw new RiceIllegalArgumentException("principalId was null or blank"); 069 } 070 071 if (groupIds == null) { 072 throw new RiceIllegalArgumentException("groupIds was null or blank"); 073 } 074 075 if (StringUtils.isBlank(namespaceCode)) { 076 throw new RiceIllegalArgumentException("namespaceCode was null or blank"); 077 } 078 079 if (StringUtils.isBlank(roleName)) { 080 throw new RiceIllegalArgumentException("roleName was null or blank"); 081 } 082 083 if (qualification == null) { 084 throw new RiceIllegalArgumentException("qualification was null"); 085 } 086 087 return false; 088 } 089 090 @Override 091 public boolean isDerivedRoleType() { 092 return false; 093 } 094 095 public List<String> getAcceptedAttributeNames() { 096 return Collections.emptyList(); 097 } 098 099 @Override 100 public List<KimAttributeField> getAttributeDefinitions(String kimTypeId) { 101 if (StringUtils.isBlank(kimTypeId)) { 102 throw new RiceIllegalArgumentException("kimTypeId was null or blank"); 103 } 104 105 return Collections.emptyList(); 106 } 107 108 @Override 109 public String getWorkflowDocumentTypeName() { 110 return null; 111 } 112 113 @Override 114 public List<String> getWorkflowRoutingAttributes(String routeLevel) { 115 if (StringUtils.isBlank(routeLevel)) { 116 throw new RiceIllegalArgumentException("routeLevel was null or blank"); 117 } 118 119 return Collections.emptyList(); 120 } 121 122 public boolean supportsAttributes(List<String> attributeNames) { 123 if (attributeNames == null) { 124 throw new RiceIllegalArgumentException("attributeNames was null"); 125 } 126 127 return true; 128 } 129 130 public Map<String, String> translateInputAttributes(Map<String, String> inputAttributes) { 131 if (inputAttributes == null) { 132 throw new RiceIllegalArgumentException("inputAttributes was null"); 133 } 134 135 return inputAttributes; 136 } 137 138 @Override 139 public List<RemotableAttributeError> validateAttributes(String kimTypeId, Map<String, String> attributes) { 140 if (StringUtils.isBlank(kimTypeId)) { 141 throw new RiceIllegalArgumentException("kimTypeId was null or blank"); 142 } 143 144 if (attributes == null) { 145 throw new RiceIllegalArgumentException("attributes was null or blank"); 146 } 147 148 return Collections.emptyList(); 149 } 150 151 @Override 152 public List<RemotableAttributeError> validateAttributesAgainstExisting(String kimTypeId, Map<String, String> newAttributes, Map<String, String> oldAttributes){ 153 if (StringUtils.isBlank(kimTypeId)) { 154 throw new RiceIllegalArgumentException("kimTypeId was null or blank"); 155 } 156 157 if (newAttributes == null) { 158 throw new RiceIllegalArgumentException("newAttributes was null or blank"); 159 } 160 161 if (oldAttributes == null) { 162 throw new RiceIllegalArgumentException("oldAttributes was null or blank"); 163 } 164 165 return Collections.emptyList(); 166 } 167 168 @Override 169 public boolean dynamicRoleMembership(String namespaceCode, String roleName) { 170 if (StringUtils.isBlank(namespaceCode)) { 171 throw new RiceIllegalArgumentException("namespaceCode was null or blank"); 172 } 173 174 if (StringUtils.isBlank(roleName)) { 175 throw new RiceIllegalArgumentException("roleName was null or blank"); 176 } 177 178 return false; 179 } 180 181}