use of org.springframework.http.client.HttpComponentsClientHttpRequestFactory in project spring-framework by spring-projects.
the class RequestPartIntegrationTests method setup.
@Before
public void setup() {
ByteArrayHttpMessageConverter emptyBodyConverter = new ByteArrayHttpMessageConverter();
emptyBodyConverter.setSupportedMediaTypes(Collections.singletonList(MediaType.APPLICATION_JSON));
List<HttpMessageConverter<?>> converters = new ArrayList<>(3);
converters.add(emptyBodyConverter);
converters.add(new ByteArrayHttpMessageConverter());
converters.add(new ResourceHttpMessageConverter());
converters.add(new MappingJackson2HttpMessageConverter());
AllEncompassingFormHttpMessageConverter converter = new AllEncompassingFormHttpMessageConverter();
converter.setPartConverters(converters);
restTemplate = new RestTemplate(new HttpComponentsClientHttpRequestFactory());
restTemplate.setMessageConverters(Collections.singletonList(converter));
}
use of org.springframework.http.client.HttpComponentsClientHttpRequestFactory in project OpenClinica by OpenClinica.
the class RandomizationRegistrar method getRandomizationDTOObject.
// Rest Call to OCUI to get Randomization
public SeRandomizationDTO getRandomizationDTOObject(String studyOid) {
String ocUrl = CoreResources.getField("sysURL.base") + "rest2/openrosa/" + studyOid;
String randomizationUrl = CoreResources.getField("moduleManager") + "/app/rest/oc/se_randomizations?studyoid=" + studyOid + "&instanceurl=" + ocUrl;
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
requestFactory.setReadTimeout(RANDOMIZATION_READ_TIMEOUT);
RestTemplate rest = new RestTemplate(requestFactory);
try {
SeRandomizationDTO response = rest.getForObject(randomizationUrl, SeRandomizationDTO.class);
if (response.getStudyOid() != null) {
return response;
} else {
return null;
}
} catch (Exception e) {
logger.error(e.getMessage());
logger.error(ExceptionUtils.getStackTrace(e));
System.out.println(e.getMessage());
System.out.println(ExceptionUtils.getStackTrace(e));
}
return null;
}
use of org.springframework.http.client.HttpComponentsClientHttpRequestFactory in project OpenClinica by OpenClinica.
the class ParticipantPortalRegistrar method loadRegistrationStatus.
private String loadRegistrationStatus(String studyOid) {
String ocUrl = CoreResources.getField("sysURL.base") + "rest2/openrosa/" + studyOid;
String pManageUrl = CoreResources.getField("portalURL") + "/app/rest/oc/authorizations?studyoid=" + studyOid + "&instanceurl=" + ocUrl;
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
requestFactory.setReadTimeout(PARTICIPATE_READ_TIMEOUT);
RestTemplate rest = new RestTemplate(requestFactory);
try {
Authorization[] response = rest.getForObject(pManageUrl, Authorization[].class);
if (response.length > 0 && response[0].getAuthorizationStatus() != null)
return response[0].getAuthorizationStatus().getStatus();
} catch (Exception e) {
logger.error(e.getMessage());
logger.debug(ExceptionUtils.getStackTrace(e));
}
return "";
}
use of org.springframework.http.client.HttpComponentsClientHttpRequestFactory in project OpenClinica by OpenClinica.
the class ParticipantPortalRegistrar method getAuthorization.
public Authorization getAuthorization(String studyOid) {
String ocUrl = CoreResources.getField("sysURL.base") + "rest2/openrosa/" + studyOid;
String pManageUrl = CoreResources.getField("portalURL") + "/app/rest/oc/authorizations?studyoid=" + studyOid + "&instanceurl=" + ocUrl;
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
requestFactory.setReadTimeout(PARTICIPATE_READ_TIMEOUT);
RestTemplate rest = new RestTemplate(requestFactory);
try {
Authorization[] response = rest.getForObject(pManageUrl, Authorization[].class);
if (response.length > 0 && response[0].getAuthorizationStatus() != null)
return response[0];
} catch (Exception e) {
logger.error(e.getMessage());
logger.error(ExceptionUtils.getStackTrace(e));
}
return null;
}
use of org.springframework.http.client.HttpComponentsClientHttpRequestFactory in project OpenClinica by OpenClinica.
the class ParticipantPortalRegistrar method sendEmailThruMandrillViaOcui.
public String sendEmailThruMandrillViaOcui(ParticipantDTO participantDTO, String hostname) {
String host = hostname.substring(0, hostname.indexOf("/#/login"));
String pManageUrl = host + "/app/rest/oc/email";
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
requestFactory.setReadTimeout(PARTICIPATE_READ_TIMEOUT);
RestTemplate rest = new RestTemplate(requestFactory);
try {
ParticipantDTO response = rest.postForObject(pManageUrl, participantDTO, ParticipantDTO.class);
} catch (Exception e) {
logger.error(e.getMessage());
logger.error(ExceptionUtils.getStackTrace(e));
}
return "";
}
Aggregations