@Test public void infosDocument() throws Exception { ResultActions resultActions = mockMvc.perform( get(urlTemplate.replaceFirst("SIREN", "sys250601879") + "/infosdoc/3000") .headers(httpHeaders)); resultActions .andExpect(matchAll( status().isOk(), jsonPath("$.status").value(200), jsonPath("$.status_message").value("OK"), jsonPath("$.data").hasJsonPath(), jsonPath("$.data.EtatClasseur").value(ClasseurStatus.IN_PROGRESS.toString()))) .andDo(print()); }
@GetMapping("/infosdoc/{idFlux}") public ResponseEntity<?> infosDocument(@PathVariable String siren, @PathVariable Integer idFlux, @RequestHeader("userid") String userid, @RequestHeader("password") String password) throws IOException { Map<String, Object> data = new HashMap<>(); if (paullService.emailAuth(userid, password) == null) return this.authGenericAccountForbidden(data); Optional<LocalAuthority> localAuthority = localAuthorityService.getBySiren(StringUtils.removeStart(siren, "sys")); if (!localAuthority.isPresent()) return this.notFoundLocalAuthority(data); ResponseEntity<Classeur> classeurResponse = sesileService.checkClasseurStatus(localAuthority.get(), idFlux); Optional<GenericDocument> genericDocument = sesileService.getGenericDocument(idFlux); if ((classeurResponse.getStatusCode().isError() && !classeurResponse.hasBody()) || !genericDocument.isPresent()) return this.notFoundClasseur(data); Classeur classeur = classeurResponse.getBody(); if (classeur == null) return this.errorWhileSearchingClasseur(data); if (classeur.getDocuments().isEmpty()) return this.noDocumentInClasseur(data); Document document = classeur.getDocuments().get(0); data.put("Title", classeur.getNom()); data.put("Name", classeur.getNom()); data.put("Username", genericDocument.get().getDepositEmail()); data.put("NomDocument", document.getName()); data.put("dateDepot", classeur.getCreation()); data.put("datevalide", classeur.getValidation()); data.put("service", classeur.getCircuit()); data.put("EtatClasseur", classeur.getStatus().ordinal()); return new ResponseEntity<Object>(generatePaullResponse(HttpStatus.OK, data, "OK"), HttpStatus.OK); }
PaullGenericController { @GetMapping("/infosdoc/{idFlux}") public ResponseEntity<?> infosDocument(@PathVariable String siren, @PathVariable Integer idFlux, @RequestHeader("userid") String userid, @RequestHeader("password") String password) throws IOException { Map<String, Object> data = new HashMap<>(); if (paullService.emailAuth(userid, password) == null) return this.authGenericAccountForbidden(data); Optional<LocalAuthority> localAuthority = localAuthorityService.getBySiren(StringUtils.removeStart(siren, "sys")); if (!localAuthority.isPresent()) return this.notFoundLocalAuthority(data); ResponseEntity<Classeur> classeurResponse = sesileService.checkClasseurStatus(localAuthority.get(), idFlux); Optional<GenericDocument> genericDocument = sesileService.getGenericDocument(idFlux); if ((classeurResponse.getStatusCode().isError() && !classeurResponse.hasBody()) || !genericDocument.isPresent()) return this.notFoundClasseur(data); Classeur classeur = classeurResponse.getBody(); if (classeur == null) return this.errorWhileSearchingClasseur(data); if (classeur.getDocuments().isEmpty()) return this.noDocumentInClasseur(data); Document document = classeur.getDocuments().get(0); data.put("Title", classeur.getNom()); data.put("Name", classeur.getNom()); data.put("Username", genericDocument.get().getDepositEmail()); data.put("NomDocument", document.getName()); data.put("dateDepot", classeur.getCreation()); data.put("datevalide", classeur.getValidation()); data.put("service", classeur.getCircuit()); data.put("EtatClasseur", classeur.getStatus().ordinal()); return new ResponseEntity<Object>(generatePaullResponse(HttpStatus.OK, data, "OK"), HttpStatus.OK); } }
PaullGenericController { @GetMapping("/infosdoc/{idFlux}") public ResponseEntity<?> infosDocument(@PathVariable String siren, @PathVariable Integer idFlux, @RequestHeader("userid") String userid, @RequestHeader("password") String password) throws IOException { Map<String, Object> data = new HashMap<>(); if (paullService.emailAuth(userid, password) == null) return this.authGenericAccountForbidden(data); Optional<LocalAuthority> localAuthority = localAuthorityService.getBySiren(StringUtils.removeStart(siren, "sys")); if (!localAuthority.isPresent()) return this.notFoundLocalAuthority(data); ResponseEntity<Classeur> classeurResponse = sesileService.checkClasseurStatus(localAuthority.get(), idFlux); Optional<GenericDocument> genericDocument = sesileService.getGenericDocument(idFlux); if ((classeurResponse.getStatusCode().isError() && !classeurResponse.hasBody()) || !genericDocument.isPresent()) return this.notFoundClasseur(data); Classeur classeur = classeurResponse.getBody(); if (classeur == null) return this.errorWhileSearchingClasseur(data); if (classeur.getDocuments().isEmpty()) return this.noDocumentInClasseur(data); Document document = classeur.getDocuments().get(0); data.put("Title", classeur.getNom()); data.put("Name", classeur.getNom()); data.put("Username", genericDocument.get().getDepositEmail()); data.put("NomDocument", document.getName()); data.put("dateDepot", classeur.getCreation()); data.put("datevalide", classeur.getValidation()); data.put("service", classeur.getCircuit()); data.put("EtatClasseur", classeur.getStatus().ordinal()); return new ResponseEntity<Object>(generatePaullResponse(HttpStatus.OK, data, "OK"), HttpStatus.OK); } PaullGenericController(SesileService sesileService, LocalAuthorityService localAuthorityService,
                                  PaullService paullService, ExternalRestService externalRestService); }
