Creates HttpEntity depends from type of content
@param intuitRequest
@return
@throws FMSException
348977
private HttpEntity populateEntity(RequestElements intuitRequest) throws FMSException {
        byte[] compressedData = intuitRequest.getCompressedData();

        if (null == compressedData) {
            // use postString to create httpEntity
            try {
                return new StringEntity(intuitRequest.getPostString());
            } catch (UnsupportedEncodingException e) {
                throw new FMSException("UnsupportedEncodingException", e);
            }
        }

        // use compressed data to create httpEntity
        return new InputStreamEntity( new ByteArrayInputStream(compressedData) , compressedData.length);
    }
870740
public HttpResponse request(HttpRequest smartsheetRequest) throws HttpClientException {
        Util.throwIfNull(smartsheetRequest);
        if (smartsheetRequest.getUri() == null) {
            throw new IllegalArgumentException("A Request URI is required.");
        }

        int attempt = 0;
        long start = System.currentTimeMillis();

        HttpRequestBase apacheHttpRequest;
        HttpResponse smartsheetResponse;

        InputStream bodyStream = null;
        if(smartsheetRequest.getEntity() != null && smartsheetRequest.getEntity().getContent() != null) {
            bodyStream = smartsheetRequest.getEntity().getContent();
        }
        // the retry logic will consume the body stream so we make sure it supports mark/reset and mark it
        boolean canRetryRequest = bodyStream == null || bodyStream.markSupported();
        if (!canRetryRequest) {
            try {
                // attempt to wrap the body stream in a input-stream that does support mark/reset
                bodyStream = new ByteArrayInputStream(StreamUtil.readBytesFromStream(bodyStream));
                // close the old stream (just to be tidy) and then replace it with a reset-able stream
                smartsheetRequest.getEntity().getContent().close();
                smartsheetRequest.getEntity().setContent(bodyStream);
                canRetryRequest = true;
            }
            catch(IOException ignore) {
            }
        }

        // the retry loop
        while(true) {

            apacheHttpRequest = createApacheRequest(smartsheetRequest);

            // Set HTTP headers
            if (smartsheetRequest.getHeaders() != null) {
                for (Map.Entry<String, String> header : smartsheetRequest.getHeaders().entrySet()) {
                    apacheHttpRequest.addHeader(header.getKey(), header.getValue());
                }
            }

            HttpEntitySnapshot requestEntityCopy = null;
            HttpEntitySnapshot responseEntityCopy = null;
            // Set HTTP entity
            final HttpEntity entity = smartsheetRequest.getEntity();
            if (apacheHttpRequest instanceof HttpEntityEnclosingRequestBase && entity != null && entity.getContent() != null) {
                try {
                    // we need access to the original request stream so we can log it (in the event of errors and/or tracing)
                    requestEntityCopy = new HttpEntitySnapshot(entity);
                } catch (IOException iox) {
                    logger.error("failed to make copy of original request entity - {}", iox);
                }

                InputStreamEntity streamEntity = new InputStreamEntity(entity.getContent(), entity.getContentLength());
                streamEntity.setChunked(false);    // why?  not supported by library?
                ((HttpEntityEnclosingRequestBase) apacheHttpRequest).setEntity(streamEntity);
            }

            // mark the body so we can reset on retry
            if(canRetryRequest && bodyStream != null) {
                bodyStream.mark((int)smartsheetRequest.getEntity().getContentLength());
            }

            // Make the HTTP request
            smartsheetResponse = new HttpResponse();
            HttpContext context = new BasicHttpContext();
            try {
                long startTime = System.currentTimeMillis();
                apacheHttpResponse = this.httpClient.execute(apacheHttpRequest, context);
                long endTime = System.currentTimeMillis();

                // Set request headers to values ACTUALLY SENT (not just created by us), this would include:
                // 'Connection', 'Accept-Encoding', etc. However, if a proxy is used, this may be the proxy's CONNECT
                // request, hence the test for HTTP method first
                Object httpRequest = context.getAttribute("http.request");
                if(httpRequest != null && HttpRequestWrapper.class.isAssignableFrom(httpRequest.getClass())) {
                    HttpRequestWrapper actualRequest = (HttpRequestWrapper)httpRequest;
                    switch(HttpMethod.valueOf(actualRequest.getMethod())) {
                        case GET:
                        case POST:
                        case PUT:
                        case DELETE:
                            apacheHttpRequest.setHeaders(((HttpRequestWrapper)httpRequest).getAllHeaders());
                            break;
                    }
                }

                // Set returned headers
                smartsheetResponse.setHeaders(new HashMap<String, String>());
                for (Header header : apacheHttpResponse.getAllHeaders()) {
                    smartsheetResponse.getHeaders().put(header.getName(), header.getValue());
                }
                smartsheetResponse.setStatus(apacheHttpResponse.getStatusLine().getStatusCode(),
                        apacheHttpResponse.getStatusLine().toString());

                // Set returned entities
                if (apacheHttpResponse.getEntity() != null) {
                    HttpEntity httpEntity = new HttpEntity();
                    httpEntity.setContentType(apacheHttpResponse.getEntity().getContentType().getValue());
                    httpEntity.setContentLength(apacheHttpResponse.getEntity().getContentLength());
                    httpEntity.setContent(apacheHttpResponse.getEntity().getContent());
                    smartsheetResponse.setEntity(httpEntity);
                    responseEntityCopy = new HttpEntitySnapshot(httpEntity);
                }

                long responseTime = endTime - startTime;
                logRequest(apacheHttpRequest, requestEntityCopy, smartsheetResponse, responseEntityCopy, responseTime);

                if (traces.size() > 0) { // trace-logging of request and response (if so configured)
                    RequestAndResponseData requestAndResponseData = RequestAndResponseData.of(apacheHttpRequest,
                            requestEntityCopy, smartsheetResponse, responseEntityCopy, traces);
                    TRACE_WRITER.println(requestAndResponseData.toString(tracePrettyPrint));
                }

                if (smartsheetResponse.getStatusCode() == 200) {
                    // call successful, exit the retry loop
                    break;
                }

                // the retry logic might consume the content stream so we make sure it supports mark/reset and mark it
                InputStream contentStream = smartsheetResponse.getEntity().getContent();
                if (!contentStream.markSupported()) {
                    // wrap the response stream in a input-stream that does support mark/reset
                    contentStream = new ByteArrayInputStream(StreamUtil.readBytesFromStream(contentStream));
                    // close the old stream (just to be tidy) and then replace it with a reset-able stream
                    smartsheetResponse.getEntity().getContent().close();
                    smartsheetResponse.getEntity().setContent(contentStream);
                }
                try {
                    contentStream.mark((int) smartsheetResponse.getEntity().getContentLength());
                    long timeSpent = System.currentTimeMillis() - start;
                    if (!shouldRetry(++attempt, timeSpent, smartsheetResponse)) {
                        // should not retry, or retry time exceeded, exit the retry loop
                        break;
                    }
                } finally {
                    if(bodyStream != null) {
                        bodyStream.reset();
                    }
                    contentStream.reset();
                }
                // moving this to finally causes issues because socket is closed (which means response stream is closed)
                this.releaseConnection();

            } catch (ClientProtocolException e) {
                try {
                    logger.warn("ClientProtocolException " + e.getMessage());
                    logger.warn("{}", RequestAndResponseData.of(apacheHttpRequest, requestEntityCopy, smartsheetResponse,
                            responseEntityCopy, REQUEST_RESPONSE_SUMMARY));
                    // if this is a PUT and was retried by the http client, the body content stream is at the
                    // end and is a NonRepeatableRequest. If we marked the body content stream prior to execute,
                    // reset and retry
                    if (canRetryRequest && e.getCause() instanceof NonRepeatableRequestException) {
                        if (smartsheetRequest.getEntity() != null) {
                            smartsheetRequest.getEntity().getContent().reset();
                        }
                        continue;
                    }
                } catch (IOException ignore) {
                }
                throw new HttpClientException("Error occurred.", e);
            } catch (NoHttpResponseException e) {
                try {
                    logger.warn("NoHttpResponseException " + e.getMessage());
                    logger.warn("{}", RequestAndResponseData.of(apacheHttpRequest, requestEntityCopy, smartsheetResponse,
                            responseEntityCopy, REQUEST_RESPONSE_SUMMARY));
                    // check to see if the response was empty and this was a POST. All other HTTP methods
                    // will be automatically retried by the http client.
                    // (POST is non-idempotent and is not retried automatically, but is safe for us to retry)
                    if (canRetryRequest && smartsheetRequest.getMethod() == HttpMethod.POST) {
                        if (smartsheetRequest.getEntity() != null) {
                            smartsheetRequest.getEntity().getContent().reset();
                        }
                        continue;
                    }
                } catch (IOException ignore) {
                }
                throw new HttpClientException("Error occurred.", e);
            } catch (IOException e) {
                try {
                    logger.warn("{}", RequestAndResponseData.of(apacheHttpRequest, requestEntityCopy, smartsheetResponse,
                            responseEntityCopy, REQUEST_RESPONSE_SUMMARY));
                } catch (IOException ignore) {
                }
                throw new HttpClientException("Error occurred.", e);
            }
        }
        return smartsheetResponse;
    }
