Returns the body type expected in the rest response.

@param restResponseReturnType The RestResponse subtype containing the type arguments we are inspecting.
@return The type of the body.
480510
public static Type getRestResponseBodyType(Type restResponseReturnType) {
        // if this type has type arguments, then we look at the last one to determine if it expects a body
        final Type[] restResponseTypeArguments = TypeUtil.getTypeArguments(restResponseReturnType);
        if (restResponseTypeArguments != null && restResponseTypeArguments.length > 0) {
            return restResponseTypeArguments[restResponseTypeArguments.length - 1];
        } else {
            // no generic type on this RestResponse sub-type, so we go up to parent
            return getRestResponseBodyType(TypeUtil.getSuperType(restResponseReturnType));
        }
    }
1217012
@Override
    public String getContentType() {
        String type = this.response.getHeader("Content-Type");
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "getContentType: " + type);
        }
        return type;
    }
199154
public alluxio.grpc.ServiceType getServiceType() {
    alluxio.grpc.ServiceType result = alluxio.grpc.ServiceType.valueOf(serviceType_);
    return result == null ? alluxio.grpc.ServiceType.UNKNOWN_SERVICE : result;
  }
1201325
public Builder getRequest(final RequestTypeEnum requestType, final RestOperationTypeEnum restOperation) {
		return getRequest(requestType, restOperation, null);
	}
825211
public JType getGenericReturnType()
  {
    SignatureAttribute sigAttr = (SignatureAttribute) getAttribute("Signature");

    if (sigAttr != null) {
      String sig = sigAttr.getSignature();

      int t = sig.lastIndexOf(')');

      return _loader.parseParameterizedType(sig.substring(t + 1));
    }

    return getReturnType();
  }
837936
TypeIdentifier analyze(final String rootType) {
        final String type = ResponseTypeNormalizer.normalizeResponseWrapper(rootType);
        final TypeIdentifier identifier = TypeIdentifier.ofType(type);

        if (!analyzedTypes.contains(type) && (isAssignableTo(type, COLLECTION) || !isJDKType(type))) {
            analyzedTypes.add(type);
            typeRepresentations.put(identifier, analyzeInternal(identifier, type));
        }

        return identifier;
    }
449438
@Override
    public TYPE getType() {
        final IPortalUrlBuilder portalUrlBuilder = this.portletUrlBuilder.getPortalUrlBuilder();
        final UrlType urlType = portalUrlBuilder.getUrlType();
        return urlType.getPortletUrlType();
    }
187024
public TypeDescription getReturnType() {
        if (mReturnType == null) {
            mReturnType = 
                getTeaToolsUtils().createTypeDescription(
                                          getMethod().getReturnType());
        }

        return mReturnType;
    }
