MediaCentral | Middleware decomposition

Preface

Middleware is an OSGI container which runs 'plugins'. Plugin is an OSGI bundle which contains isolated(from other bundles) Java code and optionally a set of resources(js, css, and a description file), which will be discovered by the framework and dynamically loaded in the MC|UX UI environment. The middleware will go way with MediaCentral 2018.1.

New APIs

User Settings

User Settings will be stored in IAM now. IAM provides a PrincipalSettings API on the bus and as Upstream/Rest endpoint that can be used for this purpose.

'Old' APIs that use the avid.uss service cannot be used anymore. To use the new API from the Client (JS) side there is a JS API - User Settings API


Settings and Configuration Data

This kind of data has to be stored in the 'avid.acs.attributes v3 Service'. This bus service also provides Upstream/Rest endpoints. The permission for writing of attributes is for administrators only though.

For the Client (JS) side a similar API for the 'Settings API' will be provided soon.


Authentication

See Platform Authentication


Building a service by re-using existing (OSGi) modules

We can provide a quite thin utility layer and allow to reuse implemented interplay modules to declare corresponding bus and upstream/rest endpoint.

Basically instead of using the JAX-RS exposure we can declare ACS bus service instances.


Code examples


DMS job creation and monitoring

Methods:


Exposed endpoints:


DMSBusService inteface:
1
2
3
4
5
6
7
8
9
10
11
12
13
@BusService(type = "avid.pam.dms", realm = "global", version = 1, desc = "DMS service based on Avid Connector API for Java")
@Errors({
@Error(code = "ILLEGAL_STATE", severity = ErrorSeverity.ERROR, messageTemplate = "Illegal state for : %{deliveryRequestDTO}", status = 500),
})
public interface DMSBusService extends InterplayBusService {

@Operation(name = "submitDeliveryJob", desc = "Submits a delivery job for given payload. Returns response back with information whether job submitted successfully or not")
@Examples({
@Example(name = "submitDeliveryJob", file = "submitDeliveryJob.json"),
})
@RestRequest(path = "submitDeliveryJob", method = RequestMethod.POST, queryParams = { "deliveryRequestDTO" })
void submitDeliveryJob(@Param("deliveryRequestDTO") String deliveryRequestDTOJson, final OperationContext<GenericResponse> context);
}

