mirror of
https://repository.entgra.net/community/device-mgt-plugins.git
synced 2025-09-16 23:42:15 +00:00
Fixed issue in MT
This commit is contained in:
parent
883cfff218
commit
e02d336413
@ -27,10 +27,8 @@ import org.apache.commons.httpclient.methods.PutMethod;
|
|||||||
import org.apache.commons.httpclient.methods.StringRequestEntity;
|
import org.apache.commons.httpclient.methods.StringRequestEntity;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.http.HttpHost;
|
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
import org.apache.http.client.methods.HttpPost;
|
import org.apache.http.client.methods.HttpPost;
|
||||||
import org.apache.http.conn.params.ConnRoutePNames;
|
|
||||||
import org.apache.http.entity.ContentType;
|
import org.apache.http.entity.ContentType;
|
||||||
import org.apache.http.entity.StringEntity;
|
import org.apache.http.entity.StringEntity;
|
||||||
import org.apache.http.message.BasicHeader;
|
import org.apache.http.message.BasicHeader;
|
||||||
@ -70,9 +68,11 @@ import java.util.concurrent.ThreadPoolExecutor;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class HTTPEventAdapter implements OutputEventAdapter {
|
public class HTTPEventAdapter implements OutputEventAdapter {
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(OutputEventAdapter.class);
|
private static final Log log = LogFactory.getLog(OutputEventAdapter.class);
|
||||||
private static ExecutorService executorService;
|
|
||||||
private static HttpConnectionManager connectionManager;
|
private ExecutorService executorService;
|
||||||
|
private HttpConnectionManager connectionManager;
|
||||||
private OutputEventAdapterConfiguration eventAdapterConfiguration;
|
private OutputEventAdapterConfiguration eventAdapterConfiguration;
|
||||||
private Map<String, String> globalProperties;
|
private Map<String, String> globalProperties;
|
||||||
private String clientMethod;
|
private String clientMethod;
|
||||||
@ -81,7 +81,8 @@ public class HTTPEventAdapter implements OutputEventAdapter {
|
|||||||
private String contentType;
|
private String contentType;
|
||||||
private HttpClient httpClient = null;
|
private HttpClient httpClient = null;
|
||||||
private HostConfiguration hostConfiguration = null;
|
private HostConfiguration hostConfiguration = null;
|
||||||
private String clientId, clientSecret;
|
private String clientId;
|
||||||
|
private String clientSecret;
|
||||||
|
|
||||||
|
|
||||||
public HTTPEventAdapter(OutputEventAdapterConfiguration eventAdapterConfiguration,
|
public HTTPEventAdapter(OutputEventAdapterConfiguration eventAdapterConfiguration,
|
||||||
@ -166,7 +167,7 @@ public class HTTPEventAdapter implements OutputEventAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connect() {
|
public void connect() {
|
||||||
this.checkHTTPClientInit(eventAdapterConfiguration.getStaticProperties());
|
this.checkHTTPClientInit();
|
||||||
httpConnectionConfiguration =
|
httpConnectionConfiguration =
|
||||||
new HTTPConnectionConfiguration(eventAdapterConfiguration, globalProperties);
|
new HTTPConnectionConfiguration(eventAdapterConfiguration, globalProperties);
|
||||||
generateToken();
|
generateToken();
|
||||||
@ -185,8 +186,6 @@ public class HTTPEventAdapter implements OutputEventAdapter {
|
|||||||
} catch (RejectedExecutionException e) {
|
} catch (RejectedExecutionException e) {
|
||||||
EventAdapterUtil
|
EventAdapterUtil
|
||||||
.logAndDrop(eventAdapterConfiguration.getName(), message, "Job queue is full", e, log, tenantId);
|
.logAndDrop(eventAdapterConfiguration.getName(), message, "Job queue is full", e, log, tenantId);
|
||||||
} catch (MalformedURLException e) {
|
|
||||||
log.error("Malformed url: '" + url + "'", e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,7 +204,7 @@ public class HTTPEventAdapter implements OutputEventAdapter {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkHTTPClientInit(Map<String, String> staticProperties) {
|
private void checkHTTPClientInit() {
|
||||||
|
|
||||||
if (this.httpClient != null) {
|
if (this.httpClient != null) {
|
||||||
return;
|
return;
|
||||||
@ -321,38 +320,27 @@ public class HTTPEventAdapter implements OutputEventAdapter {
|
|||||||
|
|
||||||
private HttpClient httpClient;
|
private HttpClient httpClient;
|
||||||
|
|
||||||
public HTTPSender(String url, String payload, Map<String, String> headers,
|
HTTPSender(String url, String payload, Map<String, String> headers,
|
||||||
HttpClient httpClient) throws MalformedURLException {
|
HttpClient httpClient) {
|
||||||
|
this.url = url;
|
||||||
if (tenantId == -1234) {
|
|
||||||
this.url = url;
|
|
||||||
} else {
|
|
||||||
URL urlObj = new URL(url);
|
|
||||||
String protocol = urlObj.getProtocol();
|
|
||||||
String host = urlObj.getHost();
|
|
||||||
int port = urlObj.getPort();
|
|
||||||
String path = "t/" + PrivilegedCarbonContext.getThreadLocalCarbonContext()
|
|
||||||
.getTenantDomain(true) + "/" + urlObj.getPath();
|
|
||||||
this.url = protocol + "://" + host + ":" + port + "/" + path;
|
|
||||||
}
|
|
||||||
this.payload = payload;
|
this.payload = payload;
|
||||||
this.headers = headers;
|
this.headers = headers;
|
||||||
this.httpClient = httpClient;
|
this.httpClient = httpClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUrl() {
|
String getUrl() {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPayload() {
|
String getPayload() {
|
||||||
return payload;
|
return payload;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getHeaders() {
|
Map<String, String> getHeaders() {
|
||||||
return headers;
|
return headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HttpClient getHttpClient() {
|
HttpClient getHttpClient() {
|
||||||
return httpClient;
|
return httpClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user