Skip to content
Snippets Groups Projects
Commit 0ba0c4c6 authored by Jagan Gottimukkula's avatar Jagan Gottimukkula
Browse files

removed config dependencies from storageserviceimpl

parent 43c9206d
No related branches found
No related tags found
1 merge request!6Trusted ibm
......@@ -26,7 +26,6 @@ import org.opendes.core.logging.JaxRsDpsLog;
import org.opendes.core.model.RecordMetaAttribute;
import org.opendes.core.service.UrlFetchService;
import org.opendes.core.util.AppException;
import org.opendes.core.util.Config;
import org.opendes.indexer.model.*;
import org.opendes.indexer.util.IRequestInfo;
import org.opendes.indexer.util.JobStatus;
......@@ -61,13 +60,25 @@ public class StorageServiceImpl implements StorageService {
@Autowired
private JaxRsDpsLog log;
@Value("${STORAGE_SCHEMA_HOST}")
private String STORAGE_SCHEMA_HOST;
@Value("${STORAGE_QUERY_RECORD_HOST}")
private String STORAGE_QUERY_RECORD_HOST;
@Value("${STORAGE_QUERY_RECORD_FOR_CONVERSION_HOST}")
private String STORAGE_QUERY_RECORD_FOR_CONVERSION_HOST;
@Value("${STORAGE_RECORDS_BATCH_SIZE}")
private String STORAGE_RECORDS_BATCH_SIZE;
@Override
public Records getStorageRecords(List<String> ids) throws AppException, URISyntaxException {
List<Records.Entity> valid = new ArrayList<>();
List<String> notFound = new ArrayList<>();
List<ConversionStatus> conversionStatuses = new ArrayList<>();
List<List<String>> batch = Lists.partition(ids, Config.getStorageRecordsBatchSize());
List<List<String>> batch = Lists.partition(ids, Integer.parseInt(STORAGE_RECORDS_BATCH_SIZE));
for (List<String> recordsBatch : batch) {
Records storageOut = this.getRecords(recordsBatch);
valid.addAll(storageOut.getRecords());
......@@ -84,7 +95,7 @@ public class StorageServiceImpl implements StorageService {
// Map<String, String> headers = this.requestInfo.getHeadersMap();
DpsHeaders headers = this.requestInfo.getHeaders();
headers.put(SLB_FRAME_OF_REFERENCE, SLB_FRAME_OF_REFERENCE_VALUE);
HttpResponse response = this.urlFetchService.sendRequest(HttpMethods.POST, Config.getStorageQueryRecordFoRConversionHostUrl(), headers, null, body);
HttpResponse response = this.urlFetchService.sendRequest(HttpMethods.POST, STORAGE_QUERY_RECORD_FOR_CONVERSION_HOST, headers, null, body);
String dataFromStorage = response.getBody();
if (Strings.isNullOrEmpty(dataFromStorage)) {
throw new AppException(HttpStatus.SC_NOT_FOUND, "Invalid request", "Storage service cannot locate records");
......@@ -117,7 +128,7 @@ public class StorageServiceImpl implements StorageService {
public RecordQueryResponse getRecordsByKind(RecordReindexRequest request) throws URISyntaxException {
Map<String, String> queryParams = new HashMap<>();
queryParams.put(RecordMetaAttribute.KIND.getValue(), request.getKind());
queryParams.put("limit", String.valueOf(Config.getStorageRecordsBatchSize()));
queryParams.put("limit", STORAGE_RECORDS_BATCH_SIZE);
if (!Strings.isNullOrEmpty(request.getCursor())) {
queryParams.put("cursor", request.getCursor());
}
......@@ -125,13 +136,13 @@ public class StorageServiceImpl implements StorageService {
if(requestInfo == null)
throw new AppException(HttpStatus.SC_NO_CONTENT, "Invalid header", "header can't be null");
HttpResponse response = this.urlFetchService.sendRequest(HttpMethods.GET, Config.getStorageQueryRecordHostUrl(), this.requestInfo.getHeaders(), queryParams, null);
HttpResponse response = this.urlFetchService.sendRequest(HttpMethods.GET, STORAGE_QUERY_RECORD_HOST, this.requestInfo.getHeaders(), queryParams, null);
return this.gson.fromJson(response.getBody(), RecordQueryResponse.class);
}
@Override
public String getStorageSchema(String kind) throws URISyntaxException, UnsupportedEncodingException {
String url = String.format("%s/%s", Config.getStorageSchemaHostUrl(), URLEncoder.encode(kind, "UTF-8"));
String url = String.format("%s/%s", STORAGE_SCHEMA_HOST, URLEncoder.encode(kind, "UTF-8"));
HttpResponse response = this.urlFetchService.sendRequest(HttpMethods.GET, url, this.requestInfo.getHeaders(), null, null);
if (response.getResponseCode() != HttpStatus.SC_OK) return null;
return response.getBody();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment