Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ITEM-72 Message erreur fichier de traitement non conforme #65

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected void checkRcr(String rcrFichier, String rcr, int ligneCourante) throws
* @throws FileCheckingException : erreur de format de fichier
*/
protected void checkPpn(String ppn, int ligneCourante) throws FileCheckingException {
if (!ppn.matches("^\\d{8}[0-9X]$")){
if (!ppn.matches("^(\\d{8}[0-9X])?$")){
throw new FileCheckingException(Constant.ERR_FILE_ERRLINE + ligneCourante + Constant.ERR_FILE_WRONGPPN);
}
}
Expand All @@ -110,7 +110,7 @@ protected void checkPpn(String ppn, int ligneCourante) throws FileCheckingExcept
* @throws FileCheckingException: erreur de format de l'epn
*/
protected void checkEpn(String epn, int ligneCourante) throws FileCheckingException {
if (!epn.matches("^\\d{8}[0-9X]$")) {
if (!epn.matches("^(\\d{8}[0-9X])?$")) {
throw new FileCheckingException(Constant.ERR_FILE_ERRLINE + ligneCourante + Constant.ERR_FILE_WRONGEPN);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@Slf4j
Expand All @@ -40,13 +39,14 @@ public int getType() {
return Constant.ETATDEM_PREPAREE;
}


@Override
public TYPE_DEMANDE getDemandeType() {return TYPE_DEMANDE.MODIF; }
public TYPE_DEMANDE getDemandeType() {
return TYPE_DEMANDE.MODIF;
}

@Override
public void checkFileContent(Demande demandeModif) {
//nothing to do
//nothing to do
}

@Override
Expand Down Expand Up @@ -98,8 +98,8 @@ public void alimenterEpn(String input, String listeppn, String rcr) {
*/
public void alimenterPpn(String input, String listeEpn, String rcr) {
try (FileWriter fw = new FileWriter(path.resolve(filename).toString(), true);
BufferedWriter bw = new BufferedWriter(fw);
PrintWriter out = new PrintWriter(bw)) {
BufferedWriter bw = new BufferedWriter(fw);
PrintWriter out = new PrintWriter(bw)) {
String[] tabEpn = listeEpn.split(",");
Multimap<String, String> resJson = Utilitaires.parseJson(input, true);
for (String epn : tabEpn) {
Expand All @@ -125,9 +125,10 @@ public void trierLignesDeCorrespondances() throws IOException {

List<String> correspondanceSortList = new ArrayList<>();
String header = reader.readLine();//cette ligne enleve le header et le stock
correspondanceSortList.add(header + "\n");
correspondanceSortList.add(header);
reader.lines().sorted().forEach(line -> {
correspondanceSortList.add(line+"\n");
correspondanceSortList.add("\n");
correspondanceSortList.add(line);
});
reader.close();
fileReader.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private void stockerFichierOnDisk(MultipartFile file, Fichier fichier, DemandeSu
}
}

private void checkEtatDemande(DemandeSupp demande) throws DemandeCheckingException, IOException, FileTypeException {
private void checkEtatDemande(DemandeSupp demande) throws DemandeCheckingException, IOException, FileTypeException, FileCheckingException {
int etat = demande.getEtatDemande().getNumEtat();
switch (etat) {
case Constant.ETATDEM_PREPARATION -> preparerFichierEnPrep(demande);
Expand All @@ -177,16 +177,16 @@ private void checkEtatDemande(DemandeSupp demande) throws DemandeCheckingExcepti
}
}

private void preparerFichierEnPrep(DemandeSupp demande) throws IOException, DemandeCheckingException, FileTypeException {
private void preparerFichierEnPrep(DemandeSupp demande) throws IOException, DemandeCheckingException, FileTypeException, FileCheckingException {
if (demande.getTypeSuppression() != null) {
//Suppression d'un éventuel fichier existant sur le disque
storageService.delete(fichierPrepare.getFilename());
//Ecriture ligne d'en-tête dans FichierApresWS
fichierPrepare.ecrireEnTete();
//Alimentation du fichier par appel à la procédure Oracle ppntoepn
appelProcStockee(demande.getRcr(), demande.getTypeSuppression());
demande.setEtatDemande(new EtatDemande(Constant.ETATDEM_PREPAREE));
fichierPrepare.trierLignesDeCorrespondances();
demande.setEtatDemande(new EtatDemande(Constant.ETATDEM_PREPAREE));
save(demande);
checkEtatDemande(demande);
}
Expand Down
Loading