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.*; 23 24 import java.util.StringTokenizer ; 25 import java.util.List ; 26 27 32 33 class CreateCommand extends AuthenticatedSelectedStateCommand 34 { 35 public CreateCommand() 36 { 37 this.commandName = "CREATE"; 38 this.getArgs().add( new AstringArgument( "mailbox" ) ); 39 } 40 41 protected boolean doProcess( ImapRequest request, ImapSession session, List argValues ) 42 { 43 String command = this.commandName; 44 String folder = (String ) argValues.get( 0 ); 45 46 try { 47 if ( session.getCurrentFolder() == folder ) { 48 session.noResponse( command, "Folder exists and is selected." ); 49 return true; 50 } 51 System.out.println("CreteCommand FOLDERNAME: "+folder); 52 ACLMailbox target = session.getImapHost().createMailbox( session.getCurrentUser(), folder ); 53 session.okResponse( command ); 54 session.getImapHost().releaseMailbox( session.getCurrentUser(), target ); 55 } 56 catch ( AccessControlException ace ) { 57 session.noResponse( command, "No such mailbox." ); 58 session.logACE( ace ); 59 return true; 60 } 61 catch ( MailboxException mbe ) { 62 if ( mbe.isRemote() ) { 63 session.noResponse( "[REFERRAL " 64 + mbe.getRemoteServer() + "]" 65 + SP + "Wrong server. Try remote." ); 66 } 67 else { 68 session.noResponse( mbe.getStatus() ); 69 } 70 return true; 71 } 72 catch ( AuthorizationException aze ) { 73 session.noResponse( command, "You do not have the rights to create mailbox: " 74 + folder ); 75 return true; 76 } 77 if ( session.getState() == ImapSessionState.SELECTED ) { 78 session.checkSize(); 79 session.checkExpunge(); 80 } 81 return true; 82 } 83 } 84 | Popular Tags |