Package com.opengamma.livedata.cogda.msg

Examples of com.opengamma.livedata.cogda.msg.CogdaLiveDataSubscriptionResponseMessage


   * @param fudgeContext
   * @param msg
   */
  private CogdaLiveDataCommandResponseMessage handleSubscriptionRequest(FudgeContext fudgeContext, FudgeMsg msg) {
    CogdaLiveDataSubscriptionRequestMessage request = CogdaLiveDataSubscriptionRequestBuilder.buildObjectStatic(new FudgeDeserializer(fudgeContext), msg);
    CogdaLiveDataSubscriptionResponseMessage response = new CogdaLiveDataSubscriptionResponseMessage();
    response.setCorrelationId(request.getCorrelationId());
    response.setSubscriptionId(request.getSubscriptionId());
    response.setNormalizationScheme(request.getNormalizationScheme());
   
    // TODO kirk 2012-07-23 -- Check entitlements.
    if (!getServer().isValidLiveData(request.getSubscriptionId(), request.getNormalizationScheme())) {
      response.setGenericResult(CogdaCommandResponseResult.NOT_AVAILABLE);
    } else if (!isEntitled(EntitlementUtils.SUBSCRIBE, 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.setSnapshot(fields);
     
      _subscriptions.putIfAbsent(new LiveDataSpecification(request.getNormalizationScheme(), request.getSubscriptionId()), Boolean.TRUE);
    }
    return response;
  }
View Full Code Here


   *
   * @param msg  the message, not null
   * @param subHandle  the subscription handle, not null
   */
  private void dispatchSubscriptionResponse(FudgeMsg msg, SubscriptionHandle subHandle) {
    CogdaLiveDataSubscriptionResponseMessage responseMessage = CogdaLiveDataSubscriptionResponseBuilder.buildObjectStatic(new FudgeDeserializer(getFudgeContext()), msg);
    LiveDataSpecification ldSpec = new LiveDataSpecification(responseMessage.getNormalizationScheme(), responseMessage.getSubscriptionId());
   
    LiveDataSubscriptionResult ldsResult = responseMessage.getGenericResult().toLiveDataSubscriptionResult();
    LiveDataSubscriptionResponse ldsResponse = new LiveDataSubscriptionResponse(subHandle.getRequestedSpecification(), ldsResult);
    ldsResponse.setFullyQualifiedSpecification(ldSpec);
    ldsResponse.setUserMessage(responseMessage.getUserMessage());
   
    LiveDataValueUpdateBean valueUpdateBean = new LiveDataValueUpdateBean(0L, subHandle.getRequestedSpecification(), responseMessage.getSnapshot());
    ldsResponse.setSnapshot(valueUpdateBean);
   
    switch (responseMessage.getGenericResult()) {
      case SUCCESSFUL:
        super.subscriptionRequestSatisfied(subHandle, ldsResponse);
        super.subscriptionStartingToReceiveTicks(subHandle, ldsResponse);
        break;
      default:
View Full Code Here

TOP

Related Classes of com.opengamma.livedata.cogda.msg.CogdaLiveDataSubscriptionResponseMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.