private void waitIfIdle() throws ProtocolException { assert Thread.holdsLock(pool); while (pool.idleState != ConnectionPool.RUNNING) { if (pool.idleState == ConnectionPool.IDLE) { pool.idleProtocol.idleAbort(); pool.idleState = ConnectionPool.ABORTING; } try { // give up lock and wait to be not idle pool.wait(); } catch (InterruptedException ex) { // If someone is trying to interrupt us we can't keep going // around the loop waiting for IDLE to complete, but we can't // just return because callers expect the idleState to be // RUNNING when we return. Throwing this exception seems // like the best choice. throw new ProtocolException("Interrupted waitIfIdle", ex); } } }
private void waitIfIdle() throws ProtocolException { assert Thread.holdsLock(pool); while (pool.idleState != ConnectionPool.RUNNING) { if (pool.idleState == ConnectionPool.IDLE) { pool.idleProtocol.idleAbort(); pool.idleState = ConnectionPool.ABORTING; } try { // give up lock and wait to be not idle pool.wait(); } catch (InterruptedException ex) { // If someone is trying to interrupt us we can't keep going // around the loop waiting for IDLE to complete, but we can't // just return because callers expect the idleState to be // RUNNING when we return. Throwing this exception seems // like the best choice. throw new ProtocolException("Interrupted waitIfIdle", ex); } } }
throw new ProtocolException("Missing '(' at start of ID"); String name = v[i]; if (name == null) throw new ProtocolException("ID field name null"); if (i + 1 >= v.length) throw new ProtocolException("ID field without value: " + name); String value = v[i + 1];
throw new ProtocolException("Missing '(' at start of ID"); String name = v[i]; if (name == null) throw new ProtocolException("ID field name null"); if (i + 1 >= v.length) throw new ProtocolException("ID field without value: " + name); String value = v[i + 1];
/** * Parse out one of the three sets of namespaces. */ private Namespace[] getNamespaces(Response r) throws ProtocolException { // Namespace = nil / "(" 1*( Namespace_Element) ")" if (r.isNextNonSpace('(')) { List<Namespace> v = new ArrayList<>(); do { Namespace ns = new Namespace(r); v.add(ns); } while (!r.isNextNonSpace(')')); return v.toArray(new Namespace[v.size()]); } else { String s = r.readAtom(); if (s == null) throw new ProtocolException("Expected NIL, got null"); if (!s.equalsIgnoreCase("NIL")) throw new ProtocolException("Expected NIL, got " + s); return null; } } }
/** * Parse out one of the three sets of namespaces. */ private Namespace[] getNamespaces(Response r) throws ProtocolException { r.skipSpaces(); // Namespace = nil / "(" 1*( Namespace_Element) ")" if (r.peekByte() == '(') { List<Namespace> v = new ArrayList<Namespace>(); r.readByte(); do { Namespace ns = new Namespace(r); v.add(ns); } while (r.peekByte() != ')'); r.readByte(); return v.toArray(new Namespace[v.size()]); } else { String s = r.readAtom(); if (s == null) throw new ProtocolException("Expected NIL, got null"); if (!s.equalsIgnoreCase("NIL")) throw new ProtocolException("Expected NIL, got " + s); return null; } } }
throw new ProtocolException("Interrupted waitIfIdle", ex);
throw new ProtocolException("Interrupted waitIfIdle", ex);
throw new ProtocolException( "Missing '(' at start of Namespace"); delimiter = (char)r.readByte(); if (r.readByte() != '"') throw new ProtocolException( "Missing '\"' at end of QUOTED_CHAR"); } else { String s = r.readAtom(); if (s == null) throw new ProtocolException("Expected NIL, got null"); if (!s.equalsIgnoreCase("NIL")) throw new ProtocolException("Expected NIL, got " + s); delimiter = 0; throw new ProtocolException("Missing ')' at end of Namespace");
public Object doCommand(IMAPProtocol p) throws ProtocolException { if ((type & HOLDS_MESSAGES) == 0) // only holds folders p.create(fullName + sep); else { p.create(fullName); // Certain IMAP servers do not allow creation of folders // that can contain messages *and* subfolders. So, if we // were asked to create such a folder, we should verify // that we could indeed do so. if ((type & HOLDS_FOLDERS) != 0) { // we want to hold subfolders and messages. Check // whether we could create such a folder. ListInfo[] li = p.list("", fullName); if (li != null && !li[0].hasInferiors) { // Hmm ..the new folder // doesn't support Inferiors ? Fail p.delete(fullName); throw new ProtocolException("Unsupported type"); } } } return Boolean.TRUE; } });
throw new ProtocolException( "Missing '(' at start of Namespace"); delimiter = (char)r.readByte(); if (r.readByte() != '"') throw new ProtocolException( "Missing '\"' at end of QUOTED_CHAR"); } else { String s = r.readAtom(); if (s == null) throw new ProtocolException("Expected NIL, got null"); if (!s.equalsIgnoreCase("NIL")) throw new ProtocolException("Expected NIL, got " + s); delimiter = 0; r.readStringList(); if (!r.isNextNonSpace(')')) throw new ProtocolException("Missing ')' at end of Namespace");
@Override public Object doCommand(IMAPProtocol p) throws ProtocolException { if ((type & HOLDS_MESSAGES) == 0) // only holds folders p.create(fullName + sep); else { p.create(fullName); // Certain IMAP servers do not allow creation of folders // that can contain messages *and* subfolders. So, if we // were asked to create such a folder, we should verify // that we could indeed do so. if ((type & HOLDS_FOLDERS) != 0) { // we want to hold subfolders and messages. Check // whether we could create such a folder. ListInfo[] li = p.list("", fullName); if (li != null && !li[0].hasInferiors) { // Hmm ..the new folder // doesn't support Inferiors ? Fail p.delete(fullName); throw new ProtocolException("Unsupported type"); } } } return Boolean.TRUE; } });
socket.getOutputStream(), def, true), traceLogger); } catch (Exception ex) { throw new ProtocolException("can't create deflater", ex);
throw new ProtocolException("No login methods supported!");
throw new ProtocolException("Unsupported type");
throw new ProtocolException("Unsupported type");
/** * STARTTLS Command. * * @exception ProtocolException for protocol failures * @see "RFC3501, section 6.2.1" */ public void startTLS() throws ProtocolException { try { super.startTLS("STARTTLS"); } catch (ProtocolException pex) { logger.log(Level.FINE, "STARTTLS ProtocolException", pex); // ProtocolException just means the command wasn't recognized, // or failed. This should never happen if we check the // CAPABILITY first. throw pex; } catch (Exception ex) { logger.log(Level.FINE, "STARTTLS Exception", ex); // any other exception means we have to shut down the connection // generate an artificial BYE response and disconnect Response[] r = { Response.byeResponse(ex) }; notifyResponseHandlers(r); disconnect(); throw new ProtocolException("STARTTLS failure", ex); } }
/** * COMPRESS Command. Only supports DEFLATE. * * @exception ProtocolException for protocol failures * @see "RFC 4978" */ public void compress() throws ProtocolException { try { super.startCompression("COMPRESS DEFLATE"); } catch (ProtocolException pex) { logger.log(Level.FINE, "COMPRESS ProtocolException", pex); // ProtocolException just means the command wasn't recognized, // or failed. This should never happen if we check the // CAPABILITY first. throw pex; } catch (Exception ex) { logger.log(Level.FINE, "COMPRESS Exception", ex); // any other exception means we have to shut down the connection // generate an artificial BYE response and disconnect Response[] r = { Response.byeResponse(ex) }; notifyResponseHandlers(r); disconnect(); throw new ProtocolException("COMPRESS failure", ex); } }
/** * STARTTLS Command. * * @exception ProtocolException for protocol failures * @see "RFC3501, section 6.2.1" */ public void startTLS() throws ProtocolException { try { super.startTLS("STARTTLS"); } catch (ProtocolException pex) { logger.log(Level.FINE, "STARTTLS ProtocolException", pex); // ProtocolException just means the command wasn't recognized, // or failed. This should never happen if we check the // CAPABILITY first. throw pex; } catch (Exception ex) { logger.log(Level.FINE, "STARTTLS Exception", ex); // any other exception means we have to shut down the connection // generate an artificial BYE response and disconnect Response[] r = { Response.byeResponse(ex) }; notifyResponseHandlers(r); disconnect(); throw new ProtocolException("STARTTLS failure", ex); } }
/** * COMPRESS Command. Only supports DEFLATE. * * @exception ProtocolException for protocol failures * @see "RFC 4978" */ public void compress() throws ProtocolException { try { super.startCompression("COMPRESS DEFLATE"); } catch (ProtocolException pex) { logger.log(Level.FINE, "COMPRESS ProtocolException", pex); // ProtocolException just means the command wasn't recognized, // or failed. This should never happen if we check the // CAPABILITY first. throw pex; } catch (Exception ex) { logger.log(Level.FINE, "COMPRESS Exception", ex); // any other exception means we have to shut down the connection // generate an artificial BYE response and disconnect Response[] r = { Response.byeResponse(ex) }; notifyResponseHandlers(r); disconnect(); throw new ProtocolException("COMPRESS failure", ex); } }