244754
public <T extends IEntity> InputStream download(T entity) throws FMSException {

        IntuitMessage intuitMessage = prepareDownload(entity);

        //execute interceptors
        executeInterceptors(intuitMessage);

        String response = intuitMessage.getResponseElements().getDecompressedData();
        if (response != null) {
            try {
                URL url = new URL(response);
                return url.openStream();
            } catch (Exception e) {
                throw new FMSException("Exception while downloading the input file from URL.", e);
            }
        }

        return null;
    }
1188672
@SuppressWarnings("unchecked")
    private <T extends IEntity> T retrieveEntity(IntuitMessage intuitMessage) {
        T returnEntity = null;
        IntuitResponse intuitResponse = (IntuitResponse) intuitMessage.getResponseElements().getResponse();
        if (intuitResponse != null) {
            JAXBElement<? extends IntuitEntity> intuitObject = intuitResponse.getIntuitObject();
            if (intuitObject != null) {
                returnEntity = ((T) intuitObject.getValue());
            }
        }
        return returnEntity;
    }
991475
@SuppressWarnings("unchecked")
    public <T extends IEntity> T update(T entity) throws FMSException {

        IntuitMessage intuitMessage = prepareUpdate(entity);

        //execute interceptors
        executeInterceptors(intuitMessage);

        return (T) retrieveEntity(intuitMessage);
    }
289813
@SuppressWarnings("unchecked")
    public <T extends IEntity> T updateAccountOnTxns(T entity) throws FMSException {

        IntuitMessage intuitMessage = prepareupdateAccountOnTxns(entity);

        //execute interceptors
        executeInterceptors(intuitMessage);

        return (T) retrieveEntity(intuitMessage);
    }
359621
@Override
    protected RequestEntity generateRequestEntity() {
        if (!this.params.isEmpty()) {
            // Use a ByteArrayRequestEntity instead of a StringRequestEntity.
            // This is to avoid potential encoding issues.  Form url encoded strings
            // are ASCII by definition but the content type may not be.  Treating the content
            // as bytes allows us to keep the current charset without worrying about how
            // this charset will effect the encoding of the form url encoded string.
            String content = EncodingUtil.formUrlEncode(getParameters(), getRequestCharSet());
            ByteArrayRequestEntity entity = new ByteArrayRequestEntity(
                EncodingUtil.getAsciiBytes(content),
                FORM_URL_ENCODED_CONTENT_TYPE
            );
            return entity;
        }
        return super.generateRequestEntity();
    }
723273
private HttpUriRequest proxyRequest(HttpServletRequest request) throws ServletException,
            IOException {
        String newUri = serviceUriForRequest(request);

        BasicHttpEntityEnclosingRequest httpRequest
                = new BasicHttpEntityEnclosingRequest(request.getMethod(), newUri);
        HttpEntity entity = new InputStreamEntity(request.getInputStream(),
                request.getContentLength());
        httpRequest.setEntity(entity);

        try {
            // Sadly have to do this to set the URI; it is not derived from the original httpRequest
            HttpRequestWrapper wrappedRequest = HttpRequestWrapper.wrap(httpRequest);
            wrappedRequest.setURI(new URI(newUri));

            // Somehow, content type header does not come in the original request either
            wrappedRequest.setHeader("Content-Type", "application/json");

            return wrappedRequest;
        } catch (URISyntaxException e) {
            LOGGER.error("Syntax exception in service URI, " + newUri, e);
            throw new LightblueServletException("Syntax exception in service URI, " + newUri, e);
        }
    }
