Commit deb2901c authored by harshit aggarwal's avatar harshit aggarwal Committed by Kishore Battula
Browse files

Using SLF4J Logger in core

parent d8b3d75f
......@@ -101,8 +101,8 @@ spec:
- name: default_tenant
value: {{ .Values.default_tenant }}
- name: max_concurrent_calls
value: "8"
value: "32"
- name: executor_n_threads
value: "8"
value: "32"
- name: max_lock_renew_duration_seconds
value: "600"
......@@ -10,7 +10,7 @@
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<springfox-version>2.7.0</springfox-version>
<osdu.oscorecommon-version>0.3.18</osdu.oscorecommon-version>
<osdu.oscorecommon-version>0.3.24</osdu.oscorecommon-version>
</properties>
<licenses>
......
package org.opengroup.osdu.wks;
import java.util.logging.Level;
import org.opengroup.osdu.wks.config.ThreadScopeBeanFactoryPostProcessor;
import org.opengroup.osdu.wks.provider.interfaces.SubscriptionManager;
import org.opengroup.osdu.wks.service.SchemaService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
......@@ -12,15 +13,13 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.client.RestTemplate;
import lombok.extern.java.Log;
@Log
@SpringBootApplication
@ComponentScan(value = {
"org.opengroup.osdu"
})
public class WksServiceApplication {
private final static Logger LOGGER = LoggerFactory.getLogger(SchemaService.class);
public static void main(String[] args) {
ApplicationContext context = SpringApplication.run(WksServiceApplication.class, args);
try {
......@@ -29,8 +28,7 @@ public class WksServiceApplication {
}
catch (Exception e)
{
log.severe(e.getMessage());
log.log(Level.FINE, e.getMessage(), e);
LOGGER.error(e.getMessage(), e);
}
}
......
......@@ -12,11 +12,11 @@ public class Constants {
public static final String APP_KEY = "AppKey";
public static final String WKS_KIND = "wks";
public static final String WKE_KIND = "wke";
public static final String NO_MAPPING_FOR_KIND = "Mapping not found for %s";
public static final String NO_MAPPING_FOR_KIND = "Mapping not found for {}";
public static final String NO_MAPPING_FOR_ANY_RECORD = "Mapping not found for any record";
public static final String ERROR_WHILE_GETTING_RAW_RECORD = "Error retrieving raw record.";
public static final String TRANFORMATION_SUCCESSFUL = "Transformed successfully raw record id: %s, wks record id: %s and wks schema kind: %s";
public static final String TRANFORMATION_ALREADY_DONE = "Transformation already done for %d out of %d records";
public static final String TRANFORMATION_SUCCESSFUL = "Transformed successfully raw record id: {}, wks record id: {} and wks schema kind: {}";
public static final String TRANFORMATION_ALREADY_DONE = "Transformation already done for {} out of {} records";
public static final String RAW_RECORD_NOT_PRESENT = "Raw record not present";
public static final String MAPPING_NOT_PRESENT = "Mapping not present";
public static final String COLON_SEPARATOR = ":";
......@@ -27,11 +27,11 @@ public class Constants {
public static final String MISSING_RAW_RECORD_DETAILS = "Missing raw records details";
public static final String DATA_PARTITION_ID_NEEDED = "Data Partition Id is needed";
public static final String CORRELATION_ID_NEEDED = "Correlation Id is needed";
public static final String TRANFORMATION_FAILED = "Transformation failed for raw record id: %s, reason: %s";
public static final String TRANSFORMATION_FAILED_FOR_GIVEN_WKS_KIND = "Transformation failed for raw record id: %s with mapping of wks kind: %s, reason: %s";
public static final String TRANFORMATION_FAILED = "Transformation failed for raw record id: {}, reason: {}";
public static final String TRANSFORMATION_FAILED_FOR_GIVEN_WKS_KIND = "Transformation failed for raw record id: {} with mapping of wks kind: {}, reason: {}";
public static final String COULD_NOT_TRANSFORM = "Could not transform";
public static final String TRANFORMATION_PROCESS_COMPLETED = "Transformation process completed";
public static final String NOT_CREATE_OR_UPDATE_OPERATION = "%d out of %d records do not have create or update operation code";
public static final String NOT_CREATE_OR_UPDATE_OPERATION = "{} out of {} records do not have create or update operation code";
private Constants() {
}
......
......@@ -17,6 +17,8 @@ import org.opengroup.osdu.wks.model.SchemaInfoResponse;
import org.opengroup.osdu.wks.provider.interfaces.UserCredential;
import org.opengroup.osdu.wks.util.KindUtil;
import org.opengroup.osdu.wks.util.RestClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Component;
......@@ -28,6 +30,7 @@ import java.util.List;
@Component
public class SchemaService implements ISchemaService{
private final static Logger LOGGER = LoggerFactory.getLogger(SchemaService.class);
private static final String SCHEMA_SERVICE_ERROR_MESSAGE = "Schema service status code %s and message %s";
@Autowired
......@@ -94,6 +97,7 @@ public class SchemaService implements ISchemaService{
return kinds;
}
catch (JsonProcessingException exception) {
LOGGER.warn(exception.getMessage(), exception);
throw new ApplicationException(exception.getMessage(), exception.getCause());
}
}
......@@ -113,6 +117,7 @@ public class SchemaService implements ISchemaService{
return uriBuilder.build().toString();
}
catch (URISyntaxException exception) {
LOGGER.warn(exception.getMessage(), exception);
throw new ApplicationException(exception.getMessage(), exception.getCause());
}
......
......@@ -13,16 +13,16 @@ import org.opengroup.osdu.wks.model.RequestParameters;
import org.opengroup.osdu.wks.model.RestResponse;
import org.opengroup.osdu.wks.provider.interfaces.UserCredential;
import org.opengroup.osdu.wks.util.RestClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Service;
import lombok.extern.java.Log;
@Log
@Service
public class StorageServiceImpl implements StorageService {
private final static Logger LOGGER = LoggerFactory.getLogger(StorageServiceImpl.class);
@Autowired
private RestClient restClient;
......@@ -96,13 +96,14 @@ private String getAuthKey(TenantInfo tenantInfo) {
try {
return userCrendential.getIdToken(tenantInfo);
} catch(ApplicationException e) {
LOGGER.warn(e.getErrorMsg(), e);
throw new AuthorizationException(e);
}
}
private void verifyResponseStatus(RestResponse response) throws ApplicationException {
if (response.getStatus() != HttpStatus.SC_CREATED) {
log.warning(response.getException());
LOGGER.warn(response.getException());
throw new ApplicationException(response.getException());
}
}
......
......@@ -6,8 +6,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.logging.Level;
import java.util.stream.Collectors;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -24,18 +22,19 @@ import org.opengroup.osdu.wks.model.TransformationResult;
import org.opengroup.osdu.wks.provider.interfaces.StatusStoreService;
import org.opengroup.osdu.wks.util.KindUtil;
import org.opengroup.osdu.wks.util.WksTransformator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.datatree.Tree;
import lombok.extern.java.Log;
@Log
@Service("wKSService")
public class WKSServiceImpl implements WKSService {
private final static Logger LOGGER = LoggerFactory.getLogger(WKSServiceImpl.class);
private static final int SOURCE_INDEX = 1;
private static final String UPDATE = "update";
private static final String CREATE = "create";
......@@ -83,6 +82,8 @@ public class WKSServiceImpl implements WKSService {
if(rawRecordsDetailsForTransformation.length > 0) {
Map<String, List<MappingsModel>> mappingsMap = retrieveMappingsMap(rawRecordsDetailsForTransformation);
// Updating mappings with latest minor and patch versions
updateMappingsWithLatestMinorAndPatchVersions(mappingsMap);
transformRecords(rawRecordsDetailsForTransformation, mappingsMap, dataPartitionId, correlationId);
}
} finally {
......@@ -106,13 +107,12 @@ public class WKSServiceImpl implements WKSService {
}
if (invalidOpCodeCount > 0) {
log.log(Level.INFO, String.format(Constants.NOT_CREATE_OR_UPDATE_OPERATION, invalidOpCodeCount,
rawRecordsDetails.length));
LOGGER.info(Constants.NOT_CREATE_OR_UPDATE_OPERATION, invalidOpCodeCount,
rawRecordsDetails.length);
}
if (invalidSourceCount > 0) {
log.log(Level.INFO,
String.format(Constants.TRANFORMATION_ALREADY_DONE, invalidSourceCount, rawRecordsDetails.length));
LOGGER.info(Constants.TRANFORMATION_ALREADY_DONE, invalidSourceCount, rawRecordsDetails.length);
}
return rawRecordsDetailsList.toArray(new RawRecordDetails[0]);
......@@ -126,11 +126,10 @@ public class WKSServiceImpl implements WKSService {
for (RawRecordDetails rawRecord : rawRecordsDetails) {
try {
List<MappingsModel> mappingsList = retrieveMappings(mappingsMap, rawRecord);
List<MappingsModel> mappingsWithLatestMinorAndPatchVersions = updateMappingsWithLatestMinorAndPatchVersions(mappingsList);
Tree rawRecordTree = retrieveRawRecordTree(rawRecord);
for (MappingsModel mappings: mappingsWithLatestMinorAndPatchVersions) {
for (MappingsModel mappings: mappingsList) {
try {
TransformRequest transformRequest = new TransformRequest(rawRecordTree, mappings);
......@@ -144,19 +143,17 @@ public class WKSServiceImpl implements WKSService {
}
wksRecordTreeList.add(wksRecordTree);
log.log(Level.INFO, String.format(Constants.TRANFORMATION_SUCCESSFUL, rawRecord.getId(),
wksRecordTree.get(ID).asString(), wksRecordTree.get(KIND)));
LOGGER.info(Constants.TRANFORMATION_SUCCESSFUL, rawRecord.getId(),
wksRecordTree.get(ID).asString(), wksRecordTree.get(KIND));
}
catch (ApplicationException e) {
log.log(Level.WARNING,
String.format(Constants.TRANSFORMATION_FAILED_FOR_GIVEN_WKS_KIND, rawRecord.getId(), mappings.getTargetSchemaKind(), e.getErrorMsg()));
LOGGER.warn(Constants.TRANSFORMATION_FAILED_FOR_GIVEN_WKS_KIND, rawRecord.getId(), mappings.getTargetSchemaKind(), e.getErrorMsg(), e);
}
}
} catch (ApplicationException e) {
log.log(Level.WARNING,
String.format(Constants.TRANFORMATION_FAILED, rawRecord.getId(), e.getErrorMsg()));
LOGGER.warn(Constants.TRANFORMATION_FAILED, rawRecord.getId(), e.getErrorMsg(), e);
}
}
......@@ -166,17 +163,21 @@ public class WKSServiceImpl implements WKSService {
statusStoreService.createOrUpdateStoreEntry(relationshipStatusList);
}
}
log.log(Level.INFO, Constants.TRANFORMATION_PROCESS_COMPLETED);
LOGGER.info(Constants.TRANFORMATION_PROCESS_COMPLETED);
}
private List<MappingsModel> updateMappingsWithLatestMinorAndPatchVersions(List<MappingsModel> mappingsList) throws ApplicationException {
for (MappingsModel mappingsModel : mappingsList) {
private void updateMappingsWithLatestMinorAndPatchVersions(Map<String, List<MappingsModel>> mappingsMap) throws ApplicationException {
for (Map.Entry<String, List<MappingsModel>> entry : mappingsMap.entrySet()) {
List<MappingsModel> mappingsModelList = new ArrayList<>();
for (MappingsModel mappingsModel : entry.getValue()) {
List<String> schemaKindsWithLatestMinorAndPatchVersions = schemaService.getSchemas(mappingsModel.getTargetSchemaKind());
mappingsModel.setTargetSchemaKind(schemaKindsWithLatestMinorAndPatchVersions.get(0));
mappingsModelList.add(mappingsModel);
}
log.log(Level.INFO, "Schemas for WKS fetched with latest minor and patch versions");
return mappingsList;
entry.setValue(mappingsModelList);
}
LOGGER.info("Schemas for WKS fetched with latest minor and patch versions");
}
private void initializeMessageContext(String dataPartitionId, String correlationId) {
......@@ -188,7 +189,7 @@ public class WKSServiceImpl implements WKSService {
throws ApplicationException {
List<MappingsModel> mappings = mappingsMap.get(rawRecord.getKind());
if (isEmptyMappings(mappings)) {
log.warning(String.format(Constants.NO_MAPPING_FOR_KIND, rawRecord.getKind()));
LOGGER.warn(Constants.NO_MAPPING_FOR_KIND, rawRecord.getKind());
throw new ApplicationException(String.format(Constants.NO_MAPPING_FOR_KIND, rawRecord.getKind()));
}
return mappings;
......@@ -196,7 +197,7 @@ public class WKSServiceImpl implements WKSService {
private void validateTransformRecord(Tree wksRecordTree) throws ApplicationException {
if (wksRecordTree == null || wksRecordTree.isEmpty()) {
log.warning(Constants.COULD_NOT_TRANSFORM);
LOGGER.warn(Constants.COULD_NOT_TRANSFORM);
throw new ApplicationException(Constants.COULD_NOT_TRANSFORM);
}
}
......@@ -205,7 +206,7 @@ public class WKSServiceImpl implements WKSService {
throws ApplicationException {
String message = this.storageService.putRecords(convertTreeListToJsonStrArr(wksRecordTreeList),
dataPartitionId, correlationId);
log.info(message);
LOGGER.info(message);
}
private Tree retrieveRawRecordTree(RawRecordDetails rawRecord)
......@@ -213,14 +214,14 @@ public class WKSServiceImpl implements WKSService {
Optional<String> optionalRawRecord = storageService.getRecord(rawRecord.getId());
if (!optionalRawRecord.isPresent()) {
log.severe(Constants.RAW_RECORD_NOT_PRESENT);
LOGGER.warn(Constants.RAW_RECORD_NOT_PRESENT);
throw new BadRequestException(Constants.RAW_RECORD_NOT_PRESENT);
}
String rawRecordJsonStr = optionalRawRecord.get();
Tree rawRecordTree = convertJsonStringToTree(rawRecordJsonStr);
if (rawRecordTree.isEmpty()) {
log.severe(Constants.RAW_RECORD_NOT_PRESENT);
LOGGER.warn(Constants.RAW_RECORD_NOT_PRESENT);
throw new ApplicationException(Constants.RAW_RECORD_NOT_PRESENT);
}
return rawRecordTree;
......@@ -249,15 +250,15 @@ public class WKSServiceImpl implements WKSService {
|| StringUtils.isBlank(rawRecordsDetails[0].getId())
|| StringUtils.isBlank(rawRecordsDetails[0].getKind())
|| StringUtils.isBlank(rawRecordsDetails[0].getOp())) {
log.warning(Constants.MISSING_RAW_RECORD_DETAILS);
LOGGER.warn(Constants.MISSING_RAW_RECORD_DETAILS);
throw new BadRequestException(Constants.MISSING_RAW_RECORD_DETAILS);
}
if (StringUtils.isBlank(dataPartitionId)) {
log.warning(Constants.DATA_PARTITION_ID_NEEDED);
LOGGER.warn(Constants.DATA_PARTITION_ID_NEEDED);
throw new BadRequestException(Constants.DATA_PARTITION_ID_NEEDED);
}
if (StringUtils.isBlank(correlationId)) {
log.warning(Constants.CORRELATION_ID_NEEDED);
LOGGER.warn(Constants.CORRELATION_ID_NEEDED);
throw new BadRequestException(Constants.CORRELATION_ID_NEEDED);
}
}
......@@ -280,7 +281,7 @@ public class WKSServiceImpl implements WKSService {
try {
map = mapper.readValue(jsonStr, Map.class);
} catch (IOException e) {
log.warning("Could not convert json string to map");
LOGGER.warn("Could not convert json string to map", e);
}
}
return new Tree(map);
......
......@@ -8,11 +8,12 @@ import org.apache.commons.lang3.StringUtils;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.datatree.Tree;
import lombok.extern.java.Log;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Log
public class JsonTreeUtil {
private final static Logger LOGGER = LoggerFactory.getLogger(JsonTreeUtil.class);
private JsonTreeUtil(){
throw new IllegalStateException("JsonTreeUtil should not be instantiated");
}
......@@ -25,7 +26,7 @@ public class JsonTreeUtil {
try {
map = mapper.readValue(jsonStr, Map.class);
} catch (IOException e) {
log.warning("Could not convert json string to map");
LOGGER.warn("Could not convert json string to map", e);
}
}
return new Tree(map);
......
......@@ -8,9 +8,7 @@ import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.function.Predicate;
import java.util.logging.Level;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.opengroup.osdu.wks.constants.Constants;
import org.opengroup.osdu.wks.exceptions.ApplicationException;
......@@ -26,6 +24,8 @@ import org.opengroup.osdu.wks.model.UpdatedRelationshipBlock;
import org.opengroup.osdu.wks.provider.interfaces.MappingStore;
import org.opengroup.osdu.wks.service.SearchService;
import org.opengroup.osdu.wks.service.StorageService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -33,12 +33,12 @@ import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.datatree.Tree;
import lombok.extern.java.Log;
@Component
@Log
public class RelationshipBlockHandler {
private final static Logger LOGGER = LoggerFactory.getLogger(RelationshipBlockHandler.class);
private final StorageService storageService;
private final SearchService searchService;
......@@ -107,7 +107,7 @@ public class RelationshipBlockHandler {
try {
wksRelationship = getRelationshipBlockWithWksIds(rawRelationship);
} catch (ApplicationException e) {
log.log(Level.INFO, e.getMessage(), e);
LOGGER.info(e.getMessage(), e);
}
if(wksRelationship != null) {
wksRelationships.add(wksRelationship);
......@@ -142,7 +142,7 @@ public class RelationshipBlockHandler {
// on authority name are lifted search results will be unique every time and caching won't be required
searchResults = searchService.query(searchRequestPayload.getJsonString());
} catch(ApplicationException e) {
log.info("WKS not found from search service");
LOGGER.info("WKS not found from search service", e);
}
Kind rawKind = new Kind(JsonTreeUtil.toTree(rawRecordJson).get("kind").asString());
......@@ -152,7 +152,7 @@ public class RelationshipBlockHandler {
private String extractWksIdFromSearchResults(String searchResults, String rawId, Kind rawKind) {
List<WksInfo> wksInfos = getWksInfos(searchResults);
if (noWksFound(wksInfos)) {
log.log(Level.INFO, "No matching WKS found for record id");
LOGGER.info("No matching WKS found for record id");
return rawId;
}
return getUniqueWksId(rawId, wksInfos, rawKind);
......@@ -164,10 +164,10 @@ public class RelationshipBlockHandler {
// 2. Choose records having same universe as that of the mapping file
// 3. Choose the one with highest major version
log.log(Level.INFO, String.format("Total %s Records found having %s in ancestry block", wksInfos.size(), rawId));
LOGGER.info("Total {} Records found having {} in ancestry block", wksInfos.size(), rawId);
List<WksInfo> wksGeneratedByWKSService = getWKSRecordsCreatedByWKSService(rawId, wksInfos, rawKind);
log.log(Level.INFO, String.format("Total %s Records created by WKS service", wksGeneratedByWKSService.size()));
LOGGER.info("Total {} Records created by WKS service", wksGeneratedByWKSService.size());
if(wksGeneratedByWKSService.isEmpty()) {
return rawId;
}
......@@ -175,7 +175,7 @@ public class RelationshipBlockHandler {
String targetSchemaAuthority = targetSchemaKindValue.split(Constants.COLON_SEPARATOR)[0];
List<WksInfo> wksFromGivenAuthority = getWKSRecordsFromGivenAuthority(targetSchemaAuthority, wksGeneratedByWKSService);
log.log(Level.INFO, String.format("Total %s Records have same authority as that of target schema", wksGeneratedByWKSService.size()));
LOGGER.info("Total {} Records have same authority as that of target schema", wksGeneratedByWKSService.size());
if(wksFromGivenAuthority.isEmpty()) {
return rawId;
......@@ -187,7 +187,7 @@ public class RelationshipBlockHandler {
List<WksInfo> wksSortedOnMajorVersion = wksFromGivenAuthority.stream().sorted(Comparator.reverseOrder()).collect(Collectors.toList());
log.log(Level.INFO, String.format("Unique WKS Record with id: %s found for relationship with Record %s", wksSortedOnMajorVersion.get(0).getId(), rawId));
LOGGER.info("Unique WKS Record with id: {} found for relationship with Record {}", wksSortedOnMajorVersion.get(0).getId(), rawId);
return wksSortedOnMajorVersion.get(0).getId();
}
......@@ -299,7 +299,7 @@ public class RelationshipBlockHandler {
return (new ObjectMapper()).readValue(results, new TypeReference<List<WksInfo>>() {
});
} catch (Exception e) {
log.warning("Error parsing wks info from search result");
LOGGER.warn("Error parsing wks info from search result", e);
}
return new ArrayList<>();
}
......
......@@ -3,12 +3,13 @@ package org.opengroup.osdu.wks.util;
import java.util.Collections;
import java.util.concurrent.TimeUnit;
import lombok.extern.java.Log;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpException;
import org.opengroup.osdu.wks.constants.Constants;
import org.opengroup.osdu.wks.model.RequestParameters;
import org.opengroup.osdu.wks.model.RestResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
......@@ -20,10 +21,11 @@ import org.springframework.web.client.HttpServerErrorException;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
@Log
@Component
public class RestClient {
private final static Logger LOGGER = LoggerFactory.getLogger(RestClient.class);
@Autowired
private RestTemplate restTemplate;
private int retryCounter = 3;
......@@ -49,15 +51,15 @@ public class RestClient {
public RestResponse processRequest(RequestParameters requestParameters) {
HttpHeaders headers = setHeaders(requestParameters.getContent(), requestParameters.getAuthKey(),
requestParameters.getDataPartitionId(), requestParameters.getOnBehalfOf(),
requestParameters.getAppKey());
requestParameters.getDataPartitionId(), requestParameters.getCorrelationId(),
requestParameters.getOnBehalfOf(), requestParameters.getAppKey());
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
HttpEntity<?> request = new HttpEntity<>(requestParameters.getPayload(), headers);
try {
validate(requestParameters.getUrl());
submitRequest(requestParameters.getUrl(), requestParameters.getMethod(), request, retryCounter);
} catch (Exception e) {
log.warning(e.toString());
LOGGER.warn(e.toString(), e);
restResponse.setException(e.toString());
}
return restResponse;
......@@ -65,13 +67,13 @@ public class RestClient {
private void validate(String url) {
if (StringUtils.isBlank(url)) {
log.warning("URL is null or empty string.");
LOGGER.warn("URL is null or empty string.");
throw new RestClientException("'URL' is null or empty string.");
}
}
private HttpHeaders setHeaders(String content, String authKey, String accountId, String onBehalfOf,
String appKey) {
private HttpHeaders setHeaders(String content, String authKey, String dataPartitionID,
String correlationID, String onBehalfOf, String appKey) {
HttpHeaders headers = new HttpHeaders();
String contentType;
......@@ -87,8 +89,12 @@ public class RestClient {
headers.set(Constants.AUTHORIZATION, authKey);
}
if (accountId != null) {
headers.set(Constants.DATA_PARTITION_ID, accountId);
if (dataPartitionID != null) {
headers.set(Constants.DATA_PARTITION_ID, dataPartitionID);
}
if (correlationID != null) {
headers.set(Constants.CORRELATION_ID, correlationID);
}
if (onBehalfOf != null) {
......@@ -113,7 +119,7 @@ public class RestClient {
} catch (HttpServerErrorException e) {
if (retryCounter == 0) {
log.warning("Error while processing request: " + e.getMessage());
LOGGER.warn("Error while processing request: " + e.getMessage(), e);
throw new HttpException("Error while processing request: " + e.getMessage());
}
......@@ -121,7 +127,7 @@ public class RestClient {
submitRequest(url, method, request, retryCounter - 1);
} catch (RestClientException e) {
log.warning("Error while processing request: " + e.getMessage());
LOGGER.warn("Error while processing request: " + e.getMessage(), e);
throw new HttpException("Error while processing request: " + e.getMessage());
}
}
......
......@@ -17,20 +17,21 @@ import org.opengroup.osdu.wks.model.RelationshipStatus;
import org.opengroup.osdu.wks.model.TransformRequest;
import org.opengroup.osdu.wks.model.TransformationResult;
import org.opengroup.osdu.wks.model.UpdatedRelationshipBlock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;