@Override public IPatchWithBody withBody(String thePatchBody) { Validate.notBlank(thePatchBody, "thePatchBody must not be blank"); myPatchBody = thePatchBody; EncodingEnum encoding = EncodingEnum.detectEncodingNoDefault(thePatchBody); if (encoding == EncodingEnum.XML) { myPatchType = PatchTypeEnum.XML_PATCH; } else if (encoding == EncodingEnum.JSON) { myPatchType = PatchTypeEnum.JSON_PATCH; } else { throw new IllegalArgumentException("Unable to determine encoding of patch"); } return this; }
public static EncodingEnum detectEncoding(String theBody) { EncodingEnum retVal = detectEncodingNoDefault(theBody); retVal = ObjectUtils.defaultIfNull(retVal, EncodingEnum.XML); return retVal; }
public TransactionExecutable(String theBundle) { myRawBundle = theBundle; myRawBundleEncoding = EncodingEnum.detectEncodingNoDefault(myRawBundle); if (myRawBundleEncoding == null) { throw new IllegalArgumentException(myContext.getLocalizer().getMessage(GenericClient.class, "cantDetermineRequestType")); } }
protected IBaseResource parseResourceBody(String theResourceBody) { EncodingEnum encoding = EncodingEnum.detectEncodingNoDefault(theResourceBody); if (encoding == null) { throw new IllegalArgumentException(myContext.getLocalizer().getMessage(GenericClient.class, "cantDetermineRequestType")); } return encoding.newParser(myContext).parseResource(theResourceBody); }
@Override public EncodingEnum getResourceAsStringEncoding() { if (myEncoding == null) { myEncoding = EncodingEnum.detectEncodingNoDefault(theResourceBody); if (myEncoding == null) { throw new InvalidRequestException(theContext.getLocalizer().getMessage(ValidationContext.class, "unableToDetermineEncoding")); } } return myEncoding; }
@Override public IValidateUntyped resource(String theResourceRaw) { Validate.notBlank(theResourceRaw, "theResourceRaw must not be null or blank"); myResource = parseResourceBody(theResourceRaw); EncodingEnum enc = EncodingEnum.detectEncodingNoDefault(theResourceRaw); if (enc == null) { throw new IllegalArgumentException(myContext.getLocalizer().getMessage(GenericClient.class, "cantDetermineRequestType")); } switch (enc) { case XML: encodedXml(); break; case JSON: encodedJson(); break; } return this; }
ca.uhn.fhir.rest.api.EncodingEnum enc = ca.uhn.fhir.rest.api.EncodingEnum.detectEncodingNoDefault(defaultString(contents)); if (enc == null) { throw new ParseException("Could not detect encoding (json/xml) of contents"); String input = loadFile(localProfile); localProfileResource = ca.uhn.fhir.rest.api.EncodingEnum.detectEncodingNoDefault(input).newParser(ctx).parseResource(input);
@SuppressWarnings({"unchecked", "rawtypes"}) @Override public T execute() { Map<String, List<String>> params = new HashMap<String, List<String>>(); if (myResources != null) { ResourceListResponseHandler binding = new ResourceListResponseHandler(); BaseHttpClientInvocation invocation = TransactionMethodBinding.createTransactionInvocation(myResources, myContext); return (T) invoke(params, binding, invocation); } else if (myBaseBundle != null) { ResourceResponseHandler binding = new ResourceResponseHandler(myBaseBundle.getClass(), getPreferResponseTypes()); BaseHttpClientInvocation invocation = TransactionMethodBinding.createTransactionInvocation(myBaseBundle, myContext); return (T) invoke(params, binding, invocation); // } else if (myRawBundle != null) { } else { StringResponseHandler binding = new StringResponseHandler(); /* * If the user has explicitly requested a given encoding, we may need to re-encode the raw string */ if (getParamEncoding() != null) { if (EncodingEnum.detectEncodingNoDefault(myRawBundle) != getParamEncoding()) { IBaseResource parsed = parseResourceBody(myRawBundle); myRawBundle = getParamEncoding().newParser(getFhirContext()).encodeResourceToString(parsed); } } BaseHttpClientInvocation invocation = TransactionMethodBinding.createTransactionInvocation(myRawBundle, myContext); return (T) invoke(params, binding, invocation); } }
return null; encoding = EncodingEnum.detectEncodingNoDefault(body); if (encoding == null) { String msg = ctx.getLocalizer().getMessage(ResourceParameter.class, "noContentTypeInRequest", restOperationType);
@Override public IPatchWithBody withBody(String thePatchBody) { Validate.notBlank(thePatchBody, "thePatchBody must not be blank"); myPatchBody = thePatchBody; EncodingEnum encoding = EncodingEnum.detectEncodingNoDefault(thePatchBody); if (encoding == EncodingEnum.XML) { myPatchType = PatchTypeEnum.XML_PATCH; } else if (encoding == EncodingEnum.JSON) { myPatchType = PatchTypeEnum.JSON_PATCH; } else { throw new IllegalArgumentException("Unable to determine encoding of patch"); } return this; }
public static EncodingEnum detectEncoding(String theBody) { EncodingEnum retVal = detectEncodingNoDefault(theBody); retVal = ObjectUtils.defaultIfNull(retVal, EncodingEnum.XML); return retVal; }
public TransactionExecutable(String theBundle) { myRawBundle = theBundle; myRawBundleEncoding = EncodingEnum.detectEncodingNoDefault(myRawBundle); if (myRawBundleEncoding == null) { throw new IllegalArgumentException(myContext.getLocalizer().getMessage(GenericClient.class, "cantDetermineRequestType")); } }
@Override public EncodingEnum getResourceAsStringEncoding() { if (myEncoding == null) { myEncoding = EncodingEnum.detectEncodingNoDefault(theResourceBody); if (myEncoding == null) { throw new InvalidRequestException(theContext.getLocalizer().getMessage(ValidationContext.class, "unableToDetermineEncoding")); } } return myEncoding; }
protected IBaseResource parseResourceBody(String theResourceBody) { EncodingEnum encoding = EncodingEnum.detectEncodingNoDefault(theResourceBody); if (encoding == null) { throw new IllegalArgumentException(myContext.getLocalizer().getMessage(GenericClient.class, "cantDetermineRequestType")); } return encoding.newParser(myContext).parseResource(theResourceBody); }
@Override public IValidateUntyped resource(String theResourceRaw) { Validate.notBlank(theResourceRaw, "theResourceRaw must not be null or blank"); myResource = parseResourceBody(theResourceRaw); EncodingEnum enc = EncodingEnum.detectEncodingNoDefault(theResourceRaw); if (enc == null) { throw new IllegalArgumentException(myContext.getLocalizer().getMessage(GenericClient.class, "cantDetermineRequestType")); } switch (enc) { case XML: encodedXml(); break; case JSON: encodedJson(); break; } return this; }
return null; encoding = EncodingEnum.detectEncodingNoDefault(body); if (encoding == null) { String msg = ctx.getLocalizer().getMessage(ResourceParameter.class, "noContentTypeInRequest", restOperationType);
@SuppressWarnings({"unchecked", "rawtypes"}) @Override public T execute() { Map<String, List<String>> params = new HashMap<String, List<String>>(); if (myResources != null) { ResourceListResponseHandler binding = new ResourceListResponseHandler(); BaseHttpClientInvocation invocation = TransactionMethodBinding.createTransactionInvocation(myResources, myContext); return (T) invoke(params, binding, invocation); } else if (myBaseBundle != null) { ResourceResponseHandler binding = new ResourceResponseHandler(myBaseBundle.getClass(), getPreferResponseTypes()); BaseHttpClientInvocation invocation = TransactionMethodBinding.createTransactionInvocation(myBaseBundle, myContext); return (T) invoke(params, binding, invocation); // } else if (myRawBundle != null) { } else { StringResponseHandler binding = new StringResponseHandler(); /* * If the user has explicitly requested a given encoding, we may need to re-encode the raw string */ if (getParamEncoding() != null) { if (EncodingEnum.detectEncodingNoDefault(myRawBundle) != getParamEncoding()) { IBaseResource parsed = parseResourceBody(myRawBundle); myRawBundle = getParamEncoding().newParser(getFhirContext()).encodeResourceToString(parsed); } } BaseHttpClientInvocation invocation = TransactionMethodBinding.createTransactionInvocation(myRawBundle, myContext); return (T) invoke(params, binding, invocation); } }