mil.dod.th.ose.remote/src/mil/dod/th/ose/remote/asset/AssetMessageService.java
private Message captureData(final AssetNamespace message, final TerraHarvestMessage request, final RemoteChannel 
        channel) throws IOException
    {
        final CaptureDataRequestData captureRequest = CaptureDataRequestData.parseFrom(message.getData());
        final Asset asset = m_AssetDirectoryService.getAssetByUuid(SharedMessageUtils.
                    convertProtoUUIDtoUUID(captureRequest.getUuid()));

        try
        {
            final Observation observation;
            if (captureRequest.hasSensorId())
            {
                observation = asset.captureData(captureRequest.getSensorId());
            }
            else
            {
                observation = asset.captureData();
            }

            final CaptureDataResponseData.Builder responseBuilder = CaptureDataResponseData.newBuilder();
            responseBuilder.setAssetUuid(captureRequest.getUuid());

            if (captureRequest.hasSensorId())
            {
                responseBuilder.setSensorId(captureRequest.getSensorId());
            }

            switch (captureRequest.getObservationFormat())
            {
                case NATIVE:
                    //Respond with observation data if the getObservationResponse flag was set to true 
                    //Otherwise respond with the UUID of the observation data
                    final ObservationGen.Observation obsGen = (ObservationGen.Observation)m_Converter.
                            convertToProto(observation);
                    responseBuilder.setObservationNative(obsGen);
                    break;

                case UUID_ONLY:
                    final SharedMessages.UUID uuid = SharedMessageUtils.convertUUIDToProtoUUID(observation.getUuid());
                    responseBuilder.setObservationUuid(uuid);
                    break;

                default:
                    throw new UnsupportedOperationException(
                            String.format("Asset capture data request does not support the %s format", 
                                    captureRequest.getObservationFormat()));
            }

            m_MessageFactory.createAssetResponseMessage(request, AssetMessageType.CaptureDataResponse, 
                    responseBuilder.build()).queue(channel);
        }
        catch (final AssetException e)
        {
            m_Logging.error(e, "Failed to get observation from asset %s during capture data.", asset.getName());
            m_MessageFactory.createBaseErrorMessage(request, ErrorCode.ASSET_ERROR, 
                    GENERIC_ERR_MSG + e.getMessage()).queue(channel);
        }
        catch (final ObjectConverterException e)
        {
            m_Logging.error(e, "Cannot convert observation to proto message for asset %s in capture data.", 
                    asset.getName());
            m_MessageFactory.createBaseErrorMessage(request, ErrorCode.CONVERTER_ERROR, 
                    GENERIC_ERR_MSG + e.getMessage()).queue(channel);
        }

        return captureRequest;
    }
/**
     * Method that is responsible for remotely requesting an asset (specified by a UUID contained in the request
     * message) to capture data.
     * @param message
     *      capture data request message containing the UUID of the asset status to be queried
     * @param request
     *      entire remote message for the request
     * @param channel
     *    the channel that was used to send request
     * @return
     *      the data message for this request
     * @throws IOException
     *      if message cannot be parsed or if response message cannot be sent
     */
