ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor Java Examples

The following examples show how to use ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExampleServerDstu3IT.java    From hapi-fhir-jpaserver-starter with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void beforeClass() throws Exception {
	String path = Paths.get("").toAbsolutePath().toString();

	ourLog.info("Project base path is: {}", path);

	ourServer = new Server(0);

	WebAppContext webAppContext = new WebAppContext();
	webAppContext.setContextPath("/hapi-fhir-jpaserver");
	webAppContext.setDescriptor(path + "/src/main/webapp/WEB-INF/web.xml");
	webAppContext.setResourceBase(path + "/target/hapi-fhir-jpaserver-starter");
	webAppContext.setParentLoaderPriority(true);

	ourServer.setHandler(webAppContext);
	ourServer.start();

	ourPort = JettyUtil.getPortForStartedServer(ourServer);

	ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
	ourCtx.getRestfulClientFactory().setSocketTimeout(1200 * 1000);
	String ourServerBase = "http://localhost:" + ourPort + "/hapi-fhir-jpaserver/fhir/";
	ourClient = ourCtx.newRestfulGenericClient(ourServerBase);
	ourClient.registerInterceptor(new LoggingInterceptor(true));
}
 
Example #2
Source File: ExampleServerDstu2IT.java    From hapi-fhir-jpaserver-starter with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void beforeClass() throws Exception {
	String path = Paths.get("").toAbsolutePath().toString();

	ourLog.info("Project base path is: {}", path);

	ourServer = new Server(0);

	WebAppContext webAppContext = new WebAppContext();
	webAppContext.setContextPath("/hapi-fhir-jpaserver");
	webAppContext.setDescriptor(path + "/src/main/webapp/WEB-INF/web.xml");
	webAppContext.setResourceBase(path + "/target/hapi-fhir-jpaserver-starter");
	webAppContext.setParentLoaderPriority(true);

	ourServer.setHandler(webAppContext);
	ourServer.start();

	ourPort = JettyUtil.getPortForStartedServer(ourServer);

	ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
	ourCtx.getRestfulClientFactory().setSocketTimeout(1200 * 1000);
	String ourServerBase = "http://localhost:" + ourPort + "/hapi-fhir-jpaserver/fhir/";
	ourClient = ourCtx.newRestfulGenericClient(ourServerBase);
	ourClient.registerInterceptor(new LoggingInterceptor(true));
}
 
Example #3
Source File: Example09_Interceptors.java    From fhirstarters with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static void main(String[] theArgs) {

		// Create a client
      IGenericClient client = FhirContext.forDstu3().newRestfulGenericClient("http://fhirtest.uhn.ca/baseDstu3");

      // Register some interceptors
      client.registerInterceptor(new CookieInterceptor("mycookie=Chips Ahoy"));
      client.registerInterceptor(new LoggingInterceptor());

      // Read a Patient
      Patient patient = client.read().resource(Patient.class).withId("example").execute();

		// Change the gender
		patient.setGender(patient.getGender() == AdministrativeGender.MALE ? AdministrativeGender.FEMALE : AdministrativeGender.MALE);

		// Update the patient
		MethodOutcome outcome = client.update().resource(patient).execute();
		
		System.out.println("Now have ID: " + outcome.getId());
	}
 
Example #4
Source File: ExampleServerR4IT.java    From hapi-fhir-jpaserver-starter with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void beforeClass() throws Exception {
    String path = Paths.get("").toAbsolutePath().toString();

    ourLog.info("Project base path is: {}", path);

    ourServer = new Server(0);

    WebAppContext webAppContext = new WebAppContext();
    webAppContext.setContextPath("/hapi-fhir-jpaserver");
    webAppContext.setDisplayName("HAPI FHIR");
    webAppContext.setDescriptor(path + "/src/main/webapp/WEB-INF/web.xml");
    webAppContext.setResourceBase(path + "/target/hapi-fhir-jpaserver-starter");
    webAppContext.setParentLoaderPriority(true);

    ourServer.setHandler(webAppContext);
    ourServer.start();

    ourPort = JettyUtil.getPortForStartedServer(ourServer);

    ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
    ourCtx.getRestfulClientFactory().setSocketTimeout(1200 * 1000);
    String ourServerBase = HapiProperties.getServerAddress();
    ourServerBase = "http://localhost:" + ourPort + "/hapi-fhir-jpaserver/fhir/";

    ourClient = ourCtx.newRestfulGenericClient(ourServerBase);
    ourClient.registerInterceptor(new LoggingInterceptor(true));
}
 
Example #5
Source File: ExampleServerR5IT.java    From hapi-fhir-jpaserver-starter with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void beforeClass() throws Exception {
    String path = Paths.get("").toAbsolutePath().toString();

    ourLog.info("Project base path is: {}", path);

    ourServer = new Server(0);

    WebAppContext webAppContext = new WebAppContext();
    webAppContext.setContextPath("/hapi-fhir-jpaserver");
    webAppContext.setDisplayName("HAPI FHIR");
    webAppContext.setDescriptor(path + "/src/main/webapp/WEB-INF/web.xml");
    webAppContext.setResourceBase(path + "/target/hapi-fhir-jpaserver-starter");
    webAppContext.setParentLoaderPriority(true);

    ourServer.setHandler(webAppContext);
    ourServer.start();

    ourPort = JettyUtil.getPortForStartedServer(ourServer);

    ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
    ourCtx.getRestfulClientFactory().setSocketTimeout(1200 * 1000);
    String ourServerBase = "http://localhost:" + ourPort + "/hapi-fhir-jpaserver/fhir/";

    ourClient = ourCtx.newRestfulGenericClient(ourServerBase);
    ourClient.registerInterceptor(new LoggingInterceptor(true));
}
 
Example #6
Source File: MultitenantServerR4IT.java    From hapi-fhir-jpaserver-starter with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void beforeClass() throws Exception {
  String path = Paths.get("").toAbsolutePath().toString();

  ourLog.info("Project base path is: {}", path);

  ourServer = new Server(0);

  WebAppContext webAppContext = new WebAppContext();
  webAppContext.setContextPath("/hapi-fhir-jpaserver");
  webAppContext.setDisplayName("HAPI FHIR");
  webAppContext.setDescriptor(path + "/src/main/webapp/WEB-INF/web.xml");
  webAppContext.setResourceBase(path + "/target/hapi-fhir-jpaserver-starter");
  webAppContext.setParentLoaderPriority(true);

  ourServer.setHandler(webAppContext);
  ourServer.start();

  ourPort = JettyUtil.getPortForStartedServer(ourServer);

  ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
  ourCtx.getRestfulClientFactory().setSocketTimeout(1200 * 1000);
  String ourServerBase = HapiProperties.getServerAddress();
  ourServerBase = "http://localhost:" + ourPort + "/hapi-fhir-jpaserver/fhir/";

  ourClient = ourCtx.newRestfulGenericClient(ourServerBase);
  ourClient.registerInterceptor(new LoggingInterceptor(true));

  ourClientTenantInterceptor = new UrlTenantSelectionInterceptor();
  ourClient.registerInterceptor(ourClientTenantInterceptor);
}
 
Example #7
Source File: FhirUtil.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public static IGenericClient getGenericClient(String theServerBase) {
	// Create a logging interceptor
	LoggingInterceptor loggingInterceptor = new LoggingInterceptor();
	loggingInterceptor.setLogRequestSummary(true);
	loggingInterceptor.setLogRequestBody(true);

	IGenericClient client = context.newRestfulGenericClient(theServerBase);
	client.registerInterceptor(loggingInterceptor);
	return client;
}