1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.opencastproject.event.handler;
23
24 import org.opencastproject.message.broker.api.assetmanager.AssetManagerItem;
25 import org.opencastproject.message.broker.api.update.AssetManagerUpdateHandler;
26
27 import org.osgi.service.component.ComponentContext;
28 import org.osgi.service.component.annotations.Activate;
29 import org.osgi.service.component.annotations.Component;
30 import org.osgi.service.component.annotations.Deactivate;
31 import org.osgi.service.component.annotations.Reference;
32 import org.osgi.service.component.annotations.ReferenceCardinality;
33 import org.osgi.service.component.annotations.ReferencePolicy;
34 import org.slf4j.Logger;
35 import org.slf4j.LoggerFactory;
36
37
38
39
40 @Component(
41 immediate = true,
42 service = {
43 AssetManagerUpdateHandler.class
44 },
45 property = {
46 "service.description=Conducting event handler for recording events",
47 }
48 )
49 public class ConductingEpisodeUpdatedEventHandler implements AssetManagerUpdateHandler {
50
51 private static final Logger logger = LoggerFactory.getLogger(ConductingEpisodeUpdatedEventHandler.class);
52
53 private OaiPmhUpdatedEventHandler oaiPmhUpdatedEventHandler;
54
55 @Activate
56 public void activate(ComponentContext cc) {
57 logger.info("Activating {}", ConductingEpisodeUpdatedEventHandler.class.getName());
58 }
59
60 @Deactivate
61 public void deactivate(ComponentContext cc) {
62 logger.info("Deactivating {}", ConductingEpisodeUpdatedEventHandler.class.getName());
63 }
64
65 @Override
66 public void execute(AssetManagerItem messageItem) {
67 if (! (messageItem instanceof AssetManagerItem.TakeSnapshot)) {
68
69 return;
70 }
71 AssetManagerItem.TakeSnapshot snapshotItem = (AssetManagerItem.TakeSnapshot) messageItem;
72 if (AssetManagerItem.Type.Update.equals(snapshotItem.getType())) {
73
74 if (oaiPmhUpdatedEventHandler != null) {
75 oaiPmhUpdatedEventHandler.handleEvent(snapshotItem);
76 }
77 }
78 }
79
80
81
82
83 @Reference (
84 policy = ReferencePolicy.DYNAMIC,
85 cardinality = ReferenceCardinality.OPTIONAL,
86 unbind = "unsetOaiPmhUpdatedEventHandler"
87 )
88 public void setOaiPmhUpdatedEventHandler(OaiPmhUpdatedEventHandler h) {
89 this.oaiPmhUpdatedEventHandler = h;
90 }
91
92 public void unsetOaiPmhUpdatedEventHandler(OaiPmhUpdatedEventHandler h) {
93 if (this.oaiPmhUpdatedEventHandler == h) {
94 this.oaiPmhUpdatedEventHandler = null;
95 }
96 }
97 }