1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package com.fatwire.gst.foundation.tagging;
17
18 import java.util.Collection;
19
20 import com.fatwire.assetapi.data.AssetId;
21 import com.fatwire.gst.foundation.facade.assetapi.listener.RunOnceAssetEventListener;
22 import com.fatwire.gst.foundation.facade.ics.ICSFactory;
23
24
25
26
27
28
29
30
31 public final class CacheMgrTaggedAssetEventListener extends RunOnceAssetEventListener {
32
33
34
35 private AssetTaggingService getService() {
36 return AssetTaggingServiceFactory.getService(ICSFactory.getOrCreateICS());
37 }
38
39 @Override
40 public void doAssetAdded(AssetId assetId) {
41 if (LOG.isTraceEnabled()) {
42 LOG.trace("Heard assetAdded event for " + assetId);
43 }
44
45 AssetTaggingService svc = getService();
46 if (svc.isTagged(assetId)) {
47 Collection<Tag> tags = svc.getTags(assetId);
48 svc.clearCacheForTag(tags);
49 }
50 }
51
52 @Override
53 public void doAssetUpdated(AssetId assetId) {
54 if (LOG.isTraceEnabled()) {
55 LOG.trace("Heard assetUpdated event for " + assetId);
56 }
57 AssetTaggingService svc = getService();
58 if (svc.isTagged(assetId)) {
59 Collection<Tag> tags = svc.getTags(assetId);
60 svc.clearCacheForTag(tags);
61 }
62 }
63
64 @Override
65 public void doAssetDeleted(AssetId assetId) {
66 if (LOG.isTraceEnabled()) {
67 LOG.trace("Heard assetDeleted event for " + assetId);
68 }
69 AssetTaggingService svc = getService();
70 if (svc.isTagged(assetId)) {
71 Collection<Tag> tags = svc.getTags(assetId);
72 svc.clearCacheForTag(tags);
73 }
74 }
75
76
77 }