@Override public boolean deleteIfExists(final Path path) throws DirectoryNotEmptyException, IOException, SecurityException { checkNotNull("path", path); final File file = path.toFile(); try { if (file.isDirectory() && file.list().length > 0) { throw new DirectoryNotEmptyException(path.toString()); } return file.delete(); } finally { toGeneralPathImpl(path).clearCache(); } }
ErrorPopup.showMessage(CommonConstants.INSTANCE.ExceptionGeneric0(e.getMessage())); } catch (org.uberfire.java.nio.file.DirectoryNotEmptyException e) { ErrorPopup.showMessage(CommonConstants.INSTANCE.ExceptionGeneric0(e.getMessage())); } catch (org.uberfire.java.nio.file.FileAlreadyExistsException e) { ErrorPopup.showMessage(CommonConstants.INSTANCE.ExceptionFileAlreadyExists0(e.getFile()));
ErrorPopup.showMessage(CommonConstants.INSTANCE.ExceptionGeneric0(e.getMessage())); } catch (org.uberfire.java.nio.file.DirectoryNotEmptyException e) { ErrorPopup.showMessage(CommonConstants.INSTANCE.ExceptionGeneric0(e.getMessage())); } catch (org.uberfire.java.nio.file.FileAlreadyExistsException e) { ErrorPopup.showMessage(CommonConstants.INSTANCE.ExceptionFileAlreadyExists0(e.getFile()));
@Override public boolean deleteIfExists(final Path path, final DeleteOption... options) throws DirectoryNotEmptyException, IOException, SecurityException { checkNotNull("path", path); synchronized (this) { final File file = path.toFile(); try { if (file.isDirectory() && !deleteNonEmptyDirectory(options) && file.list().length > 0) { throw new DirectoryNotEmptyException(path.toString()); } final boolean result = file.exists(); try { FileUtils.forceDelete(file); } catch (final FileNotFoundException ignore) { } catch (java.io.IOException e) { throw new IOException(e); } return result; } finally { toGeneralPathImpl(path).clearCache(); } } }
@Override public boolean deleteIfExists(final Path path, final DeleteOption... options) throws DirectoryNotEmptyException, IOException, SecurityException { checkNotNull("path", path); synchronized (this) { final File file = path.toFile(); try { if (file.isDirectory() && !deleteNonEmptyDirectory(options) && file.list().length > 0) { throw new DirectoryNotEmptyException(path.toString()); } final boolean result = file.exists(); try { FileUtils.forceDelete(file); } catch (final FileNotFoundException ignore) { } catch (java.io.IOException e) { throw new IOException(e); } return result; } finally { toGeneralPathImpl(path).clearCache(); } } }
@Override public void copy(final Path source, final Path target, final CopyOption... options) throws UnsupportedOperationException, FileAlreadyExistsException, DirectoryNotEmptyException, IOException, SecurityException { checkNotNull("source", source); checkNotNull("target", target); checkCondition("source must exist", source.toFile().exists()); if (target.toFile().exists()) { throw new FileAlreadyExistsException(target.toString()); } if (source.toFile().isDirectory() && source.toFile().list().length > 0) { throw new DirectoryNotEmptyException(source.toString()); } try { if (source.toFile().isDirectory()) { FileUtils.copyDirectory(source.toFile(), target.toFile()); } else { FileUtils.copyFile(source.toFile(), target.toFile()); } } catch (java.io.IOException ex) { throw new IOException(ex); } }
@Override public void copy(final Path source, final Path target, final CopyOption... options) throws UnsupportedOperationException, FileAlreadyExistsException, DirectoryNotEmptyException, IOException, SecurityException { checkNotNull("source", source); checkNotNull("target", target); checkCondition("source must exist", source.toFile().exists()); if (target.toFile().exists()) { throw new FileAlreadyExistsException(target.toString()); } if (source.toFile().isDirectory() && source.toFile().list().length > 0) { throw new DirectoryNotEmptyException(source.toString()); } try { if (source.toFile().isDirectory()) { FileUtils.copyDirectory(source.toFile(), target.toFile()); } else { FileUtils.copyFile(source.toFile(), target.toFile()); } } catch (java.io.IOException ex) { throw new IOException(ex); } }
@Override public void move(final Path source, final Path target, final CopyOption... options) throws DirectoryNotEmptyException, AtomicMoveNotSupportedException, IOException, SecurityException { checkNotNull("source", source); checkNotNull("target", target); checkCondition("source must exist", source.toFile().exists()); if (target.toFile().exists()) { throw new FileAlreadyExistsException(target.toString()); } if (source.toFile().isDirectory() && source.toFile().list().length > 0) { throw new DirectoryNotEmptyException(source.toString()); } try { if (source.toFile().isDirectory()) { FileUtils.moveDirectory(source.toFile(), target.toFile()); } else { FileUtils.moveFile(source.toFile(), target.toFile()); } } catch (java.io.IOException ex) { throw new IOException(ex); } }
@Override public void copy(final Path source, final Path target, final CopyOption... options) throws UnsupportedOperationException, FileAlreadyExistsException, DirectoryNotEmptyException, IOException, SecurityException { checkNotNull("source", source); checkNotNull("target", target); checkCondition("source must exist", source.toFile().exists()); if (target.toFile().exists()) { throw new FileAlreadyExistsException(target.toString()); } if (source.toFile().isDirectory() && source.toFile().list().length > 0) { throw new DirectoryNotEmptyException(source.toString()); } try { if (source.toFile().isDirectory()) { FileUtils.copyDirectory(source.toFile(), target.toFile()); } else { FileUtils.copyFile(source.toFile(), target.toFile()); } } catch (java.io.IOException ex) { throw new IOException(ex); } }
@Override public void move(final Path source, final Path target, final CopyOption... options) throws DirectoryNotEmptyException, AtomicMoveNotSupportedException, IOException, SecurityException { checkNotNull("source", source); checkNotNull("target", target); checkCondition("source must exist", source.toFile().exists()); if (target.toFile().exists()) { throw new FileAlreadyExistsException(target.toString()); } if (source.toFile().isDirectory() && source.toFile().list().length > 0) { throw new DirectoryNotEmptyException(source.toString()); } try { if (source.toFile().isDirectory()) { FileUtils.moveDirectory(source.toFile(), target.toFile()); } else { FileUtils.moveFile(source.toFile(), target.toFile()); } } catch (java.io.IOException ex) { throw new IOException(ex); } }
@Override public void move(final Path source, final Path target, final CopyOption... options) throws DirectoryNotEmptyException, AtomicMoveNotSupportedException, IOException, SecurityException { checkNotNull("source", source); checkNotNull("target", target); checkCondition("source must exist", source.toFile().exists()); if (target.toFile().exists()) { throw new FileAlreadyExistsException(target.toString()); } if (source.toFile().isDirectory() && source.toFile().list().length > 0) { throw new DirectoryNotEmptyException(source.toString()); } try { if (source.toFile().isDirectory()) { FileUtils.moveDirectory(source.toFile(), target.toFile()); } else { FileUtils.moveFile(source.toFile(), target.toFile()); } } catch (java.io.IOException ex) { throw new IOException(ex); } }
public boolean deleteAssetIfExists(final JGitPathImpl path, final DeleteOption... options) { final PathInfo result = path.getFileSystem().getGit().getPathInfo(path.getRefTree(), path.getPath()); if (result.getPathType().equals(PathType.DIRECTORY)) { if (deleteNonEmptyDirectory(options)) { deleteResource(path, options); return true; } final List<PathInfo> content = path.getFileSystem().getGit().listPathContent(path.getRefTree(), path.getPath()); if (content.size() == 1 && content.get(0).getPath().equals(path.getPath().substring(1) + "/.gitkeep")) { delete(path.resolve(".gitkeep")); return true; } throw new DirectoryNotEmptyException(path.toString()); } if (result.getPathType().equals(NOT_FOUND)) { return false; } deleteResource(path, options); return true; }
public void deleteAsset(final JGitPathImpl path, final DeleteOption... options) { final PathInfo result = path.getFileSystem().getGit().getPathInfo(path.getRefTree(), path.getPath()); if (result.getPathType().equals(PathType.DIRECTORY)) { if (deleteNonEmptyDirectory(options)) { deleteResource(path, options); return; } final List<PathInfo> content = path.getFileSystem().getGit().listPathContent(path.getRefTree(), path.getPath()); if (content.size() == 1 && content.get(0).getPath().equals(path.getPath().substring(1) + "/.gitkeep")) { delete(path.resolve(".gitkeep")); deleteResource(path, options); return; } throw new DirectoryNotEmptyException(path.toString()); } if (result.getPathType().equals(NOT_FOUND)) { throw new NoSuchFileException(path.toString()); } deleteResource(path, options); }
public boolean deleteAssetIfExists(final JGitPathImpl path) { final Pair<PathType, ObjectId> result = checkPath(path.getFileSystem().gitRepo(), path.getRefTree(), path.getPath()); if (result.getK1().equals(PathType.DIRECTORY)) { throw new DirectoryNotEmptyException(path.toString()); } if (result.getK1().equals(NOT_FOUND)) { return false; } JGitUtil.delete(path.getFileSystem().gitRepo(), path.getRefTree(), path.getPath(), null, null, "delete {" + path.getPath() + "}", null, null); return true; }
public void deleteAsset(final JGitPathImpl path) { final Pair<PathType, ObjectId> result = checkPath(path.getFileSystem().gitRepo(), path.getRefTree(), path.getPath()); if (result.getK1().equals(PathType.DIRECTORY)) { throw new DirectoryNotEmptyException(path.toString()); } if (result.getK1().equals(NOT_FOUND)) { throw new NoSuchFileException(path.toString()); } JGitUtil.delete(path.getFileSystem().gitRepo(), path.getRefTree(), path.getPath(), null, null, "delete {" + path.getPath() + "}", null, null); }