diff --git a/pom.xml b/pom.xml index 4171ee96..00852cac 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.bullhorn sdk-rest - 1.4.58 + 1.4.59 jar Bullhorn REST SDK @@ -161,9 +161,9 @@ - log4j - log4j - 1.2.17 + org.apache.logging.log4j + log4j-core + 2.19.0 @@ -193,12 +193,6 @@ 2.24.0 - - de.javakaffee - kryo-serializers - 0.37 - - org.hamcrest hamcrest diff --git a/src/main/java/com/bullhornsdk/data/api/StandardBullhornData.java b/src/main/java/com/bullhornsdk/data/api/StandardBullhornData.java index 46c0d07c..c31b7967 100644 --- a/src/main/java/com/bullhornsdk/data/api/StandardBullhornData.java +++ b/src/main/java/com/bullhornsdk/data/api/StandardBullhornData.java @@ -15,7 +15,8 @@ import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; -import org.apache.log4j.Logger; +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; @@ -142,7 +143,7 @@ */ public class StandardBullhornData implements BullhornData { - protected static Logger log = Logger.getLogger(StandardBullhornData.class); + protected static Logger log = LogManager.getLogger(StandardBullhornData.class); protected final RestApiSession restSession; @@ -1451,11 +1452,9 @@ protected ParsedResume handleResumeParseError(int tryNumber, HttpStatusCodeExcep response = new StandardParsedResume(); response.setErrorCode(error.getStatusCode().name()); response.setErrorMessage("BH api responded with the following message: " + error.getResponseBodyAsString()); - log.error("Failed to parse resume after " + RESUME_PARSE_RETRY + " tries. Response body from bh rest apis = " - + error.getResponseBodyAsString()); + log.error("Failed to parse resume after {} tries. Response body from bh rest apis = {}", RESUME_PARSE_RETRY, error.getResponseBodyAsString()); } else { - log.info(error.getResponseBodyAsString() + " Try " + tryNumber + " out of " + RESUME_PARSE_RETRY - + ". Trying again. Response body from bh rest apis = " + error.getResponseBodyAsString()); + log.info("{} Try {} out of {}. Trying again. Response body from bh rest apis = {}", error.getResponseBodyAsString(), tryNumber, RESUME_PARSE_RETRY, error.getResponseBodyAsString()); } return response; @@ -1634,7 +1633,7 @@ protected FileWrapper handleGetFileContentWithMetaData(Class uriVariables, in } else if (error.getStatusCode() == HttpStatus.TOO_MANY_REQUESTS) { isTooManyRequestsError = true; } - log.error( - "HttpStatusCodeError making api call. Try number:" + tryNumber + " out of " + API_RETRY + ". Http status code: " - + error.getStatusCode() + ". Response body: " + error.getResponseBodyAsString(), error); + String errorMessage = "HttpStatusCodeError making api call. Try number:" + tryNumber + " out of " + API_RETRY + ". Http status code: " + + error.getStatusCode() + ". Response body: " + error.getResponseBodyAsString(); + log.error(errorMessage, error); if (tryNumber >= API_RETRY && !isTooManyRequestsError) { throw new RestApiException("HttpStatusCodeError making api call with url variables " + uriVariables.toString() + ". Http status code: " + error.getStatusCode().toString() + ". Response body: " + error == null ? "" @@ -2156,7 +2155,8 @@ protected boolean handleHttpStatusCodeError(Map uriVariables, in } protected void handleApiError(int tryNumber, Exception e) { - log.error("Error making api call. Try number:" + tryNumber + " out of " + API_RETRY, e); + String message = "Error making api call. Try number:" + tryNumber + " out of " + API_RETRY; + log.error(message, e); } protected void resetBhRestToken(Map uriVariables) { diff --git a/src/main/java/com/bullhornsdk/data/api/helper/EntityUpdateWorker.java b/src/main/java/com/bullhornsdk/data/api/helper/EntityUpdateWorker.java index 030e9468..38aa777a 100644 --- a/src/main/java/com/bullhornsdk/data/api/helper/EntityUpdateWorker.java +++ b/src/main/java/com/bullhornsdk/data/api/helper/EntityUpdateWorker.java @@ -2,7 +2,8 @@ import java.util.concurrent.Callable; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import com.bullhornsdk.data.api.BullhornData; import com.bullhornsdk.data.exception.RestApiException; @@ -14,7 +15,7 @@ public class EntityUpdateWorker implements Callable { private final BullhornData bullhornApiRest; private final UpdateEntity entity; - private final Logger log = Logger.getLogger(EntityUpdateWorker.class); + private final Logger log = LogManager.getLogger(EntityUpdateWorker.class); public EntityUpdateWorker(BullhornData bullhornApiRest, UpdateEntity entity) { super(); @@ -28,9 +29,8 @@ public C call() throws Exception { try { response = bullhornApiRest.updateEntity(entity); } catch (RestApiException e) { - log.error( - "Error updating entity of type " + entity.getClass().getSimpleName() + " with id " + entity.getId(), - e); + String message = "Error updating entity of type " + entity.getClass().getSimpleName() + " with id " + entity.getId(); + log.error(message, e); } return response; } diff --git a/src/main/java/com/bullhornsdk/data/api/helper/RestApiSession.java b/src/main/java/com/bullhornsdk/data/api/helper/RestApiSession.java index e87d2863..d475fa28 100644 --- a/src/main/java/com/bullhornsdk/data/api/helper/RestApiSession.java +++ b/src/main/java/com/bullhornsdk/data/api/helper/RestApiSession.java @@ -13,7 +13,8 @@ import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import org.json.JSONException; @@ -52,7 +53,7 @@ public class RestApiSession { private static final String REFRESH_TOKEN_GRANT_TYPE = "refresh_token"; - private static Logger log = Logger.getLogger(RestApiSession.class); + private static Logger log = LogManager.getLogger(RestApiSession.class); private RestTemplate restTemplate; @@ -137,7 +138,8 @@ private void createSession() { break; } catch (Exception e) { if (tryNumber < SESSION_RETRY) { - log.error("Error creating REST session. Try number: " + tryNumber + " out of " + SESSION_RETRY + " trying again.", e); + String message = "Error creating REST session. Try number: " + tryNumber + " out of " + SESSION_RETRY + " trying again."; + log.error(message, e); } else { log.error("Final error creating REST session. Shutting down.", e); @@ -244,9 +246,9 @@ private void login() { restUrl = (String) responseJson.get("restUrl"); } catch (RestClientException | IOException e) { - log.error("Failed to login. " + responseJson, e); - - throw new RestApiException("Failed to login and get BhRestToken: " + responseJson, e); + String message = "Failed to login and get BhRestToken: " + responseJson; + log.error(message, e); + throw new RestApiException(message, e); } } @@ -426,9 +428,10 @@ private synchronized JSONObject getLoginInfoFromApi() { return this.loginInfo; } catch(RestClientException | JSONException e) { - log.error("Error occurred dynamically determining REST urls with username " + restCredentials.getUsername(), e); + String message = "Error occurred dynamically determining REST urls with username " + restCredentials.getUsername(); + log.error(message, e); - throw new RestApiException("Failed to dynamically determine REST urls with username " + restCredentials.getUsername()); + throw new RestApiException(message); } } diff --git a/src/main/java/com/bullhornsdk/data/api/helper/RestFileManager.java b/src/main/java/com/bullhornsdk/data/api/helper/RestFileManager.java index dbbb4210..372e3f6d 100644 --- a/src/main/java/com/bullhornsdk/data/api/helper/RestFileManager.java +++ b/src/main/java/com/bullhornsdk/data/api/helper/RestFileManager.java @@ -5,7 +5,8 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.springframework.core.io.FileSystemResource; import org.springframework.util.FileCopyUtils; import org.springframework.util.LinkedMultiValueMap; @@ -20,7 +21,7 @@ public class RestFileManager { private final String formFileName = "file"; - private static Logger log = Logger.getLogger(RestFileManager.class); + private static Logger log = LogManager.getLogger(RestFileManager.class); /** * Will create a unique sub folder in the temp directory. This is done so that we can name the file with the original file @@ -80,7 +81,7 @@ public void deleteTempFile(MultiValueMap multiValueMap) { try { FileUtils.deleteDirectory(newFolder); } catch (IOException e) { - log.info("Unable to delete temp file " + filePath); + log.info("Unable to delete temp file {}", filePath); } } @@ -103,7 +104,7 @@ public void deleteTempResume(MultiValueMap multiValueMap) { File file = fileSystemResource.getFile(); if (!file.delete()) { - log.info("Unable to delete temp resume " + file.getAbsolutePath()); + log.info("Unable to delete temp resume {}", file.getAbsolutePath()); } } diff --git a/src/main/java/com/bullhornsdk/data/api/helper/RestJsonConverter.java b/src/main/java/com/bullhornsdk/data/api/helper/RestJsonConverter.java index 5c121df1..eacbb829 100644 --- a/src/main/java/com/bullhornsdk/data/api/helper/RestJsonConverter.java +++ b/src/main/java/com/bullhornsdk/data/api/helper/RestJsonConverter.java @@ -2,7 +2,8 @@ import java.io.IOException; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import com.bullhornsdk.data.exception.RestMappingException; import com.bullhornsdk.data.model.entity.core.type.BullhornEntity; @@ -16,7 +17,7 @@ public class RestJsonConverter { - private static Logger log = Logger.getLogger(RestJsonConverter.class); + private static Logger log = LogManager.getLogger(RestJsonConverter.class); private final ObjectMapper objectMapperWrapped; @@ -109,7 +110,8 @@ public String convertEntityToJsonString(T entity) { try { jsonString = objectMapperStandard.writeValueAsString(entity); } catch (JsonProcessingException e) { - log.error("Error deserializing entity of type" + entity.getClass() + " to jsonString.", e); + String message = "Error deserializing entity of type" + entity.getClass() + " to jsonString."; + log.error(message, e); } return jsonString; } diff --git a/src/main/java/com/bullhornsdk/data/api/helper/concurrency/standard/RestConcurrencyService.java b/src/main/java/com/bullhornsdk/data/api/helper/concurrency/standard/RestConcurrencyService.java index 9a426e49..23154a12 100644 --- a/src/main/java/com/bullhornsdk/data/api/helper/concurrency/standard/RestConcurrencyService.java +++ b/src/main/java/com/bullhornsdk/data/api/helper/concurrency/standard/RestConcurrencyService.java @@ -9,13 +9,14 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import com.bullhornsdk.data.api.helper.concurrency.ConcurrencyService; public class RestConcurrencyService implements ConcurrencyService { - private static Logger log = Logger.getLogger(RestConcurrencyService.class); + private static Logger log = LogManager.getLogger(RestConcurrencyService.class); @Override public > List spinThreadsAndWaitForResult(List taskList) { diff --git a/src/main/java/com/bullhornsdk/data/api/mock/MockBullhornData.groovy b/src/main/java/com/bullhornsdk/data/api/mock/MockBullhornData.groovy index 5857c51e..663432bd 100644 --- a/src/main/java/com/bullhornsdk/data/api/mock/MockBullhornData.groovy +++ b/src/main/java/com/bullhornsdk/data/api/mock/MockBullhornData.groovy @@ -31,7 +31,8 @@ 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 com.bullhornsdk.data.model.response.subscribe.standard.StandardSubscribeToEventsResponse -import org.apache.log4j.Logger +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.joda.time.DateTime import org.springframework.web.multipart.MultipartFile @@ -48,7 +49,7 @@ public class MockBullhornData implements BullhornData { private final MockDataHandler mockDataHandler; private final RestErrorHandler restErrorHandler; private final RestApiSession restSession; - private final Logger log = Logger.getLogger(MockBullhornData.class); + private final Logger log = LogManager.getLogger(MockBullhornData.class); protected Boolean executeFormTriggers = false; diff --git a/src/main/java/com/bullhornsdk/data/api/mock/MockDataHandler.groovy b/src/main/java/com/bullhornsdk/data/api/mock/MockDataHandler.groovy index 298ca69b..6d58a4a6 100644 --- a/src/main/java/com/bullhornsdk/data/api/mock/MockDataHandler.groovy +++ b/src/main/java/com/bullhornsdk/data/api/mock/MockDataHandler.groovy @@ -40,7 +40,8 @@ import com.bullhornsdk.data.model.response.resume.standard.StandardParsedResume import com.bullhornsdk.data.model.response.resume.standard.StandardParsedResumeAsEntity import com.bullhornsdk.data.util.copy.KryoObjectCopyHelper import org.apache.commons.lang3.StringUtils -import org.apache.log4j.Logger +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.codehaus.groovy.runtime.NullObject import org.joda.time.DateTime import org.springframework.web.multipart.MultipartFile @@ -61,7 +62,7 @@ import java.io.File as JavaFile public class MockDataHandler { - private final static Logger log = Logger.getLogger(MockDataHandler.class); + private final static Logger log = LogManager.getLogger(MockDataHandler.class); private final MockDataLoader mockDataLoader; private Map, Map> restEntityMap; private Map, MetaData> restMetaDataMap; @@ -232,9 +233,10 @@ public class MockDataHandler { try { updateExistingEntityWithNewNonNullValues(entity, existingEntity); } catch (Exception e) { + String message = "Error updating entity of type: " + entity.getClass().getSimpleName() + " with id: " + entity.getId(); response.setErrorCode("500"); - response.setErrorMessage("Error updating entity of type: " + entity.getClass().getSimpleName() + " with id: " + entity.getId()); - log.error("Error updating entity of type: " + entity.getClass().getSimpleName() + " with id: " + entity.getId(), e); + response.setErrorMessage(message); + log.error(message, e); } return (C) response; @@ -896,7 +898,6 @@ public class MockDataHandler { }else { containsValue = (field1 == value1); } - //log.info("field1 = "+field1+" value1 = "+value1+" containsValue = "+containsValue); return containsValue; }; @@ -1100,7 +1101,7 @@ public class MockDataHandler { try { setValueFromPath(copyOfFromEntity,toEntity,fullPath) } catch(MissingPropertyException e) { - log.error("Missing property " + e.getProperty() + " on entity " + fromEntity.getClass().getSimpleName()); + log.error("Missing property {} on entity {}", e.getProperty(), fromEntity.getClass().getSimpleName()); } } @@ -1134,7 +1135,7 @@ public class MockDataHandler { try { setValueFromPath(fromProperty,toProperty, partialPath) } catch(MissingPropertyException e) { - log.error("Missing property " + e.getProperty() + " on entity " + to.getClass().getSimpleName()); + log.error("Missing property {} on entity {}", e.getProperty(), to.getClass().getSimpleName()); } if(!parentPropertyIsOneToMany(fromProperty,toProperty,path)){ @@ -1144,11 +1145,11 @@ public class MockDataHandler { } }else if(fromProperty == null || fromProperty instanceof NullObject){ - log.debug("fromProperty is null, no need to set the toProperty then. "); + log.debug("fromProperty is null, no need to set the toProperty then."); }else if(parentPropertyIsOneToMany(fromProperty,toProperty,path)){ //All fields on the OneToMany are set under propertyIsOneToMany. //Field selection for OneToMany is not currently supported. - log.debug("parent is OneToMany: "+path); + log.debug("parent is OneToMany: {}", path); }else if(propertyIsOneToMany(fromProperty,toProperty,path)){ toProperty?."${path}" = fromProperty?."${path}"; }else if(propertyIsNullNestedRestEntity(fromProperty,toProperty,path)){ diff --git a/src/main/java/com/bullhornsdk/data/api/mock/MockDataLoader.groovy b/src/main/java/com/bullhornsdk/data/api/mock/MockDataLoader.groovy index 236c852e..fdb8b76c 100644 --- a/src/main/java/com/bullhornsdk/data/api/mock/MockDataLoader.groovy +++ b/src/main/java/com/bullhornsdk/data/api/mock/MockDataLoader.groovy @@ -71,14 +71,15 @@ import com.bullhornsdk.data.model.response.list.ListWrapper import com.bullhornsdk.data.model.response.list.PropertyOptionsListWrapper import com.bullhornsdk.data.util.copy.KryoObjectCopyHelper import org.apache.commons.io.IOUtils -import org.apache.log4j.Logger +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.springframework.core.io.ClassPathResource import java.util.concurrent.ConcurrentHashMap public class MockDataLoader { - private final static Logger log = Logger.getLogger(MockDataLoader.class); + private final static Logger log = LogManager.getLogger(MockDataLoader.class); private final RestJsonConverter restJsonConverter; private Map, Map> restEntityMapCache; @@ -346,7 +347,7 @@ public class MockDataLoader { jsonDataString = IOUtils.toString(data.getInputStream(), "UTF-8"); } catch (IOException e) { - log.error("Unable to load test data from filename: " + fileName); + log.error("Unable to load test data from filename: {}", fileName); throw new IllegalArgumentException("Unable to load test data from filename: " + fileName, e); } diff --git a/src/main/java/com/bullhornsdk/data/exception/CustomResponseErrorHandler.java b/src/main/java/com/bullhornsdk/data/exception/CustomResponseErrorHandler.java index 5db7e039..c02167cc 100644 --- a/src/main/java/com/bullhornsdk/data/exception/CustomResponseErrorHandler.java +++ b/src/main/java/com/bullhornsdk/data/exception/CustomResponseErrorHandler.java @@ -6,7 +6,8 @@ import java.nio.charset.Charset; import org.apache.commons.io.IOUtils; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; @@ -28,7 +29,7 @@ */ public class CustomResponseErrorHandler extends DefaultResponseErrorHandler { - private static Logger log = Logger.getLogger(CustomResponseErrorHandler.class); + private static Logger log = LogManager.getLogger(CustomResponseErrorHandler.class); @Override public void handleError(ClientHttpResponse response) throws IOException { @@ -86,4 +87,4 @@ private HttpStatus getHttpStatusCode(ClientHttpResponse response) throws IOExcep public boolean hasError(ClientHttpResponse response) throws IOException { return super.hasError(response); } -} \ No newline at end of file +} diff --git a/src/main/java/com/bullhornsdk/data/model/entity/core/type/AbstractEntity.java b/src/main/java/com/bullhornsdk/data/model/entity/core/type/AbstractEntity.java index d22095e8..8e5c3e7b 100644 --- a/src/main/java/com/bullhornsdk/data/model/entity/core/type/AbstractEntity.java +++ b/src/main/java/com/bullhornsdk/data/model/entity/core/type/AbstractEntity.java @@ -9,7 +9,8 @@ import org.apache.commons.beanutils.PropertyUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import com.bullhornsdk.data.util.RestUtil; import com.fasterxml.jackson.annotation.JsonAnyGetter; @@ -27,7 +28,7 @@ */ public class AbstractEntity { - private final static Logger log = Logger.getLogger(AbstractEntity.class); + private final static Logger log = LogManager.getLogger(AbstractEntity.class); private Map additionalProperties = new HashMap(); @@ -50,17 +51,8 @@ public void handleJsonArrayToJavaString(String name, Object value) { try { PropertyUtils.setProperty(this, name, this.convertListToString(value)); - } catch (IllegalAccessException e) { - log.debug("Error setting field " + name + " with value " + value - + " on entity " + this.getClass().getSimpleName()); - this.additionalProperties.put(name, value); - } catch (InvocationTargetException e) { - log.debug("Error setting field " + name + " with value " + value - + " on entity " + this.getClass().getSimpleName()); - this.additionalProperties.put(name, value); - } catch (NoSuchMethodException e) { - log.debug("Error setting field " + name + " with value " + value - + " on entity " + this.getClass().getSimpleName()); + } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { + log.debug("Error setting field {} with value {} on entity {}", name, value, this.getClass().getSimpleName()); this.additionalProperties.put(name, value); } diff --git a/src/main/java/com/bullhornsdk/data/model/enums/BhRestEnvironment.java b/src/main/java/com/bullhornsdk/data/model/enums/BhRestEnvironment.java index b9f9ff4d..63939f0c 100644 --- a/src/main/java/com/bullhornsdk/data/model/enums/BhRestEnvironment.java +++ b/src/main/java/com/bullhornsdk/data/model/enums/BhRestEnvironment.java @@ -1,6 +1,7 @@ package com.bullhornsdk.data.model.enums; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -16,7 +17,7 @@ public enum BhRestEnvironment { BH_NEXT("BH-Next"), BH_PRODUCTION("BH-Production"); - private static Logger log = Logger.getLogger(BhRestEnvironment.class); + private static Logger log = LogManager.getLogger(BhRestEnvironment.class); private final String name; private BhRestEnvironment(String name) { diff --git a/src/main/java/com/bullhornsdk/data/model/response/file/standard/StandardFileWrapper.java b/src/main/java/com/bullhornsdk/data/model/response/file/standard/StandardFileWrapper.java index 38ae0c30..d69e1ef2 100644 --- a/src/main/java/com/bullhornsdk/data/model/response/file/standard/StandardFileWrapper.java +++ b/src/main/java/com/bullhornsdk/data/model/response/file/standard/StandardFileWrapper.java @@ -6,7 +6,8 @@ import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang3.StringUtils; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.joda.time.DateTime; import org.springframework.util.FileCopyUtils; @@ -16,7 +17,7 @@ public final class StandardFileWrapper implements FileWrapper { - private static Logger log = Logger.getLogger(StandardFileWrapper.class); + private static Logger log = LogManager.getLogger(StandardFileWrapper.class); private byte[] fileContentAsByteArray; @@ -48,8 +49,7 @@ public StandardFileWrapper(FileContent fileContent, FileMeta fileMeta) { super(); if (fileContent == null) { - log.error("fileContent is null in StandardFileWrapper for filemeta.id=" + fileMeta.getId() - + ". This means there was an issue finding the file content using the bullhorn apis. The file could be lost"); + log.error("fileContent is null in StandardFileWrapper for filemeta.id={}. This means there was an issue finding the file content using the bullhorn apis. The file could be lost", fileMeta.getId()); this.base64RawFileContent = null; this.contentType = null; } else { @@ -86,8 +86,7 @@ public byte[] getFileContentAsByteArray() { @Override public String getBase64RawFileContent() { if (base64RawFileContent == null) { - log.error("base64RawFileContent is null in StandardFileWrapper for filemeta.id=" + id - + ". This means there was an issue finding the file content using the bullhorn apis. The file could be lost"); + log.error("base64RawFileContent is null in StandardFileWrapper for filemeta.id={}. This means there was an issue finding the file content using the bullhorn apis. The file could be lost", id); } return base64RawFileContent; } @@ -112,7 +111,8 @@ private void createTempFile() { FileCopyUtils.copy(getFileContentAsByteArray(), tempFile); file = tempFile; } catch (IOException e) { - log.error("Error while creating temp file: " + name, e); + String message = "Error while creating temp file: " + name; + log.error(message, e); } } diff --git a/src/main/java/com/bullhornsdk/data/util/copy/IdentifiableChronology.java b/src/main/java/com/bullhornsdk/data/util/copy/IdentifiableChronology.java new file mode 100644 index 00000000..f528f729 --- /dev/null +++ b/src/main/java/com/bullhornsdk/data/util/copy/IdentifiableChronology.java @@ -0,0 +1,94 @@ +package com.bullhornsdk.data.util.copy; + +import org.joda.time.Chronology; +import org.joda.time.chrono.BuddhistChronology; +import org.joda.time.chrono.CopticChronology; +import org.joda.time.chrono.EthiopicChronology; +import org.joda.time.chrono.GJChronology; +import org.joda.time.chrono.GregorianChronology; +import org.joda.time.chrono.ISOChronology; +import org.joda.time.chrono.IslamicChronology; +import org.joda.time.chrono.JulianChronology; + +import com.esotericsoftware.kryo.io.Input; + +/** + * Copied from https://github.com/magro/kryo-serializers under Apache-2.0 license + * + * An enumeration that provides a String id for subclasses of {@link Chronology}. + * For {@link ISOChronology}, null is used as id, as {@link ISOChronology} + * is used as default and the id does not have to be serialized. + * + * @author Martin Grotzke (martin.grotzke@freiheit.com) (initial creation) + */ +enum IdentifiableChronology { + + ISO( null, ISOChronology.getInstance() ), + COPTIC( "COPTIC", CopticChronology.getInstance() ), + ETHIOPIC( "ETHIOPIC", EthiopicChronology.getInstance()), + GREGORIAN("GREGORIAN", GregorianChronology.getInstance()), + JULIAN("JULIAN", JulianChronology.getInstance()), + ISLAMIC("ISLAMIC",IslamicChronology.getInstance()), + BUDDHIST( "BUDDHIST", BuddhistChronology.getInstance()), + GJ( "GJ", GJChronology.getInstance()); + + private final String _id; + private final Chronology _chronology; + + private IdentifiableChronology( final String id, final Chronology chronology ) { + _id = id; + _chronology = chronology; + } + + public String getId() { + return _id; + } + + /** + * Determines the id for the given {@link Chronology} subclass that later + * can be used to resolve the {@link Chronology} with {@link #valueOfId(String)}. + * For {@link ISOChronology} class null is returned. + * + * @param clazz a subclass of {@link Chronology}. + * @return an id, or null for {@link ISOChronology}. + * @throws IllegalArgumentException if the {@link Chronology} is not supported. + */ + public static String getIdByChronology( final Class clazz ) throws IllegalArgumentException { + for( final IdentifiableChronology item : values() ) { + if ( clazz.equals( item._chronology.getClass() ) ) { + return item._id; + } + } + throw new IllegalArgumentException( "Chronology not supported: " + clazz.getSimpleName() ); + } + + /** + * Returns the chronology of the {@link IdentifiableChronology} matching the + * provided id. If the provided id is null, + * {@link ISOChronology} is returned. + * @param id the id from {@link #getIdByChronology(Class)}. + * @return a matching {@link Chronology} if any was found. + * @throws IllegalArgumentException if no match was found. + */ + public static Chronology valueOfId(final String id) throws IllegalArgumentException { + if ( id == null ) { + return ISO._chronology; + } + for( final IdentifiableChronology item : values() ) { + if ( id.equals( item._id ) ) { + return item._chronology; + } + } + throw new IllegalArgumentException( "No chronology found for id " + id ); + } + + static Chronology readChronology( final Input input ) { + final String chronologyId = input.readString(); + return IdentifiableChronology.valueOfId( "".equals( chronologyId ) ? null : chronologyId ); + } + + static String getChronologyId( final Chronology chronology ) { + return IdentifiableChronology.getIdByChronology( chronology.getClass() ); + } + +} diff --git a/src/main/java/com/bullhornsdk/data/util/copy/JodaDateTimeSerializer.java b/src/main/java/com/bullhornsdk/data/util/copy/JodaDateTimeSerializer.java new file mode 100644 index 00000000..b78b000b --- /dev/null +++ b/src/main/java/com/bullhornsdk/data/util/copy/JodaDateTimeSerializer.java @@ -0,0 +1,86 @@ +package com.bullhornsdk.data.util.copy; + +import org.joda.time.Chronology; +import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; +import org.joda.time.chrono.BuddhistChronology; +import org.joda.time.chrono.CopticChronology; +import org.joda.time.chrono.EthiopicChronology; +import org.joda.time.chrono.GJChronology; +import org.joda.time.chrono.GregorianChronology; +import org.joda.time.chrono.ISOChronology; +import org.joda.time.chrono.IslamicChronology; +import org.joda.time.chrono.JulianChronology; + +import com.esotericsoftware.kryo.Kryo; +import com.esotericsoftware.kryo.Serializer; +import com.esotericsoftware.kryo.io.Input; +import com.esotericsoftware.kryo.io.Output; + +/** + * Copied from https://github.com/magro/kryo-serializers under Apache-2.0 license + * + * A format for joda {@link DateTime}, that stores the millis, chronology and + * time zone as separate attributes. If the chronology is {@link ISOChronology}, + * the attribute is omitted, thus {@link ISOChronology} is seen as default. If + * the time zone is the default time zone ({@link DateTimeZone#getDefault()}), + * the time zone attribute is omitted. This requires different machines to + * have the same time zone settings. + *

+ * The following chronologies are supported: + *

    + *
  • {@link ISOChronology}
  • + *
  • {@link CopticChronology}
  • + *
  • {@link EthiopicChronology}
  • + *
  • {@link GregorianChronology}
  • + *
  • {@link JulianChronology}
  • + *
  • {@link IslamicChronology}
  • + *
  • {@link BuddhistChronology}
  • + *
  • {@link GJChronology}
  • + *
+ *

+ * + * @author Martin Grotzke + */ +public class JodaDateTimeSerializer extends Serializer { + + static final String MILLIS = "millis"; + static final String DATE_TIME = "dt"; + static final String CHRONOLOGY = "ch"; + static final String TIME_ZONE = "tz"; + + public JodaDateTimeSerializer() { + setImmutable(true); + } + + @Override + public DateTime read(final Kryo kryo, final Input input, final Class type) { + final long millis = input.readLong(true); + final Chronology chronology = IdentifiableChronology.readChronology( input ); + final DateTimeZone tz = readTimeZone( input ); + return new DateTime( millis, chronology.withZone( tz ) ); + } + + @Override + public void write(final Kryo kryo, final Output output, final DateTime obj) { + output.writeLong(obj.getMillis(), true); + + final String chronologyId = IdentifiableChronology.getChronologyId( obj.getChronology() ); + output.writeString(chronologyId == null ? "" : chronologyId); + + output.writeString(obj.getZone().getID()); + } + + private DateTimeZone readTimeZone( final Input input ) { + final String tz = input.readString(); + + // special case for "" to maintain backwards compatibility, but generally this is considered harmful, + // potentially remove this with the next major release that involves breaking changes + // https://github.com/magro/kryo-serializers/issues/30 + if ("".equals(tz)) { + return DateTimeZone.getDefault(); + } + + return DateTimeZone.forID(tz); + } +} diff --git a/src/main/java/com/bullhornsdk/data/util/copy/KryoObjectCopyHelper.java b/src/main/java/com/bullhornsdk/data/util/copy/KryoObjectCopyHelper.java index 09bb350f..f9aa8bde 100644 --- a/src/main/java/com/bullhornsdk/data/util/copy/KryoObjectCopyHelper.java +++ b/src/main/java/com/bullhornsdk/data/util/copy/KryoObjectCopyHelper.java @@ -4,8 +4,6 @@ import com.esotericsoftware.kryo.Kryo; -import de.javakaffee.kryoserializers.jodatime.JodaDateTimeSerializer; - public class KryoObjectCopyHelper { public static T copy(T entity) { diff --git a/src/test/java/com/bullhornsdk/data/TestNestedEntities.java b/src/test/java/com/bullhornsdk/data/TestNestedEntities.java index d2aace25..8018ba0b 100644 --- a/src/test/java/com/bullhornsdk/data/TestNestedEntities.java +++ b/src/test/java/com/bullhornsdk/data/TestNestedEntities.java @@ -4,7 +4,8 @@ import static org.junit.Assert.assertNull; import com.bullhornsdk.data.model.entity.core.standard.JobShift; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.junit.Test; import com.bullhornsdk.data.model.entity.core.standard.Candidate; @@ -12,7 +13,7 @@ import com.google.common.collect.Sets; public class TestNestedEntities extends BaseTest { - private final Logger log = Logger.getLogger(TestNestedEntities.class); + private final Logger log = LogManager.getLogger(TestNestedEntities.class); public TestNestedEntities() { super(); diff --git a/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRest.java b/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRest.java index 361ed281..8148665a 100644 --- a/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRest.java +++ b/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRest.java @@ -12,7 +12,8 @@ import com.bullhornsdk.data.model.entity.core.onboarding365.forms.StateTaxForm; import com.bullhornsdk.data.model.entity.core.paybill.invoice.InvoiceStatementHistory; import com.bullhornsdk.data.model.entity.core.standard.*; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.junit.Test; import com.bullhornsdk.data.model.entity.core.customobjectinstances.clientcorporation.ClientCorporationCustomObjectInstance1; @@ -24,7 +25,7 @@ import com.google.common.collect.Sets; public class TestStandardBullhornApiRest extends BaseTest { - private final Logger log = Logger.getLogger(TestStandardBullhornApiRest.class); + private final Logger log = LogManager.getLogger(TestStandardBullhornApiRest.class); public TestStandardBullhornApiRest() { super(); diff --git a/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestAssociations.java b/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestAssociations.java index b9383994..19469f98 100644 --- a/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestAssociations.java +++ b/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestAssociations.java @@ -15,7 +15,8 @@ import com.bullhornsdk.data.model.entity.core.standard.PlacementShiftSet; import com.google.common.collect.Sets; import org.apache.commons.beanutils.PropertyUtils; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.junit.Test; import com.bullhornsdk.data.model.entity.association.AssociationFactory; @@ -37,7 +38,7 @@ import com.bullhornsdk.data.model.response.crud.CrudResponse; public class TestStandardBullhornApiRestAssociations extends BaseTest { - private final Logger log = Logger.getLogger(TestStandardBullhornApiRestAssociations.class); + private final Logger log = LogManager.getLogger(TestStandardBullhornApiRestAssociations.class); public TestStandardBullhornApiRestAssociations() { super(); diff --git a/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestCreate.java b/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestCreate.java index 6a2083a1..796bc67d 100644 --- a/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestCreate.java +++ b/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestCreate.java @@ -8,7 +8,8 @@ import com.bullhornsdk.data.model.entity.core.onboarding365.forms.StateTaxForm; import com.bullhornsdk.data.model.entity.core.standard.*; import com.google.common.collect.Sets; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.junit.After; import org.junit.Test; @@ -18,7 +19,7 @@ import com.bullhornsdk.data.model.response.crud.DeleteResponse; public class TestStandardBullhornApiRestCreate extends BaseTest { - private final Logger log = Logger.getLogger(TestStandardBullhornApiRestCreate.class); + private final Logger log = LogManager.getLogger(TestStandardBullhornApiRestCreate.class); private Integer entityId; diff --git a/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestDateHandling.java b/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestDateHandling.java index 99e10679..dafe9f12 100644 --- a/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestDateHandling.java +++ b/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestDateHandling.java @@ -5,7 +5,8 @@ import static org.junit.Assert.assertTrue; import com.google.common.collect.Sets; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import org.junit.After; @@ -16,7 +17,7 @@ import com.bullhornsdk.data.model.response.crud.UpdateResponse; public class TestStandardBullhornApiRestDateHandling extends BaseTest { - private final Logger log = Logger.getLogger(TestStandardBullhornApiRestDateHandling.class); + private final Logger log = LogManager.getLogger(TestStandardBullhornApiRestDateHandling.class); private T entity; diff --git a/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestFastFind.java b/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestFastFind.java index 961ac0e7..86922a63 100644 --- a/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestFastFind.java +++ b/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestFastFind.java @@ -3,7 +3,8 @@ import com.bullhornsdk.data.model.entity.core.standard.FastFindResult; import com.bullhornsdk.data.model.parameter.FastFindParams; import com.bullhornsdk.data.model.parameter.standard.ParamFactory; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.junit.Test; import java.util.List; @@ -18,7 +19,7 @@ */ public class TestStandardBullhornApiRestFastFind extends BaseTest { - private final Logger log = Logger.getLogger(TestStandardBullhornApiRestSearch.class); + private final Logger log = LogManager.getLogger(TestStandardBullhornApiRestSearch.class); private FastFindParams fastFindParams; diff --git a/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestFile.java b/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestFile.java index 06c1c215..8cfcc8ba 100644 --- a/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestFile.java +++ b/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestFile.java @@ -13,7 +13,8 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.junit.Test; import org.springframework.core.io.ClassPathResource; import org.springframework.mock.web.MockMultipartFile; @@ -31,7 +32,7 @@ import com.bullhornsdk.data.model.response.file.FileWrapper; public class TestStandardBullhornApiRestFile extends BaseTest { - private final Logger log = Logger.getLogger(TestStandardBullhornApiRestFile.class); + private final Logger log = LogManager.getLogger(TestStandardBullhornApiRestFile.class); private final static String FILE_NAME = "charlotte"; diff --git a/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestQuery.java b/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestQuery.java index 0e292445..468a5fb6 100644 --- a/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestQuery.java +++ b/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestQuery.java @@ -9,7 +9,8 @@ import com.bullhornsdk.data.model.entity.core.paybill.invoice.InvoiceStatementHistory; import com.bullhornsdk.data.model.entity.core.standard.*; import com.bullhornsdk.data.model.entity.file.*; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.junit.Test; import com.bullhornsdk.data.model.entity.core.type.BullhornEntity; @@ -26,7 +27,7 @@ */ public class TestStandardBullhornApiRestQuery extends BaseTest { - private final Logger log = Logger.getLogger(TestStandardBullhornApiRestQuery.class); + private final Logger log = LogManager.getLogger(TestStandardBullhornApiRestQuery.class); private String where = "id>0"; diff --git a/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestResumeParse.java b/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestResumeParse.java index d91263ab..08d9b705 100644 --- a/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestResumeParse.java +++ b/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestResumeParse.java @@ -9,7 +9,8 @@ import java.io.UnsupportedEncodingException; import java.util.List; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.junit.After; import org.junit.Test; import org.springframework.core.io.ClassPathResource; @@ -26,7 +27,7 @@ import com.bullhornsdk.data.model.response.resume.ParsedResume; public class TestStandardBullhornApiRestResumeParse extends BaseTest { - private final Logger log = Logger.getLogger(TestStandardBullhornApiRestResumeParse.class); + private final Logger log = LogManager.getLogger(TestStandardBullhornApiRestResumeParse.class); private final static String FILE_NAME = "Amy L"; diff --git a/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestSearch.java b/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestSearch.java index 1149eab8..9f4322ea 100644 --- a/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestSearch.java +++ b/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestSearch.java @@ -6,7 +6,8 @@ import java.util.HashMap; import java.util.Map; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.junit.Test; import com.bullhornsdk.data.model.entity.core.standard.Candidate; @@ -27,7 +28,7 @@ */ public class TestStandardBullhornApiRestSearch extends BaseTest { - private final Logger log = Logger.getLogger(TestStandardBullhornApiRestSearch.class); + private final Logger log = LogManager.getLogger(TestStandardBullhornApiRestSearch.class); private String query = "id:1*"; diff --git a/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestUpdate.java b/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestUpdate.java index 79d3d9cc..033262cf 100644 --- a/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestUpdate.java +++ b/src/test/java/com/bullhornsdk/data/TestStandardBullhornApiRestUpdate.java @@ -10,7 +10,8 @@ import com.bullhornsdk.data.model.entity.core.onboarding365.forms.StateTaxForm; import com.bullhornsdk.data.model.entity.core.standard.*; import com.google.common.collect.Sets; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.joda.time.DateTime; import org.junit.After; import org.junit.Test; @@ -27,7 +28,7 @@ import com.google.common.collect.Sets; public class TestStandardBullhornApiRestUpdate extends BaseTest { - private final Logger log = Logger.getLogger(TestStandardBullhornApiRestUpdate.class); + private final Logger log = LogManager.getLogger(TestStandardBullhornApiRestUpdate.class); private T entity; diff --git a/src/test/java/com/bullhornsdk/data/api/TestMockDataHandler.groovy b/src/test/java/com/bullhornsdk/data/api/TestMockDataHandler.groovy index d096b69f..9c366eac 100644 --- a/src/test/java/com/bullhornsdk/data/api/TestMockDataHandler.groovy +++ b/src/test/java/com/bullhornsdk/data/api/TestMockDataHandler.groovy @@ -2,13 +2,14 @@ package com.bullhornsdk.data.api import com.bullhornsdk.data.api.mock.MockDataHandler import com.bullhornsdk.data.model.entity.core.standard.* -import org.apache.log4j.Logger +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.junit.BeforeClass import org.junit.Test public class TestMockDataHandler { - private final static Logger log = Logger.getLogger(TestMockDataHandler.class); + private final static Logger log = LogManager.getLogger(TestMockDataHandler.class); private static MockDataHandler mockDataHandler; diff --git a/src/test/java/com/bullhornsdk/data/api/TestMockDataLoader.groovy b/src/test/java/com/bullhornsdk/data/api/TestMockDataLoader.groovy index a61c91f2..993c51b8 100644 --- a/src/test/java/com/bullhornsdk/data/api/TestMockDataLoader.groovy +++ b/src/test/java/com/bullhornsdk/data/api/TestMockDataLoader.groovy @@ -8,14 +8,15 @@ import com.bullhornsdk.data.model.entity.core.edithistory.FieldChange import com.bullhornsdk.data.model.entity.core.type.BullhornEntity import com.bullhornsdk.data.model.entity.core.type.SearchEntity import com.bullhornsdk.data.model.entity.meta.MetaData -import org.apache.log4j.Logger +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.junit.Test import static org.junit.Assert.assertFalse public class TestMockDataLoader { - private final static Logger log = Logger.getLogger(TestMockDataHandler.class); + private final static Logger log = LogManager.getLogger(TestMockDataHandler.class); private MockDataLoader mockDataLoader = new MockDataLoader();