1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.ken.util; |
17 | |
|
18 | |
import org.apache.log4j.Logger; |
19 | |
import org.kuali.rice.ken.bo.NotificationContentType; |
20 | |
import org.kuali.rice.ken.service.NotificationContentTypeService; |
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
public class ContentTypeResourceResolver { |
28 | |
protected static final String CONTENT_TYPE_PREFIX = "resource:notification/ContentType"; |
29 | |
|
30 | 0 | protected final Logger LOG = Logger.getLogger(getClass()); |
31 | |
|
32 | |
private NotificationContentTypeService notificationContentTypeService; |
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | 0 | public ContentTypeResourceResolver(NotificationContentTypeService notificationContentTypeService) { |
39 | 0 | this.notificationContentTypeService = notificationContentTypeService; |
40 | 0 | } |
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
public NotificationContentType resolveContentType(String id) { |
48 | 0 | if (!id.startsWith(CONTENT_TYPE_PREFIX)) return null; |
49 | 0 | String contentType = id.substring(CONTENT_TYPE_PREFIX.length()); |
50 | 0 | NotificationContentType notificationContentType = notificationContentTypeService.getNotificationContentType(contentType); |
51 | 0 | if (contentType == null) { |
52 | 0 | LOG.warn("Content type '" + contentType + "' not found in notification database"); |
53 | 0 | return null; |
54 | |
} |
55 | |
|
56 | 0 | LOG.info("Resolved '" + id + "' to notification content type: " + notificationContentType); |
57 | 0 | return notificationContentType; |
58 | |
} |
59 | |
} |