use of org.ehrbase.response.openehr.DirectoryResponseData in project ehrbase by ehrbase.
the class OpenehrDirectoryController method createDirectoryResponse.
private ResponseEntity<DirectoryResponseData> createDirectoryResponse(HttpMethod method, String prefer, String accept, FolderDto folderDto, UUID ehrId) {
HttpHeaders headers = new HttpHeaders();
HttpStatus successStatus;
DirectoryResponseData body;
if (prefer != null && prefer.equals(RETURN_REPRESENTATION)) {
headers.setContentType(resolveContentType(accept, MediaType.APPLICATION_XML));
body = buildResponse(folderDto);
successStatus = getSuccessStatus(method);
} else {
body = null;
successStatus = HttpStatus.NO_CONTENT;
}
if (folderDto != null) {
String versionUid = folderDto.getUid().toString();
headers.setETag("\"" + versionUid + "\"");
headers.setLocation(URI.create(encodePath(getBaseEnvLinkURL() + "/rest/openehr/v1/ehr/" + ehrId.toString() + "/directory/" + versionUid)));
// TODO: Extract last modified from SysPeriod timestamp of fetched folder record
headers.setLastModified(DateTime.now().getMillis());
}
return new ResponseEntity<>(body, headers, successStatus);
}
use of org.ehrbase.response.openehr.DirectoryResponseData in project ehrbase by ehrbase.
the class OpenehrDirectoryController method buildResponse.
private DirectoryResponseData buildResponse(FolderDto folderDto) {
DirectoryResponseData resBody = new DirectoryResponseData();
resBody.setDetails(folderDto.getDetails());
resBody.setFolders(folderDto.getFolders());
resBody.setItems(folderDto.getItems());
resBody.setName(folderDto.getName());
resBody.setUid(folderDto.getUid());
return resBody;
}
Aggregations