1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.ken.service.impl; |
17 | |
|
18 | |
import org.kuali.rice.core.framework.persistence.dao.GenericDao; |
19 | |
import org.kuali.rice.ken.bo.NotificationChannel; |
20 | |
import org.kuali.rice.ken.bo.NotificationProducer; |
21 | |
import org.kuali.rice.ken.service.NotificationAuthorizationService; |
22 | |
import org.kuali.rice.ken.util.NotificationConstants; |
23 | |
import org.kuali.rice.kim.api.KimConstants; |
24 | |
import org.kuali.rice.kim.api.group.Group; |
25 | |
import org.kuali.rice.kim.api.group.GroupService; |
26 | |
import org.kuali.rice.kim.api.identity.Person; |
27 | |
import org.kuali.rice.kim.api.services.KimApiServiceLocator; |
28 | |
|
29 | |
import java.util.List; |
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
public class NotificationAuthorizationServiceImpl implements NotificationAuthorizationService { |
37 | 0 | private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(NotificationAuthorizationServiceImpl.class); |
38 | |
|
39 | |
private GenericDao businessObjectDao; |
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | 0 | public NotificationAuthorizationServiceImpl(GenericDao businessObjectDao) { |
46 | 0 | this.businessObjectDao = businessObjectDao; |
47 | 0 | } |
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
public boolean isProducerAuthorizedToSendNotificationForChannel(NotificationProducer producer, NotificationChannel channel) { |
53 | 0 | List channels = producer.getChannels(); |
54 | |
|
55 | 0 | if(channels.contains(channel)) { |
56 | 0 | return true; |
57 | |
} else { |
58 | 0 | return false; |
59 | |
} |
60 | |
} |
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
public boolean isUserAdministrator(String userId) { |
68 | 0 | String groupNameId = NotificationConstants.KEW_CONSTANTS.NOTIFICATION_ADMIN_GROUP_NAME; |
69 | 0 | Person user = KimApiServiceLocator.getPersonService().getPerson(userId); |
70 | 0 | if (user == null) { |
71 | 0 | return false; |
72 | |
} |
73 | |
|
74 | 0 | final GroupService groupService = KimApiServiceLocator.getGroupService(); |
75 | 0 | Group group = groupService.getGroupByNameAndNamespaceCode(KimConstants.KIM_GROUP_WORKFLOW_NAMESPACE_CODE, |
76 | |
groupNameId); |
77 | 0 | return group == null ? false : groupService.isMemberOfGroup(user.getPrincipalId(), group.getId()); |
78 | |
} |
79 | |
} |