Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
NotificationAuthorizationServiceImpl |
|
| 2.3333333333333335;2.333 |
1 | /* | |
2 | * Copyright 2007 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.kuali.rice.core.dao.GenericDao; | |
21 | import org.kuali.rice.ken.bo.NotificationChannel; | |
22 | import org.kuali.rice.ken.bo.NotificationProducer; | |
23 | import org.kuali.rice.ken.service.NotificationAuthorizationService; | |
24 | import org.kuali.rice.ken.util.NotificationConstants; | |
25 | import org.kuali.rice.kim.bo.Person; | |
26 | import org.kuali.rice.kim.service.KIMServiceLocator; | |
27 | import org.kuali.rice.kim.util.KimConstants; | |
28 | ||
29 | ||
30 | /** | |
31 | * NotificationAuthorizationService implementation - this is the default out-of-the-box implementation of the service. | |
32 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
33 | */ | |
34 | public class NotificationAuthorizationServiceImpl implements NotificationAuthorizationService { | |
35 | 0 | private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(NotificationAuthorizationServiceImpl.class); |
36 | ||
37 | private GenericDao businessObjectDao; | |
38 | ||
39 | /** | |
40 | * Constructs a NotificationAuthorizationServiceImpl class instance. | |
41 | * @param businessObjectDao | |
42 | */ | |
43 | 0 | public NotificationAuthorizationServiceImpl(GenericDao businessObjectDao) { |
44 | 0 | this.businessObjectDao = businessObjectDao; |
45 | 0 | } |
46 | ||
47 | /** | |
48 | * @see org.kuali.rice.ken.service.NotificationAuthorizationService#isProducerAuthorizedToSendNotificationForChannel(org.kuali.rice.ken.bo.NotificationProducer, org.kuali.rice.ken.bo.NotificationChannel) | |
49 | */ | |
50 | public boolean isProducerAuthorizedToSendNotificationForChannel(NotificationProducer producer, NotificationChannel channel) { | |
51 | 0 | List channels = producer.getChannels(); |
52 | ||
53 | 0 | if(channels.contains(channel)) { |
54 | 0 | return true; |
55 | } else { | |
56 | 0 | return false; |
57 | } | |
58 | } | |
59 | ||
60 | /** | |
61 | * Implements by calling the is user member of service in KEW's workgroup service, looking for a specific membership | |
62 | * in the "NotificationAdmin" workgroup. | |
63 | * @see org.kuali.rice.ken.service.NotificationAuthorizationService#isUserAdministrator(java.lang.String) | |
64 | */ | |
65 | public boolean isUserAdministrator(String userId) { | |
66 | 0 | String groupNameId = NotificationConstants.KEW_CONSTANTS.NOTIFICATION_ADMIN_GROUP_NAME; |
67 | 0 | Person user = KIMServiceLocator.getPersonService().getPerson(userId); |
68 | 0 | if (user == null) { |
69 | 0 | return false; |
70 | } | |
71 | 0 | return KIMServiceLocator.getIdentityManagementService().isMemberOfGroup(user.getPrincipalId(), KimConstants.KIM_GROUP_WORKFLOW_NAMESPACE_CODE, groupNameId); |
72 | } | |
73 | } |