Merge pull request 'dev' (#32) from dev into master

Reviewed-on: #32
This commit is contained in:
Thibaut Valentin 2025-02-08 14:01:04 +01:00
commit 2cdb495402
4 changed files with 12 additions and 4 deletions

View File

@ -245,7 +245,7 @@ public class AffiliationService {
keycloakService.setClubGroupMembre(m, club).map(__ -> m.getUserId())) keycloakService.setClubGroupMembre(m, club).map(__ -> m.getUserId()))
.call(userId -> keycloakService.setAutoRoleMembre(userId, m.getRole(), m.getGrade_arbitrage()))) .call(userId -> keycloakService.setAutoRoleMembre(userId, m.getRole(), m.getGrade_arbitrage())))
.call(m -> Mutiny.fetch(m.getLicences()) .call(m -> Mutiny.fetch(m.getLicences())
.call(l1 -> l1.stream().anyMatch(l -> l.getSaison() == saison) ? .call(l1 -> l1 != null && l1.stream().anyMatch(l -> l.getSaison() == saison) ?
Uni.createFrom().nullItem() : Uni.createFrom().nullItem() :
Panache.withTransaction(() -> licenceRepository.persist( Panache.withTransaction(() -> licenceRepository.persist(
new LicenceModel(null, m, saison, null, true))))); new LicenceModel(null, m, saison, null, true)))));

View File

@ -185,7 +185,7 @@ public class AffiliationRequestEndpoints {
}) })
public Uni<Response> getStatus( public Uni<Response> getStatus(
@Parameter(description = "L'identifiant de la demande d'affiliation") @PathParam("id") long id) throws URISyntaxException { @Parameter(description = "L'identifiant de la demande d'affiliation") @PathParam("id") long id) throws URISyntaxException {
return Utils.getMediaFile(id, media, "aff_request/status", "affiliation_request_" + id + ".pdf", return Utils.getMediaFile(id, media, "aff_request/status", "affiliation_request_" + id,
Uni.createFrom().nullItem()); Uni.createFrom().nullItem());
} }
} }

View File

@ -305,7 +305,7 @@ public class ClubEndpoints {
return clubService.getById(id).onItem().invoke(checkPerm).chain(Unchecked.function(clubModel -> { return clubService.getById(id).onItem().invoke(checkPerm).chain(Unchecked.function(clubModel -> {
try { try {
return Utils.getMediaFile(clubModel.getId(), media, "clubStatus", return Utils.getMediaFile(clubModel.getId(), media, "clubStatus",
"statue-" + clubModel.getName() + ".pdf", Uni.createFrom().nullItem()); "statue-" + clubModel.getName(), Uni.createFrom().nullItem());
} catch (URISyntaxException e) { } catch (URISyntaxException e) {
throw new InternalError(); throw new InternalError();
} }

View File

@ -162,12 +162,20 @@ public class Utils {
return Uni.createFrom().item(() -> { return Uni.createFrom().item(() -> {
String mimeType = URLConnection.guessContentTypeFromName(filePair.getKey().getName()); String mimeType = URLConnection.guessContentTypeFromName(filePair.getKey().getName());
String filename = out_filename;
if (filename != null && (filename.length() < 5 || filename.lastIndexOf(
'.') <= filename.length() - 6)) {
filename += filePair.getKey().getName()
.substring(filePair.getKey().getName().lastIndexOf('.'));
}
Response.ResponseBuilder resp = Response.ok(filePair.getValue()); Response.ResponseBuilder resp = Response.ok(filePair.getValue());
resp.type(MediaType.APPLICATION_OCTET_STREAM); resp.type(MediaType.APPLICATION_OCTET_STREAM);
resp.header(HttpHeaders.CONTENT_LENGTH, filePair.getValue().length); resp.header(HttpHeaders.CONTENT_LENGTH, filePair.getValue().length);
resp.header(HttpHeaders.CONTENT_TYPE, mimeType); resp.header(HttpHeaders.CONTENT_TYPE, mimeType);
resp.header(HttpHeaders.CONTENT_DISPOSITION, resp.header(HttpHeaders.CONTENT_DISPOSITION,
"inline; " + ((out_filename == null) ? "" : "filename=\"" + out_filename + "\"")); "inline; " + ((filename == null) ? "" : "filename=\"" + filename + "\""));
return resp.build(); return resp.build();
}); });
} }