Skip to content

Commit

Permalink
Adding Unique Call ID tracking with BH Rest API requests (#449)
Browse files Browse the repository at this point in the history
  • Loading branch information
taswartz authored Jan 30, 2024
1 parent 135366b commit 5ba1513
Show file tree
Hide file tree
Showing 8 changed files with 182 additions and 127 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.bullhorn</groupId>
<artifactId>sdk-rest</artifactId>
<version>2.3.1</version>
<version>2.3.2</version>
<packaging>jar</packaging>

<name>Bullhorn REST SDK</name>
Expand Down
20 changes: 13 additions & 7 deletions src/main/java/com/bullhornsdk/data/api/BullhornData.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
package com.bullhornsdk.data.api;

import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.springframework.web.multipart.MultipartFile;

import com.bullhornsdk.data.api.helper.EntityIdBoundaries;
import com.bullhornsdk.data.api.helper.RestApiSession;
import com.bullhornsdk.data.exception.RestApiException;
Expand Down Expand Up @@ -56,6 +49,12 @@
import com.bullhornsdk.data.model.response.resume.ParsedResume;
import com.bullhornsdk.data.model.response.resume.ParsedResumeAsEntity;
import com.bullhornsdk.data.model.response.subscribe.SubscribeToEventsResponse;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
* Core bullhorn data service, handles api calls and data mapping.
Expand Down Expand Up @@ -409,6 +408,13 @@ public <T extends QueryEntity & AllRecordsEntity, L extends ListWrapper<T>> L qu
*/
public Map<String, Object> getSettings(Set<String> settingSet, SettingsParams params);

/**
* Returns uniqueCallId used to identify rest requests.
*
* @return UniqueCallId
*/
public String getUniqueCallId();

/**
* Returns a valid bhRestToken to be used in a bh rest api call.
*
Expand Down
98 changes: 56 additions & 42 deletions src/main/java/com/bullhornsdk/data/api/StandardBullhornData.java
Original file line number Diff line number Diff line change
@@ -1,37 +1,5 @@
package com.bullhornsdk.data.api;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.stream.Collectors;

import com.bullhornsdk.data.model.response.single.StandardFileContentWrapper;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.HttpStatusCodeException;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;

import com.bullhornsdk.data.api.helper.EntityIdBoundaries;
import com.bullhornsdk.data.api.helper.EntityUpdateWorker;
import com.bullhornsdk.data.api.helper.FileWorker;
Expand Down Expand Up @@ -109,7 +77,6 @@
import com.bullhornsdk.data.model.response.file.FileWrapper;
import com.bullhornsdk.data.model.response.file.standard.StandardEntityMetaFiles;
import com.bullhornsdk.data.model.response.file.standard.StandardFileApiResponse;
import com.bullhornsdk.data.model.response.file.standard.StandardFileContent;
import com.bullhornsdk.data.model.response.file.standard.StandardFileWrapper;
import com.bullhornsdk.data.model.response.list.FastFindListWrapper;
import com.bullhornsdk.data.model.response.list.IdListWrapper;
Expand All @@ -121,10 +88,42 @@
import com.bullhornsdk.data.model.response.resume.ParsedResumeAsEntity;
import com.bullhornsdk.data.model.response.resume.standard.StandardParsedResume;
import com.bullhornsdk.data.model.response.resume.standard.StandardParsedResumeAsEntity;
import com.bullhornsdk.data.model.response.single.StandardFileContentWrapper;
import com.bullhornsdk.data.model.response.subscribe.SubscribeToEventsResponse;
import com.bullhornsdk.data.model.response.subscribe.UnsubscribeToEventsResponse;
import com.bullhornsdk.data.model.response.subscribe.standard.StandardSubscribeToEventsResponse;
import com.bullhornsdk.data.model.response.subscribe.standard.StandardUnsubscribeToEventsResponse;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.HttpStatusCodeException;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.stream.Collectors;

/**
* Standard implementation of the BullhornData interface that manages all rest calls and data binding from/to json - java.
Expand Down Expand Up @@ -152,6 +151,8 @@ public class StandardBullhornData implements BullhornData {

protected final String restUrl;

protected final String uniqueCallId;

protected final RestJsonConverter restJsonConverter;

protected final RestUrlFactory restUrlFactory;
Expand All @@ -177,18 +178,18 @@ public class StandardBullhornData implements BullhornData {
protected Boolean executeFormTriggers = false;

public StandardBullhornData(BullhornRestCredentials bullhornRestCredentials) {
this.restSession = new RestApiSession(bullhornRestCredentials);
this.restTemplate = RestTemplateFactory.getInstance();
this.restUrl = restSession.getRestUrl();
this.restJsonConverter = new RestJsonConverter();
this.restUrlFactory = new RestUrlFactory(restUrl);
this.restFileManager = new RestFileManager();
this.restUriVariablesFactory = new RestUriVariablesFactory(this, this.restFileManager);
this.restErrorHandler = new RestErrorHandler();
this.concurrencyService = new RestConcurrencyService();
this(new RestApiSession(bullhornRestCredentials), null);
}

public StandardBullhornData(RestApiSession restApiSession) {
this(restApiSession, null);
}

public StandardBullhornData(BullhornRestCredentials bullhornRestCredentials, String uniqueCallIdPrefix) {
this(new RestApiSession(bullhornRestCredentials), uniqueCallIdPrefix);
}

public StandardBullhornData(RestApiSession restApiSession, String uniqueCallIdPrefix) {
this.restSession = restApiSession;
this.restTemplate = RestTemplateFactory.getInstance();
this.restUrl = restSession.getRestUrl();
Expand All @@ -198,6 +199,11 @@ public StandardBullhornData(RestApiSession restApiSession) {
this.restUriVariablesFactory = new RestUriVariablesFactory(this, this.restFileManager);
this.restErrorHandler = new RestErrorHandler();
this.concurrencyService = new RestConcurrencyService();
if (StringUtils.isNotBlank(uniqueCallIdPrefix)) {
this.uniqueCallId = uniqueCallIdPrefix + "_" + UUID.randomUUID();
} else {
this.uniqueCallId = "CUSTOM_" + UUID.randomUUID();
}
}

public void setHttpRequestConnectTimeout(int connectTimeout) {
Expand Down Expand Up @@ -826,6 +832,14 @@ protected void setStart(AssociationParams params, int numberOfRecordsPulledAlrea
params.setStart(numberOfRecordsPulledAlready);
}

/**
* {@inheritDoc}
*/
@Override
public String getUniqueCallId() {
return this.uniqueCallId;
}

/**
* {@inheritDoc}
*/
Expand Down
Loading

0 comments on commit 5ba1513

Please sign in to comment.