コード例 #1
0
 public UriMtHelper(IOidStrategy oidStrategy, HttpRequestMessage req, ITypeFacade spec)
     : this(oidStrategy, req)
 {
     this.spec  = spec;
     cachedId   = "";
     CachedType = RestUtils.SpecToPredefinedTypeString(spec, oidStrategy);
 }
コード例 #2
0
        public bool RequestingAttachment()
        {
            var headers = new RequestHeaders(requestMessage.Headers);

            var incomingMediaTypes = headers.Accept;

            return(incomingMediaTypes.Any() &&
                   !incomingMediaTypes.Any(mt => RestUtils.IsJsonMediaType(mt.MediaType.ToString())));
        }
コード例 #3
0
 private static void FilterBlobsAndClobs(PropertyContextFacade propertyContext, RestControlFlags flags)
 {
     if (!flags.BlobsClobs)
     {
         if (RestUtils.IsBlobOrClob(propertyContext.Specification) && !RestUtils.IsAttachment(propertyContext.Specification))
         {
             throw new PropertyResourceNotFoundNOSException(propertyContext.Id);
         }
     }
 }
コード例 #4
0
        public bool RequestingAttachment()
        {
            HttpHeaderValueCollection <MediaTypeWithQualityHeaderValue> incomingMediaTypes = requestMessage.Headers.Accept;

            if (!incomingMediaTypes.Any() || incomingMediaTypes.Any(mt => RestUtils.IsJsonMediaType(mt.MediaType)))
            {
                return(false);
            }

            return(true);
        }
コード例 #5
0
        public void ValidateIncomingMediaTypeAsJson()
        {
            if (AcceptHeaderStrict)
            {
                HttpHeaderValueCollection <MediaTypeWithQualityHeaderValue> incomingMediaTypes = requestMessage.Headers.Accept;

                if (!incomingMediaTypes.Any() || incomingMediaTypes.Any(mt => RestUtils.IsJsonMediaType(mt.MediaType)))
                {
                    return;
                }

                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotAcceptable));
            }
        }
コード例 #6
0
        public void ValidateIncomingMediaTypeAsJson()
        {
            if (AcceptHeaderStrict)
            {
                var headers            = new RequestHeaders(requestMessage.Headers);
                var incomingMediaTypes = headers.Accept;

                if (!incomingMediaTypes.Any() || incomingMediaTypes.Any(mt => RestUtils.IsJsonMediaType(mt.MediaType.ToString())))
                {
                    return;
                }

                var msg = DebugFilter(() => $"Failed incoming MT validation: {string.Join(',', incomingMediaTypes.Select(mt => mt.MediaType.ToString()).ToArray())}");

                throw new ValidationException((int)HttpStatusCode.NotAcceptable, msg);
            }
        }
コード例 #7
0
 public object GetChoiceValue(IOidStrategy oidStrategy, HttpRequestMessage req, IObjectFacade item, RestControlFlags flags)
 {
     return(association != null?RestUtils.GetChoiceValue(oidStrategy, req, item, association, flags) : RestUtils.GetChoiceValue(oidStrategy, req, item, parameter, flags));
 }
コード例 #8
0
 private string GetParameterValue(RestControlFlags flags, ITypeFacade parameterValueSpec)
 {
     return(RestUtils.SpecToPredefinedTypeString(parameterValueSpec, oidStrategy));
 }