diff --git a/src/main/java/org/olat/modules/adobeconnect/AdobeConnectModule.java b/src/main/java/org/olat/modules/adobeconnect/AdobeConnectModule.java index 5bfb87066a743981a20aa16dfef09acff79312cd..2d86845f6848dc2607807ac2c579edc320c6780b 100644 --- a/src/main/java/org/olat/modules/adobeconnect/AdobeConnectModule.java +++ b/src/main/java/org/olat/modules/adobeconnect/AdobeConnectModule.java @@ -23,6 +23,8 @@ import java.net.URI; import javax.ws.rs.core.UriBuilder; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.impl.client.HttpClientBuilder; import org.olat.core.configuration.AbstractSpringModule; import org.olat.core.configuration.ConfigOnOff; import org.olat.core.util.StringHelper; @@ -362,4 +364,13 @@ public class AdobeConnectModule extends AbstractSpringModule implements ConfigOn public int getHttpSocketTimeout() { return httpSocketTimeout; } + + public HttpClientBuilder httpClientBuilder() { + RequestConfig requestConfig = RequestConfig.copy(RequestConfig.DEFAULT) + .setConnectTimeout(getHttpConnectTimeout()) + .setConnectionRequestTimeout(getHttpConnectRequestTimeout()) + .setSocketTimeout(getHttpSocketTimeout()) + .build(); + return HttpClientBuilder.create().setDefaultRequestConfig(requestConfig); + } } diff --git a/src/main/java/org/olat/modules/adobeconnect/manager/AbstractAdobeConnectProvider.java b/src/main/java/org/olat/modules/adobeconnect/manager/AbstractAdobeConnectProvider.java index 96272f3ca8c3e4131ed23020ff60f237cf1bc3f1..5c44638cec93579521f6326f3a9971ff696e4c92 100644 --- a/src/main/java/org/olat/modules/adobeconnect/manager/AbstractAdobeConnectProvider.java +++ b/src/main/java/org/olat/modules/adobeconnect/manager/AbstractAdobeConnectProvider.java @@ -30,11 +30,9 @@ import java.util.Locale; import javax.ws.rs.core.UriBuilder; import org.apache.http.HttpEntity; -import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.message.BasicHeader; import org.apache.http.util.EntityUtils; import org.apache.logging.log4j.Logger; @@ -634,15 +632,9 @@ public abstract class AbstractAdobeConnectProvider implements AdobeConnectSPI { return scos; } - private CloseableHttpClient buildHttpClient() { + protected CloseableHttpClient buildHttpClient() { dbInstance.commit();// free connection - - RequestConfig requestConfig = RequestConfig.copy(RequestConfig.DEFAULT) - .setConnectTimeout(adobeConnectModule.getHttpConnectTimeout()) - .setConnectionRequestTimeout(adobeConnectModule.getHttpConnectRequestTimeout()) - .setSocketTimeout(adobeConnectModule.getHttpSocketTimeout()) - .build(); - return HttpClientBuilder.create().setDefaultRequestConfig(requestConfig).build(); + return adobeConnectModule.httpClientBuilder().build(); } protected List<AdobeConnectPrincipal> sendPrincipalRequest(UriBuilder builder, AdobeConnectErrors errors) { diff --git a/src/main/java/org/olat/modules/adobeconnect/manager/AdobeConnect9Provider.java b/src/main/java/org/olat/modules/adobeconnect/manager/AdobeConnect9Provider.java index ed476520e9d8b826c8e602d454e2d4ce6b95b71a..c821b6b80f7bc1487a232aa4eeea4f2dcbe87931 100644 --- a/src/main/java/org/olat/modules/adobeconnect/manager/AdobeConnect9Provider.java +++ b/src/main/java/org/olat/modules/adobeconnect/manager/AdobeConnect9Provider.java @@ -30,7 +30,6 @@ import org.apache.http.Header; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.util.EntityUtils; import org.apache.logging.log4j.Logger; import org.olat.basesecurity.Authentication; @@ -134,7 +133,7 @@ public class AdobeConnect9Provider extends AbstractAdobeConnectProvider { URI uri = builder.build(); BreezeSession session = null; HttpGet getInfo = new HttpGet(uri); - try(CloseableHttpClient httpClient = HttpClientBuilder.create().build(); + try(CloseableHttpClient httpClient = buildHttpClient(); CloseableHttpResponse response = httpClient.execute(getInfo)) { int statusCode = response.getStatusLine().getStatusCode(); if(statusCode == 200 && AdobeConnectUtils.isStatusOk(response.getEntity())) { diff --git a/src/main/java/org/olat/modules/adobeconnect/manager/AdobeConnectManagerImpl.java b/src/main/java/org/olat/modules/adobeconnect/manager/AdobeConnectManagerImpl.java index b7e25674c505304887de23f3c84367561a6933f9..34ca2c5622b48338b7f73ca53843f21d18245d22 100644 --- a/src/main/java/org/olat/modules/adobeconnect/manager/AdobeConnectManagerImpl.java +++ b/src/main/java/org/olat/modules/adobeconnect/manager/AdobeConnectManagerImpl.java @@ -33,7 +33,6 @@ import org.apache.http.Header; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.message.BasicHeader; import org.apache.http.util.EntityUtils; import org.apache.logging.log4j.Logger; @@ -586,13 +585,15 @@ public class AdobeConnectManagerImpl implements AdobeConnectManager, DeletableGr @Override public boolean checkConnection(String url, String login, String password, AdobeConnectErrors error) { + dbInstance.commit(); + boolean allOk = false; String common = buildUrl(url, null) + "?action=common-info"; BreezeSession session = null; HttpGet commonGet = new HttpGet(common); - try(CloseableHttpClient httpClient = HttpClientBuilder.create().build(); + try(CloseableHttpClient httpClient = adobeConnectModule.httpClientBuilder().build(); CloseableHttpResponse response = httpClient.execute(commonGet)) { int statusCode = response.getStatusLine().getStatusCode(); if(statusCode == 200) { @@ -612,7 +613,7 @@ public class AdobeConnectManagerImpl implements AdobeConnectManager, DeletableGr request += "&session" + session.getSession(); get.setHeader(new BasicHeader("Cookie", AbstractAdobeConnectProvider.COOKIE + session.getSession())); } - try(CloseableHttpClient httpClient = HttpClientBuilder.create().build(); + try(CloseableHttpClient httpClient = adobeConnectModule.httpClientBuilder().build(); CloseableHttpResponse response = httpClient.execute(get)) { int statusCode = response.getStatusLine().getStatusCode(); if(statusCode == 200 && AdobeConnectUtils.isStatusOk(response.getEntity())) { diff --git a/src/main/java/org/olat/modules/adobeconnect/manager/AdobeConnectSPI.java b/src/main/java/org/olat/modules/adobeconnect/manager/AdobeConnectSPI.java index e90c74cb80cb9566f8fd57eb6dcd2134f9f94f2e..228f454613c11f30c6735cf7469f386353c92797 100644 --- a/src/main/java/org/olat/modules/adobeconnect/manager/AdobeConnectSPI.java +++ b/src/main/java/org/olat/modules/adobeconnect/manager/AdobeConnectSPI.java @@ -91,5 +91,4 @@ public interface AdobeConnectSPI { public BreezeSession commonInfo(Authentication authentication, AdobeConnectErrors error); - } diff --git a/src/main/java/org/olat/modules/adobeconnect/manager/DFNprovider.java b/src/main/java/org/olat/modules/adobeconnect/manager/DFNprovider.java index d0a6804a24201fe5649c1622cdd93e742677a806..d039d80951fa1f5f8541540dea2f8396ce214e49 100644 --- a/src/main/java/org/olat/modules/adobeconnect/manager/DFNprovider.java +++ b/src/main/java/org/olat/modules/adobeconnect/manager/DFNprovider.java @@ -29,7 +29,6 @@ import javax.ws.rs.core.UriBuilder; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.util.EntityUtils; import org.apache.logging.log4j.Logger; import org.olat.basesecurity.Authentication; @@ -75,7 +74,7 @@ public class DFNprovider extends AbstractAdobeConnectProvider { List<AdobeConnectPrincipal> users = null; HttpGet get = createAdminMethod(builder, errors); if(get != null) { - try(CloseableHttpClient httpClient = HttpClientBuilder.create().build(); + try(CloseableHttpClient httpClient = buildHttpClient(); CloseableHttpResponse response = httpClient.execute(get)) { int statusCode = response.getStatusLine().getStatusCode(); if(statusCode == 200 || statusCode == 201) { @@ -102,7 +101,7 @@ public class DFNprovider extends AbstractAdobeConnectProvider { List<AdobeConnectPrincipal> users = null; HttpGet get = createAdminMethod(builder, errors); if(get != null) { - try(CloseableHttpClient httpClient = HttpClientBuilder.create().build(); + try(CloseableHttpClient httpClient = buildHttpClient(); CloseableHttpResponse response = httpClient.execute(get)) { int statusCode = response.getStatusLine().getStatusCode(); if(statusCode == 200 || statusCode == 201) { @@ -132,7 +131,7 @@ public class DFNprovider extends AbstractAdobeConnectProvider { BreezeSession session = null; HttpGet get = createAdminMethod(builder, errors); if(get != null) { - try(CloseableHttpClient httpClient = HttpClientBuilder.create().build(); + try(CloseableHttpClient httpClient = buildHttpClient(); CloseableHttpResponse response = httpClient.execute(get)) { int statusCode = response.getStatusLine().getStatusCode(); if(statusCode == 200) {