/** * Template methods for handling command processing. This method reads * argument values (validating them), and checks the request for correctness. * If correct, the command processing is delegated to the specific command * implementation. * * @see ImapCommand#process */ @Override public void process(ImapRequestLineReader request, ImapResponse response, ImapSession session) { try { doProcess(request, response, session); } catch (FolderException e) { log.warn("Error processing command", e); response.commandFailed(this, e.getResponseCode(), e.getMessage()); } catch (AuthorizationException e) { log.warn("Error processing command due to authentication", e); String msg = "Authorization error: Lacking permissions to perform requested operation."; response.commandFailed(this, msg); } catch (ProtocolException e) { String msg = e.getMessage() + " Command should be '" + getExpectedMessage() + '\''; log.warn("Error processing command: {}", msg, e); response.commandError(msg); } }
@Override protected void doProcess(final ImapRequestLineReader request, final ImapResponse response, final ImapSession session) { if(!session.getHost().getStore().isQuotaSupported()) { response.commandFailed(this,"Quota is not supported. Activate quota capability first"); } try { String root = parser.mailbox(request); Quota quota = new Quota(root); parser.consumeChar(request, ' '); parser.consumeChar(request, '('); quota.setResourceLimit(parser.astring(request), parser.consumeLong(request)); char c =request.nextWordChar(); if(')' != c) { quota.setResourceLimit(parser.astring(request), parser.consumeLong(request)); } parser.consumeChar(request, ')'); session.getHost().getStore().setQuota( quota, session.getUser().getQualifiedMailboxName()); response.commandComplete(this); } catch (ProtocolException e) { response.commandFailed(this, "Can not parse command"+e.getMessage()); } } }