Skip to content

Commit

Permalink
Add a preference to enable raw logging to cf http calls
Browse files Browse the repository at this point in the history
  • Loading branch information
shroffk committed May 23, 2022
1 parent eecd680 commit 1d5013d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ public class ChannelFinderClientImpl implements ChannelFinderClient {
private static final String resourceProperties = "resources/properties";
private static final String resourceTags = "resources/tags";


private static CFProperties properties = new CFProperties();
private static final Logger log = Logger.getLogger(ChannelFinderClient.class.getName());
/**
* A Builder class to help create the client to the Channelfinder Service
Expand Down Expand Up @@ -101,11 +103,10 @@ public static class CFCBuilder {

private ExecutorService executor = Executors.newSingleThreadExecutor();

private CFProperties properties = new CFProperties();

private CFCBuilder()
{
this.uri = URI.create(this.properties.getPreferenceValue("serviceURL"));
this.uri = URI.create(properties.getPreferenceValue("serviceURL"));
this.protocol = this.uri.getScheme();
}

Expand Down Expand Up @@ -263,21 +264,24 @@ public boolean verify(String hostname, SSLSession session) {
properties.getPreferenceValue("username"),
properties.getPreferenceValue("password"));
}

return new ChannelFinderClientImpl(this.uri, this.clientConfig, this.httpBasicAuthFilter, this.executor);
}
}

ChannelFinderClientImpl(URI uri, ClientConfig config, HTTPBasicAuthFilter httpBasicAuthFilter,
ExecutorService executor) {
Client client = Client.create(config);
client.setFollowRedirects(true);
cfResource = client.resource(uri.toString());
cfAuthenticatedResource = client.resource(uri.toString());
if (httpBasicAuthFilter != null) {
client.addFilter(httpBasicAuthFilter);
cfAuthenticatedResource.addFilter(httpBasicAuthFilter);
}
// TODO add a preference to add logging
// client.addFilter(new RawLoggingFilter(Logger.getLogger(RawLoggingFilter.class.getName())));
client.setFollowRedirects(true);
cfAuthenticatedResource = client.resource(uri.toString());
if(Boolean.parseBoolean(properties.getPreferenceValue("rawFiltering"))) {
client.addFilter(new RawLoggingFilter(Logger.getLogger(RawLoggingFilter.class.getName())));
}
this.executor = executor;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@

serviceURL=http://localhost:8080/ChannelFinder
username=admin
password=adminPass
password=adminPass

rawFiltering=false

0 comments on commit 1d5013d

Please sign in to comment.