Search in sources :

Example 1 with DirectoryResponseData

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);
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) DirectoryResponseData(org.ehrbase.response.openehr.DirectoryResponseData) ResponseEntity(org.springframework.http.ResponseEntity) HttpStatus(org.springframework.http.HttpStatus)

Example 2 with DirectoryResponseData

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;
}
Also used : DirectoryResponseData(org.ehrbase.response.openehr.DirectoryResponseData)

Aggregations

DirectoryResponseData (org.ehrbase.response.openehr.DirectoryResponseData)2 HttpHeaders (org.springframework.http.HttpHeaders)1 HttpStatus (org.springframework.http.HttpStatus)1 ResponseEntity (org.springframework.http.ResponseEntity)1