292543
public void execute(List<IntuitMessage> intuitMessages) throws FMSException {
        LOG.debug("Enter HTTPBatchClientConnectionInterceptor - batch...");
        
        RequestElements intuitRequest = getFirst(intuitMessages).getRequestElements();
        
        IntuitRetryPolicyHandler handler = getRetryHandler();
        HttpClientBuilder hcBuilder = HttpClients.custom()
                .setRetryHandler(handler)
                .setDefaultRequestConfig(setTimeout(intuitRequest.getContext()))
                .setDefaultCredentialsProvider(setProxyAuthentication())
                .setSSLSocketFactory(prepareClientSSL());
        
        entitiesManager.reset();
        HttpHost proxy = getProxy();

        if (proxy != null) {
            hcBuilder.setProxy(proxy);
        }

        CloseableHttpClient client = hcBuilder.build();
        HttpRequestBase httpRequest = prepareHttpRequest(intuitRequest);

        //Additional processing for POST requests
        if(httpRequest instanceof HttpPost) {
            for (IntuitMessage intuitMessage : intuitMessages) {
                execute(intuitMessage);
            }
            try {
                ((HttpPost) httpRequest).setEntity(entitiesManager.asSingleEntity());
            } catch (IOException ex) {
                LOG.debug("HTTPBatchClientConnectionInterceptor was unable to convert input into single HTTP entity");
                throw new FMSException("Unable to prepare http entity" + ex.getMessage() + "\n" + ex.getStackTrace());
            } finally {
                entitiesManager.reset();
            }


        }

        //Method to send request
        IntuitMessage intuitMessage = executeHttpRequest(httpRequest,client);

        //TODO review this implementation, since it is using one temporary instance to fill up response elements in original
        for (IntuitMessage originalMessage : intuitMessages) {
            ResponseElements originalResponseElements = originalMessage.getResponseElements();
            ResponseElements receivedResponseElements = intuitMessage.getResponseElements();

            originalResponseElements.setResponseContent(   receivedResponseElements.getResponseContent()   );
            originalResponseElements.setEncodingHeader(    receivedResponseElements.getEncodingHeader()    );
            originalResponseElements.setContentTypeHeader( receivedResponseElements.getContentTypeHeader() );
            originalResponseElements.setStatusLine(        receivedResponseElements.getStatusLine()        );
            originalResponseElements.setStatusCode(        receivedResponseElements.getStatusCode()        );

        }
        LOG.debug("Exit HTTPBatchClientConnectionInterceptor.");

    }
1132625
private <T extends IEntity> IntuitMessage prepareUpload(T entity, InputStream docContent, String boundaryId) throws FMSException {
        IntuitMessage intuitMessage = new IntuitMessage();
        RequestElements requestElements = intuitMessage.getRequestElements();

        //set the request parameters
        Map<String, String> requestParameters = requestElements.getRequestParameters();
        requestParameters.put(RequestElements.REQ_PARAM_METHOD_TYPE, MethodType.POST.toString());

        UploadRequestElements uploadRequestElements = requestElements.getUploadRequestElements();
        uploadRequestElements.setDocContent(docContent);
        uploadRequestElements.setBoundaryId( utilizeIf(boundaryId) );
        uploadRequestElements.setElementsId(generateId().substring(0, 5));

        requestElements.setAction(OperationType.UPLOAD.toString());
        requestElements.setContext(context);
        requestElements.setEntity(entity);
        requestElements.setObjectToSerialize(getSerializableObject(entity));

        return intuitMessage;
    }
362976
private IntuitMessage prepareReport(String reportName) throws FMSException {
		IntuitMessage intuitMessage = new IntuitMessage();
		RequestElements requestElements = intuitMessage.getRequestElements();

		//set the request params
		Map<String, String> requestParameters = requestElements.getRequestParameters();
			requestParameters.put(RequestElements.REQ_PARAM_METHOD_TYPE, MethodType.GET.toString());

        if (getReport_date() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_REPORT_DT, getReport_date());
        }
			if (getStart_date() != null)
			{
				requestParameters.put(RequestElements.REPORT_PARAM_START_DT, getStart_date());
			}
			if (getEnd_date() != null)
			{
				requestParameters.put(RequestElements.REPORT_PARAM_END_DT, getEnd_date());
			}
			if (getDate_macro() != null)
			{
				requestParameters.put(RequestElements.REPORT_PARAM_DT_MACRO, getDate_macro());
			}
        if (getPast_due() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_PAST_DUE, getPast_due());
        }
        if (getStart_duedate() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_START_DUE_DT, getStart_duedate());
        }
        if (getEnd_duedate() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_END_DUE_DT, getEnd_duedate());
        }
        if (getDuedate_macro() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_DUE_DT_MACRO, getDuedate_macro());
        }

			if (getAccounting_method() != null)
			{
				requestParameters.put(RequestElements.REPORT_PARAM_ACC_METHOD, getAccounting_method());
			}
        if (getAccount() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_ACCOUNT, getAccount());
        }
        if (getSource_account() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_SOURCE_ACCOUNT, getSource_account());
        }
        if (getAccount_type() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_ACCOUNT_TYPE, getAccount_type());
        }
        if (getSource_account_type() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_SOURCE_ACCOUNT_TYPE, getSource_account_type());
        }

			if (getSummarize_column_by() != null)
			{
				requestParameters.put(RequestElements.REPORT_PARAM_SUM_COL_BY, getSummarize_column_by());
			}
			if (getCustomer() != null)
			{
				requestParameters.put(RequestElements.REPORT_PARAM_CUSTOMER, getCustomer());
			}
			if (getVendor() != null)
			{
				requestParameters.put(RequestElements.REPORT_PARAM_VENDOR, getVendor());
			}
			if (getItem() != null)
			{
				requestParameters.put(RequestElements.REPORT_PARAM_ITEM, getItem());
			}
			if (getClassid() != null)
			{
				requestParameters.put(RequestElements.REPORT_PARAM_CLASS, getClassid());
			}
        if (getAppaid() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_APPAID, getAppaid());
        }
			if (getDepartment() != null)
			{
				requestParameters.put(RequestElements.REPORT_PARAM_DEPARTMENT, getDepartment());
			}
			if (getQzurl() != null)
			{
				requestParameters.put(RequestElements.REPORT_PARAM_QZURL, getQzurl());
			}
			if (getAging_period() != null)
			{
				requestParameters.put(RequestElements.REPORT_PARAM_AGING_PERIOD, getAging_period());
			}
        if (getAging_method() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_AGING_METHOD, getAging_method());
        }
			if (getNum_periods() != null)
			{
				requestParameters.put(RequestElements.REPORT_PARAM_NUM_PERIOD, getNum_periods());
			}
        if (getTerm() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_TERM, getTerm());
        }
        if (getColumns() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_COLUMNS, getColumns());
        }
        if (getSort_by() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_SORT_BY, getSort_by());
        }
        if (getSort_order() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_SORT_ORDER, getSort_order());
        }
        if (getGroup_by() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_GROUP_BY, getGroup_by());
        }

        if (getCreatedate_macro() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_CREATE_DT_MACRO, getCreatedate_macro());
        }
        if (getEnd_createdate() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_END_CREATED_DT, getEnd_createdate());
        }
        if (getStart_createdate() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_START_CREATED_DT, getStart_createdate());
        }
        if (getModdate_macro() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_MOD_DT_MACRO, getModdate_macro());
        }
        if (getEnd_moddate() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_END_MOD_DT, getEnd_moddate());
        }
        if (getStart_moddate() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_START_MOD_DT, getStart_moddate());
        }
        if (getPayment_method() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_PAYMENT_METHOD, getPayment_method());
        }
        if (getName() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_NAME, getName());
        }
        if (getTransaction_type() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_TRANSACTION_TYPE, getTransaction_type());
        }
        if (getCleared() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_CLEARED, getCleared());
        }
        if (getArpaid() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_ARPAID, getArpaid());
        }
        if (getPrinted() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_PRINTED, getPrinted());
        }
        if (getBoth_amount() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_BOTH_AMT, getBoth_amount());
        }
        if (getMemo() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_MEMO, getMemo());
        }
        if (getDoc_num() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_DOC_NUM, getDoc_num());
        }
        if (getJournal_code() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_JOURNAL_CODE, getJournal_code());
        }
        if (getEmployee() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_EMPLOYEE, getEmployee());
        }
        if (getAgency_id() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_AGENCY_ID, getAgency_id());
        }
        if (getCustom1() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_CUSTOM1, getCustom1());
        }
        if (getCustom2() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_CUSTOM2, getCustom2());
        }
        if (getCustom3() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_CUSTOM3, getCustom3());
        }
        if (getShipvia() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_SHIPVIA, getShipvia());
        }
        if (getAccount_status() != null)
        {
            requestParameters.put(RequestElements.REPORT_PARAM_ACCOUNT_STATUS, getAccount_status());
        }

			
			requestElements.setAction(OperationType.REPORTS.toString() + "/" + reportName);
			requestElements.setContext(context);

		return intuitMessage;
	}
