Skip to content

Commit

Permalink
Merge pull request #54 from AO-StreetArt/udpApi
Browse files Browse the repository at this point in the history
Return all histories associated with an asset
  • Loading branch information
AO-StreetArt committed Mar 26, 2018
2 parents 14cd0ad + 8bf34f5 commit f0a41a1
Showing 1 changed file with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,19 @@ public class AssetHistoryController {
*/
@GetMapping("/v1/asset-history/{assetId}")
@ResponseBody
public ResponseEntity<AssetHistory> getHistory(@PathVariable String assetId) {
HttpStatus returnCode = HttpStatus.OK;
public ResponseEntity<List<AssetHistory>> getHistory(@PathVariable String assetId) {
logger.info("Responding to Asset History Get Request");
HttpStatus returnCode = HttpStatus.OK;
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.set("Content-Type", "application/json");

List<AssetHistory> existingHistoryList = assetHistories.findByAsset(assetId);
AssetHistory returnAsset = new AssetHistory();
// If we have an existing history, return it.
if (existingHistoryList.size() > 0) {
returnAsset = existingHistoryList.get(0);
} else {
if (existingHistoryList.size() == 0) {
returnCode = HttpStatus.REQUESTED_RANGE_NOT_SATISFIABLE;
logger.debug("No Asset Histories found");
}

// Create and return the new HTTP Response
return new ResponseEntity<AssetHistory>(returnAsset, responseHeaders, returnCode);
return new ResponseEntity<List<AssetHistory>>(existingHistoryList, responseHeaders, returnCode);
}

}

0 comments on commit f0a41a1

Please sign in to comment.