Response[] r = protocol.command("FETCH", args); Response response = r[r.length - 1]; if (response.isOK()) { Properties props = new Properties(); props.setProperty("mail.store.protocol", "imap");
/** * CAPABILITY command. * * @exception ProtocolException for protocol failures * @see "RFC2060, section 6.1.1" */ public void capability() throws ProtocolException { // Check CAPABILITY Response[] r = command("CAPABILITY", null); Response response = r[r.length-1]; if (response.isOK()) handleCapabilityResponse(r); handleResult(response); }
/** * Handle the result response for a LOGIN or AUTHENTICATE command. * Look for IMAP login REFERRAL. * * @param r the response * @exception ProtocolException for protocol failures * @since JavaMail 1.5.5 */ protected void handleLoginResult(Response r) throws ProtocolException { if (hasCapability("LOGIN-REFERRALS") && (!r.isOK() || referralException)) checkReferral(r); handleResult(r); }
/** * Handle the result response for a LOGIN or AUTHENTICATE command. * Look for IMAP login REFERRAL. * * @param r the response * @exception ProtocolException for protocol failures * @since JavaMail 1.5.5 */ protected void handleLoginResult(Response r) throws ProtocolException { if (hasCapability("LOGIN-REFERRALS") && (!r.isOK() || referralException)) checkReferral(r); handleResult(r); }
/** * CAPABILITY command. * * @exception ProtocolException for protocol failures * @see "RFC2060, section 6.1.1" */ public void capability() throws ProtocolException { // Check CAPABILITY Response[] r = command("CAPABILITY", null); Response response = r[r.length-1]; if (response.isOK()) { capabilities = new HashMap<String, String>(10); authmechs = new ArrayList<String>(5); for (int i = 0, len = r.length; i < len; i++) { if (!(r[i] instanceof IMAPResponse)) continue; IMAPResponse ir = (IMAPResponse)r[i]; // Handle *all* untagged CAPABILITY responses. // Though the spec seemingly states that only // one CAPABILITY response string is allowed (6.1.1), // some server vendors claim otherwise. if (ir.keyEquals("CAPABILITY")) parseCapabilities(ir); } } handleResult(response); }
/** * If the response contains an APPENDUID response code, extract * it and return an AppendUID object with the information. */ private AppendUID getAppendUID(Response r) { if (!r.isOK()) return null; byte b; while ((b = r.readByte()) > 0 && b != (byte)'[') ; if (b == 0) return null; String s; s = r.readAtom(); if (!s.equalsIgnoreCase("APPENDUID")) return null; long uidvalidity = r.readLong(); long uid = r.readLong(); return new AppendUID(uidvalidity, uid); }
/** * If the response contains an APPENDUID response code, extract * it and return an AppendUID object with the information. */ private AppendUID getAppendUID(Response r) { if (!r.isOK()) return null; byte b; while ((b = r.readByte()) > 0 && b != (byte)'[') ; if (b == 0) return null; String s; s = r.readAtom(); if (!s.equalsIgnoreCase("APPENDUID")) return null; long uidvalidity = r.readLong(); long uid = r.readLong(); return new AppendUID(uidvalidity, uid); }
public void handleResponse(Response r) { // Any of these responses may have a response code. if (r.isOK() || r.isNO() || r.isBAD() || r.isBYE()) handleResponseCode(r); if (r.isBYE()) logger.fine("IMAPStore non-store connection dead"); } };
@Override public void handleResponse(Response r) { // Any of these responses may have a response code. if (r.isOK() || r.isNO() || r.isBAD() || r.isBYE()) handleResponseCode(r); if (r.isBYE()) logger.fine("IMAPStore non-store connection dead"); } };
/** * Fetch the BODYSTRUCTURE of the specified message. * * @param msgno the message number * @return the BODYSTRUCTURE item * @exception ProtocolException for protocol failures */ public BODYSTRUCTURE fetchBodyStructure(int msgno) throws ProtocolException { Response[] r = fetch(msgno, "BODYSTRUCTURE"); notifyResponseHandlers(r); Response response = r[r.length-1]; if (response.isOK()) return FetchResponse.getItem(r, msgno, BODYSTRUCTURE.class); else if (response.isNO()) return null; else { handleResult(response); return null; } }
/** * Fetch the IMAP UID for the given message. * * @param msgno the message number * @return the UID * @exception ProtocolException for protocol failures */ public UID fetchUID(int msgno) throws ProtocolException { Response[] r = fetch(msgno, "UID"); // dispatch untagged responses notifyResponseHandlers(r); Response response = r[r.length-1]; if (response.isOK()) return FetchResponse.getItem(r, msgno, UID.class); else if (response.isNO()) // XXX: Issue NOOP ? return null; else { handleResult(response); return null; // NOTREACHED } }
/** * Fetch the IMAP MODSEQ for the given message. * * @param msgno the message number * @return the MODSEQ * @exception ProtocolException for protocol failures * @since JavaMail 1.5.1 */ public MODSEQ fetchMODSEQ(int msgno) throws ProtocolException { Response[] r = fetch(msgno, "MODSEQ"); // dispatch untagged responses notifyResponseHandlers(r); Response response = r[r.length-1]; if (response.isOK()) return FetchResponse.getItem(r, msgno, MODSEQ.class); else if (response.isNO()) // XXX: Issue NOOP ? return null; else { handleResult(response); return null; // NOTREACHED } }
/** * Fetch the IMAP UID for the given message. * * @param msgno the message number * @return the UID * @exception ProtocolException for protocol failures */ public UID fetchUID(int msgno) throws ProtocolException { Response[] r = fetch(msgno, "UID"); // dispatch untagged responses notifyResponseHandlers(r); Response response = r[r.length-1]; if (response.isOK()) return FetchResponse.getItem(r, msgno, UID.class); else if (response.isNO()) // XXX: Issue NOOP ? return null; else { handleResult(response); return null; // NOTREACHED } }
/** * Fetch the BODYSTRUCTURE of the specified message. * * @param msgno the message number * @return the BODYSTRUCTURE item * @exception ProtocolException for protocol failures */ public BODYSTRUCTURE fetchBodyStructure(int msgno) throws ProtocolException { Response[] r = fetch(msgno, "BODYSTRUCTURE"); notifyResponseHandlers(r); Response response = r[r.length-1]; if (response.isOK()) return FetchResponse.getItem(r, msgno, BODYSTRUCTURE.class); else if (response.isNO()) return null; else { handleResult(response); return null; } }
/** * Fetch the IMAP MODSEQ for the given message. * * @param msgno the message number * @return the MODSEQ * @exception ProtocolException for protocol failures * @since JavaMail 1.5.1 */ public MODSEQ fetchMODSEQ(int msgno) throws ProtocolException { Response[] r = fetch(msgno, "MODSEQ"); // dispatch untagged responses notifyResponseHandlers(r); Response response = r[r.length-1]; if (response.isOK()) return FetchResponse.getItem(r, msgno, MODSEQ.class); else if (response.isNO()) // XXX: Issue NOOP ? return null; else { handleResult(response); return null; // NOTREACHED } }
/** * Fetch the specified RFC822 Data item. 'what' names * the item to be fetched. 'what' can be <code>null</code> * to fetch the whole message. * * @param msgno the message number * @param what the item to fetch * @return the RFC822DATA item * @exception ProtocolException for protocol failures */ public RFC822DATA fetchRFC822(int msgno, String what) throws ProtocolException { Response[] r = fetch(msgno, what == null ? "RFC822" : "RFC822." + what ); // dispatch untagged responses notifyResponseHandlers(r); Response response = r[r.length-1]; if (response.isOK()) return FetchResponse.getItem(r, msgno, RFC822DATA.class); else if (response.isNO()) return null; else { handleResult(response); return null; } }
/** * Convenience routine to handle OK, NO, BAD and BYE responses. * * @param response the response * @exception ProtocolException for protocol failures */ public void handleResult(Response response) throws ProtocolException { if (response.isOK()) return; else if (response.isNO()) throw new CommandFailedException(response); else if (response.isBAD()) throw new BadCommandException(response); else if (response.isBYE()) { disconnect(); throw new ConnectionException(this, response); } }
/** * Convenience routine to handle OK, NO, BAD and BYE responses. * * @param response the response * @exception ProtocolException for protocol failures */ public void handleResult(Response response) throws ProtocolException { if (response.isOK()) return; else if (response.isNO()) throw new CommandFailedException(response); else if (response.isBAD()) throw new BadCommandException(response); else if (response.isBYE()) { disconnect(); throw new ConnectionException(this, response); } }
/** * Response handler method. */ public void handleResponse(Response r) { // Any of these responses may have a response code. if (r.isOK() || r.isNO() || r.isBAD() || r.isBYE()) handleResponseCode(r); if (r.isBYE()) { logger.fine("IMAPStore connection dead"); // Store's IMAP connection is dead, save the response so that // releaseStoreProtocol will cleanup later. synchronized (connectionFailedLock) { connectionFailed = true; if (r.isSynthetic()) forceClose = true; } return; } }
/** * Response handler method. */ @Override public void handleResponse(Response r) { // Any of these responses may have a response code. if (r.isOK() || r.isNO() || r.isBAD() || r.isBYE()) handleResponseCode(r); if (r.isBYE()) { logger.fine("IMAPStore connection dead"); // Store's IMAP connection is dead, save the response so that // releaseStoreProtocol will cleanup later. synchronized (connectionFailedLock) { connectionFailed = true; if (r.isSynthetic()) forceClose = true; } return; } }