@Override public void FilesRecursiveSaving(post post, Set<part> neededParts) { try { Files.walk(Paths.get(post.getPath())) .filter(Files::isRegularFile) .map( path -> new part() .setName(path.toString().replace(post.getPath(), "")) .setPath(path.toString())) .filter( part -> neededParts.stream().anyMatch(part1 -> part.getName().equals(part1.getName()))) .map( part2 -> { String collect = ""; try { collect = Files.lines(Paths.get(part2.getPath(), "")).collect(Collectors.joining("\n")); } catch (IOException e) { } return part2.setContent(collect); }) .map(p -> p.setPost(post)) .forEach(pa3 -> partRepository.save(pa3)); } catch (IOException e) { } }
@Override public String CloneService(post post) { File localPath = null; try { localPath = File.createTempFile("TestGitRepository", ""); localPath.delete(); post.setPath(localPath.getPath()); Git.cloneRepository().setURI(post.getUrl()).setDirectory(localPath).call(); return post.getPath(); } catch (GitAPIException | IOException e) { } return ""; }
@Override public Set<part> FilesRecursive(post post) { try { if (post.getPath().trim().equals("")) return new HashSet<part>(); return Files.walk(Paths.get(post.getPath())) .filter(Files::isRegularFile) .map( path -> new part() .setName(path.toString().replace(post.getPath(), "")) .setPath(path.toString())) .collect(Collectors.toSet()); } catch (IOException e) { return new HashSet<part>(); } }