referenceRoot = "";
removeUserPrefix = true;
}
// Get the mailbox for the reference name.
ImapMailbox referenceMailbox = getMailbox( referenceRoot, session, false );
// If it doesn't exist, act as though "" was passed for reference name.
if ( referenceMailbox == null )
{
referenceMailbox = getMailbox( "", session, true );
removeUserPrefix = true;
}
mailboxes = new ArrayList( 1 );
mailboxes.add( referenceMailbox );
}
else {
String searchPattern;
// If the mailboxPattern is fully qualified, ignore the
// reference name.
if ( mailboxPattern.charAt( 0 ) == NAMESPACE_PREFIX_CHAR ) {
searchPattern = mailboxPattern;
}
else {
searchPattern = combineSearchTerms( referenceName, mailboxPattern );
}
// If the search pattern is relative, need to remove user prefix from results.
removeUserPrefix = ( searchPattern.charAt(0) != NAMESPACE_PREFIX_CHAR );
mailboxes = doList( session, searchPattern );
}
String personalNamespace = USER_NAMESPACE + HIERARCHY_DELIMITER_CHAR +
session.getUser().getUserName();
int prefixLength = personalNamespace.length();
Iterator iterator = mailboxes.iterator();
while ( iterator.hasNext() ) {
ImapMailbox mailbox = ( ImapMailbox ) iterator.next();
StringBuffer message = new StringBuffer( "(" );
if ( !mailbox.isSelectable() ) {
message.append( "\\Noselect" );
}
message.append( ") \"" );
message.append( HIERARCHY_DELIMITER_CHAR );
message.append( "\" " );
String mailboxName = mailbox.getFullName();
if ( removeUserPrefix ) {
if ( mailboxName.length() <= prefixLength ) {
mailboxName = "";
}
else {