Method that is responsible for remotely requesting an asset (specified by a UUID contained in the request
message) to capture data.
Method that is responsible for remotely requesting an asset ( specified by a UUID contained in the request message ) to capture data .
private Message captureData(final AssetNamespace message, final TerraHarvestMessage request, final RemoteChannel 
        channel) throws IOException
    {
        final CaptureDataRequestData captureRequest = CaptureDataRequestData.parseFrom(message.getData());
        final Asset asset = m_AssetDirectoryService.getAssetByUuid(SharedMessageUtils.
                    convertProtoUUIDtoUUID(captureRequest.getUuid()));
        try
        {
            final Observation observation;
            if (captureRequest.hasSensorId())
            {
                observation = asset.captureData(captureRequest.getSensorId());
            }
            else
            {
                observation = asset.captureData();
            }
            final CaptureDataResponseData.Builder responseBuilder = CaptureDataResponseData.newBuilder();
            responseBuilder.setAssetUuid(captureRequest.getUuid());
            if (captureRequest.hasSensorId())
            {
                responseBuilder.setSensorId(captureRequest.getSensorId());
            }
            switch (captureRequest.getObservationFormat())
            {
                case NATIVE:
                    final ObservationGen.Observation obsGen = (ObservationGen.Observation)m_Converter.
                            convertToProto(observation);
                    responseBuilder.setObservationNative(obsGen);
                    break;
                case UUID_ONLY:
                    final SharedMessages.UUID uuid = SharedMessageUtils.convertUUIDToProtoUUID(observation.getUuid());
                    responseBuilder.setObservationUuid(uuid);
                    break;
                default:
                    throw new UnsupportedOperationException(
                            String.format("Asset capture data request does not support the %s format", 
                                    captureRequest.getObservationFormat()));
            }
            m_MessageFactory.createAssetResponseMessage(request, AssetMessageType.CaptureDataResponse, 
                    responseBuilder.build()).queue(channel);
        }
        catch (final AssetException e)
        {
            m_Logging.error(e, "Failed to get observation from asset %s during capture data.", asset.getName());
            m_MessageFactory.createBaseErrorMessage(request, ErrorCode.ASSET_ERROR, 
                    GENERIC_ERR_MSG + e.getMessage()).queue(channel);
        }
        catch (final ObjectConverterException e)
        {
            m_Logging.error(e, "Cannot convert observation to proto message for asset %s in capture data.", 
                    asset.getName());
            m_MessageFactory.createBaseErrorMessage(request, ErrorCode.CONVERTER_ERROR, 
                    GENERIC_ERR_MSG + e.getMessage()).queue(channel);
        }
        return captureRequest;
    }
private Message captureData ( final AssetNamespace message , final TerraHarvestMessage request , final RemoteChannel channel ) throws IOException { final CaptureDataRequestData captureRequest = CaptureDataRequestData . parseFrom ( message . getData ( ) ) ; final Asset asset = m_AssetDirectoryService . getAssetByUuid ( SharedMessageUtils . convertProtoUUIDtoUUID ( captureRequest . getUuid ( ) ) ) ; try { final Observation observation ; if ( captureRequest . hasSensorId ( ) ) { observation = asset . captureData ( captureRequest . getSensorId ( ) ) ; } else { observation = asset . captureData ( ) ; } final CaptureDataResponseData . Builder responseBuilder = CaptureDataResponseData . newBuilder ( ) ; responseBuilder . setAssetUuid ( captureRequest . getUuid ( ) ) ; if ( captureRequest . hasSensorId ( ) ) { responseBuilder . setSensorId ( captureRequest . getSensorId ( ) ) ; } switch ( captureRequest . getObservationFormat ( ) ) { case NATIVE : final ObservationGen . Observation obsGen = ( ObservationGen . Observation ) m_Converter . convertToProto ( observation ) ; responseBuilder . setObservationNative ( obsGen ) ; break ; case UUID_ONLY : final SharedMessages . UUID uuid = SharedMessageUtils . convertUUIDToProtoUUID ( observation . getUuid ( ) ) ; responseBuilder . setObservationUuid ( uuid ) ; break ; default : throw new UnsupportedOperationException ( String . format ( "Asset capture data request does not support the %s format" , captureRequest . getObservationFormat ( ) ) ) ; } m_MessageFactory . createAssetResponseMessage ( request , AssetMessageType . CaptureDataResponse , responseBuilder . build ( ) ) . queue ( channel ) ; } catch ( final AssetException e ) { m_Logging . error ( e , "Failed to get observation from asset %s during capture data." , asset . getName ( ) ) ; m_MessageFactory . createBaseErrorMessage ( request , ErrorCode . ASSET_ERROR , GENERIC_ERR_MSG + e . getMessage ( ) ) . queue ( channel ) ; } catch ( final ObjectConverterException e ) { m_Logging . error ( e , "Cannot convert observation to proto message for asset %s in capture data." , asset . getName ( ) ) ; m_MessageFactory . createBaseErrorMessage ( request , ErrorCode . CONVERTER_ERROR , GENERIC_ERR_MSG + e . getMessage ( ) ) . queue ( channel ) ; } return captureRequest ; }
Method that is responsible for remotely requesting an asset (specified by a UUID contained in the request
 message) to capture data.
Method that is responsible for remotely requesting an asset ( specified by a UUID contained in the request message ) to capture data .
//Respond with observation data if the getObservationResponse flag was set to true  //Otherwise respond with the UUID of the observation data