* @param fudgeContext
* @param msg
*/
private CogdaLiveDataCommandResponseMessage handleSnapshotRequest(FudgeContext fudgeContext, FudgeMsg msg) {
CogdaLiveDataSnapshotRequestMessage request = CogdaLiveDataSnapshotRequestBuilder.buildObjectStatic(new FudgeDeserializer(fudgeContext), msg);
CogdaLiveDataSnapshotResponseMessage response = new CogdaLiveDataSnapshotResponseMessage();
response.setCorrelationId(request.getCorrelationId());
response.setSubscriptionId(request.getSubscriptionId());
response.setNormalizationScheme(request.getNormalizationScheme());
if (!getServer().isValidLiveData(request.getSubscriptionId(), request.getNormalizationScheme())) {
response.setGenericResult(CogdaCommandResponseResult.NOT_AVAILABLE);
} else if (!isEntitled(EntitlementUtils.SNAPSHOT, request.getSubscriptionId(), request.getNormalizationScheme())) {
response.setGenericResult(CogdaCommandResponseResult.NOT_AUTHORIZED);
} else {
LastKnownValueStore lkvStore = getServer().getLastKnownValueStore(request.getSubscriptionId(), request.getNormalizationScheme());
FudgeMsg fields = null;
if (lkvStore != null) {
fields = lkvStore.getFields();
} else {
s_logger.warn("Valid live data {} lacks fields in LKV store", request);
fields = fudgeContext.newMessage();
}
response.setGenericResult(CogdaCommandResponseResult.SUCCESSFUL);
response.setValues(fields);
}
return response;
}