294351
@RequestMapping(path = "", method = RequestMethod.POST)
    public ResponseEntity<Customer> createCustomer(@RequestBody Customer customer){
        Customer newCustomer = customerService.createCustomer(customer);
        if(newCustomer != null){
            return new ResponseEntity<Customer>(newCustomer, HttpStatus.CREATED);
        }else{
            return new ResponseEntity<Customer>(HttpStatus.CONFLICT);
        }
    }
103321
public void setContent(final byte[] content,
                         final String contentType) throws HttpException {
    if (!(method instanceof HttpEntityEnclosingRequestBase)) {
      throw new HttpException("Invalid operation for method " +
                               method.getMethod());
    }

    final HttpEntityEnclosingRequestBase eem = (HttpEntityEnclosingRequestBase)method;

    ByteArrayEntity entity = new ByteArrayEntity(content);
    entity.setContentType(contentType);
    eem.setEntity(entity);
  }
841336
protected RequestEntity createStringRequestContent(HTTPRequest httpRequest)
    {
        RequestEntity requestEntity=null;
        String contentString=httpRequest.getContentAsString();
        if(contentString!=null)
        {
            try
            {
                requestEntity=new StringRequestEntity(contentString,"text/plain",null);
            }
            catch(UnsupportedEncodingException exception)
            {
                throw new FaxException("Unable to set string request entity.",exception);
            }
        }
        
        return requestEntity;
    }
703640
private <T extends IEntity> String prepareQBOUri(String entityName, Context context, 
			Map<String, String> requestParameters) throws FMSException {

		StringBuilder uri = new StringBuilder();
		if(entityName.equalsIgnoreCase("Taxservice"))
				{
					entityName = entityName + "/" + "taxcode";
				}
		
		// constructs request URI
		uri.append(getBaseUrl(Config.getProperty(Config.BASE_URL_QBO))).append("/").append(context.getRealmID()).append("/").append(entityName);
        addEntityID(requestParameters, uri);
        addEntitySelector(requestParameters, uri);
        addParentID(requestParameters, uri);

        // adds the built request param
      /*  if(requestParameters.equals("updateaccountontxns"))
        {
        	
    		uri.append("include=updateaccountontxns");

        }*/
		uri.append("?").append(buildRequestParams(requestParameters));
		// adds the generated request id as a parameter
		uri.append("requestid").append("=").append(context.getRequestID()).append("&");
		//set RequestId to null once appended, so the next random num can be generated
		context.setRequestID(null);
		//uri.append("include=abcdgef");
		
		if(context.getMinorVersion() == null)
		{
		context.setMinorVersion("37");
		}
		
		uri.append("minorversion").append("=").append(context.getMinorVersion()).append("&");
		if( context.getIncludeParam() !=null)
		{
		int includeval = context.getIncludeParam().size();
		String includeParam = "";
		if (includeval > 0)
		{
			for (int i=0; i<includeval; i++)
			{
				includeParam = includeParam + context.getIncludeParam().get(i) + ",";				
			}
			uri.append("include").append("=").append(includeParam.substring(0, includeParam.length()-1)).append("&");
		}
		}
		
		return uri.toString();
	}
1147829
public <T extends IEntity> void downloadAsync(T entity, CallbackHandler callbackHandler) throws FMSException {

        IntuitMessage intuitMessage = prepareDownload(entity);

        //set callback handler
        intuitMessage.getRequestElements().setCallbackHandler(callbackHandler);

        //execute async interceptors
        executeAsyncInterceptors(intuitMessage);
    }
945263
private URI extractURI(RequestElements intuitRequest) throws FMSException
    {
        URI uri = null;

        try {
            uri = new URI(intuitRequest.getRequestParameters().get(RequestElements.REQ_PARAM_RESOURCE_URL));
        } catch (URISyntaxException e) {
            throw new FMSException("URISyntaxException", e);
        }
        return uri;
    }