Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support Bulk v2 and latest version check thru proxy #1274

Merged
merged 1 commit into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,7 @@ private String getBinaryContentForURL(String urlStr, String fieldName) {
+ refId;

HttpTransportInterface transport = (HttpTransportInterface) controller.getClient().getConnectorConfig().createTransport();
HttpURLConnection httpConnection = transport.openHttpGetConnection(urlStr, null);
InputStream is = transport.httpGet(httpConnection, urlStr);
InputStream is = transport.httpGet(urlStr);
byte[] binaryResponse = is.readAllBytes();
return Base64.getEncoder().encodeToString(binaryResponse);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,14 @@ private static void writeTo(BufferedInputStream bis, BufferedOutputStream bos) t
import java.io.OutputStream;
import java.io.Serializable;
import java.io.FileOutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

Expand Down Expand Up @@ -426,8 +427,7 @@ private JobInfo doSendJobRequestToServer(String urlString,
}
// make a get request
try {
HttpURLConnection conn = transport.openHttpGetConnection(urlString, headers);
in = transport.httpGet(conn, urlString);
in = transport.httpGet(urlString);
} catch (HttpClientTransportException ex) {
parseAndThrowException(ex);
}
Expand Down Expand Up @@ -526,11 +526,19 @@ private InputStream doGetQueryResultStream(URL resultsURL, HashMap<String, Strin
InputStream is = null;
try {
HttpTransportInterface transport = (HttpTransportInterface) getConfig().createTransport();
HttpURLConnection httpConnection = transport.openHttpGetConnection(resultsURL.toString(), headers);
is = transport.httpGet(httpConnection, resultsURL.toString());
this.queryLocator = httpConnection.getHeaderField("Sforce-Locator");
this.numberOfRecordsInQueryResult = Integer.valueOf(httpConnection.getHeaderField("Sforce-NumberOfRecords"));
} catch (HttpClientTransportException ex) {
is = transport.httpGet(resultsURL.toString());
HttpResponse httpResponse = transport.getHttpResponse();
if (httpResponse != null) {
Header header = httpResponse.getFirstHeader("Sforce-Locator");
if (header != null) {
this.queryLocator = header.getValue();
}
header = httpResponse.getFirstHeader("Sforce-NumberOfRecords");
if (header != null) {
this.numberOfRecordsInQueryResult = Integer.valueOf(header.getValue());
}
}
} catch (HttpClientTransportException ex) {
parseAndThrowException(ex);
}
return is;
Expand All @@ -548,8 +556,7 @@ private InputStream doGetIngestResultsStream(String jobId, String resultsType) t
InputStream is = null;
try {
HttpTransportInterface transport = (HttpTransportInterface) getConfig().createTransport();
HttpURLConnection httpConnection = transport.openHttpGetConnection(resultsURLString, headers);
is = transport.httpGet(httpConnection, resultsURLString);
is = transport.httpGet(resultsURLString);
} catch (IOException | ConnectionException e) {
throw new AsyncApiException("Failed to get " + resultsType + " for job id " + jobId, AsyncExceptionCode.ClientInputError, e);
} catch (HttpClientTransportException e) {
Expand Down
38 changes: 3 additions & 35 deletions src/main/java/com/salesforce/dataloader/client/ClientBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.salesforce.dataloader.config.Messages;
import com.salesforce.dataloader.controller.Controller;
import com.salesforce.dataloader.exception.ParameterLoadException;
import com.salesforce.dataloader.util.AppUtil;
import com.sforce.soap.partner.Connector;
import com.sforce.soap.partner.GetUserInfoResult;
import com.sforce.ws.ConnectorConfig;
Expand Down Expand Up @@ -130,40 +131,7 @@ public ConnectorConfig getConnectorConfig() {
cc.setUsername(username);
cc.setPassword(config.getString(Config.PASSWORD));

// proxy properties
try {
String proxyHost = config.getString(Config.PROXY_HOST);
int proxyPort = config.getInt(Config.PROXY_PORT);
if (proxyHost != null && proxyHost.length() > 0 && proxyPort > 0) {
logger.info(Messages.getFormattedString(
"Client.sforceLoginProxyDetail", new String[] { proxyHost, String.valueOf(proxyPort) })); //$NON-NLS-1$
cc.setProxy(proxyHost, proxyPort);

String proxyUsername = config.getString(Config.PROXY_USERNAME);
if (proxyUsername != null && proxyUsername.length() > 0) {
logger.info(Messages.getFormattedString("Client.sforceLoginProxyUser", proxyUsername)); //$NON-NLS-1$
cc.setProxyUsername(proxyUsername);

String proxyPassword = config.getString(Config.PROXY_PASSWORD);
if (proxyPassword != null && proxyPassword.length() > 0) {
logger.info(Messages.getString("Client.sforceLoginProxyPassword")); //$NON-NLS-1$
cc.setProxyPassword(proxyPassword);
} else {
cc.setProxyPassword("");
}
}

String proxyNtlmDomain = config.getString(Config.PROXY_NTLM_DOMAIN);
if (proxyNtlmDomain != null && proxyNtlmDomain.length() > 0) {
logger.info(Messages.getFormattedString("Client.sforceLoginProxyNtlm", proxyNtlmDomain)); //$NON-NLS-1$
cc.setNtlmDomain(proxyNtlmDomain);
}
}

} catch (ParameterLoadException e) {
logger.error(e.getMessage());
}

AppUtil.setConnectorConfigProxySettings(config, cc);
// Time out after 5 seconds for connection
int connTimeoutSecs;
try {
Expand Down Expand Up @@ -210,7 +178,7 @@ public ConnectorConfig getConnectorConfig() {

return cc;
}

public static String getCurrentAPIVersionInWSC() {
String[] connectURLArray = Connector.END_POINT.split("\\/");
return connectURLArray[connectURLArray.length-1];
Expand Down
Loading
Loading