PaullGenericController { @GetMapping("/infosdoc/{idFlux}") public ResponseEntity<?> infosDocument(@PathVariable String siren, @PathVariable Integer idFlux, @RequestHeader("userid") String userid, @RequestHeader("password") String password) throws IOException { Map<String, Object> data = new HashMap<>(); if (paullService.emailAuth(userid, password) == null) return this.authGenericAccountForbidden(data); Optional<LocalAuthority> localAuthority = localAuthorityService.getBySiren(StringUtils.removeStart(siren, "sys")); if (!localAuthority.isPresent()) return this.notFoundLocalAuthority(data); ResponseEntity<Classeur> classeurResponse = sesileService.checkClasseurStatus(localAuthority.get(), idFlux); Optional<GenericDocument> genericDocument = sesileService.getGenericDocument(idFlux); if ((classeurResponse.getStatusCode().isError() && !classeurResponse.hasBody()) || !genericDocument.isPresent()) return this.notFoundClasseur(data); Classeur classeur = classeurResponse.getBody(); if (classeur == null) return this.errorWhileSearchingClasseur(data); if (classeur.getDocuments().isEmpty()) return this.noDocumentInClasseur(data); Document document = classeur.getDocuments().get(0); data.put("Title", classeur.getNom()); data.put("Name", classeur.getNom()); data.put("Username", genericDocument.get().getDepositEmail()); data.put("NomDocument", document.getName()); data.put("dateDepot", classeur.getCreation()); data.put("datevalide", classeur.getValidation()); data.put("service", classeur.getCircuit()); data.put("EtatClasseur", classeur.getStatus().ordinal()); return new ResponseEntity<Object>(generatePaullResponse(HttpStatus.OK, data, "OK"), HttpStatus.OK); } PaullGenericController(SesileService sesileService, LocalAuthorityService localAuthorityService,
                                  PaullService paullService, ExternalRestService externalRestService); @PostMapping("/depot") ResponseEntity<?> depotDocument(@PathVariable String siren, MultipartHttpServletRequest request,
            @RequestParam(name = "title", required = false) String title,
            @RequestParam(name = "comment", required = false) String comment,
            @RequestParam(name = "name", required = false) String name,
            @RequestParam(name = "desc", required = false) String desc,
            @RequestParam(name = "validation", required = false) String validation,
            @RequestParam(name = "email", required = false) String email,
            @RequestParam(name = "type", required = false) Integer type,
            @RequestParam(name = "service", required = false) String service,
            @RequestHeader("userid") String userid,
            @RequestHeader("password") String password); @GetMapping("/infosdoc/{idFlux}") ResponseEntity<?> infosDocument(@PathVariable String siren, @PathVariable Integer idFlux,
            @RequestHeader("userid") String userid, @RequestHeader("password") String password); @GetMapping("/doc/{idFlux}") ResponseEntity<?> getDocument(@PathVariable String siren, @PathVariable Integer idFlux,
            @RequestHeader("userid") String userid, @RequestHeader("password") String password); @GetMapping("/servicesorganisationnels/{email}") ResponseEntity<?> getServices(@PathVariable String siren, @PathVariable String email,
            @RequestHeader("userid") String userid, @RequestHeader("password") String password); }
