Coverage Report - org.kuali.rice.ken.service.impl.NotificationRecipientServiceKimImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
NotificationRecipientServiceKimImpl
0%
0/18
0%
0/10
1.5
 
 1  
 /*
 2  
  * Copyright 2008 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.ken.service.impl;
 17  
 
 18  
 import java.util.List;
 19  
 
 20  
 import org.apache.log4j.Level;
 21  
 import org.apache.log4j.Logger;
 22  
 import org.kuali.rice.ken.service.NotificationRecipientService;
 23  
 import org.kuali.rice.kim.api.services.IdentityManagementService;
 24  
 import org.kuali.rice.kim.api.group.Group;
 25  
 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
 26  
 import org.kuali.rice.kim.util.KimConstants.KimGroupMemberTypes;
 27  
 
 28  
 /**
 29  
  * NotificationRecipientService implementation
 30  
  * This implementation relies on KIM user and group management
 31  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 32  
  */
 33  0
 public class NotificationRecipientServiceKimImpl implements NotificationRecipientService
 34  
 {
 35  0
     private static final Logger LOG =
 36  
         Logger.getLogger(NotificationRecipientServiceKimImpl.class);
 37  
 
 38  
     protected IdentityManagementService getIdentityManagementService()
 39  
     {
 40  0
         return KimApiServiceLocator.getIdentityManagementService();
 41  
     }
 42  
 
 43  
     /**
 44  
      * Uses the IdentityManagementService of KIM to get the members of a group.
 45  
      *
 46  
      * @param groupRecipientId the String name of the recipient group
 47  
      * @return a String array of all direct (child) principals and descendent principals
 48  
      * @see org.kuali.rice.ken.service.NotificationRecipientService#getGroupMembers(java.lang.String)
 49  
      */
 50  
     public String[] getGroupMembers(String groupRecipientId)
 51  
     {
 52  0
         Group group = getIdentityManagementService().getGroup(groupRecipientId);
 53  
 
 54  0
         List<String> ids = getIdentityManagementService().getGroupMemberPrincipalIds(group.getId());
 55  
 
 56  0
         String[] array = new String[ids.size()];
 57  0
         return ids.toArray(array);
 58  
     }
 59  
 
 60  
     /**
 61  
      * This method retrieves the display name for a user.
 62  
      * @param userId
 63  
      * @return String
 64  
      */
 65  
     public String getUserDisplayName(String userId)
 66  
     {
 67  
         //Gary's handling user conversion
 68  0
         return null;
 69  
     }
 70  
 
 71  
     /**
 72  
      *
 73  
      * @see org.kuali.rice.ken.service.NotificationRecipientService#isRecipientValid(java.lang.String, java.lang.String)
 74  
      */
 75  
      public boolean isRecipientValid(String recipientId, String recipientType)
 76  
      {
 77  0
          boolean b = false;
 78  
 
 79  0
          if( recipientType.equals(KimGroupMemberTypes.GROUP_MEMBER_TYPE))
 80  
          {
 81  0
              b = isGroupRecipientValid( recipientId );
 82  
          }
 83  0
          else if( recipientType.equals(KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE) )
 84  
          {
 85  0
              b = isUserRecipientValid( recipientId );
 86  
          }
 87  
          else
 88  
          {
 89  0
              if( LOG.isEnabledFor(Level.ERROR) )
 90  
              {
 91  0
                  LOG.error("Recipient Type is neither of two acceptable values");
 92  
              }
 93  
          }
 94  0
          return b;
 95  
      }
 96  
 
 97  
     /**
 98  
      * This overridden method ...
 99  
      *
 100  
      * @see org.kuali.rice.ken.service.NotificationRecipientService#isGroupRecipientValid(java.lang.String)
 101  
      */
 102  
     public boolean isGroupRecipientValid(String groupRecipientId)
 103  
     {
 104  0
         return (KimApiServiceLocator.getIdentityManagementService().getGroup( groupRecipientId ) != null);
 105  
     }
 106  
 
 107  
     /**
 108  
      * This overridden method ...
 109  
      *
 110  
      * @see org.kuali.rice.ken.service.NotificationRecipientService#isUserRecipientValid(java.lang.String)
 111  
      */
 112  
     public boolean isUserRecipientValid(String principalName)
 113  
     {
 114  0
         return (KimApiServiceLocator.getIdentityManagementService()
 115  
                 .getPrincipalByPrincipalName(principalName) != null);
 116  
     }
 117  
 
 118  
 }