Skip to content

Update PlatformClient.java #6

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
25 changes: 14 additions & 11 deletions src/com/docuware/dev/Extensions/PlatformClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,22 @@ ApacheHttpClient createApacheClientDefault(ServiceConnectionTransportData sctd,
* @return the ApacheHttpClient
*/
ApacheHttpClient createApacheClient(ServiceConnectionTransportData sctd, String baseUri, ClientConfig cc) {
String applicationName = null;
String version = null;
String platformClientRequestTimeout = null;

try {
config.load(new FileInputStream(new File("src/com/docuware/dev/Extensions/config.properties")));
platformClientRequestTimeout = config.getProperty("PlatformClientRequestTimeout");
applicationName = config.getProperty("name");
version = config.getProperty("version");
} catch (IOException ex) {
Logger.getLogger(PlatformClient.class.getName()).log(Level.INFO, null, ex);
Logger.getLogger(PlatformClient.class.getName()).log(Level.INFO, "config.properties file not found, default values are applied.", ex);
platformClientRequestTimeout = "60";
applicationName = "PlatformJavaClient";
version = "Hawk";
}

// Initialize the HTTP client
ApacheHttpClient localClient = ApacheHttpClient.create(cc);
if (sctd != null) {
Expand All @@ -114,19 +125,11 @@ ApacheHttpClient createApacheClient(ServiceConnectionTransportData sctd, String
@Override
public ClientResponse handle(ClientRequest cr) throws ClientHandlerException {
cr.getHeaders().add(HttpHeaders.USER_AGENT, System.getProperty("java.specification.name").replace("Specification", "").trim().replace(" ", "+")+"/"+System.getProperty("java.version"));
cr.getHeaders().add(HttpHeaders.USER_AGENT, config.getProperty("name")+"/"+config.getProperty("version"));
cr.getHeaders().add(HttpHeaders.USER_AGENT, applicationName + "/" + version);
return getNext().handle(cr);
}
});
String platformClientRequestTimeout = null;
try {
platformClientRequestTimeout = config.getProperty("PlatformClientRequestTimeout");
} catch (Exception ex) {
Logger.getLogger(PlatformClient.class.getName()).log(Level.INFO, null, ex);
}
if(platformClientRequestTimeout == null){
platformClientRequestTimeout = "60";
}

localClient.setReadTimeout(Integer.parseInt(platformClientRequestTimeout)*1000);
localClient.setConnectTimeout(Integer.parseInt(platformClientRequestTimeout)*1000);
// localClient.addFilter(new LoggingFilter(System.out));
Expand Down