1 17 18 package org.apache.james.fetchmail; 19 20 import java.util.List ; 21 import java.util.Set ; 22 23 import javax.mail.MessagingException ; 24 import javax.mail.Session ; 25 26 import org.apache.avalon.framework.logger.Logger; 27 import org.apache.james.services.MailServer; 28 import org.apache.mailet.MailAddress; 29 import org.apache.james.services.UsersRepository; 30 31 47 abstract public class ProcessorAbstract 48 { 49 52 private String fieldAttributePrefix; 53 54 57 private Account fieldAccount; 58 59 62 private ProcessorAbstract() 63 { 64 super(); 65 } 66 67 71 protected ProcessorAbstract(Account account) 72 { 73 this(); 74 setAccount(account); 75 } 76 77 81 protected String getDefaultDomainName() 82 { 83 return getConfiguration().getDefaultDomainName(); 84 } 85 86 91 protected List getDeferredRecipientNotFoundMessageIDs() 92 { 93 return getAccount().getDeferredRecipientNotFoundMessageIDs(); 94 } 95 96 100 protected String getFetchTaskName() 101 { 102 return getConfiguration().getFetchTaskName(); 103 } 104 105 106 110 protected String getHost() 111 { 112 return getConfiguration().getHost(); 113 } 114 115 116 120 protected String getJavaMailFolderName() 121 { 122 return getConfiguration().getJavaMailFolderName(); 123 } 124 125 126 127 131 protected String getJavaMailProviderName() 132 { 133 return getConfiguration().getJavaMailProviderName(); 134 } 135 136 137 138 142 protected Logger getLogger() 143 { 144 return getConfiguration().getLogger(); 145 } 146 147 148 152 protected String getPassword() 153 { 154 return getAccount().getPassword(); 155 } 156 157 158 162 protected MailAddress getRecipient() 163 { 164 return getAccount().getRecipient(); 165 } 166 167 171 protected int getRemoteReceivedHeaderIndex() 172 { 173 return getConfiguration().getRemoteReceivedHeaderIndex(); 174 } 175 176 177 181 protected MailServer getServer() 182 { 183 return getConfiguration().getServer(); 184 } 185 186 190 protected Session getSession() 191 { 192 return getAccount().getSession(); 193 } 194 195 199 protected UsersRepository getLocalUsers() 200 { 201 return getConfiguration().getLocalUsers(); 202 } 203 204 205 209 protected String getUser() 210 { 211 return getAccount().getUser(); 212 } 213 214 215 219 protected boolean isFetchAll() 220 { 221 return getConfiguration().isFetchAll(); 222 } 223 224 225 229 protected boolean isDeferRecipientNotFound() 230 { 231 return getConfiguration().isDeferRecipientNotFound(); 232 } 233 234 238 protected boolean isIgnoreRecipientHeader() 239 { 240 return getAccount().isIgnoreRecipientHeader(); 241 } 242 243 244 248 protected boolean isLeave() 249 { 250 return getConfiguration().isLeave(); 251 } 252 253 254 258 protected boolean isMarkSeen() 259 { 260 return getConfiguration().isMarkSeen(); 261 } 262 263 267 protected boolean isLeaveBlacklisted() 268 { 269 return getConfiguration().isLeaveBlacklisted(); 270 } 271 272 276 protected boolean isLeaveRemoteRecipient() 277 { 278 return getConfiguration().isLeaveRemoteRecipient(); 279 } 280 281 285 protected boolean isLeaveUserUndefined() 286 { 287 return getConfiguration().isLeaveUserUndefined(); 288 } 289 290 294 protected boolean isLeaveRemoteReceivedHeaderInvalid() 295 { 296 return getConfiguration().isLeaveRemoteReceivedHeaderInvalid(); 297 } 298 299 303 protected boolean isLeaveMaxMessageSizeExceeded() 304 { 305 return getConfiguration().isLeaveMaxMessageSizeExceeded(); 306 } 307 308 312 protected boolean isLeaveUndeliverable() 313 { 314 return getConfiguration().isLeaveUndeliverable(); 315 } 316 317 321 protected boolean isRejectUserUndefined() 322 { 323 return getConfiguration().isRejectUserUndefined(); 324 } 325 326 330 protected boolean isRejectRemoteReceivedHeaderInvalid() 331 { 332 return getConfiguration().isRejectRemoteReceivedHeaderInvalid(); 333 } 334 335 339 protected boolean isRejectMaxMessageSizeExceeded() 340 { 341 return getConfiguration().isRejectMaxMessageSizeExceeded(); 342 } 343 344 348 protected boolean isRejectBlacklisted() 349 { 350 return getConfiguration().isRejectBlacklisted(); 351 } 352 353 357 protected boolean isRejectRemoteRecipient() 358 { 359 return getConfiguration().isRejectRemoteRecipient(); 360 } 361 362 366 protected boolean isMarkBlacklistedSeen() 367 { 368 return getConfiguration().isMarkBlacklistedSeen(); 369 } 370 371 375 protected boolean isMarkRecipientNotFoundSeen() 376 { 377 return getConfiguration().isMarkRecipientNotFoundSeen(); 378 } 379 380 384 protected boolean isLeaveRecipientNotFound() 385 { 386 return getConfiguration().isLeaveRecipientNotFound(); 387 } 388 389 393 protected boolean isRejectRecipientNotFound() 394 { 395 return getConfiguration().isRejectRecipientNotFound(); 396 } 397 398 402 protected boolean isMarkRemoteRecipientSeen() 403 { 404 return getConfiguration().isMarkRemoteRecipientSeen(); 405 } 406 407 411 protected boolean isMarkUserUndefinedSeen() 412 { 413 return getConfiguration().isMarkUserUndefinedSeen(); 414 } 415 416 420 protected boolean isMarkRemoteReceivedHeaderInvalidSeen() 421 { 422 return getConfiguration().isMarkRemoteReceivedHeaderInvalidSeen(); 423 } 424 425 429 protected boolean isMarkMaxMessageSizeExceededSeen() 430 { 431 return getConfiguration().isMarkMaxMessageSizeExceededSeen(); 432 } 433 434 438 protected boolean isMarkUndeliverableSeen() 439 { 440 return getConfiguration().isMarkUndeliverableSeen(); 441 } 442 443 450 protected boolean isOpenReadOnly() 451 { 452 return getConfiguration().isOpenReadOnly(); 453 } 454 455 456 460 protected boolean isRecurse() 461 { 462 return getConfiguration().isRecurse(); 463 } 464 465 466 467 468 471 abstract public void process() throws MessagingException ; 472 473 477 protected Set getBlacklist() 478 { 479 return getConfiguration().getBlacklist(); 480 } 481 482 486 protected ParsedConfiguration getConfiguration() 487 { 488 return getAccount().getParsedConfiguration(); 489 } 490 491 495 protected String getAttributePrefix() 496 { 497 String value = null; 498 if (null == (value = getAttributePrefixBasic())) 499 { 500 updateAttributePrefix(); 501 return getAttributePrefix(); 502 } 503 return value; 504 } 505 506 510 private String getAttributePrefixBasic() 511 { 512 return fieldAttributePrefix; 513 } 514 515 519 protected String computeAttributePrefix() 520 { 521 return getClass().getPackage().getName() + "."; 522 } 523 524 528 protected void setAttributePrefix(String attributePrefix) 529 { 530 fieldAttributePrefix = attributePrefix; 531 } 532 533 536 protected void updateAttributePrefix() 537 { 538 setAttributePrefix(computeAttributePrefix()); 539 } 540 541 545 public Account getAccount() 546 { 547 return fieldAccount; 548 } 549 550 554 protected void setAccount(Account account) 555 { 556 fieldAccount = account; 557 } 558 559 563 protected int getMaxMessageSizeLimit() 564 { 565 return getConfiguration().getMaxMessageSizeLimit(); 566 } 567 568 } 569 | Popular Tags |