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