I'm kinda new in Spring and we start to use Spring framework at work.
We're working on a self-service installation website that performs these steps: accept file, parse, store locally, "install"(via running a Linux shell script).
My controller accepts the file and I'm using a validator to check if the file is empty and the type of content, then I extract from the file the fields that I need to validate against my DB, meaning let's say I extracted the server name from the text file, I need to validate if the server name exists in the DB.
My question is the following:
What is the best practice to handle file content validation?
- Put all checks in the FileValidator that already checks if the file is empty, etc.
- Put the checks in the service class that I wrote to extract the file content.
- use custom annotation validation on my VO
Should the file content validation be in the service layer with the extraction functions?
In another topic:
I wrote 2 service classes to extract the file content (e.g ServerExtractService & ModeExtractService), I used services since I'm accessing repositories, should I use a utility class instead?
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire