return new StringBuilder(32).append(BASE_CLIENT_NAME).append(apiType).append(interfaceType)
.append("/").append(Controller.API_VERSION).toString(); //$NON-NLS-1$
}
protected ConnectorConfig getConnectorConfig() {
ConnectorConfig cc = new ConnectorConfig();
cc.setTransport(HttpClientTransport.class);
cc.setSessionId(getSessionId());
// set authentication credentials
// blank username is not acceptible
String username = config.getString(Config.USERNAME);
if (!(config.getBoolean(Config.SFDC_INTERNAL) && config.getBoolean(Config.SFDC_INTERNAL_IS_SESSION_ID_LOGIN))
&& (username == null || username.length() == 0)) {
String errMsg = Messages.getMessage(getClass(), "emptyUsername", Config.USERNAME);
logger.error(errMsg);
throw new IllegalStateException(errMsg);
}
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());
}
// Time out after 5 seconds for connection
int connTimeoutSecs;
try {
connTimeoutSecs = config.getInt(Config.CONNECTION_TIMEOUT_SECS);
} catch (ParameterLoadException e1) {
connTimeoutSecs = Config.DEFAULT_CONNECTION_TIMEOUT_SECS;
}
cc.setConnectionTimeout(connTimeoutSecs * 1000);
// Time out after 1 minute 10 sec for login response
// set timeout for operations based on config
int timeoutSecs;
try {
timeoutSecs = config.getInt(Config.TIMEOUT_SECS);
} catch (ParameterLoadException e) {
timeoutSecs = Config.DEFAULT_TIMEOUT_SECS;
}
cc.setReadTimeout((timeoutSecs * 1000));
// use compression or turn it off
if (config.contains(Config.NO_COMPRESSION)) {
cc.setCompression(!config.getBoolean(Config.NO_COMPRESSION));
}
if (config.getBoolean(Config.DEBUG_MESSAGES)) {
cc.setTraceMessage(true);
cc.setPrettyPrintXml(true);
String filename = config.getString(Config.DEBUG_MESSAGES_FILE);
if (filename.length() > 0) {
try {
cc.setTraceFile(filename);
} catch (FileNotFoundException e) {
logger.warn(Messages.getFormattedString("Client.errorMsgDebugFilename", filename));
}
}
}
String server = getSession().getServer();
if (server != null) {
cc.setAuthEndpoint(server + DEFAULT_AUTH_ENDPOINT_URL.getPath());
cc.setServiceEndpoint(server + DEFAULT_AUTH_ENDPOINT_URL.getPath());
cc.setRestEndpoint(server + REST_ENDPOINT);
}
return cc;
}