Commit 8258398c authored by Matt Wise's avatar Matt Wise
Browse files

API changes for DMS, Cleaner Storage Record Error Handling

commit cebbee58 
Author: Matt Wise <wsmatth@amazon.com> 
Date: Mon Jan 11 2021 12:13:27 GMT-0600 (Central Standard Time) 

    Changes for new DMS API. Improved storage error
parent 05415586
......@@ -20,9 +20,9 @@ import lombok.Data;
@Data
public class GetDatasetStorageInstructionsResponse {
Map<String, Object> storageProperties;
Map<String, Object> storageLocation;
public GetDatasetStorageInstructionsResponse(Map<String, Object> storageProperties) {
this.storageProperties = storageProperties;
public GetDatasetStorageInstructionsResponse(Map<String, Object> storageLocation) {
this.storageLocation = storageLocation;
}
}
......@@ -23,6 +23,9 @@ import java.util.regex.Pattern;
import javax.inject.Inject;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.model.storage.MultiRecordIds;
......@@ -65,6 +68,8 @@ public class DatasetDmsServiceImpl implements DatasetDmsService {
Pattern resourceTypeIdPattern = Pattern.compile(RESOURCE_TYPE_ID_PATTERN_REGEX);
private ObjectMapper jsonObjectMapper = new ObjectMapper();
public DatasetDmsServiceImpl() {
}
......@@ -124,8 +129,13 @@ public class DatasetDmsServiceImpl implements DatasetDmsService {
MultiRecordIds multiRecordIds = new MultiRecordIds(datasetRegistryIds, null);
getRecordsResponse = storageService.getRecords(multiRecordIds);
if (getRecordsResponse.getInvalidRecords().size() > 0 || getRecordsResponse.getRetryRecords().size() > 0) {
throw new AppException(HttpStatus.INTERNAL_SERVER_ERROR.value(), "Storage Service: Invalid or Failed Record Get", "Invalid or Failed Record Get");
if (getRecordsResponse.getInvalidRecords().size() > 0 || getRecordsResponse.getRetryRecords().size() > 0) {
try {
throw new AppException(HttpStatus.BAD_REQUEST.value(), "Storage Service: Invalid or Failed Record Get", jsonObjectMapper.writeValueAsString(getRecordsResponse));
}
catch (JsonProcessingException e) {
throw new AppException(HttpStatus.BAD_REQUEST.value(), "Storage Service: Invalid or Failed Record Get", "Invalid or Failed Record Get");
}
}
}
catch (StorageException e) {
......
......@@ -26,6 +26,6 @@ import lombok.Data;
@Data
public class GetRecordsResponse {
private List<Record> records;
private List<Record> invalidRecords;
private List<Record> retryRecords;
private List<String> invalidRecords;
private List<String> retryRecords;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment