1 17 18 package org.apache.james.imapserver.commands; 19 20 import org.apache.james.imapserver.AccessControlException; 21 import org.apache.james.imapserver.AuthorizationException; 22 import org.apache.james.imapserver.ImapRequest; 23 import org.apache.james.imapserver.ImapSession; 24 import org.apache.james.imapserver.ImapSessionState; 25 import org.apache.james.imapserver.MailboxException; 26 27 import java.util.StringTokenizer ; 28 import java.util.List ; 29 30 class DeleteCommand extends AuthenticatedSelectedStateCommand 31 { 32 public DeleteCommand() 33 { 34 this.commandName = "DELETE"; 35 36 this.getArgs().add( new AstringArgument( "mailbox" ) ); 37 } 38 39 public boolean doProcess( ImapRequest request, ImapSession session, List argValues ) 40 { 41 String command = this.getCommand(); 42 43 String folder = (String ) argValues.get( 0 ); 44 45 if ( session.getCurrentFolder().equals( folder ) ) { 46 session.noResponse( command, "You can't delete a folder while you have it selected." ); 47 return true; 48 } 49 try { 50 if ( session.getImapHost().deleteMailbox( session.getCurrentUser(), folder ) ) { 51 session.okResponse( command ); 52 } 53 else { 54 session.noResponse( command ); 55 getLogger().info( "Attempt to delete mailbox " + folder 56 + " by user " + session.getCurrentUser() + " failed." ); 57 } 58 if ( session.getState() == ImapSessionState.SELECTED ) { 59 session.checkSize(); 60 session.checkExpunge(); 61 } 62 return true; 63 } 64 catch ( MailboxException mbe ) { 65 session.noResponse( command, mbe.getMessage() ); 66 return true; 67 } 68 catch ( AuthorizationException aze ) { 69 session.noResponse( command, "You do not have the rights to delete mailbox: " + folder ); 70 session.logAZE( aze ); 71 return true; 72 } 73 catch ( AccessControlException ace ) { 74 session.noResponse( command, ace.getMessage() ); 75 session.logACE( ace ); 76 return true; 77 } 78 } 79 } 80 | Popular Tags |