@Test public void testRequirePath() throws Exception { exception.expect(NullPointerException.class); underTest.validateFilePath(null, MAX_NAME_LENGTH); }
@Override public boolean validateFilePath(final String filePath, final int maxLength) { requireNonNull(filePath); checkArgument(maxLength > 0, "maxLength should be greater than zero."); Path path = Paths.get(separatorsToSystem(filePath)).toAbsolutePath(); List<String> fileNames = new ArrayList<>(); Path pathParent = path.getParent(); while (pathParent != null) { if (path.getFileName() != null) { fileNames.add(path.getFileName().toString()); } path = pathParent; pathParent = path.getParent(); } return !fileNames.stream().anyMatch(fileOrDirectory -> fileOrDirectory.length() > maxLength); }
BlobStoreUtilImpl implements BlobStoreUtil { @Override public boolean validateFilePath(final String filePath, final int maxLength) { requireNonNull(filePath); checkArgument(maxLength > 0, "maxLength should be greater than zero."); Path path = Paths.get(separatorsToSystem(filePath)).toAbsolutePath(); List<String> fileNames = new ArrayList<>(); Path pathParent = path.getParent(); while (pathParent != null) { if (path.getFileName() != null) { fileNames.add(path.getFileName().toString()); } path = pathParent; pathParent = path.getParent(); } return !fileNames.stream().anyMatch(fileOrDirectory -> fileOrDirectory.length() > maxLength); } }
BlobStoreUtilImpl implements BlobStoreUtil { @Override public boolean validateFilePath(final String filePath, final int maxLength) { requireNonNull(filePath); checkArgument(maxLength > 0, "maxLength should be greater than zero."); Path path = Paths.get(separatorsToSystem(filePath)).toAbsolutePath(); List<String> fileNames = new ArrayList<>(); Path pathParent = path.getParent(); while (pathParent != null) { if (path.getFileName() != null) { fileNames.add(path.getFileName().toString()); } path = pathParent; pathParent = path.getParent(); } return !fileNames.stream().anyMatch(fileOrDirectory -> fileOrDirectory.length() > maxLength); } @Inject  BlobStoreUtilImpl(final RepositoryManager repositoryManager); }
BlobStoreUtilImpl implements BlobStoreUtil { @Override public boolean validateFilePath(final String filePath, final int maxLength) { requireNonNull(filePath); checkArgument(maxLength > 0, "maxLength should be greater than zero."); Path path = Paths.get(separatorsToSystem(filePath)).toAbsolutePath(); List<String> fileNames = new ArrayList<>(); Path pathParent = path.getParent(); while (pathParent != null) { if (path.getFileName() != null) { fileNames.add(path.getFileName().toString()); } path = pathParent; pathParent = path.getParent(); } return !fileNames.stream().anyMatch(fileOrDirectory -> fileOrDirectory.length() > maxLength); } @Inject  BlobStoreUtilImpl(final RepositoryManager repositoryManager); @Override int usageCount(final String blobStoreId); @Override boolean validateFilePath(final String filePath, final int maxLength); }
BlobStoreUtilImpl implements BlobStoreUtil { @Override public boolean validateFilePath(final String filePath, final int maxLength) { requireNonNull(filePath); checkArgument(maxLength > 0, "maxLength should be greater than zero."); Path path = Paths.get(separatorsToSystem(filePath)).toAbsolutePath(); List<String> fileNames = new ArrayList<>(); Path pathParent = path.getParent(); while (pathParent != null) { if (path.getFileName() != null) { fileNames.add(path.getFileName().toString()); } path = pathParent; pathParent = path.getParent(); } return !fileNames.stream().anyMatch(fileOrDirectory -> fileOrDirectory.length() > maxLength); } @Inject  BlobStoreUtilImpl(final RepositoryManager repositoryManager); @Override int usageCount(final String blobStoreId); @Override boolean validateFilePath(final String filePath, final int maxLength);  }