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

            var incomingMediaTypes = headers.Accept;

            return(incomingMediaTypes.Any() &&
                   !incomingMediaTypes.Any(mt => RestUtils.IsJsonMediaType(mt.MediaType.ToString())));
        }
 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);
         }
     }
 }
        public bool RequestingAttachment()
        {
            HttpHeaderValueCollection <MediaTypeWithQualityHeaderValue> incomingMediaTypes = requestMessage.Headers.Accept;

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

            return(true);
        }
        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));
            }
        }
        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));
 }