@Override public ResponseEntity<List<DdiArtifact>> getSoftwareModulesArtifacts(@PathVariable("tenant") final String tenant, @PathVariable("controllerId") final String controllerId, @PathVariable("softwareModuleId") final Long softwareModuleId) { LOG.debug("getSoftwareModulesArtifacts({})", controllerId); final Target target = controllerManagement.getByControllerId(controllerId) .orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId)); final SoftwareModule softwareModule = controllerManagement.getSoftwareModule(softwareModuleId) .orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, softwareModuleId)); return new ResponseEntity<>( DataConversionHelper.createArtifacts(target, softwareModule, artifactUrlHandler, systemManagement, new ServletServerHttpRequest(requestResponseContextHolder.getHttpServletRequest())), HttpStatus.OK); }
@Override public ResponseEntity<List<DdiArtifact>> getSoftwareModulesArtifacts(@PathVariable("tenant") final String tenant, @PathVariable("controllerId") final String controllerId, @PathVariable("softwareModuleId") final Long softwareModuleId) { LOG.debug("getSoftwareModulesArtifacts({})", controllerId); final Target target = controllerManagement.getByControllerId(controllerId) .orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId)); final SoftwareModule softwareModule = controllerManagement.getSoftwareModule(softwareModuleId) .orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, softwareModuleId)); return new ResponseEntity<>( DataConversionHelper.createArtifacts(target, softwareModule, artifactUrlHandler, systemManagement, new ServletServerHttpRequest(requestResponseContextHolder.getHttpServletRequest())), HttpStatus.OK); }
@Override // Exception squid:S3655 - Optional access is checked in checkModule // subroutine @SuppressWarnings("squid:S3655") public ResponseEntity<Void> downloadArtifactMd5(@PathVariable("tenant") final String tenant, @PathVariable("controllerId") final String controllerId, @PathVariable("softwareModuleId") final Long softwareModuleId, @PathVariable("fileName") final String fileName) { final Target target = controllerManagement.getByControllerId(controllerId) .orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId)); final SoftwareModule module = controllerManagement.getSoftwareModule(softwareModuleId) .orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, softwareModuleId)); if (checkModule(fileName, module)) { LOG.warn("Software module with id {} could not be found.", softwareModuleId); return ResponseEntity.notFound().build(); } final Artifact artifact = module.getArtifactByFilename(fileName) .orElseThrow(() -> new EntityNotFoundException(Artifact.class, fileName)); checkAndLogDownload(requestResponseContextHolder.getHttpServletRequest(), target, module.getId()); try { FileStreamingUtil.writeMD5FileResponse(requestResponseContextHolder.getHttpServletResponse(), artifact.getMd5Hash(), fileName); } catch (final IOException e) { LOG.error("Failed to stream MD5 File", e); return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } return ResponseEntity.ok().build(); }
@Override // Exception squid:S3655 - Optional access is checked in checkModule // subroutine @SuppressWarnings("squid:S3655") public ResponseEntity<Void> downloadArtifactMd5(@PathVariable("tenant") final String tenant, @PathVariable("controllerId") final String controllerId, @PathVariable("softwareModuleId") final Long softwareModuleId, @PathVariable("fileName") final String fileName) { final Target target = controllerManagement.getByControllerId(controllerId) .orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId)); final SoftwareModule module = controllerManagement.getSoftwareModule(softwareModuleId) .orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, softwareModuleId)); if (checkModule(fileName, module)) { LOG.warn("Software module with id {} could not be found.", softwareModuleId); return ResponseEntity.notFound().build(); } final Artifact artifact = module.getArtifactByFilename(fileName) .orElseThrow(() -> new EntityNotFoundException(Artifact.class, fileName)); checkAndLogDownload(requestResponseContextHolder.getHttpServletRequest(), target, module.getId()); try { FileStreamingUtil.writeMD5FileResponse(requestResponseContextHolder.getHttpServletResponse(), artifact.getMd5Hash(), fileName); } catch (final IOException e) { LOG.error("Failed to stream MD5 File", e); return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } return ResponseEntity.ok().build(); }
final SoftwareModule module = controllerManagement.getSoftwareModule(softwareModuleId) .orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, softwareModuleId));
final SoftwareModule module = controllerManagement.getSoftwareModule(softwareModuleId) .orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, softwareModuleId));