Ejemplo n.º 1
0
        private IGrowingObjectDataAdapter GetDataAdapterAndValidateUri(long messageId, string uri, out EtpUri etpUri)
        {
            etpUri = this.CreateAndValidateUri(uri, messageId);

            if (!etpUri.IsValid || !this.ValidateUriObjectType(etpUri, messageId))
            {
                return(null);
            }

            if (!ObjectTypes.IsGrowingDataObject(etpUri.ObjectType))
            {
                this.UnsupportedObject(null, uri, messageId);
                return(null);
            }

            try
            {
                return(Container.Resolve <IGrowingObjectDataAdapter>(new ObjectName(etpUri.ObjectType, etpUri.GetDataSchemaVersion())));
            }
            catch (ContainerException ex)
            {
                this.UnsupportedObject(ex, uri, messageId);
                return(null);
            }
        }
Ejemplo n.º 2
0
        ///// <summary>
        ///// Handles the GetObject message of the Store protocol.
        ///// </summary>
        ///// <param name="args">The <see cref="ProtocolEventArgs{GetObject, DataObject}" /> instance containing the event data.</param>
        ///// <param name="dataObjects">The data objects.</param>
        ///// <param name="errors">The errors.</param>
        /////commented by Naren as no suitable override method present
        /////
        //protected override void HandleGetDataObjects(ProtocolEventArgs<GetDataObjects> args, IList<DataObject> dataObjects, IList<ErrorInfo> errors)
        //{
        //    foreach (var uri in args.Message.Uris)
        //    {
        //        GetObject(args, uri, dataObjects, errors);
        //    }
        //}

        ///// <summary>
        ///// Handles the PutObject message of the Store protocol.
        ///// </summary>
        ///// <param name="header">The message header.</param>
        ///// <param name="putDataObjects">The put data objects message.</param>
        //protected override void HandlePutDataObjects(IMessageHeader header, PutDataObjects putDataObjects)
        //{
        //    base.HandlePutDataObjects(header, putDataObjects);

        //    foreach (var dataObject in putDataObjects.DataObjects)
        //    {
        //        PutObject(header, dataObject);
        //    }
        //}

        ///// <summary>
        ///// Handles the DeleteObject message of the Store protocol.
        ///// </summary>
        ///// <param name="header">The message header.</param>
        ///// <param name="deleteDataObjects">The delete data objects message.</param>
        //protected override void HandleDeleteDataObjects(IMessageHeader header, DeleteDataObjects deleteDataObjects)
        //{
        //    base.HandleDeleteDataObjects(header, deleteDataObjects);

        //    foreach (var uri in deleteDataObjects.Uris)
        //    {
        //        DeleteObject(header, uri);
        //    }
        //}

        /// <summary>
        /// Gets the data object from the data store.
        /// </summary>
        /// <param name="args">The event args.</param>
        /// <param name="uri">The URI.</param>
        /// <param name="dataObjects">The data objects.</param>
        /// <param name="errors">The errors.</param>
        private void GetObject(ProtocolEventArgs <GetDataObjects> args, string uri, IList <DataObject> dataObjects, IList <ErrorInfo> errors)
        {
            try
            {
                var dataObject = new DataObject();
                var etpUri     = new EtpUri(uri);

                if (!etpUri.IsValid)
                {
                    errors.Add(new ErrorInfo
                    {
                        Code    = (int)EtpErrorCodes.InvalidUri,
                        Message = "Invalid data object URI",
                        Uri     = uri
                    });
                    return;
                }

                if (string.IsNullOrWhiteSpace(etpUri.ObjectType))
                {
                    errors.Add(new ErrorInfo
                    {
                        Code    = (int)EtpErrorCodes.UnsupportedObject,
                        Message = "Data object not supported",
                        Uri     = uri
                    });
                    return;
                }

                // Validate that objectId was provided
                if (string.IsNullOrWhiteSpace(etpUri.ObjectId))
                {
                    errors.Add(new ErrorInfo
                    {
                        Code    = (int)EtpErrorCodes.InvalidUri,
                        Message = "Invalid data object URI",
                        Uri     = uri
                    });
                    return;
                }

                WitsmlOperationContext.Current.Request = new RequestContext(Functions.GetObject, etpUri.ObjectType, null, null, null);

                var provider = Container.Resolve <IStoreStoreProvider>(new ObjectName(etpUri.GetDataSchemaVersion()));
                provider.GetObject(Session.Adapter, args, uri, dataObject);

                if (dataObject.Data == null || dataObject.Data.Length < 1)
                {
                    errors.Add(new ErrorInfo
                    {
                        Code    = (int)EtpErrorCodes.NotFound,
                        Message = "Data object not found",
                        Uri     = uri
                    });
                    return;
                }

                // Success
                dataObjects.Add(dataObject);
            }
            catch (ContainerException)
            {
                errors.Add(new ErrorInfo
                {
                    Code    = (int)EtpErrorCodes.UnsupportedObject,
                    Message = "Data object not supported",
                    Uri     = uri
                });
            }
        }
Ejemplo n.º 3
0
        private void FindObjects(IEtpAdapter etpAdapter, string uri, IList <Etp12.Datatypes.Object.DataObject> context)
        {
            var etpUri      = new EtpUri(uri);
            var dataAdapter = Container.Resolve <IEtpDataProvider>(new ObjectName(etpUri.ObjectType, etpUri.GetDataSchemaVersion()));

            foreach (var result in dataAdapter.GetAll(etpUri))
            {
                var entity      = result as Witsml200.AbstractObject;
                var lastChanged = (entity?.Citation.LastUpdate).ToUnixTimeMicroseconds().GetValueOrDefault();
                var dataObject  = new Etp12.Datatypes.Object.DataObject();

                etpAdapter.SetDataObject(dataObject, entity, etpUri, GetName(entity), lastChanged: lastChanged);
                context.Add(dataObject);
            }
        }
Ejemplo n.º 4
0
        private void GetObject(IEtpAdapter etpAdapter, string uri, Energistics.Etp.Common.Datatypes.Object.IDataObject dataObject)
        {
            var etpUri      = new EtpUri(uri);
            var dataAdapter = Container.Resolve <IEtpDataProvider>(new ObjectName(etpUri.ObjectType, etpUri.GetDataSchemaVersion()));
            var entity      = dataAdapter.Get(etpUri) as Witsml200.AbstractObject;
            var lastChanged = (entity?.Citation.LastUpdate).ToUnixTimeMicroseconds().GetValueOrDefault();

            etpAdapter.SetDataObject(dataObject, entity, etpUri, GetName(entity), lastChanged: lastChanged);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets the object details for the specified URI.
        /// </summary>
        /// <param name="args">The <see cref="ProtocolEventArgs{GetObject, DataObject}" /> instance containing the event data.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        public void GetObject(ProtocolEventArgs <GetObject, DataObject> args)
        {
            var uri         = new EtpUri(args.Message.Uri);
            var dataAdapter = Container.Resolve <IEtpDataProvider>(new ObjectName(uri.ObjectType, uri.GetDataSchemaVersion()));
            var entity      = dataAdapter.Get(uri) as Witsml200.AbstractObject;
            var lastChanged = (entity?.Citation.LastUpdate).ToUnixTimeMicroseconds().GetValueOrDefault();

            StoreStoreProvider.SetDataObject(args.Context, entity, uri, GetName(entity), lastChanged: lastChanged);
        }