504504
public final TypeParser.type_return type() throws RecognitionException {
        TypeParser.type_return retval = new TypeParser.type_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        TypeParser.typeExpression_return typeExpression1 = null;



        try {
            // org/javaruntype/type/parser/Type.g:101:5: ( typeExpression )
            // org/javaruntype/type/parser/Type.g:101:7: typeExpression
            {
            root_0 = (CommonTree)adaptor.nil();

            pushFollow(FOLLOW_typeExpression_in_type160);
            typeExpression1=typeExpression();

            state._fsp--;

            adaptor.addChild(root_0, typeExpression1.getTree());

            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }

            catch (RecognitionException e) {
            	throw e;
            }
        finally {
        }
        return retval;
    }
1018870
@SuppressWarnings("unchecked")
    public <T extends Serializable> T getParsedBody(Class<T> parseClass) throws FoxHttpResponseException {
        if (foxHttpClient.getFoxHttpResponseParser() == null) {
            throw new FoxHttpResponseException("getParsedBody needs a FoxHttpResponseParser to deserialize the body");
        }
        try {
            return (T) foxHttpClient.getFoxHttpResponseParser().serializedToObject(getStringBody(), (Class<Serializable>) parseClass);
        } catch (IOException e) {
            throw new FoxHttpResponseException(e);
        }
    }
925772
int getResponseCodeFromBundle(Bundle b) {
        Object o = b.get(RESPONSE_CODE);
        if (o == null) {
            logDebug("Bundle with null response code, assuming OK (known issue)");
            return BILLING_RESPONSE_RESULT_OK;
        }
        else if (o instanceof Integer) return ((Integer)o).intValue();
        else if (o instanceof Long) return (int)((Long)o).longValue();
        else {
            logError("Unexpected type for bundle response code.");
            logError(o.getClass().getName());
            throw new RuntimeException("Unexpected type for bundle response code: " + o.getClass().getName());
        }
    }
249571
static String normalizeResponseWrapper(final String type) {
        if (!getTypeParameters(type).isEmpty() && isAssignableTo(type, Types.GENERIC_ENTITY))
            return getTypeParameters(type).get(0);
        return type;
    }
243305
private <T> T deserializeResult(Response response, @Nullable String envelopeFieldName, TypeRef returnType) throws WebApplicationException {
        String contentType = readContentType(response);
        String body = readBody(response);

        if (contentType.startsWith("application/json")) {
            try {
                if (envelopeFieldName!=null) {
                    return jsonMarshaller.deserializeEnveloped(body, envelopeFieldName, returnType);
                } else {
                    return jsonMarshaller.deserialize(body, returnType);
                }
            } catch (JsonMarshallingException e) {
                String msg = "Failed unmarshalling JSON data from server to object: "+e.getMessage();
//                throw new ClientErrorException(Response.Status.BAD_REQUEST, e);

                Retry retry;
                if (response.getStatusInfo().getFamily() == Response.Status.Family.SERVER_ERROR) {
                    //it is likely that the server can handle it next time, and there won't be an error at all.
                    //then there won't be a problem unmarshalling the error info either.
                    retry = Retry.now();
                } else {
                    //success:      no, because it's unlikely the server sends a different response next time.
                    //client error: no, because the client's data is wrong anyway, we just can't understand the detail
                    //              why it's wrong, but it's still wrong next time.
                    //              this could happen when the client uses an outdated protocol. server rejects it, and
                    //              the client can't even understand (the detail of) the response.
                    retry = Retry.no();
                }
                throw new ClientServiceException(
                        new RestFaultInfo(
                                "Protocol", Blame.CLIENT,
                                msg, ""+ErrorCodes.Client.UNMARSHALLING_FAILED.getCode(),
                                null,
                                retry, retry,
                                response.getStatusInfo().getStatusCode(),
                                response.getStatusInfo().getReasonPhrase()
                        ), e
                );
            }
        } else if (returnType.getType().equals(String.class)) {
            // Expecting string, return the raw response body.
            return (T) body;
        } else {
            String msg = "Client requested content type >>>"+ACCEPT+"<<< but server sent >>>\"" + contentType + "\"<<< and that is not supported for type: " + returnType.getType();
//            throw new NotSupportedException(msg);
            throw new BadResponseServiceException(
                    new RestFaultInfo("BadResponse", Blame.SERVER,
                            msg, ""+ErrorCodes.Server.BAD_RESPONSE.getCode(),
                            null,
                            Retry.no(), Retry.no(),
                            response.getStatusInfo().getStatusCode(),
                            response.getStatusInfo().getReasonPhrase()
                    )
            );
        }
    }
169281
private String getResponseBody(HttpResponse postResponse) {
        InputStream input = null;
        try {
            input = postResponse.getEntity().getContent();
            Reader reader = new InputStreamReader(input,
                    MwsUtl.DEFAULT_ENCODING);
            StringBuilder b = new StringBuilder();
            char[] c = new char[1024];
            int len;
            while (0 < (len = reader.read(c))) {
                b.append(c, 0, len);
            }
            return b.toString();
        } catch (Exception e) {
            throw MwsUtl.wrap(e);
        } finally {
            MwsUtl.close(input);
        }
    }
506403
public static JmsBodyType getBodyType(String format) {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "getBodyType");

    JmsBodyType result = null;
    if (format.equals(SIApiConstants.JMS_FORMAT_BYTES))
      result = BYTES;
    else if (format.equals(SIApiConstants.JMS_FORMAT_TEXT))
      result = TEXT;
    else if (format.equals(SIApiConstants.JMS_FORMAT_OBJECT))
      result = OBJECT;
    else if (format.equals(SIApiConstants.JMS_FORMAT_STREAM))
      result = STREAM;
    else if (format.equals(SIApiConstants.JMS_FORMAT_MAP))
      result = MAP;
    else if (format.equals(SIApiConstants.JMS_FORMAT))
      result = NULL;

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "getBodyType");
    return result;
  }
968291
protected String getTypeName(JvmType type) {
		if (type != null) {
			if (type instanceof JvmDeclaredType) {
				final ITypeReferenceOwner owner = new StandardTypeReferenceOwner(this.services, type);
				return owner.toLightweightTypeReference(type).getHumanReadableName();
			}
			return type.getSimpleName();
		}
		return Messages.SARLHoverSignatureProvider_1;
	}
432309
private static DocumentType getDocType(final InputStream body)
        throws IOException {
        final DocumentBuilderFactory factory =
            DocumentBuilderFactory.newInstance();
        try {
            factory.setFeature(RsPrettyXml.LOAD_EXTERNAL_DTD, false);
            final DocumentBuilder builder = factory.newDocumentBuilder();
            return builder.parse(body).getDoctype();
        } catch (final ParserConfigurationException | SAXException ex) {
            throw new IOException(ex);
        }
    }