@Override public boolean delete(boolean recurse) throws MessagingException { if (isOpen()) { throw new IllegalStateException("Folder not closed!"); } try { if (recurse) { for (javax.mail.Folder aFolder : list()) { aFolder.delete(recurse); } } else { // Simplest approach if (getMessageCount() > 0) { return false; } } folder.delete(DELETE_MODE); notifyFolderListeners(FolderEvent.DELETED); return true; } catch (Exception e) { throw new MessagingException(e.getMessage(), e); } }
@Override public boolean renameTo(javax.mail.Folder f) throws MessagingException { if (isOpen()) { throw new IllegalStateException("Folder must be closed!"); } FolderId targetFolderId; if (f instanceof EwsFolder) { targetFolderId = ((EwsFolder) f).folder.getId(); } else { targetFolderId = getFolder(f.getFullName()).folder.getId(); } try { folder.move(targetFolderId); getStore().notifyFolderListeners(FolderEvent.RENAMED, this); return true; } catch (Exception e) { throw new MessagingException(e.getMessage(), e); } }
public boolean create(int type) throws MessagingException { log.debug("create (" + getFullName() + ')'); if (exists()) { return false; } log.debug("request to create folder: " + dir); log.debug("creating folder: " + dir.getAbsolutePath()); dir.mkdirs(); curd.mkdir(); newd.mkdir(); tmpd.mkdir(); final boolean result = exists(); if (result) { notifyFolderListeners(FolderEvent.CREATED); } return result; }
@Override public boolean create(int type) throws MessagingException { try { folder.save(parentFolder.getId()); notifyFolderListeners(FolderEvent.CREATED); return true; } catch (Exception e) { throw new MessagingException(e.getMessage(), e); } }
@Override public synchronized boolean create(final int type) throws MessagingException { abortIdle(); if (exists()) { return true; } mailboxFolder.create(); notifyFolderListeners(FolderEvent.CREATED); return mailboxFolder.isExists(); // return mailboxFolder.reCreate().isExists(); }
@Override public synchronized boolean delete(final boolean recurse) throws MessagingException { abortIdle(); checkExists(); checkClosed(); mailboxFolder.deleteFolder(recurse); notifyFolderListeners(FolderEvent.DELETED); return true; }
public boolean delete(boolean recurse) throws MessagingException { if (isOpen()) throw new IllegalStateException("cannot delete open folder"); if (isdefault || str.equals(".")) { throw new MessagingException("cant delete root and INBOX folder"); } if (!exists()) throw new FolderNotFoundException(this); boolean result = true; final String[] list = rootdir.list(); if (!recurse) { boolean hasSubfolders = false; for (int i = 0; i < list.length; i++) if (list[i].startsWith(str) && !list[i].equals(str)) { hasSubfolders = true; break; } result = hasSubfolders ? false : rmdir(getDir()); } else { for (int i = 0; i < list.length; i++) if (list[i].startsWith(str)) { final String path = root + list[i] + File.separatorChar; result = result & rmdir(new File(path)); } } if (result) notifyFolderListeners(FolderEvent.DELETED); return result; }
@Override public void folderCreated(FolderEvent e) { getStore().notifyFolderListeners(e.getType(), EwsFolder.this); }
@Override public void folderDeleted(FolderEvent e) { getStore().notifyFolderListeners(e.getType(), EwsFolder.this); }
@Override public void folderRenamed(FolderEvent e) { getStore().notifyFolderListeners(e.getType(), EwsFolder.this); }