diff --git a/BimServer/src/org/bimserver/webservices/impl/OAuthServiceImpl.java b/BimServer/src/org/bimserver/webservices/impl/OAuthServiceImpl.java
index c92641f81d..f59787be34 100644
--- a/BimServer/src/org/bimserver/webservices/impl/OAuthServiceImpl.java
+++ b/BimServer/src/org/bimserver/webservices/impl/OAuthServiceImpl.java
@@ -1,70 +1,70 @@
-package org.bimserver.webservices.impl;
-
-/******************************************************************************
- * Copyright (C) 2009-2019 BIMserver.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see {@literal}.
- *****************************************************************************/
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.http.NameValuePair;
-import org.apache.http.client.entity.UrlEncodedFormEntity;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.message.BasicNameValuePair;
-import org.apache.oltu.oauth2.client.request.OAuthClientRequest;
-import org.apache.oltu.oauth2.common.message.types.ResponseType;
-import org.apache.oltu.oauth2.ext.dynamicreg.client.OAuthRegistrationClient;
-import org.apache.oltu.oauth2.ext.dynamicreg.client.request.OAuthClientRegistrationRequest;
-import org.apache.oltu.oauth2.ext.dynamicreg.client.response.OAuthClientRegistrationResponse;
-import org.apache.oltu.oauth2.ext.dynamicreg.common.OAuthRegistration;
-import org.bimserver.BimserverDatabaseException;
-import org.bimserver.database.DatabaseSession;
-import org.bimserver.database.OldQuery;
-import org.bimserver.database.OperationType;
-import org.bimserver.interfaces.objects.SAuthorization;
-import org.bimserver.interfaces.objects.SOAuthAuthorizationCode;
-import org.bimserver.interfaces.objects.SOAuthServer;
-import org.bimserver.interfaces.objects.SRunServiceAuthorization;
-import org.bimserver.interfaces.objects.SSingleProjectAuthorization;
-import org.bimserver.models.store.Authorization;
-import org.bimserver.models.store.InternalServicePluginConfiguration;
-import org.bimserver.models.store.NewService;
-import org.bimserver.models.store.OAuthAuthorizationCode;
-import org.bimserver.models.store.OAuthServer;
-import org.bimserver.models.store.Project;
-import org.bimserver.models.store.RunServiceAuthorization;
-import org.bimserver.models.store.ServerSettings;
-import org.bimserver.models.store.ServiceStatus;
-import org.bimserver.models.store.SingleProjectAuthorization;
-import org.bimserver.models.store.StorePackage;
-import org.bimserver.models.store.User;
-import org.bimserver.shared.exceptions.ServerException;
-import org.bimserver.shared.exceptions.UserException;
-import org.bimserver.shared.interfaces.OAuthInterface;
-import org.bimserver.utils.NetUtils;
-import org.bimserver.webservices.ServiceMap;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
+package org.bimserver.webservices.impl;
+
+/******************************************************************************
+ * Copyright (C) 2009-2019 BIMserver.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see {@literal}.
+ *****************************************************************************/
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.hc.core5.http.NameValuePair;
+import org.apache.hc.core5.http.message.BasicNameValuePair;
+import org.apache.hc.client5.http.entity.UrlEncodedFormEntity;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.oltu.oauth2.client.request.OAuthClientRequest;
+import org.apache.oltu.oauth2.common.message.types.ResponseType;
+import org.apache.oltu.oauth2.ext.dynamicreg.client.OAuthRegistrationClient;
+import org.apache.oltu.oauth2.ext.dynamicreg.client.request.OAuthClientRegistrationRequest;
+import org.apache.oltu.oauth2.ext.dynamicreg.client.response.OAuthClientRegistrationResponse;
+import org.apache.oltu.oauth2.ext.dynamicreg.common.OAuthRegistration;
+import org.bimserver.BimserverDatabaseException;
+import org.bimserver.database.DatabaseSession;
+import org.bimserver.database.OldQuery;
+import org.bimserver.database.OperationType;
+import org.bimserver.interfaces.objects.SAuthorization;
+import org.bimserver.interfaces.objects.SOAuthAuthorizationCode;
+import org.bimserver.interfaces.objects.SOAuthServer;
+import org.bimserver.interfaces.objects.SRunServiceAuthorization;
+import org.bimserver.interfaces.objects.SSingleProjectAuthorization;
+import org.bimserver.models.store.Authorization;
+import org.bimserver.models.store.InternalServicePluginConfiguration;
+import org.bimserver.models.store.NewService;
+import org.bimserver.models.store.OAuthAuthorizationCode;
+import org.bimserver.models.store.OAuthServer;
+import org.bimserver.models.store.Project;
+import org.bimserver.models.store.RunServiceAuthorization;
+import org.bimserver.models.store.ServerSettings;
+import org.bimserver.models.store.ServiceStatus;
+import org.bimserver.models.store.SingleProjectAuthorization;
+import org.bimserver.models.store.StorePackage;
+import org.bimserver.models.store.User;
+import org.bimserver.shared.exceptions.ServerException;
+import org.bimserver.shared.exceptions.UserException;
+import org.bimserver.shared.interfaces.OAuthInterface;
+import org.bimserver.utils.NetUtils;
+import org.bimserver.webservices.ServiceMap;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
public class OAuthServiceImpl extends GenericServiceImpl implements OAuthInterface {
@@ -73,23 +73,23 @@ public class OAuthServiceImpl extends GenericServiceImpl implements OAuthInterfa
public OAuthServiceImpl(ServiceMap serviceMap) {
super(serviceMap);
}
-
- public SOAuthServer registerRemoteApplication(String redirectUrl, String name, String description) throws UserException {
- try {
- OAuthClientRequest request = OAuthClientRegistrationRequest.location(getBimServer().getServerSettingsCache().getServerSettings().getSiteAddress() + "/oauth/register/",
- OAuthRegistration.Type.PUSH).setName(name).setUrl(redirectUrl).setDescription(description)
- .setRedirectURL(redirectUrl).buildJSONMessage();
- OAuthRegistrationClient oauthclient = new OAuthRegistrationClient(new org.bimserver.webservices.impl.URLConnectionClient());
- OAuthClientRegistrationResponse response = oauthclient.clientInfo(request);
-
- SOAuthServer server = new SOAuthServer();
- server.setClientId(response.getClientId());
- server.setClientSecret(response.getClientSecret());
- return server;
- } catch (Exception e) {
- throw new UserException(e);
- }
- }
+
+ public SOAuthServer registerRemoteApplication(String redirectUrl, String name, String description) throws UserException {
+ try {
+ OAuthClientRequest request = OAuthClientRegistrationRequest.location(getBimServer().getServerSettingsCache().getServerSettings().getSiteAddress() + "/oauth/register/",
+ OAuthRegistration.Type.PUSH).setName(name).setUrl(redirectUrl).setDescription(description)
+ .setRedirectURL(redirectUrl).buildJSONMessage();
+ OAuthRegistrationClient oauthclient = new OAuthRegistrationClient(new org.bimserver.webservices.impl.URLConnectionClient());
+ OAuthClientRegistrationResponse response = oauthclient.clientInfo(request);
+
+ SOAuthServer server = new SOAuthServer();
+ server.setClientId(response.getClientId());
+ server.setClientSecret(response.getClientSecret());
+ return server;
+ } catch (Exception e) {
+ throw new UserException(e);
+ }
+ }
@Override
public Long registerApplication(String registrationEndpoint, String apiUrl, String redirectUrl) throws UserException, ServerException {
@@ -195,8 +195,8 @@ public List listRegisteredServersLocal() throws ServerException, U
@Override
public void setAuthorizationCode(Long applicationId, String code) throws UserException, ServerException {
try (DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_WRITE)) {
- OAuthAuthorizationCode oAuthAuthorizationCode = session.create(OAuthAuthorizationCode.class);
- OAuthServer server = session.get(applicationId, OldQuery.getDefault());
+ OAuthAuthorizationCode oAuthAuthorizationCode = session.create(OAuthAuthorizationCode.class);
+ OAuthServer server = session.get(applicationId, OldQuery.getDefault());
oAuthAuthorizationCode.setIssued(new Date());
oAuthAuthorizationCode.setOauthServer(server);
oAuthAuthorizationCode.setCode(code);
@@ -276,19 +276,19 @@ public String authorize(Long oAuthServerOid, SAuthorization authorization) throw
if (project == null) {
throw new UserException("No project found with poid " + sSingleProjectAuthorization.getProjectId());
}
- singleProjectAuthorization.setProject(project);
+ singleProjectAuthorization.setProject(project);
- OAuthAuthorizationCode code = session.create(OAuthAuthorizationCode.class);
- code.setIssued(new Date());
-
- org.bimserver.webservices.authorization.Authorization auth = new org.bimserver.webservices.authorization.SingleProjectAuthorization(getBimServer(), user.getOid(), project.getOid());
-
- String asHexToken = auth.asHexToken(getBimServer().getEncryptionKey());
-
+ OAuthAuthorizationCode code = session.create(OAuthAuthorizationCode.class);
+ code.setIssued(new Date());
+
+ org.bimserver.webservices.authorization.Authorization auth = new org.bimserver.webservices.authorization.SingleProjectAuthorization(getBimServer(), user.getOid(), project.getOid());
+
+ String asHexToken = auth.asHexToken(getBimServer().getEncryptionKey());
+
code.setCode(asHexToken);
code.setOauthServer(session.get(oAuthServerOid, OldQuery.getDefault()));
code.setAuthorization(singleProjectAuthorization);
- code.setUser(user);
+ code.setUser(user);
user.getOAuthIssuedAuthorizationCodes().add(code);
@@ -297,40 +297,40 @@ public String authorize(Long oAuthServerOid, SAuthorization authorization) throw
session.commit();
- return code.getCode();
- } else if (authorization instanceof SRunServiceAuthorization) {
- SRunServiceAuthorization serviceAuthorization = (SRunServiceAuthorization)authorization;
-
- User user = session.get(getCurrentUser().getOid(), OldQuery.getDefault());
-
- RunServiceAuthorization runServiceAuth = session.create(RunServiceAuthorization.class);
- InternalServicePluginConfiguration conf = session.get(serviceAuthorization.getServiceId(), OldQuery.getDefault());
- if (conf == null) {
- throw new UserException("No service found with soid " + serviceAuthorization.getServiceId());
- }
- runServiceAuth.setService(conf);
-
- OAuthAuthorizationCode code = session.create(OAuthAuthorizationCode.class);
- code.setIssued(new Date());
-
- org.bimserver.webservices.authorization.Authorization auth = new org.bimserver.webservices.authorization.RunServiceAuthorization(getBimServer(), user.getOid(), conf.getOid());
-
- String asHexToken = auth.asHexToken(getBimServer().getEncryptionKey());
-
- code.setCode(asHexToken);
- code.setOauthServer(session.get(oAuthServerOid, OldQuery.getDefault()));
- code.setAuthorization(runServiceAuth);
- code.setUser(user);
-
- user.getOAuthIssuedAuthorizationCodes().add(code);
-
- session.store(user);
- session.store(code);
- session.store(runServiceAuth);
-
- session.commit();
-
- return code.getCode();
+ return code.getCode();
+ } else if (authorization instanceof SRunServiceAuthorization) {
+ SRunServiceAuthorization serviceAuthorization = (SRunServiceAuthorization)authorization;
+
+ User user = session.get(getCurrentUser().getOid(), OldQuery.getDefault());
+
+ RunServiceAuthorization runServiceAuth = session.create(RunServiceAuthorization.class);
+ InternalServicePluginConfiguration conf = session.get(serviceAuthorization.getServiceId(), OldQuery.getDefault());
+ if (conf == null) {
+ throw new UserException("No service found with soid " + serviceAuthorization.getServiceId());
+ }
+ runServiceAuth.setService(conf);
+
+ OAuthAuthorizationCode code = session.create(OAuthAuthorizationCode.class);
+ code.setIssued(new Date());
+
+ org.bimserver.webservices.authorization.Authorization auth = new org.bimserver.webservices.authorization.RunServiceAuthorization(getBimServer(), user.getOid(), conf.getOid());
+
+ String asHexToken = auth.asHexToken(getBimServer().getEncryptionKey());
+
+ code.setCode(asHexToken);
+ code.setOauthServer(session.get(oAuthServerOid, OldQuery.getDefault()));
+ code.setAuthorization(runServiceAuth);
+ code.setUser(user);
+
+ user.getOAuthIssuedAuthorizationCodes().add(code);
+
+ session.store(user);
+ session.store(code);
+ session.store(runServiceAuth);
+
+ session.commit();
+
+ return code.getCode();
} else {
throw new UserException("Unimplemented type of authorization " + authorization.getClass().getSimpleName());
}
@@ -368,36 +368,36 @@ public String getRemoteToken(Long soid, String code, Long serverId) throws Serve
OAuthServer oAuthServer = session.get(serverId, OldQuery.getDefault());
objectNode.put("client_id", oAuthServer.getClientId());
objectNode.put("client_secret", oAuthServer.getClientSecret());
-
- CloseableHttpClient httpclient = HttpClients.createDefault();
- try {
- HttpPost post = new HttpPost(newService.getTokenUrl());
- post.setHeader("Content-Type", "application/x-www-form-urlencoded");
- List nvps = new ArrayList ();
- nvps.add(new BasicNameValuePair("grant_type", "authorization_code"));
- nvps.add(new BasicNameValuePair("code", code));
- nvps.add(new BasicNameValuePair("client_id", oAuthServer.getClientId()));
- nvps.add(new BasicNameValuePair("client_secret", oAuthServer.getClientSecret()));
- nvps.add(new BasicNameValuePair("redirect_uri", "crap"));
- post.setEntity(new UrlEncodedFormEntity(nvps));
- CloseableHttpResponse httpResponse = httpclient.execute(post);
- ObjectNode response = OBJECT_MAPPER.readValue(httpResponse.getEntity().getContent(), ObjectNode.class);
-
- if (response.has("access_token")) {
- String accessToken = response.get("access_token").asText();
- newService.setAccessToken(accessToken);
- newService.setStatus(ServiceStatus.AUTHENTICATED);
- newService.setResourceUrl(response.get("resource_url").asText());
- session.store(newService);
- session.commit();
-
- return accessToken;
- } else {
- throw new UserException("No access_token received from oauth server");
- }
- } finally {
- httpclient.close();
- }
+
+ CloseableHttpClient httpclient = HttpClients.createDefault();
+ try {
+ HttpPost post = new HttpPost(newService.getTokenUrl());
+ post.setHeader("Content-Type", "application/x-www-form-urlencoded");
+ List nvps = new ArrayList ();
+ nvps.add(new BasicNameValuePair("grant_type", "authorization_code"));
+ nvps.add(new BasicNameValuePair("code", code));
+ nvps.add(new BasicNameValuePair("client_id", oAuthServer.getClientId()));
+ nvps.add(new BasicNameValuePair("client_secret", oAuthServer.getClientSecret()));
+ nvps.add(new BasicNameValuePair("redirect_uri", "crap"));
+ post.setEntity(new UrlEncodedFormEntity(nvps));
+ CloseableHttpResponse httpResponse = httpclient.execute(post);
+ ObjectNode response = OBJECT_MAPPER.readValue(httpResponse.getEntity().getContent(), ObjectNode.class);
+
+ if (response.has("access_token")) {
+ String accessToken = response.get("access_token").asText();
+ newService.setAccessToken(accessToken);
+ newService.setStatus(ServiceStatus.AUTHENTICATED);
+ newService.setResourceUrl(response.get("resource_url").asText());
+ session.store(newService);
+ session.commit();
+
+ return accessToken;
+ } else {
+ throw new UserException("No access_token received from oauth server");
+ }
+ } finally {
+ httpclient.close();
+ }
} catch (Exception e) {
return handleException(e);
}
diff --git a/BimServer/src/org/bimserver/webservices/impl/ServiceImpl.java b/BimServer/src/org/bimserver/webservices/impl/ServiceImpl.java
index ee8f7a79e1..14433b31b9 100644
--- a/BimServer/src/org/bimserver/webservices/impl/ServiceImpl.java
+++ b/BimServer/src/org/bimserver/webservices/impl/ServiceImpl.java
@@ -52,12 +52,13 @@
import javax.mail.util.ByteArrayDataSource;
import org.apache.commons.collections.comparators.ComparatorChain;
-import org.apache.http.Header;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.core5.http.io.entity.ByteArrayEntity;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.bimserver.BimServerImporter;
import org.bimserver.BimserverDatabaseException;
import org.bimserver.client.json.JsonBimServerClientFactory;
@@ -2624,15 +2625,15 @@ public void triggerRevisionService(Long roid, Long soid) throws ServerException,
}
httpPost.setHeader("Input-Type", newService.getInput());
httpPost.setHeader("Output-Type", newService.getOutput());
- httpPost.setEntity(new ByteArrayEntity(baos.toByteArray()));
+ httpPost.setEntity(new ByteArrayEntity(baos.toByteArray(), ContentType.APPLICATION_OCTET_STREAM));
long start = System.nanoTime();
CloseableHttpResponse response = httpclient.execute(httpPost);
- if (response.getStatusLine().getStatusCode() == 401) {
+ if (response.getCode() == 401) {
throw new UserException("Remote service responded with a 401 Unauthorized");
- } else if (response.getStatusLine().getStatusCode() == 200) {
+ } else if (response.getCode() == 200) {
Header[] headers = response.getHeaders("Content-Disposition");
String filename = "unknown";
if (headers.length > 0) {
@@ -2683,7 +2684,7 @@ public void triggerRevisionService(Long roid, Long soid) throws ServerException,
newService.getOid());
}
} else {
- throw new UserException("Remote service responded with a " + response.getStatusLine());
+ throw new UserException("Remote service responded with a " + response.getCode() + " (" + response.getReasonPhrase() + ")");
}
} catch (Exception e) {
handleException(e);
diff --git a/BimServerClientLib/src/org/bimserver/client/AbstractBimServerClientFactory.java b/BimServerClientLib/src/org/bimserver/client/AbstractBimServerClientFactory.java
index 2321e2faf1..7e9f6d610b 100644
--- a/BimServerClientLib/src/org/bimserver/client/AbstractBimServerClientFactory.java
+++ b/BimServerClientLib/src/org/bimserver/client/AbstractBimServerClientFactory.java
@@ -29,16 +29,17 @@
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
-import org.apache.http.config.Registry;
-import org.apache.http.config.RegistryBuilder;
-import org.apache.http.conn.socket.ConnectionSocketFactory;
-import org.apache.http.conn.socket.PlainConnectionSocketFactory;
-import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
-import org.apache.http.ssl.SSLContextBuilder;
-import org.apache.http.ssl.SSLContexts;
+import org.apache.hc.core5.http.config.Registry;
+import org.apache.hc.core5.http.config.RegistryBuilder;
+import org.apache.hc.client5.http.socket.ConnectionSocketFactory;
+import org.apache.hc.client5.http.socket.PlainConnectionSocketFactory;
+import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
+import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
+import org.apache.hc.core5.ssl.SSLContextBuilder;
+import org.apache.hc.core5.ssl.SSLContexts;
+import org.apache.hc.client5.http.ssl.HttpsSupport;
import org.bimserver.emf.MetaDataManager;
import org.bimserver.interfaces.SServiceInterfaceService;
import org.bimserver.plugins.services.BimServerClientInterface;
@@ -122,7 +123,7 @@ private void initHttpClient(SSLContext sslContext) {
sslContext == null ? SSLContexts.createSystemDefault() : sslContext,
new String[] { "TLSv1.2" },
null,
- SSLConnectionSocketFactory.getDefaultHostnameVerifier()
+ HttpsSupport.getDefaultHostnameVerifier()
);
Registry registry = RegistryBuilder.create()
.register("http", PlainConnectionSocketFactory.getSocketFactory())
diff --git a/BimServerClientLib/src/org/bimserver/client/Channel.java b/BimServerClientLib/src/org/bimserver/client/Channel.java
index 2aca4b3bc5..4e65871a96 100644
--- a/BimServerClientLib/src/org/bimserver/client/Channel.java
+++ b/BimServerClientLib/src/org/bimserver/client/Channel.java
@@ -28,15 +28,15 @@
import java.util.Set;
import java.util.zip.DeflaterInputStream;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.mime.HttpMultipartMode;
-import org.apache.http.entity.mime.MultipartEntityBuilder;
-import org.apache.http.entity.mime.content.InputStreamBody;
-import org.apache.http.entity.mime.content.StringBody;
-import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.hc.client5.http.ClientProtocolException;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.client5.http.entity.mime.HttpMultipartMode;
+import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
+import org.apache.hc.client5.http.entity.mime.InputStreamBody;
+import org.apache.hc.client5.http.entity.mime.StringBody;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.bimserver.interfaces.objects.SLongCheckinActionState;
import org.bimserver.shared.ChannelConnectionException;
import org.bimserver.shared.ConnectDisconnectListener;
@@ -116,33 +116,32 @@ protected void finish(Reflector reflector, ReflectorFactory reflectorFactory) {
public SLongCheckinActionState checkinSync(String baseAddress, String token, long poid, String comment, long deserializerOid, boolean merge, long fileSize, String filename, InputStream inputStream, Long topicId) throws ServerException, UserException {
String address = baseAddress + "/upload";
HttpPost httppost = new HttpPost(address);
- try {
- if (topicId == null) {
- topicId = getServiceInterface().initiateCheckin(poid, deserializerOid);
- }
- // TODO find some GzipInputStream variant that _compresses_ instead
- // of _decompresses_ using deflate for now
- InputStreamBody data = new InputStreamBody(new DeflaterInputStream(inputStream), filename);
+ if (topicId == null) {
+ topicId = getServiceInterface().initiateCheckin(poid, deserializerOid);
+ }
+ // TODO find some GzipInputStream variant that _compresses_ instead
+ // of _decompresses_ using deflate for now
+ InputStreamBody data = new InputStreamBody(new DeflaterInputStream(inputStream), filename);
- MultipartEntityBuilder multipartEntityBuilder = createMultiPart();
+ MultipartEntityBuilder multipartEntityBuilder = createMultiPart();
- multipartEntityBuilder.addPart("topicId", new StringBody("" + topicId, ContentType.DEFAULT_TEXT));
- multipartEntityBuilder.addPart("token", new StringBody(token, ContentType.DEFAULT_TEXT));
- multipartEntityBuilder.addPart("deserializerOid", new StringBody("" + deserializerOid, ContentType.DEFAULT_TEXT));
- multipartEntityBuilder.addPart("merge", new StringBody("" + merge, ContentType.DEFAULT_TEXT));
- multipartEntityBuilder.addPart("poid", new StringBody("" + poid, ContentType.DEFAULT_TEXT));
- multipartEntityBuilder.addPart("comment", new StringBody("" + comment, ContentType.DEFAULT_TEXT));
- multipartEntityBuilder.addPart("sync", new StringBody("" + true, ContentType.DEFAULT_TEXT));
- multipartEntityBuilder.addPart("compression", new StringBody("deflate", ContentType.DEFAULT_TEXT));
- multipartEntityBuilder.addPart("data", data);
+ multipartEntityBuilder.addPart("topicId", new StringBody("" + topicId, ContentType.DEFAULT_TEXT));
+ multipartEntityBuilder.addPart("token", new StringBody(token, ContentType.DEFAULT_TEXT));
+ multipartEntityBuilder.addPart("deserializerOid", new StringBody("" + deserializerOid, ContentType.DEFAULT_TEXT));
+ multipartEntityBuilder.addPart("merge", new StringBody("" + merge, ContentType.DEFAULT_TEXT));
+ multipartEntityBuilder.addPart("poid", new StringBody("" + poid, ContentType.DEFAULT_TEXT));
+ multipartEntityBuilder.addPart("comment", new StringBody("" + comment, ContentType.DEFAULT_TEXT));
+ multipartEntityBuilder.addPart("sync", new StringBody("" + true, ContentType.DEFAULT_TEXT));
+ multipartEntityBuilder.addPart("compression", new StringBody("deflate", ContentType.DEFAULT_TEXT));
+ multipartEntityBuilder.addPart("data", data);
- httppost.setEntity(multipartEntityBuilder.build());
+ httppost.setEntity(multipartEntityBuilder.build());
- HttpResponse httpResponse = closeableHttpClient.execute(httppost);
- if (httpResponse.getStatusLine().getStatusCode() == 200) {
+ try {
+ CloseableHttpResponse httpResponse = closeableHttpClient.execute(httppost);
+ if (httpResponse.getCode() == 200) {
ObjectMapper objectMapper = new ObjectMapper();
- InputStreamReader in = new InputStreamReader(httpResponse.getEntity().getContent());
- try {
+ try (InputStreamReader in = new InputStreamReader(httpResponse.getEntity().getContent())) {
ObjectNode result = objectMapper.readValue(in, ObjectNode.class);
if (result.has("exception")) {
ObjectNode exceptionJson = (ObjectNode) result.get("exception");
@@ -161,22 +160,12 @@ public SLongCheckinActionState checkinSync(String baseAddress, String token, lon
throw new ServerException(e);
}
}
- } finally {
- in.close();
}
} else {
- throw new ServerException("HTTP Status Code " + httpResponse.getStatusLine().getStatusCode() + " " + httpResponse.getStatusLine().getReasonPhrase());
+ throw new ServerException("HTTP Status Code " + httpResponse.getCode() + " " + httpResponse.getReasonPhrase());
}
- } catch (ClientProtocolException e) {
- throw new ServerException(e);
} catch (IOException e) {
throw new ServerException(e);
- } catch (PublicInterfaceNotFoundException e) {
- throw new ServerException(e);
- } catch (Exception e) {
- throw new ServerException(e);
- } finally {
- httppost.releaseConnection();
}
throw new ServerException("Null result");
}
@@ -184,7 +173,7 @@ public SLongCheckinActionState checkinSync(String baseAddress, String token, lon
private MultipartEntityBuilder createMultiPart() {
MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create();
multipartEntityBuilder.setCharset(Charsets.UTF_8);
- multipartEntityBuilder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
+ multipartEntityBuilder.setMode(HttpMultipartMode.LEGACY);
return multipartEntityBuilder;
}
@@ -199,30 +188,29 @@ protected SServicesMap getSServicesMap() {
public long checkinAsync(String baseAddress, String token, long poid, String comment, long deserializerOid, boolean merge, long fileSize, String filename, InputStream inputStream, long topicId) throws ServerException, UserException {
String address = baseAddress + "/upload";
HttpPost httppost = new HttpPost(address);
- try {
- // TODO find some GzipInputStream variant that _compresses_ instead
- // of _decompresses_ using deflate for now
- InputStreamBody data = new InputStreamBody(new DeflaterInputStream(inputStream), filename);
-
- MultipartEntityBuilder multipartEntityBuilder = createMultiPart();
+ // TODO find some GzipInputStream variant that _compresses_ instead
+ // of _decompresses_ using deflate for now
+ InputStreamBody data = new InputStreamBody(new DeflaterInputStream(inputStream), filename);
+
+ MultipartEntityBuilder multipartEntityBuilder = createMultiPart();
+
+ multipartEntityBuilder.addPart("topicId", new StringBody("" + topicId, ContentType.DEFAULT_TEXT));
+ multipartEntityBuilder.addPart("token", new StringBody(token, ContentType.DEFAULT_TEXT));
+ multipartEntityBuilder.addPart("deserializerOid", new StringBody("" + deserializerOid, ContentType.DEFAULT_TEXT));
+ multipartEntityBuilder.addPart("merge", new StringBody("" + merge, ContentType.DEFAULT_TEXT));
+ multipartEntityBuilder.addPart("poid", new StringBody("" + poid, ContentType.DEFAULT_TEXT));
+ multipartEntityBuilder.addPart("comment", new StringBody("" + comment, ContentType.DEFAULT_TEXT));
+ multipartEntityBuilder.addPart("sync", new StringBody("" + false, ContentType.DEFAULT_TEXT));
+ multipartEntityBuilder.addPart("compression", new StringBody("deflate", ContentType.DEFAULT_TEXT));
+ multipartEntityBuilder.addPart("data", data);
- multipartEntityBuilder.addPart("topicId", new StringBody("" + topicId, ContentType.DEFAULT_TEXT));
- multipartEntityBuilder.addPart("token", new StringBody(token, ContentType.DEFAULT_TEXT));
- multipartEntityBuilder.addPart("deserializerOid", new StringBody("" + deserializerOid, ContentType.DEFAULT_TEXT));
- multipartEntityBuilder.addPart("merge", new StringBody("" + merge, ContentType.DEFAULT_TEXT));
- multipartEntityBuilder.addPart("poid", new StringBody("" + poid, ContentType.DEFAULT_TEXT));
- multipartEntityBuilder.addPart("comment", new StringBody("" + comment, ContentType.DEFAULT_TEXT));
- multipartEntityBuilder.addPart("sync", new StringBody("" + false, ContentType.DEFAULT_TEXT));
- multipartEntityBuilder.addPart("compression", new StringBody("deflate", ContentType.DEFAULT_TEXT));
- multipartEntityBuilder.addPart("data", data);
-
- httppost.setEntity(multipartEntityBuilder.build());
-
- HttpResponse httpResponse = closeableHttpClient.execute(httppost);
- if (httpResponse.getStatusLine().getStatusCode() == 200) {
+ httppost.setEntity(multipartEntityBuilder.build());
+
+ try {
+ CloseableHttpResponse httpResponse = closeableHttpClient.execute(httppost);
+ if (httpResponse.getCode() == 200) {
ObjectMapper objectMapper = new ObjectMapper();
- InputStreamReader in = new InputStreamReader(httpResponse.getEntity().getContent());
- try {
+ try (InputStreamReader in = new InputStreamReader(httpResponse.getEntity().getContent())) {
ObjectNode result = objectMapper.readValue(in, ObjectNode.class);
if (result.has("exception")) {
ObjectNode exceptionJson = (ObjectNode) result.get("exception");
@@ -240,18 +228,10 @@ public long checkinAsync(String baseAddress, String token, long poid, String com
throw new ServerException("No topicId found in response: " + result.toString());
}
}
- } finally {
- in.close();
}
}
- } catch (ClientProtocolException e) {
- throw new ServerException(e);
} catch (IOException e) {
throw new ServerException(e);
- } catch (PublicInterfaceNotFoundException e) {
- throw new ServerException(e);
- } finally {
- httppost.releaseConnection();
}
return -1;
}
@@ -260,15 +240,12 @@ public InputStream getDownloadData(String baseAddress, String token, long topicI
String address = baseAddress + "/download?token=" + token + "&topicId=" + topicId;
HttpPost httppost = new HttpPost(address);
try {
- HttpResponse httpResponse = closeableHttpClient.execute(httppost);
- if (httpResponse.getStatusLine().getStatusCode() == 200) {
+ CloseableHttpResponse httpResponse = closeableHttpClient.execute(httppost);
+ if (httpResponse.getCode() == 200) {
return httpResponse.getEntity().getContent();
} else {
- LOGGER.error(httpResponse.getStatusLine().getStatusCode() + " - " + httpResponse.getStatusLine().getReasonPhrase());
- httppost.releaseConnection();
+ LOGGER.error(httpResponse.getCode() + " - " + httpResponse.getReasonPhrase());
}
- } catch (ClientProtocolException e) {
- LOGGER.error("", e);
} catch (IOException e) {
LOGGER.error("", e);
}
@@ -278,16 +255,13 @@ public InputStream getDownloadData(String baseAddress, String token, long topicI
public InputStream getDownloadExtendedData(String baseAddress, String token, long edid) throws IOException {
String address = baseAddress + "/download?token=" + token + "&action=extendeddata&edid=" + edid;
HttpPost httppost = new HttpPost(address);
- try {
- HttpResponse httpResponse = closeableHttpClient.execute(httppost);
- if (httpResponse.getStatusLine().getStatusCode() == 200) {
+ try {
+ CloseableHttpResponse httpResponse = closeableHttpClient.execute(httppost);
+ if (httpResponse.getCode() == 200) {
return httpResponse.getEntity().getContent();
} else {
- LOGGER.error(httpResponse.getStatusLine().getStatusCode() + " - " + httpResponse.getStatusLine().getReasonPhrase());
- httppost.releaseConnection();
+ LOGGER.error(httpResponse.getCode() + " - " + httpResponse.getReasonPhrase());
}
- } catch (ClientProtocolException e) {
- LOGGER.error("", e);
} catch (IOException e) {
LOGGER.error("", e);
}
@@ -370,11 +344,10 @@ public void bulkCheckin(String baseAddress, String token, long poid, String comm
httppost.setEntity(multipartEntityBuilder.build());
- HttpResponse httpResponse = closeableHttpClient.execute(httppost);
- if (httpResponse.getStatusLine().getStatusCode() == 200) {
+ CloseableHttpResponse httpResponse = closeableHttpClient.execute(httppost);
+ if (httpResponse.getCode() == 200) {
ObjectMapper objectMapper = new ObjectMapper();
- InputStreamReader in = new InputStreamReader(httpResponse.getEntity().getContent());
- try {
+ try (InputStreamReader in = new InputStreamReader(httpResponse.getEntity().getContent())) {
ObjectNode result = objectMapper.readValue(in, ObjectNode.class);
if (result.has("exception")) {
ObjectNode exceptionJson = (ObjectNode) result.get("exception");
@@ -386,18 +359,10 @@ public void bulkCheckin(String baseAddress, String token, long poid, String comm
throw new ServerException(message);
}
}
- } finally {
- in.close();
}
}
- } catch (ClientProtocolException e) {
- throw new ServerException(e);
} catch (IOException e) {
throw new ServerException(e);
- } catch (PublicInterfaceNotFoundException e) {
- throw new ServerException(e);
- } finally {
- httppost.releaseConnection();
}
}
}
\ No newline at end of file
diff --git a/BimServerClientLib/src/org/bimserver/client/DirectChannel.java b/BimServerClientLib/src/org/bimserver/client/DirectChannel.java
index 02af0e1d09..e882fb6d7d 100644
--- a/BimServerClientLib/src/org/bimserver/client/DirectChannel.java
+++ b/BimServerClientLib/src/org/bimserver/client/DirectChannel.java
@@ -22,7 +22,7 @@
import javax.activation.DataHandler;
-import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.bimserver.interfaces.objects.SDownloadResult;
import org.bimserver.interfaces.objects.SLongCheckinActionState;
import org.bimserver.models.log.AccessMethod;
@@ -39,9 +39,9 @@
import org.bimserver.utils.InputStreamDataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
+
public class DirectChannel extends Channel implements TokenChangeListener {
- private static final Logger LOGGER = LoggerFactory.getLogger(DirectChannel.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(DirectChannel.class);
private ServiceFactory serviceFactory;
private SServicesMap sServicesMap;
@@ -61,12 +61,12 @@ public void connect() throws UserException {
}
}
}
- notifyOfConnect();
- }
-
- @Override
- public void disconnect() {
- notifyOfDisconnect();
+ notifyOfConnect();
+ }
+
+ @Override
+ public void disconnect() {
+ notifyOfDisconnect();
}
@Override
@@ -108,5 +108,5 @@ public void newToken(String token) {
LOGGER.error("", e);
}
}
- }
+ }
}
\ No newline at end of file
diff --git a/BimServerClientLib/src/org/bimserver/client/json/JsonChannel.java b/BimServerClientLib/src/org/bimserver/client/json/JsonChannel.java
index 3b06955608..a11f1a42c7 100644
--- a/BimServerClientLib/src/org/bimserver/client/json/JsonChannel.java
+++ b/BimServerClientLib/src/org/bimserver/client/json/JsonChannel.java
@@ -17,7 +17,7 @@
* along with this program. If not, see {@literal}.
*****************************************************************************/
-import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.bimserver.client.Channel;
import org.bimserver.shared.ChannelConnectionException;
import org.bimserver.shared.TokenHolder;
@@ -26,35 +26,35 @@
import org.bimserver.shared.json.JsonReflector;
import org.bimserver.shared.meta.SServicesMap;
import org.bimserver.shared.reflector.ReflectorFactory;
-
-public class JsonChannel extends Channel {
-
- private final ReflectorFactory reflectorFactory;
- private final JsonReflectorFactory jsonReflectorFactory;
+
+public class JsonChannel extends Channel {
+
+ private final ReflectorFactory reflectorFactory;
+ private final JsonReflectorFactory jsonReflectorFactory;
private JsonReflector reflector;
private String address;
private SServicesMap sServicesMap;
-
+
public JsonChannel(CloseableHttpClient closeableHttpClient, ReflectorFactory reflectorFactory, JsonReflectorFactory jsonReflectorFactory, String address, SServicesMap sServicesMap) {
super(closeableHttpClient);
- this.reflectorFactory = reflectorFactory;
+ this.reflectorFactory = reflectorFactory;
this.jsonReflectorFactory = jsonReflectorFactory;
this.address = address;
this.sServicesMap = sServicesMap;
- }
-
- @Override
+ }
+
+ @Override
public void disconnect() {
- reflector.close();
- }
-
- public void connect(TokenHolder tokenHolder) throws ChannelConnectionException {
- reflector = jsonReflectorFactory.create(address, tokenHolder);
+ reflector.close();
+ }
+
+ public void connect(TokenHolder tokenHolder) throws ChannelConnectionException {
+ reflector = jsonReflectorFactory.create(address, tokenHolder);
for (Class extends PublicInterface> interface1 : sServicesMap.getInterfaceClasses()) {
PublicInterface createReflector = reflectorFactory.createReflector(interface1, reflector);
add(interface1.getName(), createReflector);
}
- finish(reflector, reflectorFactory);
+ finish(reflector, reflectorFactory);
}
@Override
@@ -65,5 +65,5 @@ protected JsonConverter getJsonConverter() {
@Override
protected SServicesMap getSServicesMap() {
return sServicesMap;
- }
+ }
}
\ No newline at end of file
diff --git a/BimServerClientLib/src/org/bimserver/client/json/JsonSocketReflectorFactory.java b/BimServerClientLib/src/org/bimserver/client/json/JsonSocketReflectorFactory.java
index 8224de3b27..2f8c53e5cc 100644
--- a/BimServerClientLib/src/org/bimserver/client/json/JsonSocketReflectorFactory.java
+++ b/BimServerClientLib/src/org/bimserver/client/json/JsonSocketReflectorFactory.java
@@ -17,48 +17,48 @@
* along with this program. If not, see {@literal}.
*****************************************************************************/
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
+import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.bimserver.shared.TokenHolder;
import org.bimserver.shared.json.JsonSocketReflector;
import org.bimserver.shared.meta.SServicesMap;
-
-public class JsonSocketReflectorFactory implements JsonReflectorFactory {
- private SServicesMap servicesMap;
- private CloseableHttpClient httpclient;
- private PoolingHttpClientConnectionManager poolingHttpClientConnectionManager;
-
+
+public class JsonSocketReflectorFactory implements JsonReflectorFactory {
+ private SServicesMap servicesMap;
+ private CloseableHttpClient httpclient;
+ private PoolingHttpClientConnectionManager poolingHttpClientConnectionManager;
+
public JsonSocketReflectorFactory(SServicesMap servicesMap, CloseableHttpClient closeableHttpClient) {
if (servicesMap == null) {
throw new IllegalArgumentException("servicesMap cannot be null");
- }
+ }
this.servicesMap = servicesMap;
if (closeableHttpClient == null) {
poolingHttpClientConnectionManager = new PoolingHttpClientConnectionManager();
- poolingHttpClientConnectionManager.setDefaultMaxPerRoute(20);
- poolingHttpClientConnectionManager.setMaxTotal(20);
+ poolingHttpClientConnectionManager.setDefaultMaxPerRoute(20);
+ poolingHttpClientConnectionManager.setMaxTotal(20);
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
httpClientBuilder.setConnectionManager(poolingHttpClientConnectionManager);
-
+
httpclient = httpClientBuilder.build();
} else {
httpclient = closeableHttpClient;
- }
- }
+ }
+ }
public JsonSocketReflectorFactory(SServicesMap servicesMap) {
this(servicesMap, null);
}
-
- public void close() {
- poolingHttpClientConnectionManager.shutdown();
- }
-
- public JsonSocketReflector create(String remoteAddress, TokenHolder tokenHolder) {
- return new JsonSocketReflector(httpclient, servicesMap, remoteAddress, tokenHolder);
- }
+
+ public void close() {
+ poolingHttpClientConnectionManager.close();
+ }
+
+ public JsonSocketReflector create(String remoteAddress, TokenHolder tokenHolder) {
+ return new JsonSocketReflector(httpclient, servicesMap, remoteAddress, tokenHolder);
+ }
}
\ No newline at end of file
diff --git a/BimServerClientLib/src/org/bimserver/client/protocolbuffers/ProtocolBuffersChannel.java b/BimServerClientLib/src/org/bimserver/client/protocolbuffers/ProtocolBuffersChannel.java
index 0e7521ba99..a3fb353226 100644
--- a/BimServerClientLib/src/org/bimserver/client/protocolbuffers/ProtocolBuffersChannel.java
+++ b/BimServerClientLib/src/org/bimserver/client/protocolbuffers/ProtocolBuffersChannel.java
@@ -20,7 +20,7 @@
import java.io.IOException;
import java.net.InetSocketAddress;
-import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.bimserver.client.Channel;
import org.bimserver.shared.ChannelConnectionException;
import org.bimserver.shared.ConnectDisconnectListener;
@@ -31,10 +31,10 @@
import org.bimserver.shared.pb.ProtocolBuffersReflector;
import org.bimserver.shared.pb.SocketProtocolBuffersChannel;
import org.bimserver.shared.reflector.ReflectorFactory;
-
-public class ProtocolBuffersChannel extends Channel implements ConnectDisconnectListener {
-
- private SocketProtocolBuffersChannel protocolBuffersChannel;
+
+public class ProtocolBuffersChannel extends Channel implements ConnectDisconnectListener {
+
+ private SocketProtocolBuffersChannel protocolBuffersChannel;
private SServicesMap servicesMap;
private ReflectorFactory reflectorFactory;
private String address;
@@ -42,46 +42,46 @@ public class ProtocolBuffersChannel extends Channel implements ConnectDisconnect
private ProtocolBuffersMetaData protocolBuffersMetaData;
public ProtocolBuffersChannel(CloseableHttpClient httpClient, SServicesMap servicesMap, ProtocolBuffersMetaData protocolBuffersMetaData, ReflectorFactory reflectorFactory, String address, int port) {
- super(httpClient);
+ super(httpClient);
this.servicesMap = servicesMap;
this.protocolBuffersMetaData = protocolBuffersMetaData;
this.reflectorFactory = reflectorFactory;
this.address = address;
this.port = port;
- }
-
- public void connect(TokenHolder tokenHolder) throws ChannelConnectionException {
- protocolBuffersChannel = new SocketProtocolBuffersChannel(tokenHolder);
+ }
+
+ public void connect(TokenHolder tokenHolder) throws ChannelConnectionException {
+ protocolBuffersChannel = new SocketProtocolBuffersChannel(tokenHolder);
protocolBuffersChannel.registerConnectDisconnectListener(this);
ProtocolBuffersReflector reflector = new ProtocolBuffersReflector(protocolBuffersMetaData, servicesMap, protocolBuffersChannel);
for (Class extends PublicInterface> interface1 : servicesMap.getInterfaceClasses()) {
PublicInterface createReflector = reflectorFactory.createReflector(interface1, reflector);
add(interface1.getName(), createReflector);
- }
+ }
- finish(reflector, reflectorFactory);
+ finish(reflector, reflectorFactory);
try {
protocolBuffersChannel.connect(new InetSocketAddress(address, port));
} catch (IOException e) {
throw new ChannelConnectionException(e);
- }
- }
-
- @Override
- public void connected() {
- notifyOfConnect();
- }
-
- @Override
- public void disconnected() {
- notifyOfDisconnect();
- }
-
- @Override
+ }
+ }
+
+ @Override
+ public void connected() {
+ notifyOfConnect();
+ }
+
+ @Override
+ public void disconnected() {
+ notifyOfDisconnect();
+ }
+
+ @Override
public void disconnect() {
if (protocolBuffersChannel != null) {
protocolBuffersChannel.disconnect();
- }
- }
+ }
+ }
}
\ No newline at end of file
diff --git a/BimServerClientLib/src/org/bimserver/client/soap/SoapChannel.java b/BimServerClientLib/src/org/bimserver/client/soap/SoapChannel.java
index f01ae1f507..aac68342f3 100644
--- a/BimServerClientLib/src/org/bimserver/client/soap/SoapChannel.java
+++ b/BimServerClientLib/src/org/bimserver/client/soap/SoapChannel.java
@@ -33,45 +33,44 @@
import org.apache.cxf.jaxb.JAXBDataBinding;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.apache.cxf.transport.http.HTTPConduit;
-import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.bimserver.client.Channel;
import org.bimserver.shared.Token;
import org.bimserver.shared.TokenChangeListener;
import org.bimserver.shared.TokenHolder;
import org.bimserver.shared.interfaces.PublicInterface;
-import org.bimserver.shared.json.JsonConverter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
-public class SoapChannel extends Channel implements TokenChangeListener {
- private static final Logger LOGGER = LoggerFactory.getLogger(SoapChannel.class);
+
+public class SoapChannel extends Channel implements TokenChangeListener {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SoapChannel.class);
private Client client;
private boolean useSoapHeaderSessions;
private String address;
private Set> interfaces;
-
+
public SoapChannel(CloseableHttpClient httpClient, String address, boolean useSoapHeaderSessions, Set> interfaces) {
super(httpClient);
this.address = address;
this.useSoapHeaderSessions = useSoapHeaderSessions;
this.interfaces = interfaces;
}
-
+
public void connect(TokenHolder tokenHolder) {
for (Class extends PublicInterface> interface1 : interfaces) {
- JaxWsProxyFactoryBean cpfb = new JaxWsProxyFactoryBean();
- cpfb.setServiceClass(interface1);
- cpfb.setAddress(address + "/" + interface1.getSimpleName());
- Map properties = new HashMap();
- properties.put("mtom-enabled", Boolean.TRUE);
- cpfb.setProperties(properties);
-
- PublicInterface serviceInterface = (PublicInterface) cpfb.create();
+ JaxWsProxyFactoryBean cpfb = new JaxWsProxyFactoryBean();
+ cpfb.setServiceClass(interface1);
+ cpfb.setAddress(address + "/" + interface1.getSimpleName());
+ Map properties = new HashMap();
+ properties.put("mtom-enabled", Boolean.TRUE);
+ cpfb.setProperties(properties);
+
+ PublicInterface serviceInterface = (PublicInterface) cpfb.create();
client = ClientProxy.getClient(serviceInterface);
- HTTPConduit http = (HTTPConduit) client.getConduit();
+ HTTPConduit http = (HTTPConduit) client.getConduit();
http.getClient().setConnectionTimeout(360000);
- http.getClient().setAllowChunking(false);
+ http.getClient().setAllowChunking(false);
http.getClient().setReceiveTimeout(320000);
if (!useSoapHeaderSessions) {
@@ -80,8 +79,8 @@ public void connect(TokenHolder tokenHolder) {
add(interface1.getName(), serviceInterface);
}
tokenHolder.registerTokenChangeListener(this);
- notifyOfConnect();
- }
+ notifyOfConnect();
+ }
@Override
public void newToken(String token) {
@@ -99,10 +98,10 @@ public void newToken(String token) {
}
}
}
-
- @Override
- public void disconnect() {
- client.destroy();
- notifyOfDisconnect();
+
+ @Override
+ public void disconnect() {
+ client.destroy();
+ notifyOfDisconnect();
}
}
\ No newline at end of file
diff --git a/PluginBase/pom.xml b/PluginBase/pom.xml
index 20163ee603..7396ed0c10 100644
--- a/PluginBase/pom.xml
+++ b/PluginBase/pom.xml
@@ -51,12 +51,17 @@
org.apache.httpcomponents
httpclient
- 4.5.7
+ 4.5.13
org.apache.httpcomponents
httpmime
- 4.5.7
+ 4.5.13
+
+
+ org.apache.httpcomponents.client5
+ httpclient5
+ 5.1.3
org.eclipse.aether
diff --git a/PluginBase/src/org/bimserver/plugins/services/BimBotClient.java b/PluginBase/src/org/bimserver/plugins/services/BimBotClient.java
index 2d4edcc132..3188ed764d 100644
--- a/PluginBase/src/org/bimserver/plugins/services/BimBotClient.java
+++ b/PluginBase/src/org/bimserver/plugins/services/BimBotClient.java
@@ -1,39 +1,40 @@
-package org.bimserver.plugins.services;
-
-/******************************************************************************
- * Copyright (C) 2009-2019 BIMserver.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see {@literal}.
- *****************************************************************************/
-
-import java.io.File;
-import java.io.IOException;
-
-import org.apache.http.Header;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.bimserver.bimbots.BimBotsInput;
-import org.bimserver.bimbots.BimBotsOutput;
-import org.bimserver.plugins.SchemaName;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.io.ByteStreams;
+package org.bimserver.plugins.services;
+
+/******************************************************************************
+ * Copyright (C) 2009-2019 BIMserver.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see {@literal}.
+ *****************************************************************************/
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.client5.http.ClientProtocolException;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.core5.http.io.entity.ByteArrayEntity;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.bimserver.bimbots.BimBotsInput;
+import org.bimserver.bimbots.BimBotsOutput;
+import org.bimserver.plugins.SchemaName;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.io.ByteStreams;
import com.google.common.io.Files;
public class BimBotClient implements AutoCloseable {
@@ -47,9 +48,7 @@ public static void main(String[] args) {
BimBotsOutput bimBotsOutput = bimBotCaller.call("3866702", bimBotsInput);
ObjectNode readValue = new ObjectMapper().readValue(bimBotsOutput.getData(), ObjectNode.class);
System.out.println(readValue.toString());
- } catch (IOException e) {
- e.printStackTrace();
- } catch (BimBotExecutionException e) {
+ } catch (IOException | BimBotExecutionException e) {
e.printStackTrace();
}
}
@@ -65,23 +64,20 @@ public BimBotsOutput call(String identifier, BimBotsInput input) throws BimBotEx
post.setHeader("Input-Type", input.getSchemaName());
post.setHeader("Token", token);
post.setHeader("Accept-Flow", "SYNC");
- post.setEntity(new ByteArrayEntity(input.getData()));
+ post.setEntity(new ByteArrayEntity(input.getData(), ContentType.APPLICATION_OCTET_STREAM));
try {
CloseableHttpResponse httpResponse = httpClient.execute(post);
- if (httpResponse.getStatusLine().getStatusCode() == 200) {
+ if (httpResponse.getCode() == 200) {
Header outputType = httpResponse.getFirstHeader("Output-Type");
if (outputType == null) {
throw new BimBotExecutionException("No Output-Type given");
}
String outputSchema = outputType.getValue();
- BimBotsOutput bimBotsOutput = new BimBotsOutput(outputSchema, ByteStreams.toByteArray(httpResponse.getEntity().getContent()));
- return bimBotsOutput;
+ return new BimBotsOutput(outputSchema, ByteStreams.toByteArray(httpResponse.getEntity().getContent()));
} else {
- throw new BimBotExecutionException("Unexpected HTTP status code " + httpResponse.getStatusLine().toString());
+ throw new BimBotExecutionException("Unexpected HTTP status code " + httpResponse.getCode() + " " + httpResponse.getReasonPhrase());
}
- } catch (ClientProtocolException e) {
- e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
diff --git a/PluginBase/src/org/bimserver/utils/NetUtils.java b/PluginBase/src/org/bimserver/utils/NetUtils.java
index c3a47e45dd..d4f304dc44 100644
--- a/PluginBase/src/org/bimserver/utils/NetUtils.java
+++ b/PluginBase/src/org/bimserver/utils/NetUtils.java
@@ -26,45 +26,45 @@
import java.net.URLConnection;
import org.apache.commons.io.IOUtils;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.entity.ContentType;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.core5.http.io.entity.ByteArrayEntity;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.base.Charsets;
-
-public class NetUtils {
+
+public class NetUtils {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
public static String getContent(URL url, int timeOut) throws IOException {
try {
- URLConnection openConnection = url.openConnection();
- openConnection.setConnectTimeout(timeOut);
- openConnection.setReadTimeout(timeOut);
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- InputStream in = openConnection.getInputStream();
- IOUtils.copy(in, byteArrayOutputStream);
- in.close();
+ URLConnection openConnection = url.openConnection();
+ openConnection.setConnectTimeout(timeOut);
+ openConnection.setReadTimeout(timeOut);
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ InputStream in = openConnection.getInputStream();
+ IOUtils.copy(in, byteArrayOutputStream);
+ in.close();
return new String(byteArrayOutputStream.toByteArray(), Charsets.UTF_8);
} catch (ConnectException e) {
throw new ConnectException(e.getMessage() + " (" + url.toString() + ")");
- }
+ }
}
- public static byte[] getContentAsBytes(URL url, int timeOut) throws IOException {
- URLConnection openConnection = url.openConnection();
- openConnection.setConnectTimeout(timeOut);
+ public static byte[] getContentAsBytes(URL url, int timeOut) throws IOException {
+ URLConnection openConnection = url.openConnection();
+ openConnection.setConnectTimeout(timeOut);
openConnection.setReadTimeout(timeOut);
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- InputStream in = openConnection.getInputStream();
- IOUtils.copy(in, byteArrayOutputStream);
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ InputStream in = openConnection.getInputStream();
+ IOUtils.copy(in, byteArrayOutputStream);
in.close();
- return byteArrayOutputStream.toByteArray();
+ return byteArrayOutputStream.toByteArray();
}
public static void main(String[] args) {
@@ -92,5 +92,5 @@ public static ObjectNode post(String url, ObjectNode objectNode) throws IOExcept
} finally {
httpclient.close();
}
- }
-}
+ }
+}
diff --git a/Shared/src/org/bimserver/shared/json/JsonReflector.java b/Shared/src/org/bimserver/shared/json/JsonReflector.java
index b3cece7d12..17c893d534 100644
--- a/Shared/src/org/bimserver/shared/json/JsonReflector.java
+++ b/Shared/src/org/bimserver/shared/json/JsonReflector.java
@@ -1,6 +1,6 @@
package org.bimserver.shared.json;
-import org.apache.http.conn.HttpHostConnectException;
+import org.apache.hc.client5.http.HttpHostConnectException;
import org.bimserver.plugins.deserializers.DeserializerErrorCode;
import org.bimserver.shared.exceptions.DefaultErrorCode;
@@ -33,44 +33,44 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
-
-public abstract class JsonReflector implements Reflector {
- private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
- private final JsonConverter converter;
- private final SServicesMap servicesMap;
-
+public abstract class JsonReflector implements Reflector {
+
+ private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+ private final JsonConverter converter;
+ private final SServicesMap servicesMap;
+
public JsonReflector(SServicesMap servicesMap) {
if (servicesMap == null) {
throw new IllegalArgumentException("servicesMap cannot be null");
- }
- this.servicesMap = servicesMap;
- this.converter = new JsonConverter(servicesMap);
- }
-
- @Override
- public Object callMethod(String interfaceName, String methodName, Class> definedReturnType, KeyValuePair... args) throws ServerException, UserException {
+ }
+ this.servicesMap = servicesMap;
+ this.converter = new JsonConverter(servicesMap);
+ }
+
+ @Override
+ public Object callMethod(String interfaceName, String methodName, Class> definedReturnType, KeyValuePair... args) throws ServerException, UserException {
try {
- ObjectNode request = OBJECT_MAPPER.createObjectNode();
- request.put("interface", interfaceName);
- request.put("method", methodName);
- ObjectNode parameters = OBJECT_MAPPER.createObjectNode();
- for (KeyValuePair arg : args) {
- parameters.set(arg.getFieldName(), converter.toJson(arg.getValue()));
- }
- request.set("parameters", parameters);
- ObjectNode requestObject = OBJECT_MAPPER.createObjectNode();
- requestObject.set("request", request);
- JsonNode jsonResult = call(requestObject);
- if (!isOneWay()) {
- if (jsonResult == null) {
- return null;
- }
- ObjectNode response = (ObjectNode) jsonResult.get("response");
- if (response.has("exception")) {
- ObjectNode exceptionJson = (ObjectNode) response.get("exception");
- String exceptionType = exceptionJson.get("__type").asText();
- String message = exceptionJson.has("message") ? exceptionJson.get("message").asText() : "unknown";
+ ObjectNode request = OBJECT_MAPPER.createObjectNode();
+ request.put("interface", interfaceName);
+ request.put("method", methodName);
+ ObjectNode parameters = OBJECT_MAPPER.createObjectNode();
+ for (KeyValuePair arg : args) {
+ parameters.set(arg.getFieldName(), converter.toJson(arg.getValue()));
+ }
+ request.set("parameters", parameters);
+ ObjectNode requestObject = OBJECT_MAPPER.createObjectNode();
+ requestObject.set("request", request);
+ JsonNode jsonResult = call(requestObject);
+ if (!isOneWay()) {
+ if (jsonResult == null) {
+ return null;
+ }
+ ObjectNode response = (ObjectNode) jsonResult.get("response");
+ if (response.has("exception")) {
+ ObjectNode exceptionJson = (ObjectNode) response.get("exception");
+ String exceptionType = exceptionJson.get("__type").asText();
+ String message = exceptionJson.has("message") ? exceptionJson.get("message").asText() : "unknown";
if (exceptionType.equals(UserException.class.getSimpleName())) {
if (exceptionJson.has("errorCode")) {
String errorType = exceptionJson.get("errorType").asText();
@@ -83,8 +83,8 @@ public Object callMethod(String interfaceName, String methodName, Class> defin
}
} else {
throw new UserException(message);
- }
- } else if (exceptionType.equals(ServerException.class.getSimpleName())) {
+ }
+ } else if (exceptionType.equals(ServerException.class.getSimpleName())) {
String errorType = exceptionJson.get("errorType").asText();
if (errorType.equals("DefaultErrorCode")) {
throw new ServerException(message, DefaultErrorCode.fromCode(exceptionJson.get("errorCode").asInt()));
@@ -99,32 +99,32 @@ public Object callMethod(String interfaceName, String methodName, Class> defin
} else {
throw new ServerException(message);
}
- }
- } else if (response.has("result")) {
- Object result = response.get("result");
- SMethod method = servicesMap.getBySimpleName(interfaceName).getSMethod(methodName);
- return converter.fromJson(method.getReturnType(), method.getGenericReturnType(), result);
- } else {
- return null;
- }
- } else {
- return null;
- }
+ }
+ } else if (response.has("result")) {
+ Object result = response.get("result");
+ SMethod method = servicesMap.getBySimpleName(interfaceName).getSMethod(methodName);
+ return converter.fromJson(method.getReturnType(), method.getGenericReturnType(), result);
+ } else {
+ return null;
+ }
+ } else {
+ return null;
+ }
} catch (HttpHostConnectException e) {
throw new UserException(e.getMessage(), DefaultErrorCode.HTTP_CONNECTION_REFUSED);
} catch (UserException e) {
throw e;
} catch (ServerException e) {
- throw e;
- } catch (Exception e) {
- throw new UserException(e);
- }
- }
-
- protected boolean isOneWay() {
- return false;
- }
-
+ throw e;
+ } catch (Exception e) {
+ throw new UserException(e);
+ }
+ }
+
+ protected boolean isOneWay() {
+ return false;
+ }
+
public abstract JsonNode call(ObjectNode request) throws ReflectorException;
public void close() {
@@ -132,5 +132,5 @@ public void close() {
public JsonConverter getConverter() {
return converter;
- }
+ }
}
\ No newline at end of file
diff --git a/Shared/src/org/bimserver/shared/json/JsonSocketReflector.java b/Shared/src/org/bimserver/shared/json/JsonSocketReflector.java
index 513982acd5..4170332208 100644
--- a/Shared/src/org/bimserver/shared/json/JsonSocketReflector.java
+++ b/Shared/src/org/bimserver/shared/json/JsonSocketReflector.java
@@ -21,13 +21,13 @@
import java.io.InputStream;
import org.apache.commons.io.IOUtils;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.HttpContext;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.core5.http.io.entity.StringEntity;
+import org.apache.hc.core5.http.protocol.BasicHttpContext;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.bimserver.shared.TokenHolder;
import org.bimserver.shared.meta.SServicesMap;
import org.bimserver.shared.reflector.ReflectorException;
@@ -38,60 +38,56 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.base.Charsets;
-
-public class JsonSocketReflector extends JsonReflector {
-
+
+public class JsonSocketReflector extends JsonReflector {
+
private static final Logger LOGGER = LoggerFactory.getLogger(JsonSocketReflector.class);
- private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
- private final String remoteAddress;
- private final HttpClient httpclient;
+ private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+ private final String remoteAddress;
+ private final CloseableHttpClient httpclient;
private final HttpContext context;
- private TokenHolder tokenHolder;
-
- public JsonSocketReflector(HttpClient httpclient, SServicesMap servicesMap, String remoteAddress, TokenHolder tokenHolder) {
- super(servicesMap);
- this.httpclient = httpclient;
- this.remoteAddress = remoteAddress;
- this.tokenHolder = tokenHolder;
+ private TokenHolder tokenHolder;
+
+ public JsonSocketReflector(CloseableHttpClient httpclient, SServicesMap servicesMap, String remoteAddress, TokenHolder tokenHolder) {
+ super(servicesMap);
+ this.httpclient = httpclient;
+ this.remoteAddress = remoteAddress;
+ this.tokenHolder = tokenHolder;
this.context = new BasicHttpContext();
- }
-
- public JsonNode call(ObjectNode request) throws ReflectorException {
+ }
+
+ public JsonNode call(ObjectNode request) throws ReflectorException {
try {
- if (tokenHolder.getToken() != null) {
- request.put("token", tokenHolder.getToken());
- }
+ if (tokenHolder.getToken() != null) {
+ request.put("token", tokenHolder.getToken());
+ }
HttpPost httppost = new HttpPost(remoteAddress);
httppost.setHeader("Content-Type", "application/json");
- httppost.setEntity(new StringEntity(request.toString(), Charsets.UTF_8));
+ httppost.setEntity(new StringEntity(request.toString(), Charsets.UTF_8));
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(request.toString());
}
-
- HttpResponse response = httpclient.execute(httppost, context);
- try {
- if (response.getStatusLine().getStatusCode() == 200) {
- HttpEntity resultEntity = response.getEntity();
-
- if (LOGGER.isDebugEnabled()) {
- InputStream inputStream = resultEntity.getContent();
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- IOUtils.copy(inputStream, byteArrayOutputStream);
+
+ try(CloseableHttpResponse response = httpclient.execute(httppost, context)) {
+ if (response.getCode() == 200) {
+ HttpEntity resultEntity = response.getEntity();
+
+ if (LOGGER.isDebugEnabled()) {
+ InputStream inputStream = resultEntity.getContent();
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ IOUtils.copy(inputStream, byteArrayOutputStream);
LOGGER.debug(new String(byteArrayOutputStream.toByteArray(), Charsets.UTF_8));
- ObjectNode resultObject = OBJECT_MAPPER.readValue(byteArrayOutputStream.toByteArray(), ObjectNode.class);
- return resultObject;
- } else {
+ return OBJECT_MAPPER.readValue(byteArrayOutputStream.toByteArray(), ObjectNode.class);
+ } else {
return OBJECT_MAPPER.readValue(resultEntity.getContent(), ObjectNode.class);
- }
- } else {
- throw new ReflectorException("Call unsuccessful, status code: " + response.getStatusLine().getStatusCode() + " (" + response.getStatusLine().getReasonPhrase() + "), " + remoteAddress);
- }
- } finally {
- httppost.releaseConnection();
- }
+ }
+ } else {
+ throw new ReflectorException("Call unsuccessful, status code: " + response.getCode() + " (" + response.getReasonPhrase() + "), " + remoteAddress);
+ }
+ }
} catch (Exception e) {
- throw new ReflectorException(e);
- }
+ throw new ReflectorException(e);
+ }
}
}
\ No newline at end of file