PaullGenericController { @GetMapping("/infosdoc/{idFlux}") public ResponseEntity<?> infosDocument(@PathVariable String siren, @PathVariable Integer idFlux, @RequestHeader("userid") String userid, @RequestHeader("password") String password) throws IOException { Map<String, Object> data = new HashMap<>(); if (paullService.emailAuth(userid, password) == null) return this.authGenericAccountForbidden(data); Optional<LocalAuthority> localAuthority = localAuthorityService.getBySiren(StringUtils.removeStart(siren, "sys")); if (!localAuthority.isPresent()) return this.notFoundLocalAuthority(data); ResponseEntity<Classeur> classeurResponse = sesileService.checkClasseurStatus(localAuthority.get(), idFlux); Optional<GenericDocument> genericDocument = sesileService.getGenericDocument(idFlux); if ((classeurResponse.getStatusCode().isError() && !classeurResponse.hasBody()) || !genericDocument.isPresent()) return this.notFoundClasseur(data); Classeur classeur = classeurResponse.getBody(); if (classeur == null) return this.errorWhileSearchingClasseur(data); if (classeur.getDocuments().isEmpty()) return this.noDocumentInClasseur(data); Document document = classeur.getDocuments().get(0); data.put("Title", classeur.getNom()); data.put("Name", classeur.getNom()); data.put("Username", genericDocument.get().getDepositEmail()); data.put("NomDocument", document.getName()); data.put("dateDepot", classeur.getCreation()); data.put("datevalide", classeur.getValidation()); data.put("service", classeur.getCircuit()); data.put("EtatClasseur", classeur.getStatus().ordinal()); return new ResponseEntity<Object>(generatePaullResponse(HttpStatus.OK, data, "OK"), HttpStatus.OK); } PaullGenericController(SesileService sesileService, LocalAuthorityService localAuthorityService,
                                  PaullService paullService, ExternalRestService externalRestService); @PostMapping("/depot") ResponseEntity<?> depotDocument(@PathVariable String siren, MultipartHttpServletRequest request,
            @RequestParam(name = "title", required = false) String title,
            @RequestParam(name = "comment", required = false) String comment,
            @RequestParam(name = "name", required = false) String name,
            @RequestParam(name = "desc", required = false) String desc,
            @RequestParam(name = "validation", required = false) String validation,
            @RequestParam(name = "email", required = false) String email,
            @RequestParam(name = "type", required = false) Integer type,
            @RequestParam(name = "service", required = false) String service,
            @RequestHeader("userid") String userid,
            @RequestHeader("password") String password); @GetMapping("/infosdoc/{idFlux}") ResponseEntity<?> infosDocument(@PathVariable String siren, @PathVariable Integer idFlux,
            @RequestHeader("userid") String userid, @RequestHeader("password") String password); @GetMapping("/doc/{idFlux}") ResponseEntity<?> getDocument(@PathVariable String siren, @PathVariable Integer idFlux,
            @RequestHeader("userid") String userid, @RequestHeader("password") String password); @GetMapping("/servicesorganisationnels/{email}") ResponseEntity<?> getServices(@PathVariable String siren, @PathVariable String email,
            @RequestHeader("userid") String userid, @RequestHeader("password") String password);  }