generated from pagopa/pagopa-functions-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SELC-5466] feat: added filename handling to persist signed contract …
…with correct extension (#486)
- Loading branch information
Showing
7 changed files
with
119 additions
and
48 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
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
13 changes: 13 additions & 0 deletions
13
apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/model/FormItem.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,13 @@ | ||
package it.pagopa.selfcare.onboarding.model; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
import java.io.File; | ||
|
||
@Builder | ||
@Getter | ||
public class FormItem { | ||
private File file; | ||
private String fileName; | ||
} |
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
28 changes: 28 additions & 0 deletions
28
apps/onboarding-ms/src/main/java/it/pagopa/selfcare/onboarding/util/Utils.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,28 @@ | ||
package it.pagopa.selfcare.onboarding.util; | ||
|
||
import it.pagopa.selfcare.onboarding.constants.CustomError; | ||
import it.pagopa.selfcare.onboarding.exception.InvalidRequestException; | ||
import it.pagopa.selfcare.onboarding.model.FormItem; | ||
import org.jboss.resteasy.reactive.server.core.multipart.FormData; | ||
import org.jboss.resteasy.reactive.server.multipart.FormValue; | ||
|
||
import java.io.File; | ||
import java.util.Deque; | ||
|
||
public class Utils { | ||
private static final String DEFAULT_CONTRACT_FORM_DATA_NAME = "contract"; | ||
private Utils() { | ||
} | ||
|
||
public static FormItem retrieveContractFromFormData(FormData formData, File file) { | ||
Deque<FormValue> deck = formData.get(DEFAULT_CONTRACT_FORM_DATA_NAME); | ||
if(deck.size() > 1) { | ||
throw new InvalidRequestException(CustomError.TOO_MANY_CONTRACTS.getMessage(), CustomError.TOO_MANY_CONTRACTS.getCode()); | ||
} | ||
|
||
return FormItem.builder() | ||
.file(file) | ||
.fileName(deck.getFirst().getFileName()) | ||
.build(); | ||
} | ||
} |
Oops, something went wrong.