-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new Controller with Tests and rearranged ProjectController method…
…s in 1 util class to share the methods with managerService
- Loading branch information
Showing
7 changed files
with
326 additions
and
268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/org/highmed/numportal/service/util/ExportHeaderUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.highmed.numportal.service.util; | ||
|
||
import org.highmed.numportal.domain.model.ExportType; | ||
|
||
import lombok.AllArgsConstructor; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.util.LinkedMultiValueMap; | ||
import org.springframework.util.MultiValueMap; | ||
|
||
@AllArgsConstructor | ||
@Component | ||
public class ExportHeaderUtil { | ||
|
||
private static final String ZIP_FILE_ENDING = ".zip"; | ||
private static final String JSON_FILE_ENDING = ".json"; | ||
private static final String ZIP_MEDIA_TYPE = "application/zip"; | ||
|
||
private final ExportUtil exportUtil; | ||
|
||
public MultiValueMap<String, String> getExportHeaders(ExportType format, Long projectId) { | ||
MultiValueMap<String, String> headers = new LinkedMultiValueMap<>(); | ||
String fileEnding; | ||
if (format == ExportType.json) { | ||
fileEnding = JSON_FILE_ENDING; | ||
headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); | ||
} else { | ||
fileEnding = ZIP_FILE_ENDING; | ||
headers.add(HttpHeaders.CONTENT_TYPE, ZIP_MEDIA_TYPE); | ||
} | ||
headers.add( | ||
HttpHeaders.CONTENT_DISPOSITION, | ||
"attachment; filename=" + exportUtil.getExportFilenameBody(projectId) + fileEnding); | ||
return headers; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.