DMSBusService implementation:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
public class DMSBusServiceImpl extends InterplayBusServiceImpl implements DMSBusService {

private static final Logger LOG = LoggerFactory.getLogger(DMSBusServiceImpl.class);
private ProcessComponent bgService;

public DMSBusServiceImpl() {
ProcessProvider processProvider = new SampleProcessProvider();
bgService = new ProcessComponent();
bgService.addProcessProvider(processProvider);
}

@Override
public void setBaseJXDKUtils(BaseJXDKUtils baseJXDKUtils) {
super.setBaseJXDKUtils(baseJXDKUtils);

setupDMSBusRegistryService(baseJXDKUtils);

}

private void setupDMSBusRegistryService(BaseJXDKUtils baseJXDKUtils) {
final IpcBusAccessFactory busAccessFactory = new IpcBusAccessFactory();

BusRegistryService dmsBusRegistryService = new BusRegistryService();
BusClientConfigResolver configResolver = new BusClientConfigResolver();
configResolver.setBusAccessFactory(busAccessFactory);

dmsBusRegistryService.setConfigResolver(configResolver);
final UserSessionService sessionService = new UserSessionService() {
@Override
public void addUserSessionListener(UserSessionListener userSessionListener) {
LOG.info("addUserSessionListener: {}", userSessionListener);
}

@Override
public void removeUserSessionListener(UserSessionListener userSessionListener) {
LOG.info("removeUserSessionListener: {}", userSessionListener);

}
};
dmsBusRegistryService.setSessionService(sessionService);

BusServiceRegisterImpl register = new BusServiceRegisterImpl();
register.setBusAccessFactory(busAccessFactory);
DMSClientFactory clientFactory = new DefaultDMSClientFactory();
register.setClientFactory(clientFactory);
dmsBusRegistryService.setRegistry(register);

try {
final BaseJXDKUtils.InterplaySettingsServiceExt interplaySettingsService = baseJXDKUtils.getInterplaySettingsServiceExt(busAccessFactory);
final ClientCache clientCache = BaseJXDKUtils.getClientCache(baseJXDKUtils);
interplaySettingsService.setClientCache(clientCache);
interplaySettingsService.activate();
dmsBusRegistryService.setSettingsService(interplaySettingsService);
dmsBusRegistryService.activate();
LOG.info("DMS Bus Service activated");
} catch (Exception e) {
LOG.warn("Error", e);
}
}

@NotNull
private RestComponent getDMSComponent(BaseJXDKUtils baseJXDKUtils, UserIdentity userIdentity) throws BusAccessException {
final IpcBusAccessFactory busAccessFactory = new IpcBusAccessFactory();

baseJXDKUtils.getInterplaySettingsService().getInterCredentialServiceExtended().setUserIdentity(userIdentity);

final InterplayComponent interplayComponent = BaseJXDKUtils.getInterplayComponent(baseJXDKUtils, userIdentity);

RestComponent dmsRestComponent = new RestComponent();
dmsRestComponent.setClientCache(interplayComponent);

ServerPush serverPush = new ServerPush() {
@Override
public void push(String userLogin, NotificationDTO notification) {
LOG.info(">>>>>>>> push for user {} with data {} for recipient {}", userLogin, new ObjectData(notification.getData()).asJson(), notification.getRecipient());
}

@Override
public void pushToParticularSession(String httpSessionId, NotificationDTO notification) {
LOG.info("pushToParticularSession for userSessionId {} with data {}", httpSessionId, new ObjectData(notification).asJson());
}

@Override
public void pushToAllClients(NotificationDTO notification) {
LOG.info("pushToAllClients with data {}", new ObjectData(notification).asJson());
}
};
UserProcessRegistry registry = new UserProcessRegistry() {
@Override
public void setupBusAccess() throws BusAccessException {
setBusAccessFactory(busAccessFactory);
super.setupBusAccess();
}
};

registry.setPusher(serverPush);
registry.setupBusAccess();

ClientNotifier notifier = new ClientNotifier() {
@Override
public void setupBusAccess() throws BusAccessException {
setBusAccessFactory(busAccessFactory);
super.setupBusAccess();
}
};
notifier.setupBusAccess();

bgService.setRegistry(registry);

dmsRestComponent.setProcessService(bgService);

BusDMSClientFactoryClient dmsClientFactory = new BusDMSClientFactoryClient();
dmsClientFactory.setBusAccessFactory(busAccessFactory);
dmsRestComponent.setBusDMSClientFactory(dmsClientFactory);
return dmsRestComponent;
}

@Override
public void submitDeliveryJob(final String deliveryRequestDTOJson, final OperationContext<GenericResponse> context) {

try {
final BaseServiceUtils<GenericResponse> serviceUtils = new BaseServiceUtils<>();

serviceUtils.proceed(new BaseServiceUtils.AuthenticatedCallback<GenericResponse>(context) {
@Override
public void onProceed(final UserIdentity userIdentity) throws BusAccessException {

final ErrorSet errorSet = new ErrorSet();
JsonNode result = null;

try {
RestComponent dmsRestComponent = getDMSComponent(baseJXDKUtils, userIdentity);

SubmitDeliveryResource submitDeliveryResource = new SubmitDeliveryResource(dmsRestComponent, dmsRestComponent);

UserInfo userInfo = new UserInfo(serviceUtils.getUserSession(), Locale.ENGLISH);

ObjectMapper mapper = new ObjectMapper();
final DeliveryRequestDTO deliveryRequestDTO = mapper.readValue(deliveryRequestDTOJson, DeliveryRequestDTO.class);

final Response response = submitDeliveryResource.deliver(userInfo, deliveryRequestDTO);

result = new POJONode(response) ;

} catch (Exception e) {
LOG.error("An error occurred.", e);
errorSet.add("ILLEGAL_STATE", Collections.singletonMap("deliveryRequestDTO", deliveryRequestDTOJson), e.getLocalizedMessage()) ;
}
finally {

}
context.respond(new GenericResponse(errorSet, result), context.getMessage().context());
}

});

} catch (BusAccessException e) {
LOG.error("???", e);
}
}
}

Example:
1
2
3
4
5
6
7
8
9
{
"serviceType": "avid.pam.dms",
"serviceRealm": "global",
"serviceVersion": 1,
"op": "submitDeliveryJob",
"paramSet": {
"deliveryRequestDTO": "{\"profile\":\"wg1 full all\",\"in\":0,\"out\":100,\"deliveryFromInToOut\":false,\"assetIds\":[\"interplay-pam:28FDD0DA-3BB3-4695-800D-85AD364557CE:sequence:060a2b340101010501010f1013-000000-9b19e66331e200a5-5c7e002655d6-3a94\"]}"
}
}