001 /* 002 * Copyright 2010 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package com.hs.mail.imap.dao; 017 018 import java.util.List; 019 020 import com.hs.mail.imap.mailbox.Mailbox; 021 import com.hs.mail.imap.message.PhysMessage; 022 023 /** 024 * 025 * @author Won Chul Doh 026 * @since Mar 8, 2010 027 * 028 */ 029 public interface MailboxDao { 030 031 /** 032 * Get the named mailbox. 033 * 034 * @param ownerID 035 * the id of the user who owns the mailbox 036 * @param mailboxName 037 * fullname of the mailbox 038 * @return Mailbox object 039 */ 040 public Mailbox getMailbox(long ownerID, String mailboxName); 041 042 /** 043 * Get all child mailboxes of named mailbox. 044 * 045 * @param userID 046 * ID of user who called this method 047 * @param ownerID 048 * ID of user who owns the mailbox 049 * @param mailboxName 050 * fullname of the parent mailbox 051 * @param subscribed 052 * If true, only subscribed mailboxes are returned 053 * @return list of child Mailbox objects 054 */ 055 public List<Mailbox> getChildren(long userID, long ownerID, 056 String mailboxName, boolean subscribed); 057 058 /** 059 * Get the child mailboxes count. 060 * 061 * @param ownerID 062 * ID of the user who owns the mailbox 063 * @param mailboxName 064 * fullname of the parent mailbox 065 * @return total number of child mailboxes 066 */ 067 public int getChildCount(long ownerID, String mailboxName); 068 069 /** 070 * Get the identifiers of mailboxes whose name match the given name. 071 * 072 * @param mailboxName 073 * fullname of the mailboxes to find 074 * @return list of mailbox identifiers 075 */ 076 public List<Long> getMailboxIDList(String mailboxName); 077 078 /** 079 * Get the deleted message's identifiers. 080 * 081 * @param mailboxID 082 * id of the mailbox 083 * @return list of message identifies which has \Delete message flag 084 */ 085 public List<Long> getDeletedMessageIDList(long mailboxID); 086 087 /** 088 * Get the list of physical message identifiers which will be dangling 089 * pointers (pointing messages which are already deleted) after deleting all 090 * the messages owned by the user. 091 * 092 * @param ownerID 093 * ID of the user 094 * @return list of PhysMessage objects 095 */ 096 public List<PhysMessage> getDanglingMessageIDList(long ownerID); 097 098 /** 099 * Get the list of physical message identifiers which will be dangling 100 * pointers (pointing messages which are already deleted) after expunging 101 * the mailbox. 102 * 103 * @param ownerID 104 * ID of the user who owns the mailbox 105 * @param mailboxID 106 * ID of the mailbox 107 * @return list of PhysMessage objects 108 */ 109 public List<PhysMessage> getDanglingMessageIDList(long ownerID, long mailboxID); 110 111 /** 112 * Check whether the mailbox really exists. 113 * 114 * @param ownerID 115 * ID of the user who owns the mailbox 116 * @param mailboxName 117 * fullname of the parent mailbox 118 * @return true if the mailbox exists, otherwise false 119 */ 120 public boolean mailboxExists(long ownerID, String mailboxName); 121 122 /** 123 * Create a mailbox with given name. 124 * 125 * @param ownerID 126 * ID of the user who owns the mailbox 127 * @param mailboxName 128 * fullname of the mailbox to create 129 * @return Mailbox object created 130 */ 131 public Mailbox createMailbox(long ownerID, String mailboxName); 132 133 /** 134 * Rename the mailbox. 135 * 136 * @param source 137 * fullname of the mailbox to rename 138 * @param dest 139 * new name for the mailbox 140 */ 141 public void renameMailbox(Mailbox source, String dest); 142 143 /** 144 * Delete all the mailboxes owned by the user. 145 * 146 * @param ownerID 147 * ID of the user 148 */ 149 public void deleteMailboxes(long ownerID); 150 /** 151 * Delete the mailbox. 152 * 153 * @param ownerID 154 * ID of the user 155 * @param mailboxID 156 * ID of the mailbox 157 */ 158 public void deleteMailbox(long ownerID, long mailboxID); 159 160 /** 161 * Delete all the messages owned by the user. 162 * 163 * @param ownerID 164 * ID of the user 165 */ 166 public void deleteMessages(long ownerID); 167 168 /** 169 * Delete all the messages in the mailbox. 170 * 171 * @param ownerID 172 * ID of the user 173 * @param mailboxID 174 * ID of the mailbox 175 */ 176 public void deleteMessages(long ownerID, long mailboxID); 177 178 /** 179 * Set \Noselect mailbox name attribute. 180 * 181 * @param ownerID 182 * ID of the user 183 * @param mailboxID 184 * ID of the mailbox 185 */ 186 public void forbidSelectMailbox(long ownerID, long mailboxID); 187 188 /** 189 * Check whether the mailbox is subscribed. 190 * 191 * @param userID 192 * ID of the user 193 * @param mailboxID 194 * ID of the mailbox 195 * @return true if the mailbox is subscribed, otherwise false 196 */ 197 public boolean isSubscribed(long userID, String mailboxName); 198 199 /** 200 * Subscribe the mailbox. 201 * 202 * @param userID 203 * ID of the user 204 * @param mailboxID 205 * ID of the mailbox to subscribe 206 */ 207 public void addSubscription(long userID, long mailboxID, String mailboxName); 208 209 /** 210 * Unsubscribe the mailbox. 211 * 212 * @param userID 213 * ID of the user 214 * @param mailboxName 215 * name of the mailbox to unsubscribe 216 */ 217 public void deleteSubscription(long userID, String mailboxName); 218 219 /** 220 * Get the total message count. 221 * 222 * @param mailboxID 223 * ID of the mailbox 224 * @return total number of messages 225 */ 226 public int getMessageCount(long mailboxID); 227 228 /** 229 * Get the recent message count. 230 * 231 * @param mailboxID 232 * ID of the mailbox 233 * @return number of recent messages 234 */ 235 public int getRecentMessageCount(long mailboxID); 236 237 /** 238 * Get the unseen message count. 239 * 240 * @param mailboxID 241 * ID of the mailbox 242 * @return total number of unseen messages 243 */ 244 public int getUnseenMessageCount(long mailboxID); 245 246 /** 247 * Get the message identifier of the first unseen message. 248 * 249 * @param mailboxID 250 * ID of the mailbox. 251 * @return ID of the first unseen message 252 */ 253 public long getFirstUnseenMessageID(long mailboxID); 254 255 }