private Optional<Artifact> findArtifactByFileResource(final FileResource fileResource) { if (fileResource == null) { return Optional.empty(); } if (fileResource.getSha1() != null) { return artifactManagement.findFirstBySHA1(fileResource.getSha1()); } if (fileResource.getFilename() != null) { return artifactManagement.getByFilename(fileResource.getFilename()); } if (fileResource.getArtifactId() != null) { return artifactManagement.get(fileResource.getArtifactId()); } if (fileResource.getSoftwareModuleFilenameResource() != null) { return artifactManagement.getByFilenameAndSoftwareModule( fileResource.getSoftwareModuleFilenameResource().getFilename(), fileResource.getSoftwareModuleFilenameResource().getSoftwareModuleId()); } return Optional.empty(); }