private ArrayList<File> getRecursiveRemovalContent(Directory currentDir) { ArrayList<File> toBeRemoved = new ArrayList<>(); for (File f : currentDir.getFilesSet()) { if (!f.equals(currentDir.getFather()) && !f.equals(currentDir)) { try { f.isCdAble(); toBeRemoved.addAll(getRecursiveRemovalContent((Directory) f)); } catch (IsNotDirectoryException e) { // in case of delete plainfiles } finally { toBeRemoved.add(f); } } } return toBeRemoved; }
private Directory createDir(Directory current, String name, User user) throws ImportDocumentException { Directory next = null; try { File file = current.getFileByName(name); file.isCdAble(); next = (Directory) current.getFileByName(name); } catch (FileUnknownException e) { /* This exception should not occur it only exists to protect the method against * bad programming */ log.trace(e.getMessage()); e.printStackTrace(); } catch (IsNotDirectoryException e) { throw new ImportDocumentException(); } finally { if (next == null) { next = new Directory(this.generateUniqueId(), name, user.getUmask(), user, current); current.addFile(next); } } return next; }