Search in sources :

Example 1 with FolderOptions

use of com.zimbra.cs.mailbox.Folder.FolderOptions in project zm-mailbox by Zimbra.

the class ContactBackupThread method getContactBackupFolder.

private Folder getContactBackupFolder(OperationContext octxt, Mailbox mbox, boolean createIfDontExist) {
    Folder folder = null;
    try {
        folder = mbox.getFolderByName(octxt, Mailbox.ID_FOLDER_BRIEFCASE, MailConstants.A_CONTACTS_BACKUP_FOLDER_NAME);
    } catch (ServiceException se) {
        if (se.getCode().equals(MailServiceException.NO_SUCH_FOLDER) && createIfDontExist) {
            ZimbraLog.contactbackup.debug("contact backup folder does not exist, trying to create new one");
            FolderOptions opts = new FolderOptions();
            opts.setDefaultView(Type.FOLDER);
            byte hidden = Folder.FOLDER_IS_IMMUTABLE | Folder.FOLDER_DONT_TRACK_COUNTS;
            opts.setAttributes(hidden);
            try {
                folder = mbox.createFolder(octxt, MailConstants.A_CONTACTS_BACKUP_FOLDER_NAME, Mailbox.ID_FOLDER_BRIEFCASE, opts);
                ZimbraLog.contactbackup.debug("contact backup folder created");
            } catch (ServiceException se2) {
                ZimbraLog.contactbackup.warn("failed to create contact backup folder");
                ZimbraLog.contactbackup.debug(se2);
            }
        } else {
            ZimbraLog.contactbackup.warn("exception occured while getting contact backup folder");
            ZimbraLog.contactbackup.debug(se);
        }
    }
    return folder;
}
Also used : ServiceException(com.zimbra.common.service.ServiceException) FolderOptions(com.zimbra.cs.mailbox.Folder.FolderOptions)

Aggregations

ServiceException (com.zimbra.common.service.ServiceException)1 FolderOptions (com.zimbra.cs.mailbox.Folder.FolderOptions)1