1 17 18 package org.apache.james.imapserver.commands; 19 20 import org.apache.james.imapserver.AccessControlException; 21 import org.apache.james.imapserver.ImapRequest; 22 import org.apache.james.imapserver.ImapSession; 23 import org.apache.james.imapserver.ImapSessionState; 24 import org.apache.james.imapserver.MailboxException; 25 26 import java.util.StringTokenizer ; 27 import java.util.List ; 28 29 class SubscribeCommand extends AuthenticatedSelectedStateCommand 30 { 31 public SubscribeCommand() 32 { 33 this.commandName = "SUBSCRIBE"; 34 35 this.getArgs().add( new AstringArgument( "mailbox" ) ); 36 } 37 38 protected boolean doProcess( ImapRequest request, ImapSession session, List argValues ) 39 { 40 String command = this.getCommand(); 41 42 String folder = (String ) argValues.get( 0 ); 43 44 try { 45 if ( session.getImapHost().subscribe( session.getCurrentUser(), folder ) ) { 46 session.okResponse( command ); 47 } 48 else { 49 session.noResponse( command ); 50 } 51 } 52 catch ( MailboxException mbe ) { 53 if ( mbe.isRemote() ) { 54 session.noResponse( command, "[REFERRAL " 55 + mbe.getRemoteServer() + "]" 56 + SP + "Wrong server. Try remote." ); 57 } 58 else { 59 session.noResponse( command, "No such mailbox" ); 60 } 61 return true; 62 } 63 catch ( AccessControlException ace ) { 64 session.noResponse( command, "No such mailbox" ); 65 session.logACE( ace ); 66 return true; 67 } 68 if ( session.getState() == ImapSessionState.SELECTED ) { 69 session.checkSize(); 70 session.checkExpunge(); 71 } 72 return true; 73 } 74 } 75 | Popular Tags |