Index: sandbox/expresso-solr/imapCrawler/SRC/JUserCrawler4IMAP/.classpath
===================================================================
--- sandbox/expresso-solr/imapCrawler/SRC/JUserCrawler4IMAP/.classpath	(revision 8056)
+++ sandbox/expresso-solr/imapCrawler/SRC/JUserCrawler4IMAP/.classpath	(revision 8056)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+	<classpathentry kind="lib" path="lib/apache-solr-analysis-extras-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/apache-solr-cell-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/apache-solr-clustering-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/apache-solr-core-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/apache-solr-dataimporthandler-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/apache-solr-dataimporthandler-extras-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/apache-solr-langid-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/apache-solr-solrj-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/apache-solr-test-framework-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/apache-solr-uima-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/apache-solr-velocity-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/commons-codec-1.6.jar"/>
+	<classpathentry kind="lib" path="lib/commons-io-2.1.jar"/>
+	<classpathentry kind="lib" path="lib/httpclient-4.1.3.jar"/>
+	<classpathentry kind="lib" path="lib/httpcore-4.1.4.jar"/>
+	<classpathentry kind="lib" path="lib/httpmime-4.1.3.jar"/>
+	<classpathentry kind="lib" path="lib/jcl-over-slf4j-1.6.4.jar"/>
+	<classpathentry kind="lib" path="lib/ldapjdbc.jar"/>
+	<classpathentry kind="lib" path="lib/mail.jar"/>
+	<classpathentry kind="lib" path="lib/slf4j-api-1.6.4.jar"/>
+	<classpathentry kind="lib" path="lib/wstx-asl-3.2.7.jar"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
Index: sandbox/expresso-solr/imapCrawler/SRC/JUserCrawler4IMAP/.project
===================================================================
--- sandbox/expresso-solr/imapCrawler/SRC/JUserCrawler4IMAP/.project	(revision 8056)
+++ sandbox/expresso-solr/imapCrawler/SRC/JUserCrawler4IMAP/.project	(revision 8056)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>JUserCrawler4IMAP</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>
Index: sandbox/expresso-solr/imapCrawler/SRC/JUserCrawler4IMAP/src/pkg/crawler/main/Main.java
===================================================================
--- sandbox/expresso-solr/imapCrawler/SRC/JUserCrawler4IMAP/src/pkg/crawler/main/Main.java	(revision 8056)
+++ sandbox/expresso-solr/imapCrawler/SRC/JUserCrawler4IMAP/src/pkg/crawler/main/Main.java	(revision 8056)
@@ -0,0 +1,68 @@
+package pkg.crawler.main;
+
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.net.Socket;
+import java.net.UnknownHostException;
+
+import javax.mail.MessagingException;
+
+import pkg.crawler.data.conn.Crawler;
+
+public class Main {
+
+	/**
+	 * @param args
+	 */
+	public static void main(String[] args) {
+		// TODO Auto-generated method stub
+		if (args == null || args.length != 4){
+			System.out.println("Uso:\n" +
+					"java -jar crawler.jar [imap_host] [imap_admin_password] " +
+					"[imap_user_folder] [http_solr_host_address] \n" +
+					"imap_host - O endereÃ§o que estÃ¡ instalado o Expresso Ex: \"127.1.1.1\"\n" +
+					"imap_admin_password - Senha do usuÃ¡rio 'expresso-admin' Ex: \"admin123\"\n" +
+					"http_solr_host_address - EndereÃ§o do servidor do Solr Ex: \"http://127.1.1.1:8983/solr/\"\n" +
+					" ");
+			System.exit(0);
+		}
+		
+//		String host, String user, String password, String imapFINBOXAux, String hostSolr
+		
+		//O endereÃ§o que estÃ¡ instalado o Expresso Ex: "127.1.1.1"
+		String host = args[0];
+		//Pasta do usuÃ¡rio do IMAP
+		String imapFINBOXAux = args[1];
+		//Senha do usuÃ¡rio 'expresso-admin' Ex: "admin123"
+		String password = args[2];
+		//EndereÃ§o do servidor do Solr Ex: "http://127.1.1.1:8983/solr/"
+		String hostSolr = args[3];
+		
+		try {
+			Crawler crawler = new Crawler(host, "expresso-admin", password, imapFINBOXAux, hostSolr);
+			crawler.run();
+		} catch (MessagingException e) {
+			// TODO Auto-generated catch block
+			Socket client = null;
+			ObjectOutputStream oos = null;
+			try {
+				client = new Socket("127.1.1.1", 8090);
+				
+				oos = new ObjectOutputStream(client.getOutputStream());
+				
+				oos.writeObject(imapFINBOXAux);
+				
+				oos.close();
+				
+				client.close();
+			} catch (UnknownHostException ee) {
+				e.printStackTrace();
+			} catch (IOException ee) {
+				e.printStackTrace();
+			}
+			e.printStackTrace();
+		}
+		
+	}
+
+}
Index: sandbox/expresso-solr/imapCrawler/SRC/JUserCrawler4IMAP/src/pkg/crawler/data/conn/Crawler.java
===================================================================
--- sandbox/expresso-solr/imapCrawler/SRC/JUserCrawler4IMAP/src/pkg/crawler/data/conn/Crawler.java	(revision 8056)
+++ sandbox/expresso-solr/imapCrawler/SRC/JUserCrawler4IMAP/src/pkg/crawler/data/conn/Crawler.java	(revision 8056)
@@ -0,0 +1,481 @@
+package pkg.crawler.data.conn;
+
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Properties;
+
+import javax.mail.Address;
+import javax.mail.BodyPart;
+import javax.mail.Folder;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.Multipart;
+import javax.mail.Part;
+import javax.mail.Session;
+
+import org.apache.solr.client.solrj.SolrServer;
+import org.apache.solr.client.solrj.impl.HttpSolrServer;
+import org.apache.solr.common.SolrInputDocument;
+
+import pkg.crawler.entity.Message2SolrEntity;
+
+import com.sun.mail.imap.ACL;
+import com.sun.mail.imap.IMAPFolder;
+import com.sun.mail.imap.IMAPMessage;
+import com.sun.mail.imap.IMAPStore;
+import com.sun.mail.imap.Rights;
+import com.sun.mail.imap.Rights.Right;
+
+public class Crawler {
+	
+	private String hostSolr;
+	private ACL acl;
+	private IMAPFolder imapFINBOXAux;
+	private IMAPStore store;
+	private String strIMAPFolderAux;
+	
+	public Crawler(String host, String user, String password, String imapFINBOXAux, String hostSolr) throws MessagingException
+	{
+		Properties props = System.getProperties();
+		Session session = Session.getInstance(props, null);
+		strIMAPFolderAux = imapFINBOXAux;
+		store = new IMAPStore(session, null);
+		
+		store.connect(host, user, password);
+		
+		this.hostSolr = hostSolr;
+		this.imapFINBOXAux = (IMAPFolder)store.getFolder(imapFINBOXAux);
+		
+		//Cria a ACL a ser configurada
+		acl = new ACL("expresso-admin");
+
+		//Define direito de leitura
+		Rights rights = new Rights();
+		rights.add(Right.READ);
+
+		//Configura direito de leitura para a ACL
+		acl.setRights(rights);
+	}
+	
+	public void run() {
+		//Cria uma instÃ¢ncia de conexÃ£o com o servidor Solr
+		SolrServer solrServer = new HttpSolrServer(hostSolr);
+
+		//Cria 
+		List<Message2SolrEntity> listIMAPMsgs = new ArrayList<Message2SolrEntity>();
+		//INBOX
+
+		//Adiciona ACL de permissÃ£o de leitura, para o usuÃ¡rio expresso-admin conseguir fazer a leitura
+		try
+		{
+			imapFINBOXAux.addACL(acl);
+
+
+			//Abre a caixa de e-mail
+			imapFINBOXAux.open(Folder.READ_ONLY);
+
+			//Carrega as mensagens da caixa para um array
+			Message[] msgsINBOX = imapFINBOXAux.getMessages();
+			
+			
+			int iCount = 0;
+			//Faz a iteraÃ§Ã£o entre as mensagens
+			for (Message msgAuxINBOX : msgsINBOX)
+			{
+
+				IMAPMessage m = (IMAPMessage)msgAuxINBOX;
+
+				//adiciona as mensagens na varÃ­avel listIMAPMsgs
+				try
+				{
+					dumpPart(m, listIMAPMsgs);
+					iCount++;
+				}catch(Exception e)
+				{
+					continue;
+				}
+				msgAuxINBOX = null;
+				m = null;
+				
+				
+				SolrInputDocument doc = new SolrInputDocument();
+				doc.addField("id", listIMAPMsgs.get(listIMAPMsgs.size()-1).getId().toString());
+				doc.addField("user", listIMAPMsgs.get(listIMAPMsgs.size()-1).getUser().toString());
+				doc.addField("folder", listIMAPMsgs.get(listIMAPMsgs.size()-1).getFolder().toString());
+				doc.addField("msg_no", listIMAPMsgs.get(listIMAPMsgs.size()-1).getMsgNo());
+				doc.addField("from", listIMAPMsgs.get(listIMAPMsgs.size()-1).getFrom().toString());
+				doc.addField("to", listIMAPMsgs.get(listIMAPMsgs.size()-1).getTo().toString());
+				doc.addField("subject", listIMAPMsgs.get(listIMAPMsgs.size()-1).getSubject().toString());
+				doc.addField("content", listIMAPMsgs.get(listIMAPMsgs.size()-1).getContent().toString());
+				doc.addField("copyto", listIMAPMsgs.get(listIMAPMsgs.size()-1).getCopyto().toString());
+				doc.addField("sent_date", listIMAPMsgs.get(listIMAPMsgs.size()-1).getSent_date());
+				doc.addField("hiddencopyto", listIMAPMsgs.get(listIMAPMsgs.size()-1).getHiddencopyto().toString());
+
+				try {
+					solrServer.add(doc);
+				} catch (Exception e) {
+					System.err.println("solr -> " + e.getMessage());
+				}
+				
+				
+				if(iCount%200 == 0)
+				{
+					solrServer.commit();
+					
+					listIMAPMsgs.clear();
+					
+					solrServer = new HttpSolrServer(hostSolr);
+				}
+				
+			}
+			imapFINBOXAux.removeACL("expresso-admin");
+			for(int i = 0; i < listIMAPMsgs.size(); i++ )
+			{
+				SolrInputDocument doc = new SolrInputDocument();
+				doc.addField("id", listIMAPMsgs.get(i).getId().toString());
+				doc.addField("user", listIMAPMsgs.get(i).getUser().toString());
+				doc.addField("folder", listIMAPMsgs.get(i).getFolder().toString());
+				doc.addField("msg_no", listIMAPMsgs.get(i).getMsgNo());
+				doc.addField("from", listIMAPMsgs.get(i).getFrom().toString());
+				doc.addField("to", listIMAPMsgs.get(i).getTo().toString());
+				doc.addField("subject", listIMAPMsgs.get(i).getSubject().toString());
+				doc.addField("content", listIMAPMsgs.get(i).getContent().toString());
+				doc.addField("copyto", listIMAPMsgs.get(i).getCopyto().toString());
+				doc.addField("sent_date", listIMAPMsgs.get(i).getSent_date());
+				doc.addField("hiddencopyto", listIMAPMsgs.get(i).getHiddencopyto().toString());
+
+				try {
+					solrServer.add(doc);
+				} catch (Exception e) {
+					System.err.println("solr -> " + e.getMessage());
+				}
+
+			}
+
+			listIMAPMsgs = null;
+
+			solrServer.commit();
+
+			solrServer = null;
+
+			for (Folder fAux : imapFINBOXAux.list())
+			{
+				//Verifica se nÃ£o Ã© uma pasta compartilhada
+				if(fAux.getFullName().split("/").length <= 3 && !fAux.getFullName().split("/")[2].equals("user"))
+				{
+					//INBOX
+					IMAPFolder imapFAux = (IMAPFolder)fAux;
+					
+					crawIntoUserFolders(imapFAux);
+					
+				}
+			}
+			imapFINBOXAux.close(true);
+			imapFINBOXAux = null;
+			
+			
+			Socket client = null;
+			ObjectOutputStream oos = null;
+			try {
+				client = new Socket("127.1.1.1", 8090);
+				
+				oos = new ObjectOutputStream(client.getOutputStream());
+				
+				oos.writeObject(strIMAPFolderAux);
+				
+				oos.close();
+				
+				client.close();
+			} catch (UnknownHostException e) {
+				e.printStackTrace();
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+		catch (Exception e)
+		{
+			Socket client = null;
+			ObjectOutputStream oos = null;
+			try {
+				client = new Socket("127.1.1.1", 8090);
+				
+				oos = new ObjectOutputStream(client.getOutputStream());
+				
+				oos.writeObject(strIMAPFolderAux);
+				
+				oos.close();
+				
+				client.close();
+			} catch (UnknownHostException ee) {
+				e.printStackTrace();
+			} catch (IOException ee) {
+				e.printStackTrace();
+			}
+			return;
+		}
+		
+		
+		
+	}
+
+	private void crawIntoUserFolders(IMAPFolder imapFAux) throws Exception
+	{
+		SolrServer solrServer = new HttpSolrServer(hostSolr);
+
+		List<Message2SolrEntity> listIMAPMsgs = new ArrayList<Message2SolrEntity>();
+
+		try
+		{
+			imapFAux.addACL(acl);
+		}catch(Exception e)
+		{
+			return;
+		}
+
+		imapFAux.open(Folder.READ_ONLY);
+
+		Message[] msgs= imapFAux.getMessages();
+		
+		int iCount = 0;
+		for (Message msgAux: msgs)
+		{
+			IMAPMessage m = (IMAPMessage)msgAux;
+			try
+			{
+				dumpPart(m, listIMAPMsgs);
+				iCount++;
+			}catch(Exception e)
+			{
+				continue;
+			}
+			msgAux = null;
+			m = null;
+			
+			SolrInputDocument doc = new SolrInputDocument();
+			doc.addField("id", listIMAPMsgs.get(listIMAPMsgs.size()-1).getId().toString());
+			doc.addField("user", listIMAPMsgs.get(listIMAPMsgs.size()-1).getUser().toString());
+			doc.addField("folder", listIMAPMsgs.get(listIMAPMsgs.size()-1).getFolder().toString());
+			doc.addField("msg_no", listIMAPMsgs.get(listIMAPMsgs.size()-1).getMsgNo());
+			doc.addField("from", listIMAPMsgs.get(listIMAPMsgs.size()-1).getFrom().toString());
+			doc.addField("to", listIMAPMsgs.get(listIMAPMsgs.size()-1).getTo().toString());
+			doc.addField("subject", listIMAPMsgs.get(listIMAPMsgs.size()-1).getSubject().toString());
+			doc.addField("content", listIMAPMsgs.get(listIMAPMsgs.size()-1).getContent().toString());
+			doc.addField("copyto", listIMAPMsgs.get(listIMAPMsgs.size()-1).getCopyto().toString());
+			doc.addField("sent_date", listIMAPMsgs.get(listIMAPMsgs.size()-1).getSent_date());
+			doc.addField("hiddencopyto", listIMAPMsgs.get(listIMAPMsgs.size()-1).getHiddencopyto().toString());
+
+			try {
+				solrServer.add(doc);
+			} catch (Exception e) {
+				System.err.println("solr -> " + e.getMessage());
+			}
+			
+			
+			if(iCount%200 == 0)
+			{
+				solrServer.commit();
+				
+				listIMAPMsgs.clear();
+				
+				solrServer = new HttpSolrServer(hostSolr);
+			}
+			
+		}
+		imapFAux.removeACL("expresso-admin");
+		System.out.println(imapFAux.getFullName()); 
+		for(int i = 0; i < listIMAPMsgs.size(); i++ )
+		{
+			SolrInputDocument doc = new SolrInputDocument();
+			doc.addField("id", listIMAPMsgs.get(i).getId());
+			doc.addField("user", listIMAPMsgs.get(i).getUser());
+			doc.addField("folder", listIMAPMsgs.get(i).getFolder());
+			doc.addField("msg_no", listIMAPMsgs.get(i).getMsgNo());
+			doc.addField("from", listIMAPMsgs.get(i).getFrom());
+			doc.addField("to", listIMAPMsgs.get(i).getTo());
+			doc.addField("subject", listIMAPMsgs.get(i).getSubject());
+			doc.addField("content", listIMAPMsgs.get(i).getContent());
+			doc.addField("copyto", listIMAPMsgs.get(i).getCopyto());
+			doc.addField("sent_date", listIMAPMsgs.get(i).getSent_date());
+			doc.addField("hiddencopyto", listIMAPMsgs.get(i).getHiddencopyto());
+			
+		}
+		listIMAPMsgs = null;
+		imapFAux.close(true);
+		imapFAux = null;
+		solrServer.commit();
+		solrServer = null;
+	}
+
+	private void dumpPart(IMAPMessage m, List<Message2SolrEntity> listIMAPMsgs) throws Exception 
+	{
+		//Verifica se possui identificador para poder continuar
+		if(m.getMessageID() == null || m.getMessageID().equals("")){
+			return;
+		}
+
+		Message2SolrEntity msgEntity = null;
+		msgEntity = new Message2SolrEntity();
+
+		msgEntity.setId(new StringBuilder( m.getMessageID()));
+
+		String user = m.getFolder().getFullName().split("/")[1];
+		msgEntity.setUser(new StringBuilder(user));
+
+		String folder = m.getFolder().getFullName().split("/")
+				[m.getFolder().getFullName().split("/").length-1];
+
+		if(!user.trim().equals(folder.trim()))
+		{
+			msgEntity.setFolder(new StringBuilder(folder));
+		}
+		else
+		{
+			msgEntity.setFolder(new StringBuilder("INBOX"));
+		}
+
+		msgEntity.setMsgNo(new StringBuilder(String.valueOf(m.getMessageNumber())));
+
+
+		if(m.getSubject() != null){
+			msgEntity.setSubject(new StringBuilder( m.getSubject() ));
+		}
+		Address[] a;
+		// FROM 
+		if ((a = m.getFrom()) != null) {
+			for (int j = 0; j < a.length; j++)
+			{
+				if(msgEntity.getFrom() == null)
+				{
+					msgEntity.setFrom(new StringBuilder(a[j].toString()));
+				}
+				else
+				{
+					msgEntity.setFrom(msgEntity.getFrom().append(", ").append(a[j].toString()));
+				}
+				//					System.out.println("FROM: " + a[j].toString());
+			}
+
+		}
+
+		// TO
+		if ((a = m.getRecipients(Message.RecipientType.TO)) != null) {
+			for (int j = 0; j < a.length; j++)
+			{
+				if(msgEntity.getTo() == null)
+				{
+					msgEntity.setTo(new StringBuilder(a[j].toString()));
+				}
+				else
+				{
+					msgEntity.setTo(msgEntity.getTo().append(", ").append(a[j].toString()));
+				}
+			}
+		}
+
+		// CC
+		if ((a = m.getRecipients(Message.RecipientType.CC)) != null) {
+			for (int j = 0; j < a.length; j++)
+			{
+				if(msgEntity.getCopyto() == null)
+				{
+					msgEntity.setCopyto(new StringBuilder(a[j].toString()));
+				}
+				else
+				{
+					msgEntity.setCopyto(msgEntity.getCopyto().append(", ").append(a[j].toString()));
+				}
+			}
+		}
+		// CC
+		if ((a = m.getRecipients(Message.RecipientType.BCC)) != null) {
+			for (int j = 0; j < a.length; j++)
+			{
+				if(msgEntity.getHiddencopyto() == null)
+				{
+					msgEntity.setHiddencopyto(new StringBuilder(a[j].toString()));
+				}
+				else
+				{
+					msgEntity.setHiddencopyto(new StringBuilder(msgEntity.getHiddencopyto() + ","+a[j].toString()));
+				}
+			}
+		}
+
+		// DATE
+		Date d = m.getSentDate();
+		if(msgEntity != null)
+		{
+			if(d != null)
+			{
+				msgEntity.setSent_date(new StringBuilder(String.valueOf(d.getTime())));
+			}
+			else
+			{
+				msgEntity.setSent_date(new StringBuilder(String.valueOf(new Date().getTime())));
+			}
+		}
+
+		try{
+			Object o = m.getContent();
+			if (o instanceof String) {
+				if( msgEntity != null )
+				{
+					msgEntity.setContent(new StringBuilder( o.toString()));
+				}
+			} else if (o instanceof Multipart) {
+				Multipart multipart = (Multipart)o;
+				int count = multipart.getCount();
+
+				for (int i = 0; i < count; i++)
+				{
+					if(msgEntity.getContent() == null || msgEntity.getContent().toString().trim().equals(""))
+					{
+						msgEntity.setContent(new StringBuilder(""));
+					}
+					if(multipart.getBodyPart(i).getContentType() != Part.ATTACHMENT)
+					{
+						msgEntity.setContent(msgEntity.getContent().append(" ").append(getPlainContent(multipart.getBodyPart(i))));
+					}
+
+				}
+
+			}
+		}catch (Exception e){
+			System.out.println("Exception ocurred!");
+			e.printStackTrace();
+		}
+
+		if(msgEntity != null && msgEntity.getId() != null){
+			listIMAPMsgs.add(msgEntity);
+		}
+		m = null;
+	}
+
+	private StringBuilder getPlainContent(BodyPart bodyPart) throws IOException, MessagingException
+	{
+		try
+		{
+
+			if(bodyPart.getContent() instanceof String)
+			{
+				StringBuilder text = new StringBuilder(bodyPart.getContent().toString());
+
+				return text;
+			}
+		}catch(Exception e)
+		{
+			System.out.println(e.getMessage());
+			e.printStackTrace();
+			return new StringBuilder("");
+		}
+
+
+		return new StringBuilder("");
+	}
+
+}
Index: sandbox/expresso-solr/imapCrawler/SRC/JUserCrawler4IMAP/src/pkg/crawler/entity/Message2SolrEntity.java
===================================================================
--- sandbox/expresso-solr/imapCrawler/SRC/JUserCrawler4IMAP/src/pkg/crawler/entity/Message2SolrEntity.java	(revision 8056)
+++ sandbox/expresso-solr/imapCrawler/SRC/JUserCrawler4IMAP/src/pkg/crawler/entity/Message2SolrEntity.java	(revision 8056)
@@ -0,0 +1,120 @@
+package pkg.crawler.entity;
+
+public class Message2SolrEntity {
+	
+	private StringBuilder id;
+	private StringBuilder user;
+	private StringBuilder folder;
+	private StringBuilder msgNo;
+	private StringBuilder from;
+	private StringBuilder to;
+	private StringBuilder subject;
+	private StringBuilder content;
+	private StringBuilder copyto;
+	private StringBuilder hiddencopyto;
+	private StringBuilder sent_date;
+	
+	public Message2SolrEntity()
+	{
+		id = new StringBuilder("");
+		user = new StringBuilder("");
+		folder = new StringBuilder("");
+		msgNo = new StringBuilder("");
+		from = new StringBuilder("");
+		to = new StringBuilder("");
+		subject = new StringBuilder("");
+		content = new StringBuilder("");
+		copyto = new StringBuilder("");
+		hiddencopyto = new StringBuilder("");
+		sent_date = new StringBuilder("");
+	}
+	
+	public StringBuilder getId() {
+		return id;
+	}
+	
+	public void setId(StringBuilder id) {
+		this.id = id;
+	}
+	
+	public StringBuilder getUser() {
+		return user;
+	}
+
+	public void setUser(StringBuilder user) {
+		this.user = user;
+	}
+
+	public StringBuilder getFolder() {
+		return folder;
+	}
+
+	public void setFolder(StringBuilder folder) {
+		this.folder = folder;
+	}
+	
+	public StringBuilder getMsgNo() {
+		return msgNo;
+	}
+
+	public void setMsgNo(StringBuilder msgNo) {
+		this.msgNo = msgNo;
+	}
+
+	public StringBuilder getFrom() {
+		return from;
+	}
+	
+	public void setFrom(StringBuilder from) {
+		this.from = from;
+	}
+	
+	public StringBuilder getTo() {
+		return to;
+	}
+	
+	public void setTo(StringBuilder to) {
+		this.to = to;
+	}
+	
+	public StringBuilder getSubject() {
+		return subject;
+	}
+	
+	public void setSubject(StringBuilder subject) {
+		this.subject = subject;
+	}
+	
+	public StringBuilder getContent() {
+		return content;
+	}
+	
+	public void setContent(StringBuilder content) {
+		this.content = content;
+	}
+	
+	public StringBuilder getCopyto() {
+		return copyto;
+	}
+	
+	public void setCopyto(StringBuilder copyto) {
+		this.copyto = copyto;
+	}
+	
+	public StringBuilder getHiddencopyto() {
+		return hiddencopyto;
+	}
+	
+	public void setHiddencopyto(StringBuilder hiddencopyto) {
+		this.hiddencopyto = hiddencopyto;
+	}
+	
+	public StringBuilder getSent_date() {
+		return sent_date;
+	}
+	
+	public void setSent_date(StringBuilder sent_date) {
+		this.sent_date = sent_date;
+	}
+	
+}
Index: sandbox/expresso-solr/imapCrawler/SRC/JUserCrawler4IMAP/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- sandbox/expresso-solr/imapCrawler/SRC/JUserCrawler4IMAP/.settings/org.eclipse.jdt.core.prefs	(revision 8056)
+++ sandbox/expresso-solr/imapCrawler/SRC/JUserCrawler4IMAP/.settings/org.eclipse.jdt.core.prefs	(revision 8056)
@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.7
Index: sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP/.classpath
===================================================================
--- sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP/.classpath	(revision 8056)
+++ sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP/.classpath	(revision 8056)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+	<classpathentry kind="lib" path="lib/apache-solr-analysis-extras-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/apache-solr-cell-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/apache-solr-clustering-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/apache-solr-core-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/apache-solr-dataimporthandler-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/apache-solr-dataimporthandler-extras-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/apache-solr-langid-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/apache-solr-solrj-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/apache-solr-test-framework-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/apache-solr-uima-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/apache-solr-velocity-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/commons-codec-1.6.jar"/>
+	<classpathentry kind="lib" path="lib/commons-io-2.1.jar"/>
+	<classpathentry kind="lib" path="lib/httpclient-4.1.3.jar"/>
+	<classpathentry kind="lib" path="lib/httpcore-4.1.4.jar"/>
+	<classpathentry kind="lib" path="lib/httpmime-4.1.3.jar"/>
+	<classpathentry kind="lib" path="lib/jcl-over-slf4j-1.6.4.jar"/>
+	<classpathentry kind="lib" path="lib/ldapjdbc.jar"/>
+	<classpathentry kind="lib" path="lib/mail.jar"/>
+	<classpathentry kind="lib" path="lib/slf4j-api-1.6.4.jar"/>
+	<classpathentry kind="lib" path="lib/wstx-asl-3.2.7.jar"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
Index: sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP/.project
===================================================================
--- sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP/.project	(revision 8056)
+++ sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP/.project	(revision 8056)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>JCrawlerForIMAP</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>
Index: sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP/src/pkg/crawler/tread/CrawlerThread.java
===================================================================
--- sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP/src/pkg/crawler/tread/CrawlerThread.java	(revision 8056)
+++ sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP/src/pkg/crawler/tread/CrawlerThread.java	(revision 8056)
@@ -0,0 +1,388 @@
+package pkg.crawler.tread;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Properties;
+
+import javax.mail.Address;
+import javax.mail.BodyPart;
+import javax.mail.Folder;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.Multipart;
+import javax.mail.Part;
+import javax.mail.Session;
+
+import org.apache.solr.client.solrj.SolrServer;
+import org.apache.solr.client.solrj.impl.HttpSolrServer;
+import org.apache.solr.common.SolrInputDocument;
+
+import pkg.crawler.entity.Message2SolrEntity;
+
+import com.sun.mail.imap.ACL;
+import com.sun.mail.imap.IMAPFolder;
+import com.sun.mail.imap.IMAPMessage;
+import com.sun.mail.imap.IMAPStore;
+import com.sun.mail.imap.Rights;
+import com.sun.mail.imap.Rights.Right;
+
+
+public class CrawlerThread implements Runnable{
+
+	private String hostSolr;
+	private ACL acl;
+	private IMAPFolder imapFINBOXAux;
+	private IMAPStore store;
+
+	public CrawlerThread(String host, String user, String password, String imapFINBOXAux, String hostSolr) throws MessagingException
+	{
+		Properties props = System.getProperties();
+		Session session = Session.getInstance(props, null);
+		
+		store = new IMAPStore(session, null);
+		
+		store.connect(host, user, password);
+		
+		this.hostSolr = hostSolr;
+		this.imapFINBOXAux = (IMAPFolder)store.getFolder(imapFINBOXAux);
+		
+		//Cria a ACL a ser configurada
+		acl = new ACL("expresso-admin");
+
+		//Define direito de leitura
+		Rights rights = new Rights();
+		rights.add(Right.READ);
+
+		//Configura direito de leitura para a ACL
+		acl.setRights(rights);
+	}
+	@Override
+	public void run() {
+		//Cria uma instÃ¢ncia de conexÃ£o com o servidor Solr
+		SolrServer solrServer = new HttpSolrServer(hostSolr);
+
+		//Cria 
+		List<Message2SolrEntity> listIMAPMsgs = new ArrayList<Message2SolrEntity>();
+		//INBOX
+
+		//Adiciona ACL de permissÃ£o de leitura, para o usuÃ¡rio expresso-admin conseguir fazer a leitura
+		try
+		{
+			imapFINBOXAux.addACL(acl);
+
+
+			//Abre a caixa de e-mail
+			imapFINBOXAux.open(Folder.READ_ONLY);
+
+			//Carrega as mensagens da caixa para um array
+			Message[] msgsINBOX = imapFINBOXAux.getMessages();
+
+			//Faz a iteraÃ§Ã£o entre as mensagens
+			for (Message msgAuxINBOX : msgsINBOX)
+			{
+
+				IMAPMessage m = (IMAPMessage)msgAuxINBOX;
+
+				//adiciona as mensagens na varÃ­avel listIMAPMsgs
+				try
+				{
+					dumpPart(m, listIMAPMsgs);
+				}catch(Exception e)
+				{
+					continue;
+				}
+				msgAuxINBOX = null;
+				m = null;
+			}
+			imapFINBOXAux.removeACL("expresso-admin");
+			for(int i = 0; i < listIMAPMsgs.size(); i++ )
+			{
+				SolrInputDocument doc = new SolrInputDocument();
+				doc.addField("id", listIMAPMsgs.get(i).getId().toString());
+				doc.addField("user", listIMAPMsgs.get(i).getUser().toString());
+				doc.addField("folder", listIMAPMsgs.get(i).getFolder().toString());
+				doc.addField("msg_no", listIMAPMsgs.get(i).getMsgNo());
+				doc.addField("from", listIMAPMsgs.get(i).getFrom().toString());
+				doc.addField("to", listIMAPMsgs.get(i).getTo().toString());
+				doc.addField("subject", listIMAPMsgs.get(i).getSubject().toString());
+				doc.addField("content", listIMAPMsgs.get(i).getContent().toString());
+				doc.addField("copyto", listIMAPMsgs.get(i).getCopyto().toString());
+				doc.addField("sent_date", listIMAPMsgs.get(i).getSent_date());
+				doc.addField("hiddencopyto", listIMAPMsgs.get(i).getHiddencopyto().toString());
+
+				try {
+					solrServer.add(doc);
+				} catch (Exception e) {
+					System.err.println("solr -> " + e.getMessage());
+				}
+
+			}
+
+			listIMAPMsgs = null;
+
+			solrServer.commit();
+
+			solrServer = null;
+
+			for (Folder fAux : imapFINBOXAux.list())
+			{
+				//Verifica se nÃ£o Ã© uma pasta compartilhada
+				if(fAux.getFullName().split("/").length <= 3 && !fAux.getFullName().split("/")[2].equals("user"))
+				{
+					//INBOX
+					IMAPFolder imapFAux = (IMAPFolder)fAux;
+					
+					crawIntoUserFolders(imapFAux);
+					
+				}
+			}
+			imapFINBOXAux.close(true);
+			imapFINBOXAux = null;
+		}
+		catch (Exception e)
+		{
+			return;
+		}
+	}
+
+	private void crawIntoUserFolders(IMAPFolder imapFAux) throws Exception
+	{
+		SolrServer solrServer = new HttpSolrServer(hostSolr);
+
+		List<Message2SolrEntity> listIMAPMsgs = new ArrayList<Message2SolrEntity>();
+
+		try
+		{
+			imapFAux.addACL(acl);
+		}catch(Exception e)
+		{
+			return;
+		}
+
+		imapFAux.open(Folder.READ_ONLY);
+
+		Message[] msgs= imapFAux.getMessages();
+
+		for (Message msgAux: msgs)
+		{
+			IMAPMessage m = (IMAPMessage)msgAux;
+			try
+			{
+				dumpPart(m, listIMAPMsgs);
+			}catch(Exception e)
+			{
+				continue;
+			}
+			msgAux = null;
+			m = null;
+		}
+		imapFAux.removeACL("expresso-admin");
+		System.out.println(imapFAux.getFullName()); 
+		for(int i = 0; i < listIMAPMsgs.size(); i++ )
+		{
+			SolrInputDocument doc = new SolrInputDocument();
+			doc.addField("id", listIMAPMsgs.get(i).getId());
+			doc.addField("user", listIMAPMsgs.get(i).getUser());
+			doc.addField("folder", listIMAPMsgs.get(i).getFolder());
+			doc.addField("msg_no", listIMAPMsgs.get(i).getMsgNo());
+			doc.addField("from", listIMAPMsgs.get(i).getFrom());
+			doc.addField("to", listIMAPMsgs.get(i).getTo());
+			doc.addField("subject", listIMAPMsgs.get(i).getSubject());
+			doc.addField("content", listIMAPMsgs.get(i).getContent());
+			doc.addField("copyto", listIMAPMsgs.get(i).getCopyto());
+			doc.addField("sent_date", listIMAPMsgs.get(i).getSent_date());
+			doc.addField("hiddencopyto", listIMAPMsgs.get(i).getHiddencopyto());
+
+		}
+		listIMAPMsgs = null;
+		imapFAux.close(true);
+		imapFAux = null;
+		solrServer.commit();
+		solrServer = null;
+	}
+
+	private void dumpPart(IMAPMessage m, List<Message2SolrEntity> listIMAPMsgs) throws Exception 
+	{
+		//Verifica se possui identificador para poder continuar
+		if(m.getMessageID() == null || m.getMessageID().equals("")){
+			return;
+		}
+
+		Message2SolrEntity msgEntity = null;
+		msgEntity = new Message2SolrEntity();
+
+		msgEntity.setId(new StringBuilder( m.getMessageID()));
+
+		String user = m.getFolder().getFullName().split("/")[1];
+		msgEntity.setUser(new StringBuilder(user));
+
+		String folder = m.getFolder().getFullName().split("/")
+				[m.getFolder().getFullName().split("/").length-1];
+
+		if(!user.trim().equals(folder.trim()))
+		{
+			msgEntity.setFolder(new StringBuilder(folder));
+		}
+		else
+		{
+			msgEntity.setFolder(new StringBuilder("INBOX"));
+		}
+
+		msgEntity.setMsgNo(new StringBuilder(String.valueOf(m.getMessageNumber())));
+
+
+		if(m.getSubject() != null){
+			msgEntity.setSubject(new StringBuilder( m.getSubject() ));
+		}
+		Address[] a;
+		// FROM 
+		if ((a = m.getFrom()) != null) {
+			for (int j = 0; j < a.length; j++)
+			{
+				if(msgEntity.getFrom() == null)
+				{
+					msgEntity.setFrom(new StringBuilder(a[j].toString()));
+				}
+				else
+				{
+					msgEntity.setFrom(msgEntity.getFrom().append(", ").append(a[j].toString()));
+				}
+				//					System.out.println("FROM: " + a[j].toString());
+			}
+
+		}
+
+		// TO
+		if ((a = m.getRecipients(Message.RecipientType.TO)) != null) {
+			for (int j = 0; j < a.length; j++)
+			{
+				if(msgEntity.getTo() == null)
+				{
+					msgEntity.setTo(new StringBuilder(a[j].toString()));
+				}
+				else
+				{
+					msgEntity.setTo(msgEntity.getTo().append(", ").append(a[j].toString()));
+				}
+			}
+		}
+
+		// CC
+		if ((a = m.getRecipients(Message.RecipientType.CC)) != null) {
+			for (int j = 0; j < a.length; j++)
+			{
+				if(msgEntity.getCopyto() == null)
+				{
+					msgEntity.setCopyto(new StringBuilder(a[j].toString()));
+				}
+				else
+				{
+					msgEntity.setCopyto(msgEntity.getCopyto().append(", ").append(a[j].toString()));
+				}
+			}
+		}
+		// CC
+		if ((a = m.getRecipients(Message.RecipientType.BCC)) != null) {
+			for (int j = 0; j < a.length; j++)
+			{
+				if(msgEntity.getHiddencopyto() == null)
+				{
+					msgEntity.setHiddencopyto(new StringBuilder(a[j].toString()));
+				}
+				else
+				{
+					msgEntity.setHiddencopyto(new StringBuilder(msgEntity.getHiddencopyto() + ","+a[j].toString()));
+				}
+			}
+		}
+
+		// DATE
+		Date d = m.getSentDate();
+		if(msgEntity != null)
+		{
+			if(d != null)
+			{
+				msgEntity.setSent_date(new StringBuilder(String.valueOf(d.getTime())));
+			}
+			else
+			{
+				msgEntity.setSent_date(new StringBuilder(String.valueOf(new Date().getTime())));
+			}
+		}
+
+		try{
+			Object o = m.getContent();
+			if (o instanceof String) {
+				if( msgEntity != null )
+				{
+					msgEntity.setContent(new StringBuilder( o.toString()));
+				}
+			} else if (o instanceof Multipart) {
+				Multipart multipart = (Multipart)o;
+				int count = multipart.getCount();
+
+				for (int i = 0; i < count; i++)
+				{
+					if(msgEntity.getContent() == null || msgEntity.getContent().toString().trim().equals(""))
+					{
+						msgEntity.setContent(new StringBuilder(""));
+					}
+					if(multipart.getBodyPart(i).getContentType() != Part.ATTACHMENT)
+					{
+						msgEntity.setContent(msgEntity.getContent().append(" ").append(getPlainContent(multipart.getBodyPart(i))));
+					}
+
+				}
+
+			}
+		}catch (Exception e){
+			System.out.println("Exception ocurred!");
+			e.printStackTrace();
+		}
+
+		if(msgEntity != null && msgEntity.getId() != null){
+			listIMAPMsgs.add(msgEntity);
+		}
+		m = null;
+	}
+
+	private StringBuilder getPlainContent(BodyPart bodyPart) throws IOException, MessagingException
+	{
+		try
+		{
+
+			if(bodyPart.getContent() instanceof String)
+			{
+				//				ByteArrayOutputStream out = new ByteArrayOutputStream();
+				//				InputStream in = bodyPart.getInputStream();
+				//				
+				//				byte[] buffer = new byte[1024];
+				//				byte[] data = null;
+				//				
+				//				while(in.read(buffer) != -1) {
+				//					out.write(buffer);
+				//				}
+				//				
+				//				data = out.toByteArray();
+
+				StringBuilder text = new StringBuilder(bodyPart.getContent().toString());
+
+				//				out.close();
+				//				in.close();
+
+				return text;
+			}
+		}catch(Exception e)
+		{
+			System.out.println(e.getMessage());
+			e.printStackTrace();
+			return new StringBuilder("");
+		}
+
+
+		return new StringBuilder("");
+	}
+
+}
Index: sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP/src/pkg/crawler/main/Main.java
===================================================================
--- sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP/src/pkg/crawler/main/Main.java	(revision 8056)
+++ sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP/src/pkg/crawler/main/Main.java	(revision 8056)
@@ -0,0 +1,38 @@
+package pkg.crawler.main;
+
+import pkg.crawler.data.conn.Crawler;
+
+public class Main {
+
+	/**
+	 * @param args
+	 * DeverÃ£o ser 4 argumentos: 
+	 */
+	public static void main(String[] args) {
+		
+		if (args == null || args.length != 3){
+			System.out.println("Uso:\n" +
+					"java -jar crawler.jar [imap_host] [imap_admin_password] " +
+					"[http_solr_host_address] [login_starts_with]\n" +
+					"imap_host - O endereÃ§o que estÃ¡ instalado o Expresso Ex: \"127.1.1.1\"\n" +
+					"imap_admin_password - Senha do usuÃ¡rio 'expresso-admin' Ex: \"admin123\"\n" +
+					"http_solr_host_address - EndereÃ§o do servidor do Solr Ex: \"http://127.1.1.1:8983/solr/\"\n" +
+					"login_starts_with - Caracteres que esse crawler deverÃ¡ verificar Ex: \"abcde\"");
+			System.exit(0);
+		}
+		
+		//O endereÃ§o que estÃ¡ instalado o Expresso Ex: "127.1.1.1"
+		String host = args[0];
+		//Senha do usuÃ¡rio 'expresso-admin' Ex: "admin123"
+		String password = args[1];
+		//EndereÃ§o do servidor do Solr Ex: "http://127.1.1.1:8983/solr/"
+		String hostSolr = args[2];
+		
+		Crawler crawler = new Crawler(host, password, hostSolr);
+		
+		crawler.run();
+		
+		
+	}
+
+}
Index: sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP/src/pkg/crawler/data/conn/CopyOfCrawler.java
===================================================================
--- sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP/src/pkg/crawler/data/conn/CopyOfCrawler.java	(revision 8056)
+++ sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP/src/pkg/crawler/data/conn/CopyOfCrawler.java	(revision 8056)
@@ -0,0 +1,314 @@
+package pkg.crawler.data.conn;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Properties;
+
+import javax.mail.Address;
+import javax.mail.Folder;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.Multipart;
+import javax.mail.Part;
+import javax.mail.Session;
+
+import org.apache.solr.client.solrj.SolrServer;
+import org.apache.solr.client.solrj.impl.HttpSolrServer;
+import org.apache.solr.common.SolrInputDocument;
+
+import pkg.crawler.entity.Message2SolrEntity;
+
+import com.sun.mail.imap.ACL;
+import com.sun.mail.imap.IMAPFolder;
+import com.sun.mail.imap.IMAPMessage;
+import com.sun.mail.imap.IMAPStore;
+import com.sun.mail.imap.Rights;
+import com.sun.mail.imap.Rights.Right;
+
+public class CopyOfCrawler{
+
+	private String host;
+	private String user;
+	private String password;
+	private String mbox;
+	private String url;
+	private boolean debug;
+	private String loginStartsWith;
+	private static ArrayList<Message2SolrEntity> listIMAPMsgs = new ArrayList<Message2SolrEntity>();
+
+
+//	public CopyOfCrawler(String loginStartsWith)
+//	{
+//		this.host = "172.25.60.61";
+//		this.user = "expresso-admin";
+//		this.password = "pti123";
+//		this.mbox = "user";
+//		this.url = null;
+//		this.debug = false;
+//		this.loginStartsWith = loginStartsWith; 
+//	}
+//
+//
+//	@Override
+//	public void run()
+//	{
+//
+//		//Inicializando as propriedades default da mÃ¡quina para conexÃ£o
+//		//com o servidor IMAP
+//		Properties props = System.getProperties();
+//		Session session = Session.getInstance(props, null);
+//
+//		IMAPStore store = new IMAPStore(session, null);
+//
+//		try {
+//
+//			//Conectando com o servidor IMAP
+//			store.connect(host, user, password);
+//			//Definindo a pasta base a ser usada
+//			IMAPFolder imapFolder = (IMAPFolder)store.getFolder(mbox);
+//
+//			//Cria a ACL a ser configurada
+//			ACL acl = new ACL("expresso-admin");
+//
+//			Rights rights = new Rights();
+//			rights.add(Right.READ);
+//
+//
+//			//Configura direito de leitura para a ACL
+//			acl.setRights(rights);
+//
+//			SolrServer solrServer = new HttpSolrServer("http://172.25.60.61:8983/solr/");
+//			
+//			solrServer.deleteByQuery("*:*");
+//			//Faz a iteraÃ§Ã£o entre os usuÃ¡rios
+//			for (Folder fINBOXAux : imapFolder.list())
+//			{
+//				//INBOX
+//				IMAPFolder imapFINBOXAux = (IMAPFolder)fINBOXAux;
+//
+//				imapFINBOXAux.addACL(acl);
+//
+//				imapFINBOXAux.open(Folder.READ_ONLY);
+//
+//				Message[] msgsINBOX = imapFINBOXAux.getMessages();
+//
+//				for (Message msgAuxINBOX : msgsINBOX)
+//				{
+//					dumpPart(msgAuxINBOX);
+//				}
+//				imapFINBOXAux.removeACL("expresso-admin");
+//				for(int i = 0; i < CopyOfCrawler.listIMAPMsgs.size(); i++ )
+//				{
+//					SolrInputDocument doc = new SolrInputDocument();
+//					doc.addField("id", listIMAPMsgs.get(i).getId());
+//					doc.addField("user", listIMAPMsgs.get(i).getUser());
+//					doc.addField("folder", listIMAPMsgs.get(i).getUser());
+//					doc.addField("from", listIMAPMsgs.get(i).getFrom());
+//					doc.addField("to", listIMAPMsgs.get(i).getTo());
+//					doc.addField("subject", listIMAPMsgs.get(i).getSubject());
+//					doc.addField("content", listIMAPMsgs.get(i).getContent());
+//					doc.addField("copyto", listIMAPMsgs.get(i).getCopyto());
+//					doc.addField("hiddencopyto", listIMAPMsgs.get(i).getHiddencopyto());
+//
+//					solrServer.add(doc);
+//				}
+//
+//				CopyOfCrawler.listIMAPMsgs.clear();
+//
+//				solrServer.commit();
+//
+//				for (Folder fAux : imapFINBOXAux.list())
+//				{
+//
+//					//INBOX
+//					IMAPFolder imapFAux = (IMAPFolder)fAux;
+//
+//					imapFAux.addACL(acl);
+//
+//					imapFAux.open(Folder.READ_ONLY);
+//
+//					Message[] msgs= imapFAux.getMessages();
+//
+//					for (Message msgAux: msgs)
+//					{
+//						dumpPart(msgAux);
+//					}
+//					imapFAux.removeACL("expresso-admin");
+//					System.out.println(imapFAux.getFullName()); 
+//					for(int i = 0; i < CopyOfCrawler.listIMAPMsgs.size(); i++ )
+//					{
+//						SolrInputDocument doc = new SolrInputDocument();
+//						doc.addField("id", listIMAPMsgs.get(i).getId());
+//						doc.addField("user", listIMAPMsgs.get(i).getUser());
+//						doc.addField("folder", listIMAPMsgs.get(i).getUser());
+//						doc.addField("from", listIMAPMsgs.get(i).getFrom());
+//						doc.addField("to", listIMAPMsgs.get(i).getTo());
+//						doc.addField("subject", listIMAPMsgs.get(i).getSubject());
+//						doc.addField("content", listIMAPMsgs.get(i).getContent());
+//						doc.addField("copyto", listIMAPMsgs.get(i).getCopyto());
+//						doc.addField("hiddencopyto", listIMAPMsgs.get(i).getHiddencopyto());
+//
+//						solrServer.add(doc);
+//					}
+//					CopyOfCrawler.listIMAPMsgs.clear();
+//				}
+//
+//
+//				System.out.println(imapFINBOXAux.getFullName()); 
+//				//				IMAPFolder imapFAux = (IMAPFolder)imapFolder.list()[0]; //INBOX
+//				//				IMAPFolder imapFAux = (IMAPFolder)imapFolder.list()[0].list()[0]; //AprovaÃ§Ãµes e talz
+//				//				
+//				//				imapFAux.addRights(acl);
+//				//				imapFAux.open(IMAPFolder.READ_ONLY);
+//				//				System.out.println(imapFAux.getMessageCount());
+//				//				
+//				//				IMAPMessage message = (IMAPMessage)imapFAux.getMessages()[0];
+//				//				
+//				//				System.out.println(message.getMessageID());
+//				//				System.out.println(message.getContentType());
+//				//				
+//				//				
+//				//				imapFAux.removeACL("expresso-admin");
+//				//				imapFAux.close(false);
+//			}
+//
+//
+//		} catch (MessagingException e) {
+//			// TODO Auto-generated catch block
+//			e.printStackTrace();
+//		}
+//		catch (Exception e)
+//		{
+//			e.printStackTrace();
+//		}
+//	}
+//
+//
+//	public static void dumpPart(Part p) throws Exception {
+//		Message2SolrEntity msgEntity = null;
+//
+//		if (p instanceof Message) {
+//			msgEntity = new Message2SolrEntity();
+//			IMAPMessage m = (IMAPMessage)p;
+//
+//			msgEntity.setId(m.getMessageID());
+//			
+//			if(msgEntity.getId() == null || msgEntity.getId().equals("")){
+//				System.out.println("Damn it!");
+//			}
+//
+//			String user = m.getFolder().getFullName().split("/")[1];
+//			msgEntity.setUser(user);
+//
+//			String folder = m.getFolder().getFullName().split("/")
+//					[m.getFolder().getFullName().split("/").length-1];
+//
+//			if(!user.equals(folder))
+//			{
+//				msgEntity.setFolder(folder);
+//			}
+//			else
+//			{
+//				msgEntity.setFolder("INBOX");
+//			}
+//			
+//			
+//			
+//			msgEntity.setSubject(m.getSubject());
+//			Address[] a;
+//			// FROM 
+//			if ((a = m.getFrom()) != null) {
+//				for (int j = 0; j < a.length; j++)
+//				{
+//					if(msgEntity.getFrom() == null)
+//					{
+//						msgEntity.setFrom(a[j].toString());
+//					}
+//					else
+//					{
+//						msgEntity.setFrom(msgEntity.getFrom() + ","+a[j].toString());
+//					}
+//					//					System.out.println("FROM: " + a[j].toString());
+//				}
+//
+//			}
+//
+//			// TO
+//			if ((a = m.getRecipients(Message.RecipientType.TO)) != null) {
+//				for (int j = 0; j < a.length; j++)
+//				{
+//					if(msgEntity.getTo() == null)
+//					{
+//						msgEntity.setTo(a[j].toString());
+//					}
+//					else
+//					{
+//						msgEntity.setTo(msgEntity.getTo() + ","+a[j].toString());
+//					}
+//				}
+//			}
+//
+//			// CC
+//			if ((a = m.getRecipients(Message.RecipientType.CC)) != null) {
+//				for (int j = 0; j < a.length; j++)
+//				{
+//					if(msgEntity.getCopyto() == null)
+//					{
+//						msgEntity.setCopyto(a[j].toString());
+//					}
+//					else
+//					{
+//						msgEntity.setCopyto(msgEntity.getCopyto() + ","+a[j].toString());
+//					}
+//				}
+//			}
+//			// CC
+//			if ((a = m.getRecipients(Message.RecipientType.BCC)) != null) {
+//				for (int j = 0; j < a.length; j++)
+//				{
+//					if(msgEntity.getHiddencopyto() == null)
+//					{
+//						msgEntity.setHiddencopyto(a[j].toString());
+//					}
+//					else
+//					{
+//						msgEntity.setHiddencopyto(msgEntity.getHiddencopyto() + ","+a[j].toString());
+//					}
+//				}
+//			}
+//
+//			// DATE
+//			Date d = m.getSentDate();
+//			if(msgEntity != null)
+//			{
+//				msgEntity.setSent_date((d != null ? d.toLocaleString() : "UNKNOWN"));
+//			}
+//
+//
+//		}
+//
+//		try{
+//			Object o = p.getContent();
+//			if (o instanceof String) {
+//				if( msgEntity != null )
+//				{
+//					msgEntity.setContent((String)o);
+//				}
+//			} else if (o instanceof Multipart) {
+//				Multipart mp = (Multipart)o;
+//				int count = mp.getCount();
+//				for (int i = 0; i < count; i++)
+//					dumpPart(mp.getBodyPart(i));
+//			}
+//		}catch (Exception e){
+//			System.out.println("Exception ocurred!");
+//			e.printStackTrace();
+//		}
+//
+//		if(msgEntity != null && msgEntity.getId() != null){
+//			CopyOfCrawler.listIMAPMsgs.add(msgEntity);
+//		}
+//
+//	}	
+
+}
Index: sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP/src/pkg/crawler/data/conn/Crawler.java
===================================================================
--- sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP/src/pkg/crawler/data/conn/Crawler.java	(revision 8056)
+++ sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP/src/pkg/crawler/data/conn/Crawler.java	(revision 8056)
@@ -0,0 +1,152 @@
+package pkg.crawler.data.conn;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.ArrayList;
+import java.util.Properties;
+
+import javax.mail.Folder;
+import javax.mail.MessagingException;
+import javax.mail.Session;
+
+import com.sun.mail.imap.ACL;
+import com.sun.mail.imap.IMAPFolder;
+import com.sun.mail.imap.IMAPStore;
+import com.sun.mail.imap.Rights;
+import com.sun.mail.imap.Rights.Right;
+
+public class Crawler{
+
+	private String host;
+	private String user;
+	private String password;
+	private String mbox;
+	private String hostSolr;
+	private ACL acl;
+
+	public Crawler(String host, String password, String hostSolr)
+	{
+		this.host = host;
+		this.user = "expresso-admin";
+		this.password = password;
+		this.mbox = "user";
+		this.hostSolr = hostSolr;
+
+		//Cria a ACL a ser configurada
+		acl = new ACL("expresso-admin");
+
+		//Define direito de leitura
+		Rights rights = new Rights();
+		rights.add(Right.READ);
+
+		//Configura direito de leitura para a ACL
+		acl.setRights(rights);
+	}
+
+	public void run()
+	{
+
+		int iAux0 = 0;
+		while (iAux0 == 0)
+		{
+			iAux0 = 1;
+
+			//Inicializando as propriedades default da mÃ¡quina para conexÃ£o
+			//com o servidor IMAP
+			Properties props = System.getProperties();
+			Session session = Session.getInstance(props, null);
+
+			IMAPStore store = new IMAPStore(session, null);
+
+			try {
+
+				//Conectando com o servidor IMAP
+				store.connect(host, user, password);
+				//Definindo a pasta base a ser usada
+				IMAPFolder imapFolder = (IMAPFolder)store.getFolder(mbox);
+				//Faz a iteraÃ§Ã£o entre os usuÃ¡rios/pastas do usuÃ¡rio
+
+				ArrayList<String> userMailBoxes = new ArrayList<String>();
+
+				for (Folder fINBOXAux : imapFolder.list())
+				{
+
+					System.out.println(fINBOXAux.getFullName());
+					userMailBoxes.add(fINBOXAux.getFullName());
+
+				}
+				ServerSocket server = null;
+				ObjectInputStream ois = null;
+				Socket connection = null;
+
+				try {
+					server = new ServerSocket(8090);
+
+					while (userMailBoxes.size() > 0 )
+					{
+						ProcessBuilder proc = new ProcessBuilder("java", "-jar", 
+								"-Xms2048m", "client.jar", this.host, 
+								userMailBoxes.get(0), this.password, this.hostSolr);
+
+						try 
+						{
+							proc.start();
+							System.out.println("Iniciou processo: "+
+									"java -jar client.jar "+
+									"\""+this.host+"\" \""+userMailBoxes.get(0)+"\" "+ 
+									"\""+this.password+"\" \""+this.hostSolr+"\"");
+						}
+						catch (IOException e) {
+							// TODO Auto-generated catch block
+							e.printStackTrace();
+						}
+						catch (Exception e) {
+							// TODO Auto-generated catch block
+							e.printStackTrace();
+						}
+						
+						connection = server.accept();
+
+						ois = new ObjectInputStream(connection.getInputStream());
+						try {
+							String socketMessage = (String)ois.readObject();
+							if(socketMessage.equals(userMailBoxes.get(0)))
+							{
+								System.out.println(userMailBoxes.get(0));
+								userMailBoxes.remove(0);
+							}
+						} catch (ClassNotFoundException e) {
+							// TODO Auto-generated catch block
+							e.printStackTrace();
+						}
+					}
+
+				}
+				catch (IOException e) 
+				{
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				}
+
+				imapFolder.close(true);
+				imapFolder = null;
+				store.close();
+				store = null;
+
+			} catch (MessagingException e) {
+				System.out.println(e.getMessage());
+				e.printStackTrace();
+			}
+			catch (Exception e)
+			{
+				System.out.println(e.getMessage());
+				e.printStackTrace();
+			}
+
+		}
+
+	}
+
+}
Index: sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP/src/pkg/crawler/data/conn/Copy_2_of_Crawler.java
===================================================================
--- sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP/src/pkg/crawler/data/conn/Copy_2_of_Crawler.java	(revision 8056)
+++ sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP/src/pkg/crawler/data/conn/Copy_2_of_Crawler.java	(revision 8056)
@@ -0,0 +1,423 @@
+package pkg.crawler.data.conn;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Properties;
+
+import javax.mail.Address;
+import javax.mail.BodyPart;
+import javax.mail.Folder;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.Multipart;
+import javax.mail.Part;
+import javax.mail.Session;
+
+import org.apache.solr.client.solrj.SolrServer;
+import org.apache.solr.client.solrj.impl.HttpSolrServer;
+import org.apache.solr.common.SolrInputDocument;
+
+import pkg.crawler.entity.Message2SolrEntity;
+
+import com.sun.mail.imap.ACL;
+import com.sun.mail.imap.IMAPFolder;
+import com.sun.mail.imap.IMAPMessage;
+import com.sun.mail.imap.IMAPStore;
+import com.sun.mail.imap.Rights;
+import com.sun.mail.imap.Rights.Right;
+
+public class Copy_2_of_Crawler{
+
+	private String host;
+	private String user;
+	private String password;
+	private String mbox;
+	private String hostSolr;
+	//	private ArrayList<Message2SolrEntity> listIMAPMsgs;
+	private ACL acl;
+
+	public Copy_2_of_Crawler(String host, String password, String hostSolr)
+	{
+		this.host = host;
+		this.user = "expresso-admin";
+		this.password = password;
+		this.mbox = "user";
+		this.hostSolr = hostSolr;
+
+		//Cria a ACL a ser configurada
+		acl = new ACL("expresso-admin");
+
+		//Define direito de leitura
+		Rights rights = new Rights();
+		rights.add(Right.READ);
+
+		//Configura direito de leitura para a ACL
+		acl.setRights(rights);
+	}
+
+
+	public void run()
+	{
+		
+		int iAux0 = 0;
+		while (iAux0 == 0)
+		{
+			iAux0 = 1;
+
+			//Inicializando as propriedades default da mÃ¡quina para conexÃ£o
+			//com o servidor IMAP
+			Properties props = System.getProperties();
+			Session session = Session.getInstance(props, null);
+
+			IMAPStore store = new IMAPStore(session, null);
+
+			try {
+
+				//Conectando com o servidor IMAP
+				store.connect(host, user, password);
+				//Definindo a pasta base a ser usada
+				IMAPFolder imapFolder = (IMAPFolder)store.getFolder(mbox);
+
+				//Faz a iteraÃ§Ã£o entre os usuÃ¡rios/pastas do usuÃ¡rio
+				for (Folder fINBOXAux : imapFolder.list())
+				{
+					System.out.println(fINBOXAux.getFullName());
+					
+					//Cria uma instÃ¢ncia de conexÃ£o com o servidor Solr
+					SolrServer solrServer = new HttpSolrServer(hostSolr);
+
+					//Cria 
+					List<Message2SolrEntity> listIMAPMsgs = new ArrayList<Message2SolrEntity>();
+					//INBOX
+					IMAPFolder imapFINBOXAux = (IMAPFolder)fINBOXAux;
+					
+					//Adiciona ACL de permissÃ£o de leitura, para o usuÃ¡rio expresso-admin conseguir fazer a leitura
+					try
+					{
+						imapFINBOXAux.addACL(acl);
+					}
+					catch (Exception e)
+					{
+						continue;
+					}
+					
+					//Abre a caixa de e-mail
+					imapFINBOXAux.open(Folder.READ_ONLY);
+					
+					//Carrega as mensagens da caixa para um array
+					Message[] msgsINBOX = imapFINBOXAux.getMessages();
+					
+					//Faz a iteraÃ§Ã£o entre as mensagens
+					for (Message msgAuxINBOX : msgsINBOX)
+					{
+						
+						IMAPMessage m = (IMAPMessage)msgAuxINBOX;
+						
+						//adiciona as mensagens na varÃ­avel listIMAPMsgs
+						try
+						{
+							dumpPart(m, listIMAPMsgs);
+						}catch(Exception e)
+						{
+							continue;
+						}
+					}
+					imapFINBOXAux.removeACL("expresso-admin");
+					for(int i = 0; i < listIMAPMsgs.size(); i++ )
+					{
+						SolrInputDocument doc = new SolrInputDocument();
+						doc.addField("id", listIMAPMsgs.get(i).getId().toString());
+						doc.addField("user", listIMAPMsgs.get(i).getUser().toString());
+						doc.addField("folder", listIMAPMsgs.get(i).getFolder().toString());
+						doc.addField("msg_no", listIMAPMsgs.get(i).getMsgNo());
+						doc.addField("from", listIMAPMsgs.get(i).getFrom().toString());
+						doc.addField("to", listIMAPMsgs.get(i).getTo().toString());
+						doc.addField("subject", listIMAPMsgs.get(i).getSubject().toString());
+						doc.addField("content", listIMAPMsgs.get(i).getContent().toString());
+						doc.addField("copyto", listIMAPMsgs.get(i).getCopyto().toString());
+						doc.addField("sent_date", listIMAPMsgs.get(i).getSent_date());
+						doc.addField("hiddencopyto", listIMAPMsgs.get(i).getHiddencopyto().toString());
+
+						try {
+							solrServer.add(doc);
+						} catch (Exception e) {
+							System.err.println("solr -> " + e.getMessage());
+						}
+
+					}
+
+					listIMAPMsgs = null;
+
+					solrServer.commit();
+
+					solrServer = null;
+
+					for (Folder fAux : imapFINBOXAux.list())
+					{
+						//Verifica se nÃ£o Ã© uma pasta compartilhada
+						if(fAux.getFullName().split("/").length <= 3 && !fAux.getFullName().split("/")[2].equals("user"))
+						{
+							//INBOX
+							IMAPFolder imapFAux = (IMAPFolder)fAux;
+
+							crawIntoUserFolders(imapFAux);
+
+						}
+					}
+					Thread.sleep(30000);
+					
+					System.out.println(imapFINBOXAux.getFullName()); 
+				}
+				store.close();
+				
+				
+
+			} catch (MessagingException e) {
+				System.out.println(e.getMessage());
+				e.printStackTrace();
+			}
+			catch (Exception e)
+			{
+				System.out.println(e.getMessage());
+				e.printStackTrace();
+			}
+		}
+	}
+
+	private void crawIntoUserFolders(IMAPFolder imapFAux) throws Exception
+	{
+		SolrServer solrServer = new HttpSolrServer(hostSolr);
+
+		List<Message2SolrEntity> listIMAPMsgs = new ArrayList<Message2SolrEntity>();
+		
+		try
+		{
+			imapFAux.addACL(acl);
+		}catch(Exception e)
+		{
+			return;
+		}
+
+		imapFAux.open(Folder.READ_ONLY);
+
+		Message[] msgs= imapFAux.getMessages();
+
+		for (Message msgAux: msgs)
+		{
+			IMAPMessage m = (IMAPMessage)msgAux;
+			try
+			{
+				dumpPart(m, listIMAPMsgs);
+			}catch(Exception e)
+			{
+				continue;
+			}
+		}
+		imapFAux.removeACL("expresso-admin");
+		System.out.println(imapFAux.getFullName()); 
+		for(int i = 0; i < listIMAPMsgs.size(); i++ )
+		{
+			SolrInputDocument doc = new SolrInputDocument();
+			doc.addField("id", listIMAPMsgs.get(i).getId());
+			doc.addField("user", listIMAPMsgs.get(i).getUser());
+			doc.addField("folder", listIMAPMsgs.get(i).getFolder());
+			doc.addField("msg_no", listIMAPMsgs.get(i).getMsgNo());
+			doc.addField("from", listIMAPMsgs.get(i).getFrom());
+			doc.addField("to", listIMAPMsgs.get(i).getTo());
+			doc.addField("subject", listIMAPMsgs.get(i).getSubject());
+			doc.addField("content", listIMAPMsgs.get(i).getContent());
+			doc.addField("copyto", listIMAPMsgs.get(i).getCopyto());
+			doc.addField("sent_date", listIMAPMsgs.get(i).getSent_date());
+			doc.addField("hiddencopyto", listIMAPMsgs.get(i).getHiddencopyto());
+
+		}
+		listIMAPMsgs = null;
+		solrServer.commit();
+		solrServer = null;
+	}
+
+	public void dumpPart(IMAPMessage m, List<Message2SolrEntity> listIMAPMsgs) throws Exception 
+	{
+		//Verifica se possui identificador para poder continuar
+		if(m.getMessageID() == null || m.getMessageID().equals("")){
+			return;
+		}
+		
+		Message2SolrEntity msgEntity = null;
+		msgEntity = new Message2SolrEntity();
+		
+		msgEntity.setId(new StringBuilder( m.getMessageID()));
+		
+		String user = m.getFolder().getFullName().split("/")[1];
+		msgEntity.setUser(new StringBuilder(user));
+		
+		String folder = m.getFolder().getFullName().split("/")
+				[m.getFolder().getFullName().split("/").length-1];
+		
+		if(!user.trim().equals(folder.trim()))
+		{
+			msgEntity.setFolder(new StringBuilder(folder));
+		}
+		else
+		{
+			msgEntity.setFolder(new StringBuilder("INBOX"));
+		}
+
+		msgEntity.setMsgNo(new StringBuilder(String.valueOf(m.getMessageNumber())));
+
+
+		if(m.getSubject() != null){
+			msgEntity.setSubject(new StringBuilder( m.getSubject() ));
+		}
+		Address[] a;
+		// FROM 
+		if ((a = m.getFrom()) != null) {
+			for (int j = 0; j < a.length; j++)
+			{
+				if(msgEntity.getFrom() == null)
+				{
+					msgEntity.setFrom(new StringBuilder(a[j].toString()));
+				}
+				else
+				{
+					msgEntity.setFrom(msgEntity.getFrom().append(", ").append(a[j].toString()));
+				}
+				//					System.out.println("FROM: " + a[j].toString());
+			}
+
+		}
+
+		// TO
+		if ((a = m.getRecipients(Message.RecipientType.TO)) != null) {
+			for (int j = 0; j < a.length; j++)
+			{
+				if(msgEntity.getTo() == null)
+				{
+					msgEntity.setTo(new StringBuilder(a[j].toString()));
+				}
+				else
+				{
+					msgEntity.setTo(msgEntity.getTo().append(", ").append(a[j].toString()));
+				}
+			}
+		}
+
+		// CC
+		if ((a = m.getRecipients(Message.RecipientType.CC)) != null) {
+			for (int j = 0; j < a.length; j++)
+			{
+				if(msgEntity.getCopyto() == null)
+				{
+					msgEntity.setCopyto(new StringBuilder(a[j].toString()));
+				}
+				else
+				{
+					msgEntity.setCopyto(msgEntity.getCopyto().append(", ").append(a[j].toString()));
+				}
+			}
+		}
+		// CC
+		if ((a = m.getRecipients(Message.RecipientType.BCC)) != null) {
+			for (int j = 0; j < a.length; j++)
+			{
+				if(msgEntity.getHiddencopyto() == null)
+				{
+					msgEntity.setHiddencopyto(new StringBuilder(a[j].toString()));
+				}
+				else
+				{
+					msgEntity.setHiddencopyto(new StringBuilder(msgEntity.getHiddencopyto() + ","+a[j].toString()));
+				}
+			}
+		}
+
+		// DATE
+		Date d = m.getSentDate();
+		if(msgEntity != null)
+		{
+			if(d != null)
+			{
+				msgEntity.setSent_date(new StringBuilder(String.valueOf(d.getTime())));
+			}
+			else
+			{
+				msgEntity.setSent_date(new StringBuilder(String.valueOf(new Date().getTime())));
+			}
+		}
+
+		try{
+			Object o = m.getContent();
+			if (o instanceof String) {
+				if( msgEntity != null )
+				{
+					msgEntity.setContent(new StringBuilder( o.toString()));
+				}
+			} else if (o instanceof Multipart) {
+				Multipart multipart = (Multipart)o;
+				int count = multipart.getCount();
+
+				for (int i = 0; i < count; i++)
+				{
+					if(msgEntity.getContent() == null || msgEntity.getContent().toString().trim().equals(""))
+					{
+						msgEntity.setContent(new StringBuilder(""));
+					}
+					if(multipart.getBodyPart(i).getContentType() != Part.ATTACHMENT)
+					{
+						msgEntity.setContent(msgEntity.getContent().append(" ").append(getPlainContent(multipart.getBodyPart(i))));
+					}
+
+				}
+
+			}
+		}catch (Exception e){
+			System.out.println("Exception ocurred!");
+			e.printStackTrace();
+		}
+
+		if(msgEntity != null && msgEntity.getId() != null){
+			listIMAPMsgs.add(msgEntity);
+		}
+
+	}
+
+	private StringBuilder getPlainContent(BodyPart bodyPart) throws IOException, MessagingException
+	{
+		try
+		{
+
+			if(bodyPart.getContent() instanceof String)
+			{
+				//				ByteArrayOutputStream out = new ByteArrayOutputStream();
+				//				InputStream in = bodyPart.getInputStream();
+				//				
+				//				byte[] buffer = new byte[1024];
+				//				byte[] data = null;
+				//				
+				//				while(in.read(buffer) != -1) {
+				//					out.write(buffer);
+				//				}
+				//				
+				//				data = out.toByteArray();
+
+				StringBuilder text = new StringBuilder(bodyPart.getContent().toString());
+
+				//				out.close();
+				//				in.close();
+
+				return text;
+			}
+		}catch(Exception e)
+		{
+			System.out.println(e.getMessage());
+			e.printStackTrace();
+			return new StringBuilder("");
+		}
+
+
+		return new StringBuilder("");
+	}
+
+}
Index: sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP/src/pkg/crawler/entity/Message2SolrEntity.java
===================================================================
--- sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP/src/pkg/crawler/entity/Message2SolrEntity.java	(revision 8056)
+++ sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP/src/pkg/crawler/entity/Message2SolrEntity.java	(revision 8056)
@@ -0,0 +1,120 @@
+package pkg.crawler.entity;
+
+public class Message2SolrEntity {
+	
+	private StringBuilder id;
+	private StringBuilder user;
+	private StringBuilder folder;
+	private StringBuilder msgNo;
+	private StringBuilder from;
+	private StringBuilder to;
+	private StringBuilder subject;
+	private StringBuilder content;
+	private StringBuilder copyto;
+	private StringBuilder hiddencopyto;
+	private StringBuilder sent_date;
+	
+	public Message2SolrEntity()
+	{
+		id = new StringBuilder("");
+		user = new StringBuilder("");
+		folder = new StringBuilder("");
+		msgNo = new StringBuilder("");
+		from = new StringBuilder("");
+		to = new StringBuilder("");
+		subject = new StringBuilder("");
+		content = new StringBuilder("");
+		copyto = new StringBuilder("");
+		hiddencopyto = new StringBuilder("");
+		sent_date = new StringBuilder("");
+	}
+	
+	public StringBuilder getId() {
+		return id;
+	}
+	
+	public void setId(StringBuilder id) {
+		this.id = id;
+	}
+	
+	public StringBuilder getUser() {
+		return user;
+	}
+
+	public void setUser(StringBuilder user) {
+		this.user = user;
+	}
+
+	public StringBuilder getFolder() {
+		return folder;
+	}
+
+	public void setFolder(StringBuilder folder) {
+		this.folder = folder;
+	}
+	
+	public StringBuilder getMsgNo() {
+		return msgNo;
+	}
+
+	public void setMsgNo(StringBuilder msgNo) {
+		this.msgNo = msgNo;
+	}
+
+	public StringBuilder getFrom() {
+		return from;
+	}
+	
+	public void setFrom(StringBuilder from) {
+		this.from = from;
+	}
+	
+	public StringBuilder getTo() {
+		return to;
+	}
+	
+	public void setTo(StringBuilder to) {
+		this.to = to;
+	}
+	
+	public StringBuilder getSubject() {
+		return subject;
+	}
+	
+	public void setSubject(StringBuilder subject) {
+		this.subject = subject;
+	}
+	
+	public StringBuilder getContent() {
+		return content;
+	}
+	
+	public void setContent(StringBuilder content) {
+		this.content = content;
+	}
+	
+	public StringBuilder getCopyto() {
+		return copyto;
+	}
+	
+	public void setCopyto(StringBuilder copyto) {
+		this.copyto = copyto;
+	}
+	
+	public StringBuilder getHiddencopyto() {
+		return hiddencopyto;
+	}
+	
+	public void setHiddencopyto(StringBuilder hiddencopyto) {
+		this.hiddencopyto = hiddencopyto;
+	}
+	
+	public StringBuilder getSent_date() {
+		return sent_date;
+	}
+	
+	public void setSent_date(StringBuilder sent_date) {
+		this.sent_date = sent_date;
+	}
+	
+}
Index: sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP/.settings/org.eclipse.jdt.core.prefs	(revision 8056)
+++ sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP/.settings/org.eclipse.jdt.core.prefs	(revision 8056)
@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.7
Index: sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP (cópia funcional)/.classpath
===================================================================
--- sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP (cópia funcional)/.classpath	(revision 8056)
+++ sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP (cópia funcional)/.classpath	(revision 8056)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="lib" path="lib/apache-solr-analysis-extras-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/apache-solr-cell-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/apache-solr-clustering-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/apache-solr-core-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/apache-solr-dataimporthandler-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/apache-solr-dataimporthandler-extras-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/apache-solr-langid-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/apache-solr-solrj-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/apache-solr-test-framework-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/apache-solr-uima-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/apache-solr-velocity-4.0.0-ALPHA.jar"/>
+	<classpathentry kind="lib" path="lib/commons-codec-1.6.jar"/>
+	<classpathentry kind="lib" path="lib/commons-io-2.1.jar"/>
+	<classpathentry kind="lib" path="lib/httpclient-4.1.3.jar"/>
+	<classpathentry kind="lib" path="lib/httpcore-4.1.4.jar"/>
+	<classpathentry kind="lib" path="lib/httpmime-4.1.3.jar"/>
+	<classpathentry kind="lib" path="lib/jcl-over-slf4j-1.6.4.jar"/>
+	<classpathentry kind="lib" path="lib/ldapjdbc.jar"/>
+	<classpathentry kind="lib" path="lib/mail.jar"/>
+	<classpathentry kind="lib" path="lib/slf4j-api-1.6.4.jar"/>
+	<classpathentry kind="lib" path="lib/wstx-asl-3.2.7.jar"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
Index: sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP (cópia funcional)/.project
===================================================================
--- sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP (cópia funcional)/.project	(revision 8056)
+++ sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP (cópia funcional)/.project	(revision 8056)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>JCrawlerForIMAP</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>
Index: sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP (cópia funcional)/src/pkg/crawler/tread/CrawlerThread.java
===================================================================
--- sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP (cópia funcional)/src/pkg/crawler/tread/CrawlerThread.java	(revision 8056)
+++ sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP (cópia funcional)/src/pkg/crawler/tread/CrawlerThread.java	(revision 8056)
@@ -0,0 +1,384 @@
+package pkg.crawler.tread;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.mail.Address;
+import javax.mail.BodyPart;
+import javax.mail.Folder;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.Multipart;
+import javax.mail.Part;
+
+import org.apache.solr.client.solrj.SolrServer;
+import org.apache.solr.client.solrj.impl.HttpSolrServer;
+import org.apache.solr.common.SolrInputDocument;
+
+import pkg.crawler.entity.Message2SolrEntity;
+
+import com.sun.mail.imap.ACL;
+import com.sun.mail.imap.IMAPFolder;
+import com.sun.mail.imap.IMAPMessage;
+import com.sun.mail.imap.Rights;
+import com.sun.mail.imap.Rights.Right;
+
+
+public class CrawlerThread implements Runnable{
+
+	private String hostSolr;
+	private ACL acl;
+	private IMAPFolder imapFINBOXAux;
+
+	/**
+	 * @param args
+	 */
+	public static void main(String[] args) {
+		// TODO Auto-generated method stub
+
+	}
+
+
+	public CrawlerThread(IMAPFolder imapFINBOXAux, String hostSolr)
+	{
+		this.hostSolr = hostSolr;
+		this.imapFINBOXAux = imapFINBOXAux;
+
+		//Cria a ACL a ser configurada
+		acl = new ACL("expresso-admin");
+
+		//Define direito de leitura
+		Rights rights = new Rights();
+		rights.add(Right.READ);
+
+		//Configura direito de leitura para a ACL
+		acl.setRights(rights);
+	}
+	@Override
+	public void run() {
+		try {
+			Thread.sleep(5000);
+		} catch (InterruptedException e1) {
+			// TODO Auto-generated catch block
+			e1.printStackTrace();
+		}
+		//Cria uma instÃ¢ncia de conexÃ£o com o servidor Solr
+		SolrServer solrServer = new HttpSolrServer(hostSolr);
+
+		//Cria 
+		List<Message2SolrEntity> listIMAPMsgs = new ArrayList<Message2SolrEntity>();
+		//INBOX
+
+		//Adiciona ACL de permissÃ£o de leitura, para o usuÃ¡rio expresso-admin conseguir fazer a leitura
+		try
+		{
+			imapFINBOXAux.addACL(acl);
+
+
+			//Abre a caixa de e-mail
+			imapFINBOXAux.open(Folder.READ_ONLY);
+
+			//Carrega as mensagens da caixa para um array
+			Message[] msgsINBOX = imapFINBOXAux.getMessages();
+
+			//Faz a iteraÃ§Ã£o entre as mensagens
+			for (Message msgAuxINBOX : msgsINBOX)
+			{
+
+				IMAPMessage m = (IMAPMessage)msgAuxINBOX;
+
+				//adiciona as mensagens na varÃ­avel listIMAPMsgs
+				try
+				{
+					dumpPart(m, listIMAPMsgs);
+				}catch(Exception e)
+				{
+					continue;
+				}
+			}
+			imapFINBOXAux.removeACL("expresso-admin");
+			for(int i = 0; i < listIMAPMsgs.size(); i++ )
+			{
+				SolrInputDocument doc = new SolrInputDocument();
+				doc.addField("id", listIMAPMsgs.get(i).getId().toString());
+				doc.addField("user", listIMAPMsgs.get(i).getUser().toString());
+				doc.addField("folder", listIMAPMsgs.get(i).getFolder().toString());
+				doc.addField("msg_no", listIMAPMsgs.get(i).getMsgNo());
+				doc.addField("from", listIMAPMsgs.get(i).getFrom().toString());
+				doc.addField("to", listIMAPMsgs.get(i).getTo().toString());
+				doc.addField("subject", listIMAPMsgs.get(i).getSubject().toString());
+				doc.addField("content", listIMAPMsgs.get(i).getContent().toString());
+				doc.addField("copyto", listIMAPMsgs.get(i).getCopyto().toString());
+				doc.addField("sent_date", listIMAPMsgs.get(i).getSent_date());
+				doc.addField("hiddencopyto", listIMAPMsgs.get(i).getHiddencopyto().toString());
+
+				try {
+					solrServer.add(doc);
+				} catch (Exception e) {
+					System.err.println("solr -> " + e.getMessage());
+				}
+
+			}
+
+			listIMAPMsgs = null;
+
+			solrServer.commit();
+
+			solrServer = null;
+
+			for (Folder fAux : imapFINBOXAux.list())
+			{
+				//Verifica se nÃ£o Ã© uma pasta compartilhada
+				if(fAux.getFullName().split("/").length <= 3 && !fAux.getFullName().split("/")[2].equals("user"))
+				{
+					//INBOX
+					IMAPFolder imapFAux = (IMAPFolder)fAux;
+
+					crawIntoUserFolders(imapFAux);
+
+				}
+			}
+		}
+		catch (Exception e)
+		{
+			//do nothing
+		}
+	}
+
+	private void crawIntoUserFolders(IMAPFolder imapFAux) throws Exception
+	{
+		SolrServer solrServer = new HttpSolrServer(hostSolr);
+
+		List<Message2SolrEntity> listIMAPMsgs = new ArrayList<Message2SolrEntity>();
+
+		try
+		{
+			imapFAux.addACL(acl);
+		}catch(Exception e)
+		{
+			return;
+		}
+
+		imapFAux.open(Folder.READ_ONLY);
+
+		Message[] msgs= imapFAux.getMessages();
+
+		for (Message msgAux: msgs)
+		{
+			IMAPMessage m = (IMAPMessage)msgAux;
+			try
+			{
+				dumpPart(m, listIMAPMsgs);
+			}catch(Exception e)
+			{
+				continue;
+			}
+		}
+		imapFAux.removeACL("expresso-admin");
+		System.out.println(imapFAux.getFullName()); 
+		for(int i = 0; i < listIMAPMsgs.size(); i++ )
+		{
+			SolrInputDocument doc = new SolrInputDocument();
+			doc.addField("id", listIMAPMsgs.get(i).getId());
+			doc.addField("user", listIMAPMsgs.get(i).getUser());
+			doc.addField("folder", listIMAPMsgs.get(i).getFolder());
+			doc.addField("msg_no", listIMAPMsgs.get(i).getMsgNo());
+			doc.addField("from", listIMAPMsgs.get(i).getFrom());
+			doc.addField("to", listIMAPMsgs.get(i).getTo());
+			doc.addField("subject", listIMAPMsgs.get(i).getSubject());
+			doc.addField("content", listIMAPMsgs.get(i).getContent());
+			doc.addField("copyto", listIMAPMsgs.get(i).getCopyto());
+			doc.addField("sent_date", listIMAPMsgs.get(i).getSent_date());
+			doc.addField("hiddencopyto", listIMAPMsgs.get(i).getHiddencopyto());
+
+		}
+		listIMAPMsgs = null;
+		solrServer.commit();
+		solrServer = null;
+	}
+
+	public void dumpPart(IMAPMessage m, List<Message2SolrEntity> listIMAPMsgs) throws Exception 
+	{
+		//Verifica se possui identificador para poder continuar
+		if(m.getMessageID() == null || m.getMessageID().equals("")){
+			return;
+		}
+
+		Message2SolrEntity msgEntity = null;
+		msgEntity = new Message2SolrEntity();
+
+		msgEntity.setId(new StringBuilder( m.getMessageID()));
+
+		String user = m.getFolder().getFullName().split("/")[1];
+		msgEntity.setUser(new StringBuilder(user));
+
+		String folder = m.getFolder().getFullName().split("/")
+				[m.getFolder().getFullName().split("/").length-1];
+
+		if(!user.trim().equals(folder.trim()))
+		{
+			msgEntity.setFolder(new StringBuilder(folder));
+		}
+		else
+		{
+			msgEntity.setFolder(new StringBuilder("INBOX"));
+		}
+
+		msgEntity.setMsgNo(new StringBuilder(String.valueOf(m.getMessageNumber())));
+
+
+		if(m.getSubject() != null){
+			msgEntity.setSubject(new StringBuilder( m.getSubject() ));
+		}
+		Address[] a;
+		// FROM 
+		if ((a = m.getFrom()) != null) {
+			for (int j = 0; j < a.length; j++)
+			{
+				if(msgEntity.getFrom() == null)
+				{
+					msgEntity.setFrom(new StringBuilder(a[j].toString()));
+				}
+				else
+				{
+					msgEntity.setFrom(msgEntity.getFrom().append(", ").append(a[j].toString()));
+				}
+				//					System.out.println("FROM: " + a[j].toString());
+			}
+
+		}
+
+		// TO
+		if ((a = m.getRecipients(Message.RecipientType.TO)) != null) {
+			for (int j = 0; j < a.length; j++)
+			{
+				if(msgEntity.getTo() == null)
+				{
+					msgEntity.setTo(new StringBuilder(a[j].toString()));
+				}
+				else
+				{
+					msgEntity.setTo(msgEntity.getTo().append(", ").append(a[j].toString()));
+				}
+			}
+		}
+
+		// CC
+		if ((a = m.getRecipients(Message.RecipientType.CC)) != null) {
+			for (int j = 0; j < a.length; j++)
+			{
+				if(msgEntity.getCopyto() == null)
+				{
+					msgEntity.setCopyto(new StringBuilder(a[j].toString()));
+				}
+				else
+				{
+					msgEntity.setCopyto(msgEntity.getCopyto().append(", ").append(a[j].toString()));
+				}
+			}
+		}
+		// CC
+		if ((a = m.getRecipients(Message.RecipientType.BCC)) != null) {
+			for (int j = 0; j < a.length; j++)
+			{
+				if(msgEntity.getHiddencopyto() == null)
+				{
+					msgEntity.setHiddencopyto(new StringBuilder(a[j].toString()));
+				}
+				else
+				{
+					msgEntity.setHiddencopyto(new StringBuilder(msgEntity.getHiddencopyto() + ","+a[j].toString()));
+				}
+			}
+		}
+
+		// DATE
+		Date d = m.getSentDate();
+		if(msgEntity != null)
+		{
+			if(d != null)
+			{
+				msgEntity.setSent_date(new StringBuilder(String.valueOf(d.getTime())));
+			}
+			else
+			{
+				msgEntity.setSent_date(new StringBuilder(String.valueOf(new Date().getTime())));
+			}
+		}
+
+		try{
+			Object o = m.getContent();
+			if (o instanceof String) {
+				if( msgEntity != null )
+				{
+					msgEntity.setContent(new StringBuilder( o.toString()));
+				}
+			} else if (o instanceof Multipart) {
+				Multipart multipart = (Multipart)o;
+				int count = multipart.getCount();
+
+				for (int i = 0; i < count; i++)
+				{
+					if(msgEntity.getContent() == null || msgEntity.getContent().toString().trim().equals(""))
+					{
+						msgEntity.setContent(new StringBuilder(""));
+					}
+					if(multipart.getBodyPart(i).getContentType() != Part.ATTACHMENT)
+					{
+						msgEntity.setContent(msgEntity.getContent().append(" ").append(getPlainContent(multipart.getBodyPart(i))));
+					}
+
+				}
+
+			}
+		}catch (Exception e){
+			System.out.println("Exception ocurred!");
+			e.printStackTrace();
+		}
+
+		if(msgEntity != null && msgEntity.getId() != null){
+			listIMAPMsgs.add(msgEntity);
+		}
+
+	}
+
+	private StringBuilder getPlainContent(BodyPart bodyPart) throws IOException, MessagingException
+	{
+		try
+		{
+
+			if(bodyPart.getContent() instanceof String)
+			{
+				//				ByteArrayOutputStream out = new ByteArrayOutputStream();
+				//				InputStream in = bodyPart.getInputStream();
+				//				
+				//				byte[] buffer = new byte[1024];
+				//				byte[] data = null;
+				//				
+				//				while(in.read(buffer) != -1) {
+				//					out.write(buffer);
+				//				}
+				//				
+				//				data = out.toByteArray();
+
+				StringBuilder text = new StringBuilder(bodyPart.getContent().toString());
+
+				//				out.close();
+				//				in.close();
+
+				return text;
+			}
+		}catch(Exception e)
+		{
+			System.out.println(e.getMessage());
+			e.printStackTrace();
+			return new StringBuilder("");
+		}
+
+
+		return new StringBuilder("");
+	}
+
+}
Index: sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP (cópia funcional)/src/pkg/crawler/main/Main.java
===================================================================
--- sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP (cópia funcional)/src/pkg/crawler/main/Main.java	(revision 8056)
+++ sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP (cópia funcional)/src/pkg/crawler/main/Main.java	(revision 8056)
@@ -0,0 +1,35 @@
+package pkg.crawler.main;
+
+import pkg.crawler.data.conn.Crawler;
+
+public class Main {
+
+	/**
+	 * @param args
+	 * DeverÃ£o ser 4 argumentos: 
+	 */
+	public static void main(String[] args) {
+		
+		if (args == null || args.length != 3){
+			System.out.println("Uso:\n" +
+					"java -jar crawler.jar [imap_host] " +
+					"[imap_admin_password] " +
+					"[http_solr_host_address] ");
+			System.exit(0);
+		}
+		
+		//O endereÃ§o que estÃ¡ instalado o Expresso Ex: "127.1.1.1"
+		String host = args[0];
+		//Senha do usuÃ¡rio 'expresso-admin' Ex: "admin123"
+		String password = args[1];
+		//EndereÃ§o do servidor do Solr Ex: "http://127.1.1.1:8983/solr/"
+		String hostSolr = args[2];
+		
+		Crawler crawler = new Crawler(host, password, hostSolr);
+		
+		crawler.run();
+		
+		
+	}
+
+}
Index: sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP (cópia funcional)/src/pkg/crawler/data/conn/CopyOfCrawler.java
===================================================================
--- sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP (cópia funcional)/src/pkg/crawler/data/conn/CopyOfCrawler.java	(revision 8056)
+++ sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP (cópia funcional)/src/pkg/crawler/data/conn/CopyOfCrawler.java	(revision 8056)
@@ -0,0 +1,314 @@
+package pkg.crawler.data.conn;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Properties;
+
+import javax.mail.Address;
+import javax.mail.Folder;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.Multipart;
+import javax.mail.Part;
+import javax.mail.Session;
+
+import org.apache.solr.client.solrj.SolrServer;
+import org.apache.solr.client.solrj.impl.HttpSolrServer;
+import org.apache.solr.common.SolrInputDocument;
+
+import pkg.crawler.entity.Message2SolrEntity;
+
+import com.sun.mail.imap.ACL;
+import com.sun.mail.imap.IMAPFolder;
+import com.sun.mail.imap.IMAPMessage;
+import com.sun.mail.imap.IMAPStore;
+import com.sun.mail.imap.Rights;
+import com.sun.mail.imap.Rights.Right;
+
+public class CopyOfCrawler{
+
+	private String host;
+	private String user;
+	private String password;
+	private String mbox;
+	private String url;
+	private boolean debug;
+	private String loginStartsWith;
+	private static ArrayList<Message2SolrEntity> listIMAPMsgs = new ArrayList<Message2SolrEntity>();
+
+
+//	public CopyOfCrawler(String loginStartsWith)
+//	{
+//		this.host = "172.25.60.61";
+//		this.user = "expresso-admin";
+//		this.password = "pti123";
+//		this.mbox = "user";
+//		this.url = null;
+//		this.debug = false;
+//		this.loginStartsWith = loginStartsWith; 
+//	}
+//
+//
+//	@Override
+//	public void run()
+//	{
+//
+//		//Inicializando as propriedades default da mÃ¡quina para conexÃ£o
+//		//com o servidor IMAP
+//		Properties props = System.getProperties();
+//		Session session = Session.getInstance(props, null);
+//
+//		IMAPStore store = new IMAPStore(session, null);
+//
+//		try {
+//
+//			//Conectando com o servidor IMAP
+//			store.connect(host, user, password);
+//			//Definindo a pasta base a ser usada
+//			IMAPFolder imapFolder = (IMAPFolder)store.getFolder(mbox);
+//
+//			//Cria a ACL a ser configurada
+//			ACL acl = new ACL("expresso-admin");
+//
+//			Rights rights = new Rights();
+//			rights.add(Right.READ);
+//
+//
+//			//Configura direito de leitura para a ACL
+//			acl.setRights(rights);
+//
+//			SolrServer solrServer = new HttpSolrServer("http://172.25.60.61:8983/solr/");
+//			
+//			solrServer.deleteByQuery("*:*");
+//			//Faz a iteraÃ§Ã£o entre os usuÃ¡rios
+//			for (Folder fINBOXAux : imapFolder.list())
+//			{
+//				//INBOX
+//				IMAPFolder imapFINBOXAux = (IMAPFolder)fINBOXAux;
+//
+//				imapFINBOXAux.addACL(acl);
+//
+//				imapFINBOXAux.open(Folder.READ_ONLY);
+//
+//				Message[] msgsINBOX = imapFINBOXAux.getMessages();
+//
+//				for (Message msgAuxINBOX : msgsINBOX)
+//				{
+//					dumpPart(msgAuxINBOX);
+//				}
+//				imapFINBOXAux.removeACL("expresso-admin");
+//				for(int i = 0; i < CopyOfCrawler.listIMAPMsgs.size(); i++ )
+//				{
+//					SolrInputDocument doc = new SolrInputDocument();
+//					doc.addField("id", listIMAPMsgs.get(i).getId());
+//					doc.addField("user", listIMAPMsgs.get(i).getUser());
+//					doc.addField("folder", listIMAPMsgs.get(i).getUser());
+//					doc.addField("from", listIMAPMsgs.get(i).getFrom());
+//					doc.addField("to", listIMAPMsgs.get(i).getTo());
+//					doc.addField("subject", listIMAPMsgs.get(i).getSubject());
+//					doc.addField("content", listIMAPMsgs.get(i).getContent());
+//					doc.addField("copyto", listIMAPMsgs.get(i).getCopyto());
+//					doc.addField("hiddencopyto", listIMAPMsgs.get(i).getHiddencopyto());
+//
+//					solrServer.add(doc);
+//				}
+//
+//				CopyOfCrawler.listIMAPMsgs.clear();
+//
+//				solrServer.commit();
+//
+//				for (Folder fAux : imapFINBOXAux.list())
+//				{
+//
+//					//INBOX
+//					IMAPFolder imapFAux = (IMAPFolder)fAux;
+//
+//					imapFAux.addACL(acl);
+//
+//					imapFAux.open(Folder.READ_ONLY);
+//
+//					Message[] msgs= imapFAux.getMessages();
+//
+//					for (Message msgAux: msgs)
+//					{
+//						dumpPart(msgAux);
+//					}
+//					imapFAux.removeACL("expresso-admin");
+//					System.out.println(imapFAux.getFullName()); 
+//					for(int i = 0; i < CopyOfCrawler.listIMAPMsgs.size(); i++ )
+//					{
+//						SolrInputDocument doc = new SolrInputDocument();
+//						doc.addField("id", listIMAPMsgs.get(i).getId());
+//						doc.addField("user", listIMAPMsgs.get(i).getUser());
+//						doc.addField("folder", listIMAPMsgs.get(i).getUser());
+//						doc.addField("from", listIMAPMsgs.get(i).getFrom());
+//						doc.addField("to", listIMAPMsgs.get(i).getTo());
+//						doc.addField("subject", listIMAPMsgs.get(i).getSubject());
+//						doc.addField("content", listIMAPMsgs.get(i).getContent());
+//						doc.addField("copyto", listIMAPMsgs.get(i).getCopyto());
+//						doc.addField("hiddencopyto", listIMAPMsgs.get(i).getHiddencopyto());
+//
+//						solrServer.add(doc);
+//					}
+//					CopyOfCrawler.listIMAPMsgs.clear();
+//				}
+//
+//
+//				System.out.println(imapFINBOXAux.getFullName()); 
+//				//				IMAPFolder imapFAux = (IMAPFolder)imapFolder.list()[0]; //INBOX
+//				//				IMAPFolder imapFAux = (IMAPFolder)imapFolder.list()[0].list()[0]; //AprovaÃ§Ãµes e talz
+//				//				
+//				//				imapFAux.addRights(acl);
+//				//				imapFAux.open(IMAPFolder.READ_ONLY);
+//				//				System.out.println(imapFAux.getMessageCount());
+//				//				
+//				//				IMAPMessage message = (IMAPMessage)imapFAux.getMessages()[0];
+//				//				
+//				//				System.out.println(message.getMessageID());
+//				//				System.out.println(message.getContentType());
+//				//				
+//				//				
+//				//				imapFAux.removeACL("expresso-admin");
+//				//				imapFAux.close(false);
+//			}
+//
+//
+//		} catch (MessagingException e) {
+//			// TODO Auto-generated catch block
+//			e.printStackTrace();
+//		}
+//		catch (Exception e)
+//		{
+//			e.printStackTrace();
+//		}
+//	}
+//
+//
+//	public static void dumpPart(Part p) throws Exception {
+//		Message2SolrEntity msgEntity = null;
+//
+//		if (p instanceof Message) {
+//			msgEntity = new Message2SolrEntity();
+//			IMAPMessage m = (IMAPMessage)p;
+//
+//			msgEntity.setId(m.getMessageID());
+//			
+//			if(msgEntity.getId() == null || msgEntity.getId().equals("")){
+//				System.out.println("Damn it!");
+//			}
+//
+//			String user = m.getFolder().getFullName().split("/")[1];
+//			msgEntity.setUser(user);
+//
+//			String folder = m.getFolder().getFullName().split("/")
+//					[m.getFolder().getFullName().split("/").length-1];
+//
+//			if(!user.equals(folder))
+//			{
+//				msgEntity.setFolder(folder);
+//			}
+//			else
+//			{
+//				msgEntity.setFolder("INBOX");
+//			}
+//			
+//			
+//			
+//			msgEntity.setSubject(m.getSubject());
+//			Address[] a;
+//			// FROM 
+//			if ((a = m.getFrom()) != null) {
+//				for (int j = 0; j < a.length; j++)
+//				{
+//					if(msgEntity.getFrom() == null)
+//					{
+//						msgEntity.setFrom(a[j].toString());
+//					}
+//					else
+//					{
+//						msgEntity.setFrom(msgEntity.getFrom() + ","+a[j].toString());
+//					}
+//					//					System.out.println("FROM: " + a[j].toString());
+//				}
+//
+//			}
+//
+//			// TO
+//			if ((a = m.getRecipients(Message.RecipientType.TO)) != null) {
+//				for (int j = 0; j < a.length; j++)
+//				{
+//					if(msgEntity.getTo() == null)
+//					{
+//						msgEntity.setTo(a[j].toString());
+//					}
+//					else
+//					{
+//						msgEntity.setTo(msgEntity.getTo() + ","+a[j].toString());
+//					}
+//				}
+//			}
+//
+//			// CC
+//			if ((a = m.getRecipients(Message.RecipientType.CC)) != null) {
+//				for (int j = 0; j < a.length; j++)
+//				{
+//					if(msgEntity.getCopyto() == null)
+//					{
+//						msgEntity.setCopyto(a[j].toString());
+//					}
+//					else
+//					{
+//						msgEntity.setCopyto(msgEntity.getCopyto() + ","+a[j].toString());
+//					}
+//				}
+//			}
+//			// CC
+//			if ((a = m.getRecipients(Message.RecipientType.BCC)) != null) {
+//				for (int j = 0; j < a.length; j++)
+//				{
+//					if(msgEntity.getHiddencopyto() == null)
+//					{
+//						msgEntity.setHiddencopyto(a[j].toString());
+//					}
+//					else
+//					{
+//						msgEntity.setHiddencopyto(msgEntity.getHiddencopyto() + ","+a[j].toString());
+//					}
+//				}
+//			}
+//
+//			// DATE
+//			Date d = m.getSentDate();
+//			if(msgEntity != null)
+//			{
+//				msgEntity.setSent_date((d != null ? d.toLocaleString() : "UNKNOWN"));
+//			}
+//
+//
+//		}
+//
+//		try{
+//			Object o = p.getContent();
+//			if (o instanceof String) {
+//				if( msgEntity != null )
+//				{
+//					msgEntity.setContent((String)o);
+//				}
+//			} else if (o instanceof Multipart) {
+//				Multipart mp = (Multipart)o;
+//				int count = mp.getCount();
+//				for (int i = 0; i < count; i++)
+//					dumpPart(mp.getBodyPart(i));
+//			}
+//		}catch (Exception e){
+//			System.out.println("Exception ocurred!");
+//			e.printStackTrace();
+//		}
+//
+//		if(msgEntity != null && msgEntity.getId() != null){
+//			CopyOfCrawler.listIMAPMsgs.add(msgEntity);
+//		}
+//
+//	}	
+
+}
Index: sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP (cópia funcional)/src/pkg/crawler/data/conn/Crawler.java
===================================================================
--- sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP (cópia funcional)/src/pkg/crawler/data/conn/Crawler.java	(revision 8056)
+++ sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP (cópia funcional)/src/pkg/crawler/data/conn/Crawler.java	(revision 8056)
@@ -0,0 +1,100 @@
+package pkg.crawler.data.conn;
+
+import java.util.Properties;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+
+import javax.mail.Folder;
+import javax.mail.MessagingException;
+import javax.mail.Session;
+
+import pkg.crawler.tread.CrawlerThread;
+
+import com.sun.mail.imap.ACL;
+import com.sun.mail.imap.IMAPFolder;
+import com.sun.mail.imap.IMAPStore;
+import com.sun.mail.imap.Rights;
+import com.sun.mail.imap.Rights.Right;
+
+public class Crawler{
+
+	private String host;
+	private String user;
+	private String password;
+	private String mbox;
+	private String hostSolr;
+	private ACL acl;
+
+	public Crawler(String host, String password, String hostSolr)
+	{
+		this.host = host;
+		this.user = "expresso-admin";
+		this.password = password;
+		this.mbox = "user";
+		this.hostSolr = hostSolr;
+
+		//Cria a ACL a ser configurada
+		acl = new ACL("expresso-admin");
+
+		//Define direito de leitura
+		Rights rights = new Rights();
+		rights.add(Right.READ);
+
+		//Configura direito de leitura para a ACL
+		acl.setRights(rights);
+	}
+
+
+	public void run()
+	{
+		
+		int iAux0 = 0;
+		while (iAux0 == 0)
+		{
+			iAux0 = 1;
+
+			//Inicializando as propriedades default da mÃ¡quina para conexÃ£o
+			//com o servidor IMAP
+			Properties props = System.getProperties();
+			Session session = Session.getInstance(props, null);
+
+			IMAPStore store = new IMAPStore(session, null);
+
+			try {
+
+				//Conectando com o servidor IMAP
+				store.connect(host, user, password);
+				//Definindo a pasta base a ser usada
+				IMAPFolder imapFolder = (IMAPFolder)store.getFolder(mbox);
+				ScheduledThreadPoolExecutor doAll = new ScheduledThreadPoolExecutor(4);
+				//Faz a iteraÃ§Ã£o entre os usuÃ¡rios/pastas do usuÃ¡rio
+				
+				for (Folder fINBOXAux : imapFolder.list())
+				{
+					System.out.println(fINBOXAux.getFullName());
+					try
+					{
+						CrawlerThread crawlerThread = new CrawlerThread((IMAPFolder)fINBOXAux, hostSolr);
+						
+						doAll.execute(crawlerThread);
+						
+					}
+					catch (Exception e)
+					{
+						continue;
+					}
+					
+				}	
+
+			} catch (MessagingException e) {
+				System.out.println(e.getMessage());
+				e.printStackTrace();
+			}
+			catch (Exception e)
+			{
+				System.out.println(e.getMessage());
+				e.printStackTrace();
+			}
+		}
+	}
+
+}
Index: sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP (cópia funcional)/src/pkg/crawler/data/conn/Copy_2_of_Crawler.java
===================================================================
--- sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP (cópia funcional)/src/pkg/crawler/data/conn/Copy_2_of_Crawler.java	(revision 8056)
+++ sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP (cópia funcional)/src/pkg/crawler/data/conn/Copy_2_of_Crawler.java	(revision 8056)
@@ -0,0 +1,423 @@
+package pkg.crawler.data.conn;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Properties;
+
+import javax.mail.Address;
+import javax.mail.BodyPart;
+import javax.mail.Folder;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.Multipart;
+import javax.mail.Part;
+import javax.mail.Session;
+
+import org.apache.solr.client.solrj.SolrServer;
+import org.apache.solr.client.solrj.impl.HttpSolrServer;
+import org.apache.solr.common.SolrInputDocument;
+
+import pkg.crawler.entity.Message2SolrEntity;
+
+import com.sun.mail.imap.ACL;
+import com.sun.mail.imap.IMAPFolder;
+import com.sun.mail.imap.IMAPMessage;
+import com.sun.mail.imap.IMAPStore;
+import com.sun.mail.imap.Rights;
+import com.sun.mail.imap.Rights.Right;
+
+public class Copy_2_of_Crawler{
+
+	private String host;
+	private String user;
+	private String password;
+	private String mbox;
+	private String hostSolr;
+	//	private ArrayList<Message2SolrEntity> listIMAPMsgs;
+	private ACL acl;
+
+	public Copy_2_of_Crawler(String host, String password, String hostSolr)
+	{
+		this.host = host;
+		this.user = "expresso-admin";
+		this.password = password;
+		this.mbox = "user";
+		this.hostSolr = hostSolr;
+
+		//Cria a ACL a ser configurada
+		acl = new ACL("expresso-admin");
+
+		//Define direito de leitura
+		Rights rights = new Rights();
+		rights.add(Right.READ);
+
+		//Configura direito de leitura para a ACL
+		acl.setRights(rights);
+	}
+
+
+	public void run()
+	{
+		
+		int iAux0 = 0;
+		while (iAux0 == 0)
+		{
+			iAux0 = 1;
+
+			//Inicializando as propriedades default da mÃ¡quina para conexÃ£o
+			//com o servidor IMAP
+			Properties props = System.getProperties();
+			Session session = Session.getInstance(props, null);
+
+			IMAPStore store = new IMAPStore(session, null);
+
+			try {
+
+				//Conectando com o servidor IMAP
+				store.connect(host, user, password);
+				//Definindo a pasta base a ser usada
+				IMAPFolder imapFolder = (IMAPFolder)store.getFolder(mbox);
+
+				//Faz a iteraÃ§Ã£o entre os usuÃ¡rios/pastas do usuÃ¡rio
+				for (Folder fINBOXAux : imapFolder.list())
+				{
+					System.out.println(fINBOXAux.getFullName());
+					
+					//Cria uma instÃ¢ncia de conexÃ£o com o servidor Solr
+					SolrServer solrServer = new HttpSolrServer(hostSolr);
+
+					//Cria 
+					List<Message2SolrEntity> listIMAPMsgs = new ArrayList<Message2SolrEntity>();
+					//INBOX
+					IMAPFolder imapFINBOXAux = (IMAPFolder)fINBOXAux;
+					
+					//Adiciona ACL de permissÃ£o de leitura, para o usuÃ¡rio expresso-admin conseguir fazer a leitura
+					try
+					{
+						imapFINBOXAux.addACL(acl);
+					}
+					catch (Exception e)
+					{
+						continue;
+					}
+					
+					//Abre a caixa de e-mail
+					imapFINBOXAux.open(Folder.READ_ONLY);
+					
+					//Carrega as mensagens da caixa para um array
+					Message[] msgsINBOX = imapFINBOXAux.getMessages();
+					
+					//Faz a iteraÃ§Ã£o entre as mensagens
+					for (Message msgAuxINBOX : msgsINBOX)
+					{
+						
+						IMAPMessage m = (IMAPMessage)msgAuxINBOX;
+						
+						//adiciona as mensagens na varÃ­avel listIMAPMsgs
+						try
+						{
+							dumpPart(m, listIMAPMsgs);
+						}catch(Exception e)
+						{
+							continue;
+						}
+					}
+					imapFINBOXAux.removeACL("expresso-admin");
+					for(int i = 0; i < listIMAPMsgs.size(); i++ )
+					{
+						SolrInputDocument doc = new SolrInputDocument();
+						doc.addField("id", listIMAPMsgs.get(i).getId().toString());
+						doc.addField("user", listIMAPMsgs.get(i).getUser().toString());
+						doc.addField("folder", listIMAPMsgs.get(i).getFolder().toString());
+						doc.addField("msg_no", listIMAPMsgs.get(i).getMsgNo());
+						doc.addField("from", listIMAPMsgs.get(i).getFrom().toString());
+						doc.addField("to", listIMAPMsgs.get(i).getTo().toString());
+						doc.addField("subject", listIMAPMsgs.get(i).getSubject().toString());
+						doc.addField("content", listIMAPMsgs.get(i).getContent().toString());
+						doc.addField("copyto", listIMAPMsgs.get(i).getCopyto().toString());
+						doc.addField("sent_date", listIMAPMsgs.get(i).getSent_date());
+						doc.addField("hiddencopyto", listIMAPMsgs.get(i).getHiddencopyto().toString());
+
+						try {
+							solrServer.add(doc);
+						} catch (Exception e) {
+							System.err.println("solr -> " + e.getMessage());
+						}
+
+					}
+
+					listIMAPMsgs = null;
+
+					solrServer.commit();
+
+					solrServer = null;
+
+					for (Folder fAux : imapFINBOXAux.list())
+					{
+						//Verifica se nÃ£o Ã© uma pasta compartilhada
+						if(fAux.getFullName().split("/").length <= 3 && !fAux.getFullName().split("/")[2].equals("user"))
+						{
+							//INBOX
+							IMAPFolder imapFAux = (IMAPFolder)fAux;
+
+							crawIntoUserFolders(imapFAux);
+
+						}
+					}
+					Thread.sleep(30000);
+					
+					System.out.println(imapFINBOXAux.getFullName()); 
+				}
+				store.close();
+				
+				
+
+			} catch (MessagingException e) {
+				System.out.println(e.getMessage());
+				e.printStackTrace();
+			}
+			catch (Exception e)
+			{
+				System.out.println(e.getMessage());
+				e.printStackTrace();
+			}
+		}
+	}
+
+	private void crawIntoUserFolders(IMAPFolder imapFAux) throws Exception
+	{
+		SolrServer solrServer = new HttpSolrServer(hostSolr);
+
+		List<Message2SolrEntity> listIMAPMsgs = new ArrayList<Message2SolrEntity>();
+		
+		try
+		{
+			imapFAux.addACL(acl);
+		}catch(Exception e)
+		{
+			return;
+		}
+
+		imapFAux.open(Folder.READ_ONLY);
+
+		Message[] msgs= imapFAux.getMessages();
+
+		for (Message msgAux: msgs)
+		{
+			IMAPMessage m = (IMAPMessage)msgAux;
+			try
+			{
+				dumpPart(m, listIMAPMsgs);
+			}catch(Exception e)
+			{
+				continue;
+			}
+		}
+		imapFAux.removeACL("expresso-admin");
+		System.out.println(imapFAux.getFullName()); 
+		for(int i = 0; i < listIMAPMsgs.size(); i++ )
+		{
+			SolrInputDocument doc = new SolrInputDocument();
+			doc.addField("id", listIMAPMsgs.get(i).getId());
+			doc.addField("user", listIMAPMsgs.get(i).getUser());
+			doc.addField("folder", listIMAPMsgs.get(i).getFolder());
+			doc.addField("msg_no", listIMAPMsgs.get(i).getMsgNo());
+			doc.addField("from", listIMAPMsgs.get(i).getFrom());
+			doc.addField("to", listIMAPMsgs.get(i).getTo());
+			doc.addField("subject", listIMAPMsgs.get(i).getSubject());
+			doc.addField("content", listIMAPMsgs.get(i).getContent());
+			doc.addField("copyto", listIMAPMsgs.get(i).getCopyto());
+			doc.addField("sent_date", listIMAPMsgs.get(i).getSent_date());
+			doc.addField("hiddencopyto", listIMAPMsgs.get(i).getHiddencopyto());
+
+		}
+		listIMAPMsgs = null;
+		solrServer.commit();
+		solrServer = null;
+	}
+
+	public void dumpPart(IMAPMessage m, List<Message2SolrEntity> listIMAPMsgs) throws Exception 
+	{
+		//Verifica se possui identificador para poder continuar
+		if(m.getMessageID() == null || m.getMessageID().equals("")){
+			return;
+		}
+		
+		Message2SolrEntity msgEntity = null;
+		msgEntity = new Message2SolrEntity();
+		
+		msgEntity.setId(new StringBuilder( m.getMessageID()));
+		
+		String user = m.getFolder().getFullName().split("/")[1];
+		msgEntity.setUser(new StringBuilder(user));
+		
+		String folder = m.getFolder().getFullName().split("/")
+				[m.getFolder().getFullName().split("/").length-1];
+		
+		if(!user.trim().equals(folder.trim()))
+		{
+			msgEntity.setFolder(new StringBuilder(folder));
+		}
+		else
+		{
+			msgEntity.setFolder(new StringBuilder("INBOX"));
+		}
+
+		msgEntity.setMsgNo(new StringBuilder(String.valueOf(m.getMessageNumber())));
+
+
+		if(m.getSubject() != null){
+			msgEntity.setSubject(new StringBuilder( m.getSubject() ));
+		}
+		Address[] a;
+		// FROM 
+		if ((a = m.getFrom()) != null) {
+			for (int j = 0; j < a.length; j++)
+			{
+				if(msgEntity.getFrom() == null)
+				{
+					msgEntity.setFrom(new StringBuilder(a[j].toString()));
+				}
+				else
+				{
+					msgEntity.setFrom(msgEntity.getFrom().append(", ").append(a[j].toString()));
+				}
+				//					System.out.println("FROM: " + a[j].toString());
+			}
+
+		}
+
+		// TO
+		if ((a = m.getRecipients(Message.RecipientType.TO)) != null) {
+			for (int j = 0; j < a.length; j++)
+			{
+				if(msgEntity.getTo() == null)
+				{
+					msgEntity.setTo(new StringBuilder(a[j].toString()));
+				}
+				else
+				{
+					msgEntity.setTo(msgEntity.getTo().append(", ").append(a[j].toString()));
+				}
+			}
+		}
+
+		// CC
+		if ((a = m.getRecipients(Message.RecipientType.CC)) != null) {
+			for (int j = 0; j < a.length; j++)
+			{
+				if(msgEntity.getCopyto() == null)
+				{
+					msgEntity.setCopyto(new StringBuilder(a[j].toString()));
+				}
+				else
+				{
+					msgEntity.setCopyto(msgEntity.getCopyto().append(", ").append(a[j].toString()));
+				}
+			}
+		}
+		// CC
+		if ((a = m.getRecipients(Message.RecipientType.BCC)) != null) {
+			for (int j = 0; j < a.length; j++)
+			{
+				if(msgEntity.getHiddencopyto() == null)
+				{
+					msgEntity.setHiddencopyto(new StringBuilder(a[j].toString()));
+				}
+				else
+				{
+					msgEntity.setHiddencopyto(new StringBuilder(msgEntity.getHiddencopyto() + ","+a[j].toString()));
+				}
+			}
+		}
+
+		// DATE
+		Date d = m.getSentDate();
+		if(msgEntity != null)
+		{
+			if(d != null)
+			{
+				msgEntity.setSent_date(new StringBuilder(String.valueOf(d.getTime())));
+			}
+			else
+			{
+				msgEntity.setSent_date(new StringBuilder(String.valueOf(new Date().getTime())));
+			}
+		}
+
+		try{
+			Object o = m.getContent();
+			if (o instanceof String) {
+				if( msgEntity != null )
+				{
+					msgEntity.setContent(new StringBuilder( o.toString()));
+				}
+			} else if (o instanceof Multipart) {
+				Multipart multipart = (Multipart)o;
+				int count = multipart.getCount();
+
+				for (int i = 0; i < count; i++)
+				{
+					if(msgEntity.getContent() == null || msgEntity.getContent().toString().trim().equals(""))
+					{
+						msgEntity.setContent(new StringBuilder(""));
+					}
+					if(multipart.getBodyPart(i).getContentType() != Part.ATTACHMENT)
+					{
+						msgEntity.setContent(msgEntity.getContent().append(" ").append(getPlainContent(multipart.getBodyPart(i))));
+					}
+
+				}
+
+			}
+		}catch (Exception e){
+			System.out.println("Exception ocurred!");
+			e.printStackTrace();
+		}
+
+		if(msgEntity != null && msgEntity.getId() != null){
+			listIMAPMsgs.add(msgEntity);
+		}
+
+	}
+
+	private StringBuilder getPlainContent(BodyPart bodyPart) throws IOException, MessagingException
+	{
+		try
+		{
+
+			if(bodyPart.getContent() instanceof String)
+			{
+				//				ByteArrayOutputStream out = new ByteArrayOutputStream();
+				//				InputStream in = bodyPart.getInputStream();
+				//				
+				//				byte[] buffer = new byte[1024];
+				//				byte[] data = null;
+				//				
+				//				while(in.read(buffer) != -1) {
+				//					out.write(buffer);
+				//				}
+				//				
+				//				data = out.toByteArray();
+
+				StringBuilder text = new StringBuilder(bodyPart.getContent().toString());
+
+				//				out.close();
+				//				in.close();
+
+				return text;
+			}
+		}catch(Exception e)
+		{
+			System.out.println(e.getMessage());
+			e.printStackTrace();
+			return new StringBuilder("");
+		}
+
+
+		return new StringBuilder("");
+	}
+
+}
Index: sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP (cópia funcional)/src/pkg/crawler/entity/Message2SolrEntity.java
===================================================================
--- sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP (cópia funcional)/src/pkg/crawler/entity/Message2SolrEntity.java	(revision 8056)
+++ sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP (cópia funcional)/src/pkg/crawler/entity/Message2SolrEntity.java	(revision 8056)
@@ -0,0 +1,120 @@
+package pkg.crawler.entity;
+
+public class Message2SolrEntity {
+	
+	private StringBuilder id;
+	private StringBuilder user;
+	private StringBuilder folder;
+	private StringBuilder msgNo;
+	private StringBuilder from;
+	private StringBuilder to;
+	private StringBuilder subject;
+	private StringBuilder content;
+	private StringBuilder copyto;
+	private StringBuilder hiddencopyto;
+	private StringBuilder sent_date;
+	
+	public Message2SolrEntity()
+	{
+		id = new StringBuilder("");
+		user = new StringBuilder("");
+		folder = new StringBuilder("");
+		msgNo = new StringBuilder("");
+		from = new StringBuilder("");
+		to = new StringBuilder("");
+		subject = new StringBuilder("");
+		content = new StringBuilder("");
+		copyto = new StringBuilder("");
+		hiddencopyto = new StringBuilder("");
+		sent_date = new StringBuilder("");
+	}
+	
+	public StringBuilder getId() {
+		return id;
+	}
+	
+	public void setId(StringBuilder id) {
+		this.id = id;
+	}
+	
+	public StringBuilder getUser() {
+		return user;
+	}
+
+	public void setUser(StringBuilder user) {
+		this.user = user;
+	}
+
+	public StringBuilder getFolder() {
+		return folder;
+	}
+
+	public void setFolder(StringBuilder folder) {
+		this.folder = folder;
+	}
+	
+	public StringBuilder getMsgNo() {
+		return msgNo;
+	}
+
+	public void setMsgNo(StringBuilder msgNo) {
+		this.msgNo = msgNo;
+	}
+
+	public StringBuilder getFrom() {
+		return from;
+	}
+	
+	public void setFrom(StringBuilder from) {
+		this.from = from;
+	}
+	
+	public StringBuilder getTo() {
+		return to;
+	}
+	
+	public void setTo(StringBuilder to) {
+		this.to = to;
+	}
+	
+	public StringBuilder getSubject() {
+		return subject;
+	}
+	
+	public void setSubject(StringBuilder subject) {
+		this.subject = subject;
+	}
+	
+	public StringBuilder getContent() {
+		return content;
+	}
+	
+	public void setContent(StringBuilder content) {
+		this.content = content;
+	}
+	
+	public StringBuilder getCopyto() {
+		return copyto;
+	}
+	
+	public void setCopyto(StringBuilder copyto) {
+		this.copyto = copyto;
+	}
+	
+	public StringBuilder getHiddencopyto() {
+		return hiddencopyto;
+	}
+	
+	public void setHiddencopyto(StringBuilder hiddencopyto) {
+		this.hiddencopyto = hiddencopyto;
+	}
+	
+	public StringBuilder getSent_date() {
+		return sent_date;
+	}
+	
+	public void setSent_date(StringBuilder sent_date) {
+		this.sent_date = sent_date;
+	}
+	
+}
Index: sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP (cópia funcional)/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP (cópia funcional)/.settings/org.eclipse.jdt.core.prefs	(revision 8056)
+++ sandbox/expresso-solr/imapCrawler/SRC/JCrawlerForIMAP (cópia funcional)/.settings/org.eclipse.jdt.core.prefs	(revision 8056)
@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Index: sandbox/expresso-solr/prototype/plugins/jquery-picklist/jquery-picklist.css
===================================================================
--- sandbox/expresso-solr/prototype/plugins/jquery-picklist/jquery-picklist.css	(revision 8056)
+++ sandbox/expresso-solr/prototype/plugins/jquery-picklist/jquery-picklist.css	(revision 8056)
@@ -0,0 +1,7 @@
+.pickList_sourceListContainer, .pickList_controlsContainer, .pickList_targetListContainer { float: left; margin: 0.25em; }
+.pickList_controlsContainer { text-align: center; }
+.pickList_controlsContainer button { display: block; width: 100%; text-align: center; }
+.pickList_list { list-style-type: none; margin: 0; padding: 0; float: left; width: 150px; height: 75px; border: 1px inset #eee; overflow-y: auto; cursor: default; }
+.pickList_selectedListItem { background-color: #a3c8f5; }
+.pickList_listLabel { font-size: 0.9em; font-weight: bold; text-align: center; }
+.pickList_clear { clear: both; }
Index: sandbox/expresso-solr/prototype/plugins/jquery-picklist/jquery.ui.widget.js
===================================================================
--- sandbox/expresso-solr/prototype/plugins/jquery-picklist/jquery.ui.widget.js	(revision 8056)
+++ sandbox/expresso-solr/prototype/plugins/jquery-picklist/jquery.ui.widget.js	(revision 8056)
@@ -0,0 +1,272 @@
+/*!
+ * jQuery UI Widget 1.8.23
+ *
+ * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Widget
+ */
+(function( $, undefined ) {
+
+// jQuery 1.4+
+if ( $.cleanData ) {
+	var _cleanData = $.cleanData;
+	$.cleanData = function( elems ) {
+		for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
+			try {
+				$( elem ).triggerHandler( "remove" );
+			// http://bugs.jquery.com/ticket/8235
+			} catch( e ) {}
+		}
+		_cleanData( elems );
+	};
+} else {
+	var _remove = $.fn.remove;
+	$.fn.remove = function( selector, keepData ) {
+		return this.each(function() {
+			if ( !keepData ) {
+				if ( !selector || $.filter( selector, [ this ] ).length ) {
+					$( "*", this ).add( [ this ] ).each(function() {
+						try {
+							$( this ).triggerHandler( "remove" );
+						// http://bugs.jquery.com/ticket/8235
+						} catch( e ) {}
+					});
+				}
+			}
+			return _remove.call( $(this), selector, keepData );
+		});
+	};
+}
+
+$.widget = function( name, base, prototype ) {
+	var namespace = name.split( "." )[ 0 ],
+		fullName;
+	name = name.split( "." )[ 1 ];
+	fullName = namespace + "-" + name;
+
+	if ( !prototype ) {
+		prototype = base;
+		base = $.Widget;
+	}
+
+	// create selector for plugin
+	$.expr[ ":" ][ fullName ] = function( elem ) {
+		return !!$.data( elem, name );
+	};
+
+	$[ namespace ] = $[ namespace ] || {};
+	$[ namespace ][ name ] = function( options, element ) {
+		// allow instantiation without initializing for simple inheritance
+		if ( arguments.length ) {
+			this._createWidget( options, element );
+		}
+	};
+
+	var basePrototype = new base();
+	// we need to make the options hash a property directly on the new instance
+	// otherwise we'll modify the options hash on the prototype that we're
+	// inheriting from
+//	$.each( basePrototype, function( key, val ) {
+//		if ( $.isPlainObject(val) ) {
+//			basePrototype[ key ] = $.extend( {}, val );
+//		}
+//	});
+	basePrototype.options = $.extend( true, {}, basePrototype.options );
+	$[ namespace ][ name ].prototype = $.extend( true, basePrototype, {
+		namespace: namespace,
+		widgetName: name,
+		widgetEventPrefix: $[ namespace ][ name ].prototype.widgetEventPrefix || name,
+		widgetBaseClass: fullName
+	}, prototype );
+
+	$.widget.bridge( name, $[ namespace ][ name ] );
+};
+
+$.widget.bridge = function( name, object ) {
+	$.fn[ name ] = function( options ) {
+		var isMethodCall = typeof options === "string",
+			args = Array.prototype.slice.call( arguments, 1 ),
+			returnValue = this;
+
+		// allow multiple hashes to be passed on init
+		options = !isMethodCall && args.length ?
+			$.extend.apply( null, [ true, options ].concat(args) ) :
+			options;
+
+		// prevent calls to internal methods
+		if ( isMethodCall && options.charAt( 0 ) === "_" ) {
+			return returnValue;
+		}
+
+		if ( isMethodCall ) {
+			this.each(function() {
+				var instance = $.data( this, name ),
+					methodValue = instance && $.isFunction( instance[options] ) ?
+						instance[ options ].apply( instance, args ) :
+						instance;
+				// TODO: add this back in 1.9 and use $.error() (see #5972)
+//				if ( !instance ) {
+//					throw "cannot call methods on " + name + " prior to initialization; " +
+//						"attempted to call method '" + options + "'";
+//				}
+//				if ( !$.isFunction( instance[options] ) ) {
+//					throw "no such method '" + options + "' for " + name + " widget instance";
+//				}
+//				var methodValue = instance[ options ].apply( instance, args );
+				if ( methodValue !== instance && methodValue !== undefined ) {
+					returnValue = methodValue;
+					return false;
+				}
+			});
+		} else {
+			this.each(function() {
+				var instance = $.data( this, name );
+				if ( instance ) {
+					instance.option( options || {} )._init();
+				} else {
+					$.data( this, name, new object( options, this ) );
+				}
+			});
+		}
+
+		return returnValue;
+	};
+};
+
+$.Widget = function( options, element ) {
+	// allow instantiation without initializing for simple inheritance
+	if ( arguments.length ) {
+		this._createWidget( options, element );
+	}
+};
+
+$.Widget.prototype = {
+	widgetName: "widget",
+	widgetEventPrefix: "",
+	options: {
+		disabled: false
+	},
+	_createWidget: function( options, element ) {
+		// $.widget.bridge stores the plugin instance, but we do it anyway
+		// so that it's stored even before the _create function runs
+		$.data( element, this.widgetName, this );
+		this.element = $( element );
+		this.options = $.extend( true, {},
+			this.options,
+			this._getCreateOptions(),
+			options );
+
+		var self = this;
+		this.element.bind( "remove." + this.widgetName, function() {
+			self.destroy();
+		});
+
+		this._create();
+		this._trigger( "create" );
+		this._init();
+	},
+	_getCreateOptions: function() {
+		return $.metadata && $.metadata.get( this.element[0] )[ this.widgetName ];
+	},
+	_create: function() {},
+	_init: function() {},
+
+	destroy: function() {
+		this.element
+			.unbind( "." + this.widgetName )
+			.removeData( this.widgetName );
+		this.widget()
+			.unbind( "." + this.widgetName )
+			.removeAttr( "aria-disabled" )
+			.removeClass(
+				this.widgetBaseClass + "-disabled " +
+				"ui-state-disabled" );
+	},
+
+	widget: function() {
+		return this.element;
+	},
+
+	option: function( key, value ) {
+		var options = key;
+
+		if ( arguments.length === 0 ) {
+			// don't return a reference to the internal hash
+			return $.extend( {}, this.options );
+		}
+
+		if  (typeof key === "string" ) {
+			if ( value === undefined ) {
+				return this.options[ key ];
+			}
+			options = {};
+			options[ key ] = value;
+		}
+
+		this._setOptions( options );
+
+		return this;
+	},
+	_setOptions: function( options ) {
+		var self = this;
+		$.each( options, function( key, value ) {
+			self._setOption( key, value );
+		});
+
+		return this;
+	},
+	_setOption: function( key, value ) {
+		this.options[ key ] = value;
+
+		if ( key === "disabled" ) {
+			this.widget()
+				[ value ? "addClass" : "removeClass"](
+					this.widgetBaseClass + "-disabled" + " " +
+					"ui-state-disabled" )
+				.attr( "aria-disabled", value );
+		}
+
+		return this;
+	},
+
+	enable: function() {
+		return this._setOption( "disabled", false );
+	},
+	disable: function() {
+		return this._setOption( "disabled", true );
+	},
+
+	_trigger: function( type, event, data ) {
+		var prop, orig,
+			callback = this.options[ type ];
+
+		data = data || {};
+		event = $.Event( event );
+		event.type = ( type === this.widgetEventPrefix ?
+			type :
+			this.widgetEventPrefix + type ).toLowerCase();
+		// the original event may come from any element
+		// so we need to reset the target on the new event
+		event.target = this.element[ 0 ];
+
+		// copy original event properties over to the new event
+		orig = event.originalEvent;
+		if ( orig ) {
+			for ( prop in orig ) {
+				if ( !( prop in event ) ) {
+					event[ prop ] = orig[ prop ];
+				}
+			}
+		}
+
+		this.element.trigger( event, data );
+
+		return !( $.isFunction(callback) &&
+			callback.call( this.element[0], event, data ) === false ||
+			event.isDefaultPrevented() );
+	}
+};
+
+})( jQuery );
Index: sandbox/expresso-solr/prototype/plugins/jquery-picklist/jquery-picklist.js
===================================================================
--- sandbox/expresso-solr/prototype/plugins/jquery-picklist/jquery-picklist.js	(revision 8056)
+++ sandbox/expresso-solr/prototype/plugins/jquery-picklist/jquery-picklist.js	(revision 8056)
@@ -0,0 +1,614 @@
+/**
+ * jQuery PickList Widget
+ *
+ * Copyright (c) 2012 Jonathon Freeman <jonathon@awnry.com>
+ * Distributed under the terms of the MIT License.
+ *
+ * http://code.google.com/p/jquery-ui-picklist/
+ */
+(function($)
+{
+	$.widget("awnry.pickList",
+	{
+		options:
+		{
+			// Container classes
+			mainClass:                  "pickList",
+			listContainerClass:         "pickList_listContainer",
+			sourceListContainerClass:   "pickList_sourceListContainer",
+			controlsContainerClass:     "pickList_controlsContainer",
+			targetListContainerClass:   "pickList_targetListContainer",
+			listClass:                  "pickList_list",
+			sourceListClass:            "pickList_sourceList",
+			targetListClass:            "pickList_targetList",
+			clearClass:                 "pickList_clear",
+
+			// List item classes
+			listItemClass:              "pickList_listItem",
+			richListItemClass:          "pickList_richListItem",
+			selectedListItemClass:      "pickList_selectedListItem",
+
+			// Control classes
+			addAllClass:                "pickList_addAll",
+			addClass:                   "pickList_add",
+			removeAllClass:             "pickList_removeAll",
+			removeClass:                "pickList_remove",
+
+			// Control labels
+			addAllLabel:                "&gt;&gt;",
+			addLabel:                   "&gt;",
+			removeAllLabel:             "&lt;&lt;",
+			removeLabel:                "&lt;",
+
+			// List labels
+			listLabelClass:             "pickList_listLabel",
+			sourceListLabel:            "Available",
+			sourceListLabelClass:       "pickList_sourceListLabel",
+			targetListLabel:            "Selected",
+			targetListLabelClass:       "pickList_targetListLabel",
+
+			// Sorting
+			sortItems:                  true,
+			sortAttribute:              "label",
+
+			// Name of custom value attribute for list items
+			listItemValueAttribute:     "data-value",
+
+			// Additional list items
+			items:						[]
+		},
+
+		_create: function()
+		{
+			var self = this;
+
+			self._buildPickList();
+			self._refresh();
+		},
+
+		_buildPickList: function()
+		{
+			var self = this;
+
+			self._trigger("beforeBuild");
+
+			self.pickList = $("<div/>")
+					.hide()
+					.addClass(self.options.mainClass)
+					.insertAfter(self.element)
+					.append(self._buildSourceList())
+					.append(self._buildControls())
+					.append(self._buildTargetList())
+					.append( $("<div/>").addClass(self.options.clearClass) );
+
+			self._populateLists();
+
+			self.element.hide();
+			self.pickList.show();
+
+			self._trigger("afterBuild");
+		},
+
+		_buildSourceList: function()
+		{
+			var self = this;
+
+			var container = $("<div/>")
+					.addClass(self.options.listContainerClass)
+					.addClass(self.options.sourceListContainerClass)
+					.css({
+						"-moz-user-select": "none",
+						"-webkit-user-select": "none",
+						"user-select": "none",
+						"-ms-user-select": "none"
+					})
+					.each(function()
+					{
+						this.onselectstart = function() { return false; };
+					});
+
+			var label = $("<div/>")
+					.text(self.options.sourceListLabel)
+					.addClass(self.options.listLabelClass)
+					.addClass(self.options.sourceListLabelClass);
+
+			self.sourceList = $("<ul/>")
+					.addClass(self.options.listClass)
+					.addClass(self.options.sourceListClass)
+					.delegate("li", "click", { pickList: self }, self._changeHandler);
+
+			container
+					.append(label)
+					.append(self.sourceList);
+
+			return container;
+		},
+
+		_buildTargetList: function()
+		{
+			var self = this;
+
+			var container = $("<div/>")
+					.addClass(self.options.listContainerClass)
+					.addClass(self.options.targetListContainerClass)
+					.css({
+						"-moz-user-select": "none",
+						"-webkit-user-select": "none",
+						"user-select": "none",
+						"-ms-user-select": "none"
+					})
+					.each(function()
+					{
+						this.onselectstart = function() { return false; };
+					});
+
+			var label = $("<div/>")
+					.text(self.options.targetListLabel)
+					.addClass(self.options.listLabelClass)
+					.addClass(self.options.targetListLabelClass);
+
+			self.targetList = $("<ul/>")
+					.addClass(self.options.listClass)
+					.addClass(self.options.targetListClass)
+					.delegate("li", "click", { pickList: self }, self._changeHandler);
+
+			container
+					.append(label)
+					.append(self.targetList);
+
+			return container;
+		},
+
+		_buildControls: function()
+		{
+			var self = this;
+
+			self.controls = $("<div/>").addClass(self.options.controlsContainerClass);
+
+			self.addAllButton = $("<button type='button'/>").click({pickList: self}, self._addAllHandler).html(self.options.addAllLabel).addClass(self.options.addAllClass);
+			self.addButton = $("<button type='button'/>").click({pickList: self}, self._addHandler).html(self.options.addLabel).addClass(self.options.addClass);
+			self.removeButton = $("<button type='button'/>").click({pickList: self}, self._removeHandler).html(self.options.removeLabel).addClass(self.options.removeClass);
+			self.removeAllButton = $("<button type='button'/>").click({pickList: self}, self._removeAllHandler).html(self.options.removeAllLabel).addClass(self.options.removeAllClass);
+
+			self.controls
+					.append(self.addAllButton)
+					.append(self.addButton)
+					.append(self.removeButton)
+					.append(self.removeAllButton);
+
+			return self.controls;
+		},
+
+		_populateLists: function()
+		{
+			var self = this;
+
+			self._trigger("beforePopulate");
+
+			var sourceListItems = [];
+			var targetListItems = [];
+			var selectItems = self.element.children();
+
+			selectItems.not(":selected").each(function()
+			{
+				sourceListItems.push( self._createDoppelganger(this) );
+			});
+
+			selectItems.filter(":selected").each(function()
+			{
+				targetListItems.push( self._createDoppelganger(this) );
+			});
+
+			self.sourceList.append(sourceListItems.join("\n"));
+			self.targetList.append(targetListItems.join("\n"));
+			self.insertItems(self.options.items);
+
+			self._trigger("afterPopulate");
+		},
+
+		_addAllHandler: function(e)
+		{
+			var self = e.data.pickList;
+
+			self._trigger("beforeAddAll");
+
+			var items = self.sourceList.children();
+			self.targetList.append( self._removeSelections(items) );
+
+			self.element.children().not(":selected").attr("selected", "selected");
+
+			self._refresh();
+
+			self._trigger("afterAddAll");
+			self._trigger("onChange");
+		},
+
+		_addHandler: function(e)
+		{
+			var self = e.data.pickList;
+
+			self._trigger("beforeAdd");
+
+			var items = self.sourceList.children(".ui-selected");
+			self.targetList.append( self._removeSelections(items) );
+
+			var itemIds = [];
+			items.each(function()
+			{
+				itemIds.push( self._getItemValue(this) );
+			});
+
+			self.element.children().filter(function()
+			{
+				return $.inArray(this.value, itemIds) != -1;
+			}).attr("selected", "selected");
+
+			self._refresh();
+
+			self._trigger("afterAdd");
+			self._trigger("onChange");
+		},
+
+		_removeHandler: function(e)
+		{
+			var self = e.data.pickList;
+
+			self._trigger("beforeRemove");
+
+			var items = self.targetList.children(".ui-selected");
+			self.sourceList.append( self._removeSelections(items) );
+
+			var itemIds = [];
+			items.each(function()
+			{
+				itemIds.push( self._getItemValue(this) );
+			});
+
+			self.element.children().filter(function()
+			{
+				return $.inArray(this.value, itemIds) != -1;
+			}).removeAttr("selected");
+
+			self._refresh();
+
+			self._trigger("afterRemove");
+			self._trigger("onChange");
+		},
+
+		_removeAllHandler: function(e)
+		{
+			var self = e.data.pickList;
+
+			self._trigger("beforeRemoveAll");
+
+			var items = self.targetList.children();
+			self.sourceList.append( self._removeSelections(items) );
+
+			self.element.children().filter(":selected").removeAttr("selected");
+
+			self._refresh();
+
+			self._trigger("afterRemoveAll");
+			self._trigger("onChange");
+		},
+
+		_refresh: function()
+		{
+			var self = this;
+
+			self._trigger("beforeRefresh");
+
+			self._refreshControls();
+
+			// Sort the selection lists.
+			if(self.options.sortItems)
+			{
+				self._sortItems(self.sourceList, self.options);
+				self._sortItems(self.targetList, self.options);
+			}
+
+			self._trigger("afterRefresh");
+		},
+
+		_refreshControls: function()
+		{
+			var self = this;
+
+			self._trigger("beforeRefreshControls");
+
+			// Enable/disable the Add All button state.
+			if(self.sourceList.children().length)
+			{
+				self.addAllButton.removeAttr("disabled");
+			}
+			else
+			{
+				self.addAllButton.attr("disabled", "disabled");
+			}
+
+			// Enable/disable the Remove All button state.
+			if(self.targetList.children().length)
+			{
+				self.removeAllButton.removeAttr("disabled");
+			}
+			else
+			{
+				self.removeAllButton.attr("disabled", "disabled");
+			}
+
+			// Enable/disable the Add button state.
+			if(self.sourceList.children(".ui-selected").length)
+			{
+				self.addButton.removeAttr("disabled");
+			}
+			else
+			{
+				self.addButton.attr("disabled", "disabled");
+			}
+
+			// Enable/disable the Remove button state.
+			if(self.targetList.children(".ui-selected").length)
+			{
+				self.removeButton.removeAttr("disabled");
+			}
+			else
+			{
+				self.removeButton.attr("disabled", "disabled");
+			}
+
+			self._trigger("afterRefreshControls");
+		},
+
+		_sortItems: function(list, options)
+		{
+			var items = new Array();
+
+			list.children().each(function()
+			{
+				items.push( $(this) );
+			});
+
+			items.sort(function(a, b)
+			{
+				if(a.attr(options.sortAttribute) > b.attr(options.sortAttribute))
+				{
+					return 1;
+				}
+				else if(a.attr(options.sortAttribute) == b.attr(options.sortAttribute))
+				{
+					return 0;
+				}
+				else
+				{
+					return -1;
+				}
+			});
+
+			list.empty();
+
+			for(var i = 0; i < items.length; i++)
+			{
+				list.append(items[i]);
+			}
+		},
+
+		_changeHandler: function(e)
+		{
+			var self = e.data.pickList;
+
+			if(e.ctrlKey)
+			{
+				if(self._isSelected( $(this) ))
+				{
+					self._removeSelection( $(this) );
+				}
+				else
+				{
+					self.lastSelectedItem = $(this);
+					self._addSelection( $(this) );
+				}
+			}
+			else if(e.shiftKey)
+			{
+				var current = self._getItemValue(this);
+				var last = self._getItemValue(self.lastSelectedItem);
+
+				if($(this).index() < $(self.lastSelectedItem).index())
+				{
+					var temp = current;
+					current = last;
+					last = temp;
+				}
+
+				var pastStart = false;
+				var beforeEnd = true;
+
+				self._clearSelections( $(this).parent() );
+
+				$(this).parent().children().each(function()
+				{
+					if(self._getItemValue(this) == last)
+					{
+						pastStart = true;
+					}
+
+					if(pastStart && beforeEnd)
+					{
+						self._addSelection( $(this) );
+					}
+
+					if(self._getItemValue(this) == current)
+					{
+						beforeEnd = false;
+					}
+
+				});
+			}
+			else
+			{
+				self.lastSelectedItem = $(this);
+				self._clearSelections( $(this).parent() );
+				self._addSelection( $(this) );
+			}
+
+			self._refreshControls();
+		},
+
+		_isSelected: function(listItem)
+		{
+			return listItem.hasClass("ui-selected");
+		},
+
+		_addSelection: function(listItem)
+		{
+			var self = this;
+
+			return listItem
+					.addClass("ui-selected")
+					.addClass("ui-state-highlight")
+					.addClass(self.options.selectedListItemClass);
+		},
+
+		_removeSelection: function(listItem)
+		{
+			var self = this;
+
+			return listItem
+					.removeClass("ui-selected")
+					.removeClass("ui-state-highlight")
+					.removeClass(self.options.selectedListItemClass);
+		},
+
+		_removeSelections: function(listItems)
+		{
+			var self = this;
+
+			listItems.each(function()
+			{
+				$(this)
+						.removeClass("ui-selected")
+						.removeClass("ui-state-highlight")
+						.removeClass(self.options.selectedListItemClass);
+			});
+
+			return listItems;
+		},
+
+		_clearSelections: function(list)
+		{
+			var self = this;
+
+			list.children().each(function()
+			{
+				self._removeSelection( $(this) );
+			});
+		},
+
+		_setOption: function(key, value)
+		{
+			switch(key)
+			{
+				case "clear":
+				{
+					break;
+				}
+			}
+
+			$.Widget.prototype._setOption.apply(this, arguments);
+		},
+
+		destroy: function()
+		{
+			var self = this;
+
+			self._trigger("onDestroy");
+
+			self.pickList.remove();
+			self.element.show();
+
+			$.Widget.prototype.destroy.call(self);
+		},
+
+		insert: function(item)
+		{
+			var self = this;
+
+			var list = item.selected ? self.targetList : self.sourceList;
+			var selectItem = self._createSelectItem(item);
+			var listItem = self._createListItem(item);
+
+			self.element.append(selectItem);
+			list.append(listItem);
+
+			self._trigger("onChange");
+
+			self._refresh();
+		},
+
+		insertItems: function(items)
+		{
+			var self = this;
+
+			var selectItems = [];
+			var sourceItems = [];
+			var targetItems = [];
+
+			$(items).each(function()
+			{
+				var selectItem = self._createSelectItem(this);
+				var listItem = self._createListItem(this);
+
+				selectItems.push(selectItem);
+
+				if(this.selected)
+				{
+					targetItems.push(listItem);
+				}
+				else
+				{
+					sourceItems.push(listItem);
+				}
+			});
+
+			self.element.append(selectItems.join("\n"));
+			self.sourceList.append(sourceItems.join("\n"));
+			self.targetList.append(targetItems.join("\n"));
+
+			self._trigger("onChange");
+
+			self._refresh();
+		},
+
+		_createSelectItem: function(item)
+		{
+			var selected = item.selected ? " selected='selected'" : "";
+			return "<option value='" + item.value + "'" + selected + ">" + item.label + "</option>";
+		},
+
+		_createListItem: function(item)
+		{
+			var self = this;
+
+			if(item.element != undefined)
+			{
+				var richItemHtml = item.element.clone().wrap("<div>").parent().html();
+				item.element.hide();
+				return "<li " + self.options.listItemValueAttribute + "='" + item.value + "' label='" + item.label + "' class='" + self.options.listItemClass + " " + self.options.richListItemClass + "'>" + richItemHtml + "</li>";
+			}
+
+			return "<li " + self.options.listItemValueAttribute + "='" + item.value + "' label='" + item.label + "' class='" + self.options.listItemClass + "'>" + item.label + "</li>";
+		},
+
+		_createDoppelganger: function(item)
+		{
+			var self = this;
+			return "<li " + self.options.listItemValueAttribute + "='" + $(item).val() + "' label='" + $(item).text() + "' class='" + self.options.listItemClass + "'>" + $(item).text() + "</li>";
+		},
+
+		_getItemValue: function(item)
+		{
+			var self = this;
+			return $(item).attr(self.options.listItemValueAttribute);
+		}
+	});
+}(jQuery));
Index: sandbox/expresso-solr/prototype/plugins/jquery-picklist/jquery.ui.widget.min.js
===================================================================
--- sandbox/expresso-solr/prototype/plugins/jquery-picklist/jquery.ui.widget.min.js	(revision 8056)
+++ sandbox/expresso-solr/prototype/plugins/jquery-picklist/jquery.ui.widget.min.js	(revision 8056)
@@ -0,0 +1,6 @@
+(function(c,h){if(c.cleanData){var i=c.cleanData;c.cleanData=function(a){for(var b=0,d;null!=(d=a[b]);b++)try{c(d).triggerHandler("remove")}catch(e){}i(a)}}else{var j=c.fn.remove;c.fn.remove=function(a,b){return this.each(function(){b||(!a||c.filter(a,[this]).length)&&c("*",this).add([this]).each(function(){try{c(this).triggerHandler("remove")}catch(a){}});return j.call(c(this),a,b)})}}c.widget=function(a,b,d){var e=a.split(".")[0],f,a=a.split(".")[1];f=e+"-"+a;d||(d=b,b=c.Widget);c.expr[":"][f]=
+function(b){return!!c.data(b,a)};c[e]=c[e]||{};c[e][a]=function(a,b){arguments.length&&this._createWidget(a,b)};b=new b;b.options=c.extend(!0,{},b.options);c[e][a].prototype=c.extend(!0,b,{namespace:e,widgetName:a,widgetEventPrefix:c[e][a].prototype.widgetEventPrefix||a,widgetBaseClass:f},d);c.widget.bridge(a,c[e][a])};c.widget.bridge=function(a,b){c.fn[a]=function(d){var e="string"===typeof d,f=Array.prototype.slice.call(arguments,1),g=this,d=!e&&f.length?c.extend.apply(null,[!0,d].concat(f)):d;
+if(e&&"_"===d.charAt(0))return g;e?this.each(function(){var b=c.data(this,a),e=b&&c.isFunction(b[d])?b[d].apply(b,f):b;if(e!==b&&e!==h)return g=e,!1}):this.each(function(){var e=c.data(this,a);e?e.option(d||{})._init():c.data(this,a,new b(d,this))});return g}};c.Widget=function(a,b){arguments.length&&this._createWidget(a,b)};c.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:!1},_createWidget:function(a,b){c.data(b,this.widgetName,this);this.element=c(b);this.options=c.extend(!0,
+{},this.options,this._getCreateOptions(),a);var d=this;this.element.bind("remove."+this.widgetName,function(){d.destroy()});this._create();this._trigger("create");this._init()},_getCreateOptions:function(){return c.metadata&&c.metadata.get(this.element[0])[this.widgetName]},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+
+"-disabled ui-state-disabled")},widget:function(){return this.element},option:function(a,b){var d=a;if(0===arguments.length)return c.extend({},this.options);if("string"===typeof a){if(b===h)return this.options[a];d={};d[a]=b}this._setOptions(d);return this},_setOptions:function(a){var b=this;c.each(a,function(a,c){b._setOption(a,c)});return this},_setOption:function(a,b){this.options[a]=b;"disabled"===a&&this.widget()[b?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",
+b);return this},enable:function(){return this._setOption("disabled",!1)},disable:function(){return this._setOption("disabled",!0)},_trigger:function(a,b,d){var e,f=this.options[a],d=d||{},b=c.Event(b);b.type=(a===this.widgetEventPrefix?a:this.widgetEventPrefix+a).toLowerCase();b.target=this.element[0];if(a=b.originalEvent)for(e in a)e in b||(b[e]=a[e]);this.element.trigger(b,d);return!(c.isFunction(f)&&!1===f.call(this.element[0],b,d)||b.isDefaultPrevented())}}})(jQuery);
Index: sandbox/expresso-solr/prototype/plugins/jquery-picklist/jquery-picklist.min.js
===================================================================
--- sandbox/expresso-solr/prototype/plugins/jquery-picklist/jquery-picklist.min.js	(revision 8056)
+++ sandbox/expresso-solr/prototype/plugins/jquery-picklist/jquery-picklist.min.js	(revision 8056)
@@ -0,0 +1,18 @@
+(function(c){c.widget("awnry.pickList",{options:{mainClass:"pickList",listContainerClass:"pickList_listContainer",sourceListContainerClass:"pickList_sourceListContainer",controlsContainerClass:"pickList_controlsContainer",targetListContainerClass:"pickList_targetListContainer",listClass:"pickList_list",sourceListClass:"pickList_sourceList",targetListClass:"pickList_targetList",clearClass:"pickList_clear",listItemClass:"pickList_listItem",richListItemClass:"pickList_richListItem",selectedListItemClass:"pickList_selectedListItem",
+addAllClass:"pickList_addAll",addClass:"pickList_add",removeAllClass:"pickList_removeAll",removeClass:"pickList_remove",addAllLabel:"&gt;&gt;",addLabel:"&gt;",removeAllLabel:"&lt;&lt;",removeLabel:"&lt;",listLabelClass:"pickList_listLabel",sourceListLabel:"Available",sourceListLabelClass:"pickList_sourceListLabel",targetListLabel:"Selected",targetListLabelClass:"pickList_targetListLabel",sortItems:!0,sortAttribute:"label",listItemValueAttribute:"data-value",items:[]},_create:function(){this._buildPickList();
+this._refresh()},_buildPickList:function(){this._trigger("beforeBuild");this.pickList=c("<div/>").hide().addClass(this.options.mainClass).insertAfter(this.element).append(this._buildSourceList()).append(this._buildControls()).append(this._buildTargetList()).append(c("<div/>").addClass(this.options.clearClass));this._populateLists();this.element.hide();this.pickList.show();this._trigger("afterBuild")},_buildSourceList:function(){var a=c("<div/>").addClass(this.options.listContainerClass).addClass(this.options.sourceListContainerClass).css({"-moz-user-select":"none",
+"-webkit-user-select":"none","user-select":"none","-ms-user-select":"none"}).each(function(){this.onselectstart=function(){return!1}}),b=c("<div/>").text(this.options.sourceListLabel).addClass(this.options.listLabelClass).addClass(this.options.sourceListLabelClass);this.sourceList=c("<ul/>").addClass(this.options.listClass).addClass(this.options.sourceListClass).delegate("li","click",{pickList:this},this._changeHandler);a.append(b).append(this.sourceList);return a},_buildTargetList:function(){var a=
+c("<div/>").addClass(this.options.listContainerClass).addClass(this.options.targetListContainerClass).css({"-moz-user-select":"none","-webkit-user-select":"none","user-select":"none","-ms-user-select":"none"}).each(function(){this.onselectstart=function(){return!1}}),b=c("<div/>").text(this.options.targetListLabel).addClass(this.options.listLabelClass).addClass(this.options.targetListLabelClass);this.targetList=c("<ul/>").addClass(this.options.listClass).addClass(this.options.targetListClass).delegate("li",
+"click",{pickList:this},this._changeHandler);a.append(b).append(this.targetList);return a},_buildControls:function(){this.controls=c("<div/>").addClass(this.options.controlsContainerClass);this.addAllButton=c("<button type='button'/>").click({pickList:this},this._addAllHandler).html(this.options.addAllLabel).addClass(this.options.addAllClass);this.addButton=c("<button type='button'/>").click({pickList:this},this._addHandler).html(this.options.addLabel).addClass(this.options.addClass);this.removeButton=
+c("<button type='button'/>").click({pickList:this},this._removeHandler).html(this.options.removeLabel).addClass(this.options.removeClass);this.removeAllButton=c("<button type='button'/>").click({pickList:this},this._removeAllHandler).html(this.options.removeAllLabel).addClass(this.options.removeAllClass);this.controls.append(this.addAllButton).append(this.addButton).append(this.removeButton).append(this.removeAllButton);return this.controls},_populateLists:function(){var a=this;a._trigger("beforePopulate");
+var b=[],c=[],e=a.element.children();e.not(":selected").each(function(){b.push(a._createDoppelganger(this))});e.filter(":selected").each(function(){c.push(a._createDoppelganger(this))});a.sourceList.append(b.join("\n"));a.targetList.append(c.join("\n"));a.insertItems(a.options.items);a._trigger("afterPopulate")},_addAllHandler:function(a){a=a.data.pickList;a._trigger("beforeAddAll");var b=a.sourceList.children();a.targetList.append(a._removeSelections(b));a.element.children().not(":selected").attr("selected",
+"selected");a._refresh();a._trigger("afterAddAll");a._trigger("onChange")},_addHandler:function(a){var b=a.data.pickList;b._trigger("beforeAdd");a=b.sourceList.children(".ui-selected");b.targetList.append(b._removeSelections(a));var d=[];a.each(function(){d.push(b._getItemValue(this))});b.element.children().filter(function(){return-1!=c.inArray(this.value,d)}).attr("selected","selected");b._refresh();b._trigger("afterAdd");b._trigger("onChange")},_removeHandler:function(a){var b=a.data.pickList;b._trigger("beforeRemove");
+a=b.targetList.children(".ui-selected");b.sourceList.append(b._removeSelections(a));var d=[];a.each(function(){d.push(b._getItemValue(this))});b.element.children().filter(function(){return-1!=c.inArray(this.value,d)}).removeAttr("selected");b._refresh();b._trigger("afterRemove");b._trigger("onChange")},_removeAllHandler:function(a){a=a.data.pickList;a._trigger("beforeRemoveAll");var b=a.targetList.children();a.sourceList.append(a._removeSelections(b));a.element.children().filter(":selected").removeAttr("selected");
+a._refresh();a._trigger("afterRemoveAll");a._trigger("onChange")},_refresh:function(){this._trigger("beforeRefresh");this._refreshControls();this.options.sortItems&&(this._sortItems(this.sourceList,this.options),this._sortItems(this.targetList,this.options));this._trigger("afterRefresh")},_refreshControls:function(){this._trigger("beforeRefreshControls");this.sourceList.children().length?this.addAllButton.removeAttr("disabled"):this.addAllButton.attr("disabled","disabled");this.targetList.children().length?
+this.removeAllButton.removeAttr("disabled"):this.removeAllButton.attr("disabled","disabled");this.sourceList.children(".ui-selected").length?this.addButton.removeAttr("disabled"):this.addButton.attr("disabled","disabled");this.targetList.children(".ui-selected").length?this.removeButton.removeAttr("disabled"):this.removeButton.attr("disabled","disabled");this._trigger("afterRefreshControls")},_sortItems:function(a,b){var d=[];a.children().each(function(){d.push(c(this))});d.sort(function(a,c){return a.attr(b.sortAttribute)>
+c.attr(b.sortAttribute)?1:a.attr(b.sortAttribute)==c.attr(b.sortAttribute)?0:-1});a.empty();for(var e=0;e<d.length;e++)a.append(d[e])},_changeHandler:function(a){var b=a.data.pickList;if(a.ctrlKey)b._isSelected(c(this))?b._removeSelection(c(this)):(b.lastSelectedItem=c(this),b._addSelection(c(this)));else if(a.shiftKey){var d=b._getItemValue(this),e=b._getItemValue(b.lastSelectedItem);c(this).index()<c(b.lastSelectedItem).index()&&(a=d,d=e,e=a);var f=!1,g=!0;b._clearSelections(c(this).parent());c(this).parent().children().each(function(){b._getItemValue(this)==
+e&&(f=true);f&&g&&b._addSelection(c(this));b._getItemValue(this)==d&&(g=false)})}else b.lastSelectedItem=c(this),b._clearSelections(c(this).parent()),b._addSelection(c(this));b._refreshControls()},_isSelected:function(a){return a.hasClass("ui-selected")},_addSelection:function(a){return a.addClass("ui-selected").addClass("ui-state-highlight").addClass(this.options.selectedListItemClass)},_removeSelection:function(a){return a.removeClass("ui-selected").removeClass("ui-state-highlight").removeClass(this.options.selectedListItemClass)},
+_removeSelections:function(a){var b=this;a.each(function(){c(this).removeClass("ui-selected").removeClass("ui-state-highlight").removeClass(b.options.selectedListItemClass)});return a},_clearSelections:function(a){var b=this;a.children().each(function(){b._removeSelection(c(this))})},_setOption:function(a,b){c.Widget.prototype._setOption.apply(this,arguments)},destroy:function(){this._trigger("onDestroy");this.pickList.remove();this.element.show();c.Widget.prototype.destroy.call(this)},insert:function(a){var b=
+a.selected?this.targetList:this.sourceList,c=this._createSelectItem(a),a=this._createListItem(a);this.element.append(c);b.append(a);this._trigger("onChange");this._refresh()},insertItems:function(a){var b=this,d=[],e=[],f=[];c(a).each(function(){var a=b._createSelectItem(this),c=b._createListItem(this);d.push(a);this.selected?f.push(c):e.push(c)});b.element.append(d.join("\n"));b.sourceList.append(e.join("\n"));b.targetList.append(f.join("\n"));b._trigger("onChange");b._refresh()},_createSelectItem:function(a){return"<option value='"+
+a.value+"'"+(a.selected?" selected='selected'":"")+">"+a.label+"</option>"},_createListItem:function(a){if(void 0!=a.element){var b=a.element.clone().wrap("<div>").parent().html();a.element.hide();return"<li "+this.options.listItemValueAttribute+"='"+a.value+"' label='"+a.label+"' class='"+this.options.listItemClass+" "+this.options.richListItemClass+"'>"+b+"</li>"}return"<li "+this.options.listItemValueAttribute+"='"+a.value+"' label='"+a.label+"' class='"+this.options.listItemClass+"'>"+a.label+
+"</li>"},_createDoppelganger:function(a){return"<li "+this.options.listItemValueAttribute+"='"+c(a).val()+"' label='"+c(a).text()+"' class='"+this.options.listItemClass+"'>"+c(a).text()+"</li>"},_getItemValue:function(a){return c(a).attr(this.options.listItemValueAttribute)}})})(jQuery);
Index: sandbox/expresso-solr/expressoMail1_2/templates/default/help.css
===================================================================
--- sandbox/expresso-solr/expressoMail1_2/templates/default/help.css	(revision 8056)
+++ sandbox/expresso-solr/expressoMail1_2/templates/default/help.css	(revision 8056)
@@ -0,0 +1,35 @@
+//Css janela de ajuda da busca avançada
+
+body{
+	font-size: 12px;
+	color: gray;
+	background: url(../../../phpgwapi/templates/default/images/fundo1.jpg);
+}
+
+p, li{
+	font-size: 12px;
+	color: gray;
+}
+
+.topo{
+	background: url(../../../phpgwapi/templates/default/images/back_login_help.png);
+	background-repeat: repeat-y;
+	margin-left: 5px;
+	text-align: center;
+	color: #3B5998;
+}
+
+legend{
+	color: #3B5998;	
+}
+i{
+	color: #3B5998;
+	font-size: 12px;
+
+}
+.rodape{
+	text-align: center;
+	// background: url(../../../phpgwapi/templates/default/images/rodape_help.png);
+	background-repeat: repeat-y;
+	color: #fff;
+}
Index: sandbox/expresso-solr/expressoMail1_2/templates/default/help.html
===================================================================
--- sandbox/expresso-solr/expressoMail1_2/templates/default/help.html	(revision 8056)
+++ sandbox/expresso-solr/expressoMail1_2/templates/default/help.html	(revision 8056)
@@ -0,0 +1,47 @@
+<html>
+	<head>
+		<title>Tela de Ajuda</title>
+		<link rel="stylesheet" type="text/css" href="help.css"></link>
+	</head>
+	<body>
+		<div class="topo">
+			<a> Tela de Ajuda!</a>
+		</div>	
+			<fieldset>
+				<legend>Informações</legend>
+				<p>
+					Os campos dispostos na tela de busca avançada auxiliará a realizar uma busca mais rápida. Porém os dados devem ser preenchidos corretamente.		
+				</p>
+			</fieldset>
+			<fieldset>
+				<legend>Campos dos Filtros</legend>
+				<ol>
+					<li>"<i>De</i>":Retornará as mensagens que conter o nome informado <i>(emails recebidos)</i>;</li>
+					<li>"<i>Para</i>":Retornará as mensagens que conter o nome informado <i>(emails enviados)</i>;</li>
+				    <li>"<i>Assunto</i>":Retornará mensagens com o assunto relacionados;</li>
+					<li>"<i>Corpo da Mensagem</i>":Palavras "chaves" contidas no corpo do texto das mensagens;</li>
+						<ol> 
+							<li>"<i>Desta Data</i>": Todas as mensagens apartir da data indicada;</li>
+							<li>"<i>Até Data</i>": Todas as mensagens até a data indicada;</li>
+							<li>"<i>NA Data</i>": Data correta da mensagem;</li>
+							<i>Obs: Caso seja selecionado alguma pasta somente será retornado mensagens inseridas na determinada pasta, aconselha-se deixar selecionado todas as pastas para os filtros com datas.</i>
+						</ol>	
+					
+			 	</ol>
+
+			</fieldset>		
+			<fieldset>
+					<legend>Filtros de Pastas</legend>
+					<p>Este campo vem como <i>default</i> todas as pastas marcadas, caso queira realizar uma pesquisa em um determinada pasta, basta desmarcar o checkbox para que apareça as pastas para serem selecionadas.</p>
+					<img src="images/folders01.png">
+					<img src="images/folders02.png">
+			</fieldset>	
+		<div class="rodape">
+				<p>Expresso Livre</p>
+		</div>	
+
+		<!--	<i>teste</i>
+			<img src="../../../phpgwapi/templates/default/images/back_login_top.jpg">
+		-->
+	</body>
+</html>
Index: sandbox/expresso-solr/expressoMail1_2/templates/default/config.tpl
===================================================================
--- sandbox/expresso-solr/expressoMail1_2/templates/default/config.tpl	(revision 7532)
+++ sandbox/expresso-solr/expressoMail1_2/templates/default/config.tpl	(revision 8056)
@@ -240,4 +240,33 @@
         </td>
     </tr> 
+
+  <tr bgcolor="{th_bg}">
+    <td colspan="2">
+&nbsp;
+    </td>
+  </tr>
+
+
+  <tr bgcolor="{row_on}"> 
+    <td colspan="2"> 
+        <label style="font-weight:bold;">{lang_Solr_configuration}</label> 
+    </td> 
+  </tr>
+  
+    <tr bgcolor="{row_off}">
+        <td>{lang_Enable_Solr}</td>
+        <td>
+            <select id="use_solr" name="newsettings[expressoMail_enable_solr]">
+                <option value="false" {selected_expressoMail_enable_solr_false}>{lang_No}</option>
+                <option value="true" {selected_expressoMail_enable_solr_true}>{lang_Yes}</option>
+            </select>
+        </td>
+    </tr>
+	<tr bgcolor="{row_on}">
+        <td>{lang_Solr_IP_address}</td>
+        <td>
+            <input id="solrAddress" maxlength="23" size="23" type="text" name="newsettings[expressoMail_Solr_address]" value="{value_expressoMail_Solr_address}">
+        </td>
+    </tr>
 	
 	<!-- <tr bgcolor="{row_off}">
Index: sandbox/expresso-solr/expressoMail1_2/templates/default/main.css
===================================================================
--- sandbox/expresso-solr/expressoMail1_2/templates/default/main.css	(revision 7561)
+++ sandbox/expresso-solr/expressoMail1_2/templates/default/main.css	(revision 8056)
@@ -1612,2 +1612,33 @@
 	background-repeat : no-repeat;
 }
+
+.advanced-search input {
+	width: 100%;
+	float: left;
+}
+
+.advanced-search td.label {
+	width: 5%;
+}
+
+.pickList_controlsContainer button.pickList_addAll{
+	margin-top: 12px;
+	border-top-right-radius: 5px;
+	border-top-left-radius: 5px;
+}
+
+.pickList_controlsContainer button.pickList_removeAll{
+	border-bottom-right-radius: 5px;
+	border-bottom-left-radius: 5px;
+}
+
+.pickList_list{
+	float: left;
+	text-align: left !important;
+}
+
+.pickList_controlsContainer button{
+	width: 27px !important;
+	height: 20px;
+	font-size: 8px !important;
+}
Index: sandbox/expresso-solr/expressoMail1_2/templates/default/searchMails.ejs
===================================================================
--- sandbox/expresso-solr/expressoMail1_2/templates/default/searchMails.ejs	(revision 6528)
+++ sandbox/expresso-solr/expressoMail1_2/templates/default/searchMails.ejs	(revision 8056)
@@ -1,95 +1,87 @@
-     	<fieldset style="width:340px; height:350px; text-align:right; padding: 5px; position:absolute; margin:5px; border:0px ">
+     	<fieldset style="text-align:right; padding: 5px; margin:5px; border:0px ">
 				<legend><%=data.Inform_your_search_in_the_text_fields%></legend>
-			
-				<label><%=data.From%>:</label>
-				<input style="margin-left: 6px;" type="text" id="txt_de" size="20" value="<%=data.From_value%>"/>
-				<br style="margin-bottom:15px" />
+				<img style="margin-right: 3px;" src="templates/default/images/info.png" width="20" height="20" onmouseover="window.status='Ajuda de pesquisa...';return true;" title="Ajuda de Pesquisa." onclick="window.open('templates/default/help.html', 'Pagina', 'STATUS=NO, TOOLBAR=NO, LOCATION=NO, DIRECTORIES=NO, RESISABLE=NO, SCROLLBARS=YES, TOP=200, LEFT=300, WIDTH=772, HEIGHT=400');"></img>
+				
+				 <table class="advanced-search" style="width: 95%;white-space: nowrap;">
+				  <tr>
+				  	<td class="label">
+				  		<label><%=data.From%>:</label>
+				  	</td>
+				  	<td>
 
-				<label><%=data.To%>:</label>
-				<input style="margin-left: 6px;" type="text" id="txt_para" size="20" />
-				<br style="margin-bottom:15px"/>
+				  		<input style="margin-left: 6px;" type="text" id="txt_de" size="20" value="<%=data.From_value%>"/>
+				  	</td>
+				  </tr>
 
-				<label><%=data.Cc%>:</label>
-				<input style="margin-left: 6px;" type="text" id="txt_cc" size="20" />
-				<br style="margin-bottom:15px"/>
+				  <tr>
+				  	<td class="label">
+				  		<label><%=data.To%>:</label>
+				  	</td>
+				  	<td>
+				  		<input style="margin-left: 6px;" type="text" id="txt_para" size="20" />
+				  	</td>
+				  </tr>
+				  <tr>
+				  	<td class="label">
+				  		<label><%=data.Cc%>:</label>
+				  	</td>
+				  	<td>
+				  		<input style="margin-left: 6px;" type="text" id="txt_cc" size="20" />
+				  	</td>
+				  </tr>
+				  <tr>
+				  	<td class="label">
+				  		<label><%=data.Subject%>:</label>
+				  	</td>
+				  	<td>
+						<input style="margin-left: 6px;" type="text" id="txt_ass" size="20" />  	
+				  	</td>
+				  </tr>
+				  <tr>
+				  	<td class="label">
+				  		<label><%=data.Message_body%>:</label>
+				  	</td>
+				  	<td>
+						<input style="margin-left: 6px;" type="text" id="txt_body" size="20" />
+				  	</td>
+				  </tr>
+				  <tr>
+				  	<td class="label">
+				  		<label><%=data.Since_Date%>:</label>
+				  	</td>
+				  	<td>
+						<input style="width:82px; margin-left: 6px;" type="text" id="since_date" onkeypress="return dateMask(this, event);" readonly="readonly" />
+				  	</td>
+				  </tr>
+				  <tr>
+				  	<td class="label">
+				  		<label><%=data.Before_Date%>:</label>
+				  	</td>
+				  	<td>
+						<input style="width:82px; margin-left: 6px;" type="text" id="before_date" onkeypress="return dateMask(this, event);" readonly="readonly" />
+				  	</td>
+				  </tr>
+				  <tr>
+				  	<td class="label">
+				  		<label><%=data.On_Date%>:</label>
+				  	</td>
+				  	<td>
+						<input style="width:82px; margin-left: 6px;" type="text" id="on_date" onkeypress="return dateMask(this, event);" readonly="readonly" />
+				  	</td>
+				  </tr>
+				  <tr>
+				  	<td class="label">
+				  		<label>Todas as pastas:</label>
+				  	</td>
+				  	<td>
+						<input id="check_all_msg" style="margin-left: 6px;" type="checkbox" checked="checked" class="search-all-folders"/>
+				  	</td>
+				  </tr>
+				 </table> 
 
-				<label><%=data.Subject%>:</label>
-				<input style="margin-left: 6px;" type="text" id="txt_ass" size="20" />
-				<br style="margin-bottom:15px"/>
-
-				<label><%=data.Message_body%>:</label>
-				<input style="margin-left: 6px;" type="text" id="txt_body" size="20" />
-				<br style="margin-bottom:30px" />
-			
-				<div style="text-align: right; margin-bottom:10px;">
-					<label><%=data.Since_Date%>:</label>
-					<input style="margin-left: 3px; width:82px;" type="text" id="since_date" onkeypress="return dateMask(this, event);" readonly="readonly" />
-					<label><%=data.Before_Date%>:</label>
-					<input style="margin-left: 3px; width:82px;" type="text" id="before_date" onkeypress="return dateMask(this, event);" readonly="readonly" />
-				</div>
-				
-				<label><%=data.On_Date%>:</label>
-				<input style="margin-left: 3px; width:82px;" type="text" id="on_date" onkeypress="return dateMask(this, event);" readonly="readonly" />
-				<br/>
-				<br/>
-
-				<label><%=data.Flags%>:</label>
-
-				<select style="width:15em; margin-left: 6px" name="flagged" id="flagged">
-					<option value=""/>
-					<option value="FLAGGED"><%=data.Flagged%></option>
-					<option value="UNFLAGGED"><%=data.Unflagged%></option>
-				</select>
-
-				<br style="margin-bottom:15px"/>
-			
-				<select style="width:15em;" name="seen" id="seen">
-					<option value=""/>
-					<option value="SEEN"><%=data.Seen%></option>
-					<option value="UNSEEN"><%=data.Unseen%></option>
-				</select>
-			
-				<br style="margin-bottom:15px"/>
-			
-				<select style="width:15em;" name="answered" id="answered">
-					<option value=""/>
-					<option value="ANSWERED"><%=data.Answered_Forwarded%></option>
-					<option value="UNANSWERED"><%=data.Unanswered_Unforwarded%></option>
-				</select>
-			
-				<br style="margin-bottom:15px"/>
-			
-				<select style="width:15em;visibility:hidden;" name="recent" id="recent">
-					<option value=""/>
-					<option value="RECENT"><%=data.Recent%></option>
-					<option value="OLD"><%=data.Old%></option>
-				</select>
-
-				<br style="margin-bottom:60px"/>
+				<select style="width:15em; margin-left: 6px; display : none;" name="flagged" id="flagged" multiple="multiple" >
+					<% for (var i = 0; i < data.Folders.length; i++ ){ %>
+						<option value="<%= data.Folders[i].id%>"><%= data.Folders[i].commonName%></option>
+					<% } %>
+				</select>			
 		</fieldset>
-
-		<fieldset style="width:395px; height:350px; padding: 5px; position:absolute; margin-left: 365px; margin-top:5px; border:0px;">
-			
-			<legend>
-				<%=data.Search_the_messages_in_these_folders%>
-			</legend>
-
-			<div id="divFoldersSearch" style="width:165px; height:150px; float:left; margin-bottom:10px; border:1px outset black; background:#F7F7F7; overflow:auto;"></div>
-			
-			<div style="float:left; height:100px; padding-top:50px; margin: 0 3px;">
-				<input type="button" id="incluir" name="incluir" value="<%=data.button_right%>" onclick="EsearchE.add_mailboxes()" class="button ui-button ui-widget ui-state-default ui-corner-all" role="button" aria-disabled="false" />
-				<br style="margin-bottom:15px" />
-				<input type="button" id="excluir" name="excluir" value="<%=data.button_left%>" onclick="EsearchE.del_mailboxes()" class="button ui-button ui-widget ui-state-default ui-corner-all" role="button" aria-disabled="false" />
-			</div>
-			
-			<div style="float:left;">
-				<select multiple="true" id="sel_search_nm_box1" name="sel_search_nm_box1" style="width:165px;height:150px; background:#F7F7F7; color:#FC6103; font-size:10px; font-family:sans-serif; font-weight:bold"></select>
-			</div>
-			
-			<br clear="both"/>
-
-			<input type="checkBox" id="check_all_msg" name="check_all_msg" onclick="EsearchE.all_mailboxes()"/>
-			
-			<b><%=data.In_all_the_folders%></b>
-			
-		</fieldset>
Index: sandbox/expresso-solr/expressoMail1_2/inc/class.imap_functions.inc.php
===================================================================
--- sandbox/expresso-solr/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 7552)
+++ sandbox/expresso-solr/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 8056)
@@ -4005,4 +4005,5 @@
 		$return = array();
 		$folders = $this->get_folders_list();
+		$useSolr = false;		
 
 		$j = 0;
@@ -4200,7 +4201,11 @@
 
 	function search_msg( $params = false )
-	{
-	
+	{	
 		include '../prototype/api/controller.php';
+		include 'solrclient/library/Solarium/Autoloader.php';
+		Solarium_Autoloader::register();
+
+		$useSolr = false;
+
 		if(strpos($params['condition'],"#")===false)
 		{ //local messages
@@ -4212,185 +4217,472 @@
 		}
 		
-		$params['page'] = $params['page'] * 1;
-
-	    if( is_array($search) )
-	    {
-			$search = array_unique($search); // Remove duplicated folders
-			$search_criteria = '';
-			$search_result_number = $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['search_result_number'];
-			foreach($search as $tmp)
-			{
-				$tmp1 = explode("##",$tmp);
-				$sum = 0;
-				$name_box = $tmp1[0];
-				unset($filter);
-				foreach($tmp1 as $index => $criteria)
+		if(isset($_SESSION['phpgw_info']['expresso']['expressoMail']['expressoMail_enable_solr']) && $_SESSION['phpgw_info']['expresso']['expressoMail']['expressoMail_enable_solr'] === 'true')
+		{
+			$useSolr = true;
+		}
+		$count = 0;
+		
+		if($useSolr == true)
+		{
+			$params['page'] = $params['page'] * 1;
+
+			if( is_array($search) )
+	   		{
+				$search = array_unique($search); // Remove duplicated folders
+				$search_criteria = '';
+				$search_result_number = $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['search_result_number'];
+				
+				$solrConfig = array(
+						'adapteroptions' => array(
+						'host' => '127.0.0.1',
+					        'port' => 8983,
+		        			'path' => '/solr/',
+						)
+					);
+				// create a client instance
+				$solariumClient = new Solarium_Client($solrConfig);
+				$solrQuery = $solariumClient->createSelect();
+				$usernameAux = $this->username;
+				$solrSearchString = "";
+
+				foreach($search as $tmp)
 				{
-					if ($index != 0 && strlen($criteria) != 0)
+					$tmp1 = explode("##",$tmp);
+					$sum = 0;
+					$name_box = $tmp1[0];
+					$filter = "";
+					$solrSearchString = "(";
+					
+					foreach($tmp1 as $index => $criteria)
 					{
-						$filter_array = explode("<=>",html_entity_decode(rawurldecode($criteria)));
-						$filter .= " ".$filter_array[0];
-						if (strlen($filter_array[1]) != 0)
+						if ($index != 0 && strlen($criteria) != 0)
 						{
-							if ( trim($filter_array[0]) != 'BEFORE' &&
-								 trim($filter_array[0]) != 'SINCE' &&
-								 trim($filter_array[0]) != 'ON')
+							$filter_array = explode("<=>",html_entity_decode(rawurldecode($criteria)));
+							//$filter .= " ".$filter_array[0];
+							if (strlen($filter_array[1]) != 0)
 							{
-							    $filter .= '"'.$filter_array[1].'"';
-							}else if(trim($filter_array[0]) == 'BEFORE' ){
-                                                            $filter .= '"'.$this->make_search_date($filter_array[1],true).'"';
-							}else{
-                                                            $filter .= '"'.$this->make_search_date($filter_array[1]).'"';
-                                                        }
+								
+								$filter_array[1] = mb_convert_encoding($filter_array[1], 'UTF-8',mb_detect_encoding($filter_array[1].'x', 'UTF-8, ISO-8859-1'));
+
+								if ( strlen(trim($solrSearchString)) > 1 )
+								{
+									$solrSearchString .= " OR ";
+								}
+								
+								
+								if ( trim($filter_array[0]) == 'SUBJECT' )
+								{
+									$solrSearchString .= "subject:\"".trim($filter_array[1])."\"";
+								}
+								else if ( trim($filter_array[0]) == 'FROM' )
+								{
+									$solrSearchString .= "from:\"".trim($filter_array[1])."\"";
+								}
+								else if ( trim($filter_array[0]) == 'TO' )
+								{
+									$solrSearchString .= "to:\"".trim($filter_array[1])."\"";
+								}
+								else if ( trim($filter_array[0]) == 'BODY' )
+								{
+									$solrSearchString .= "content:\"".trim($filter_array[1])."\"";
+								}
+								else if ( trim($filter_array[0]) == 'CC' )
+								{
+									$solrSearchString .= "copyto:\"".trim($filter_array[1])."\"";
+								}
+							}
 						}
 					}
+
+					$solrSearchString .= ")";
+
+					$name_box = mb_convert_encoding(utf8_decode($name_box), "UTF7-IMAP", "ISO-8859-1");
+					if(count(explode("/", $name_box)) > 1 )
+					{
+						$arrayAux = explode("/", $name_box);
+						$iArrayAux = count(explode("/", $name_box));
+						
+						$name_box = $arrayAux[$iArrayAux-1];
+					}
+
+
+					$solrQuery->setQuery("$solrSearchString AND user:$usernameAux AND folder:$name_box" );
+					$solrQuery->setFields(array('id', 'msg_no'));
+					$solrQuery->addSort("sent_date", "desc");
+					// override the default row limit of 10 by setting rows to 50
+					$solrQuery->setRows(50);
+					// this executes the query and returns the result
+					$resultset = $solariumClient->select($solrQuery);
+				
+					$count += count($resultset); 
+
+					//$filter = $this->remove_accents($filter);
+
+					//Este bloco tem a finalidade de transformar o login (quando numerico) das pastas compartilhadas em common name
+					/*if ($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['uid2cn'] && substr($name_box,0,4) == 'user')
+					{
+						$folder_name = explode($this->imap_delimiter,$name_box);
+						$this->ldap = new ldap_functions();
+						
+						if ($cn = $this->ldap->uid2cn($folder_name[1]))
+						{
+							$folder_name[1] = $cn;
+						}
+						$folder_name = implode($this->imap_delimiter,$folder_name);
+					}
+					else
+					{
+						$folder_name = mb_convert_encoding(utf8_decode($name_box), "UTF7-IMAP", "ISO-8859-1" );
+					}
+				
+					//print_r($filter);
+					//print("<br/>");
+				
+				        $this->open_mbox($name_box);
+
+					if (preg_match("/^.?\bALL\b/", $filter))
+					{ 
+						// Quick Search, note: this ALL isn't the same ALL from imap_search
+						$all_criterias = array ("TO","SUBJECT","FROM","CC");
+						
+						foreach($all_criterias as $criteria_fixed)
+						{
+							$_filter = $criteria_fixed . substr($filter,4);
+						
+							$search_criteria = imap_search($this->mbox, $_filter, SE_UID);
+						
+							if(is_array($search_criteria))
+							{
+								foreach($search_criteria as $new_search)
+								{
+									$elem = $this->get_info_head_msg($new_search);
+									$elem['udate']       = gmdate('d/m/Y', $elem['udate'] + $this->functions->CalculateDateOffset()); 
+									$elem['boxname'] = mb_convert_encoding( $name_box, "ISO-8859-1", "UTF7-IMAP" );
+									$elem['uid'] = $new_search;
+        	                                                        // compare dates in ordering /
+									$elem['udatecomp'] = substr ($elem['udate'], -4) ."-". substr ($elem['udate'], 3, 2) ."-". substr ($elem['udate'], 0, 2);
+									$retorno[] = $elem; 
+								}
+							}
+						}
+					}*/
+					//else
+					//{
+					$imap = $this->open_mbox( $name_box );
+					foreach ($resultset as $document)
+					{	
+						$v = $document['msg_no'];
+					
+						$new_search = imap_headerinfo ( $imap,  imap_msgno($imap, $v) );
+						if ($new_search->message_id != $document['id'])
+						{
+							continue;
+						}
+
+						//$search_criteria = imap_search($this->mbox, $filter, SE_UID);
+						
+						/*if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_important_flag'])
+						{
+							if((!strpos($filter,"FLAGGED") === false) || (!strpos($filter,"UNFLAGGED") === false))
+							{
+								$num_msgs = imap_num_msg($this->mbox);
+								$flagged_msgs = array();
+								for ($i=$num_msgs; $i>0; $i--)
+								{
+									$iuid = @imap_uid($this->mbox,$i);
+									$header = $this->get_header($iuid);
+									if(trim($header->Flagged))
+									{
+										$flagged_msgs[$i] = $iuid;
+									}
+								}
+								
+								if((count($flagged_msgs) >0) && (strpos($filter,"UNFLAGGED") === false))
+								{
+									$arry_diff = is_array($search_criteria) ? array_diff($flagged_msgs,$search_criteria):$flagged_msgs;
+									foreach($arry_diff as $msg)
+									{
+										$search_criteria[] = $msg;
+									}
+								}
+								else if((count($flagged_msgs) >0) && (is_array($search_criteria)) && (!strpos($filter,"UNFLAGGED") === false))
+								{
+									$search_criteria = array_diff($search_criteria,$flagged_msgs);
+								}
+							}
+						}*/
+
+						//if( is_array( $search_criteria) )
+						//{
+						//	foreach($search_criteria as $new_search)
+						//	{
+								
+
+								$elem = $this->get_info_head_msg( $new_search );
+
+								$elem['udate']       = gmdate('d/m/Y', $elem['msg_number']->udate + $this->functions->CalculateDateOffset());
+								$elem['boxname'] = mb_convert_encoding( $name_box, "ISO-8859-1", "UTF7-IMAP" ); 
+								$elem['uid'] = $new_search->Msgno;
+								$elem['flag'] = $elem['msg_number']->Unseen.$elem['msg_number']->Flagged.$elem['msg_number']->Answered.$elem['msg_number']->Draft;
+								/* compare dates in ordering */
+								$elem['from'] = $elem['msg_number']->from[0]->personal ? $elem['msg_number']->from[0]->personal : $elem['msg_number']->from[0]->mailbox . "@" . $elem['msg_number']->from[0]->host;
+								$elem['Size'] = $elem['msg_number']->Size;
+								$elem['subject'] = mb_convert_encoding(self::decodeMimeString($elem['msg_number']->subject), 'UTF-8',mb_detect_encoding(self::decodeMimeString($elem['msg_number']->subject).'x', 'UTF-8, ISO-8859-1'));
+								$elem['udatecomp'] = substr ($elem['udate'], -4) ."-". substr ($elem['udate'], 3, 2) ."-". substr ($elem['udate'], 0, 2);  
+								$filter = array('AND', array('=', 'folderName', $name_box), array('=','messageNumber', $new_search));
+								$followupflagged = Controller::find(
+											array('concept' => 'followupflagged'),
+											false, 
+											array('filter' => $filter, 'criteria' => array('deepness' => '2'))
+										);
+
+								if(isset($followupflagged[0]['followupflagId']))
+								{
+									$followupflag = Controller::read( array( 'concept' => 'followupflag', 'id' => $followupflagged[0]['followupflagId'] ));     
+									$followupflagged[0]['followupflag'] = $followupflag;
+									$elem['followupflagged'] = $followupflagged[0];
+								}	
+
+								$labeleds = Controller::find(
+											array('concept' => 'labeled'),
+											false, 
+											array('filter' => $filter, 'criteria' => array('deepness' => '2'))
+										);
+								foreach ($labeleds as $e)
+								{
+									$labels = Controller::read( array( 'concept' => 'label', 'id' =>  $e['labelId']));
+									$elem['labels'][$e['labelId']] = $labels;
+								}											
+                                         	   		$retorno[] = $elem;
+							//}
+						//}
+					}
 				}
+			}
+			imap_close($this->mbox);
+			$num_msgs = count($retorno);
+			/* Comparison functions, descendent is ascendent with parms inverted */
+			function SORTDATE($a, $b){ return ($a['udatecomp'] < $b['udatecomp']); }
+			function SORTDATE_REVERSE($b, $a) { return SORTDATE($a,$b); }
+
+			function SORTWHO($a, $b) { return (strtoupper($a['from']) > strtoupper($b['from'])); }
+			function SORTWHO_REVERSE($b, $a) { return SORTWHO($a,$b); }
+
+			function SORTSUBJECT($a, $b) { return (strtoupper($a['subject']) > strtoupper($b['subject'])); }
+			function SORTSUBJECT_REVERSE($b, $a) { return SORTSUBJECT($a,$b); }
+
+			function SORTBOX($a, $b) { return ($a['boxname'] > $b['boxname']); }
+			function SORTBOX_REVERSE($b, $a) { return SORTBOX($a,$b); }
+
+			function SORTSIZE($a, $b) { return ($a['size'] > $b['size']); }
+			function SORTSIZE_REVERSE($b, $a) { return SORTSIZE($a,$b); }
+
+			usort( $retorno, $params['sort_type']);
+			$pageret = array_slice( $retorno, $params['page'] * $this->prefs['max_email_per_page'], $this->prefs['max_email_per_page']);
+		    
+			$arrayRetorno['num_msgs']	=  $num_msgs;
+			$arrayRetorno['data']		=  $pageret;
+			$arrayRetorno['currentTab'] =  $params['current_tab'];
+
+			print_r(json_encode($arrayRetorno));
+			return;
+		}
+		else
+		{
+			$params['page'] = $params['page'] * 1;
+
+	    		if( is_array($search) )
+	   		{
+				$search = array_unique($search); // Remove duplicated folders
+				//print_r($search);
+				$search_criteria = '';
+				$search_result_number = $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['search_result_number'];
+				foreach($search as $tmp)
+				{
+					$tmp1 = explode("##",$tmp);
+					//print_r($tmp1);
+					$sum = 0;
+					$name_box = $tmp1[0];
+					//unset($filter);
+					$filter = "";
+					foreach($tmp1 as $index => $criteria)
+					{
+						if ($index != 0 && strlen($criteria) != 0)
+						{
+							$filter_array = explode("<=>",html_entity_decode(rawurldecode($criteria)));
+							$filter .= " ".$filter_array[0];
+							if (strlen($filter_array[1]) != 0)
+							{
+								if ( trim($filter_array[0]) != 'BEFORE' &&
+										 trim($filter_array[0]) != 'SINCE' &&
+										 trim($filter_array[0]) != 'ON')
+								{
+									$filter .= '"'.$filter_array[1].'"';
+								}
+								else if(trim($filter_array[0]) == 'BEFORE' )
+								{
+                                                            		$filter .= '"'.$this->make_search_date($filter_array[1],true).'"';
+								}
+								else
+								{
+									$filter .= '"'.$this->make_search_date($filter_array[1]).'"';
+								}
+							}
+						}
+					}
 				
-				$name_box = mb_convert_encoding(utf8_decode($name_box), "UTF7-IMAP", "ISO-8859-1" );
-				$filter = $this->remove_accents($filter);
-
-				//Este bloco tem a finalidade de transformar o login (quando numerico) das pastas compartilhadas em common name
-				if ($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['uid2cn'] && substr($name_box,0,4) == 'user')
-				{
-					$folder_name = explode($this->imap_delimiter,$name_box);
-					$this->ldap = new ldap_functions();
-					
-					if ($cn = $this->ldap->uid2cn($folder_name[1]))
+					$name_box = mb_convert_encoding(utf8_decode($name_box), "UTF7-IMAP", "ISO-8859-1" );
+					$filter = $this->remove_accents($filter);
+
+					//Este bloco tem a finalidade de transformar o login (quando numerico) das pastas compartilhadas em common name
+					if ($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['uid2cn'] && substr($name_box,0,4) == 'user')
 					{
-						$folder_name[1] = $cn;
+						$folder_name = explode($this->imap_delimiter,$name_box);
+						$this->ldap = new ldap_functions();
+						
+						if ($cn = $this->ldap->uid2cn($folder_name[1]))
+						{
+							$folder_name[1] = $cn;
+						}
+						$folder_name = implode($this->imap_delimiter,$folder_name);
 					}
-					$folder_name = implode($this->imap_delimiter,$folder_name);
-				}
-				else
-					$folder_name = mb_convert_encoding(utf8_decode($name_box), "UTF7-IMAP", "ISO-8859-1" );
+					else
+					{
+						$folder_name = mb_convert_encoding(utf8_decode($name_box), "UTF7-IMAP", "ISO-8859-1" );
+					}
 				
-	
-			        $this->open_mbox($name_box);
-
-				if (preg_match("/^.?\bALL\b/", $filter))
-				{ 
-					// Quick Search, note: this ALL isn't the same ALL from imap_search
-					$all_criterias = array ("TO","SUBJECT","FROM","CC");
-					    
-					foreach($all_criterias as $criteria_fixed)
+					//print_r($filter);
+					//print("<br/>");
+				
+				        $this->open_mbox($name_box);
+
+					if (preg_match("/^.?\bALL\b/", $filter))
+					{ 
+						// Quick Search, note: this ALL isn't the same ALL from imap_search
+						$all_criterias = array ("TO","SUBJECT","FROM","CC");
+						
+						foreach($all_criterias as $criteria_fixed)
+						{
+							$_filter = $criteria_fixed . substr($filter,4);
+						
+							$search_criteria = imap_search($this->mbox, $_filter, SE_UID);
+						
+							if(is_array($search_criteria))
+							{
+								foreach($search_criteria as $new_search)
+								{
+									$elem = $this->get_info_head_msg($new_search);
+
+									$elem['udate']       = gmdate('d/m/Y', $elem['udate'] + $this->functions->CalculateDateOffset()); 
+									$elem['boxname'] = mb_convert_encoding( $name_box, "ISO-8859-1", "UTF7-IMAP" );
+									$elem['uid'] = $new_search;
+        	                                                        /* compare dates in ordering */
+									$elem['udatecomp'] = substr ($elem['udate'], -4) ."-". substr ($elem['udate'], 3, 2) ."-". substr ($elem['udate'], 0, 2);
+									$retorno[] = $elem; 
+								}
+							}
+						}
+					}
+					else
 					{
-						$_filter = $criteria_fixed . substr($filter,4);
-						
-						$search_criteria = imap_search($this->mbox, $_filter, SE_UID);
-						
-						if(is_array($search_criteria))
+						$search_criteria = imap_search($this->mbox, $filter, SE_UID);
+						if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_important_flag'])
+						{
+							if((!strpos($filter,"FLAGGED") === false) || (!strpos($filter,"UNFLAGGED") === false))
+							{
+								$num_msgs = imap_num_msg($this->mbox);
+								$flagged_msgs = array();
+								for ($i=$num_msgs; $i>0; $i--)
+								{
+									$iuid = @imap_uid($this->mbox,$i);
+									$header = $this->get_header($iuid);
+									if(trim($header->Flagged))
+									{
+										$flagged_msgs[$i] = $iuid;
+									}
+								}
+								if((count($flagged_msgs) >0) && (strpos($filter,"UNFLAGGED") === false))
+								{
+									$arry_diff = is_array($search_criteria) ? array_diff($flagged_msgs,$search_criteria):$flagged_msgs;
+									foreach($arry_diff as $msg)
+									{
+										$search_criteria[] = $msg;
+									}
+								}
+								else if((count($flagged_msgs) >0) && (is_array($search_criteria)) && (!strpos($filter,"UNFLAGGED") === false))
+								{
+									$search_criteria = array_diff($search_criteria,$flagged_msgs);
+								}
+							}
+						}
+
+						if( is_array( $search_criteria) )
 						{
 							foreach($search_criteria as $new_search)
 							{
-								$elem = $this->get_info_head_msg($new_search);
-								$elem['udate']       = gmdate('d/m/Y', $elem['udate'] + $this->functions->CalculateDateOffset()); 
+								$elem = $this->get_info_head_msg( $new_search );
+								$elem['udate']       = gmdate('d/m/Y', $elem['udate'] + $this->functions->CalculateDateOffset());
 								$elem['boxname'] = mb_convert_encoding( $name_box, "ISO-8859-1", "UTF7-IMAP" ); 
 								$elem['uid'] = $new_search;
-                                                                /* compare dates in ordering */
-								$elem['udatecomp'] = substr ($elem['udate'], -4) ."-". substr ($elem['udate'], 3, 2) ."-". substr ($elem['udate'], 0, 2);
-								$retorno[] = $elem; 
+								/* compare dates in ordering */
+								$elem['udatecomp'] = substr ($elem['udate'], -4) ."-". substr ($elem['udate'], 3, 2) ."-". substr ($elem['udate'], 0, 2);  
+								$filter = array('AND', array('=', 'folderName', $name_box), array('=','messageNumber', $new_search));
+								$followupflagged = Controller::find(
+											array('concept' => 'followupflagged'),
+											false, 
+											array('filter' => $filter, 'criteria' => array('deepness' => '2'))
+										);
+
+								if(isset($followupflagged[0]['followupflagId']))
+								{
+									$followupflag = Controller::read( array( 'concept' => 'followupflag', 'id' => $followupflagged[0]['followupflagId'] ));     
+									$followupflagged[0]['followupflag'] = $followupflag;
+									$elem['followupflagged'] = $followupflagged[0];
+								}	
+
+								$labeleds = Controller::find(
+											array('concept' => 'labeled'),
+											false, 
+											array('filter' => $filter, 'criteria' => array('deepness' => '2'))
+										);
+								foreach ($labeleds as $e)
+								{
+									$labels = Controller::read( array( 'concept' => 'label', 'id' =>  $e['labelId']));
+									$elem['labels'][$e['labelId']] = $labels;
+								}											
+                                         	   		$retorno[] = $elem;
 							}
 						}
 					}
 				}
-				else{
-					$search_criteria = imap_search($this->mbox, $filter, SE_UID);
-                                    if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_important_flag'])
-                                    {
-                                        if((!strpos($filter,"FLAGGED") === false) || (!strpos($filter,"UNFLAGGED") === false))
-                                        {
-                                            $num_msgs = imap_num_msg($this->mbox);
-                                            $flagged_msgs = array();
-                                            for ($i=$num_msgs; $i>0; $i--)
-                                            {
-                                                $iuid = @imap_uid($this->mbox,$i);
-                                                $header = $this->get_header($iuid);
-                                                if(trim($header->Flagged))
-                                                {
-                                                        $flagged_msgs[$i] = $iuid;
-                                                }
-                                            }
-						if((count($flagged_msgs) >0) && (strpos($filter,"UNFLAGGED") === false))
-                                            {
-                                                    $arry_diff = is_array($search_criteria) ? array_diff($flagged_msgs,$search_criteria):$flagged_msgs;
-                                                    foreach($arry_diff as $msg)
-                                            {
-							$search_criteria[] = $msg;
-                                            }
-                                        }
-						else if((count($flagged_msgs) >0) && (is_array($search_criteria)) && (!strpos($filter,"UNFLAGGED") === false))
-                                        {
-                                                    $search_criteria = array_diff($search_criteria,$flagged_msgs);
-                                        }
-                                    }
-                                    }
-
-                                    if( is_array( $search_criteria) )
-                                    {
-                                        foreach($search_criteria as $new_search)
-                                        {
-										
-                                            $elem = $this->get_info_head_msg( $new_search );
-                                            $elem['udate']       = gmdate('d/m/Y', $elem['udate'] + $this->functions->CalculateDateOffset()); 
-											$elem['boxname'] = mb_convert_encoding( $name_box, "ISO-8859-1", "UTF7-IMAP" ); 
-                                            $elem['uid'] = $new_search;
-                                            /* compare dates in ordering */
-                                            $elem['udatecomp'] = substr ($elem['udate'], -4) ."-". substr ($elem['udate'], 3, 2) ."-". substr ($elem['udate'], 0, 2);  
-
-											$filter = array('AND', array('=', 'folderName', $name_box), array('=','messageNumber', $new_search));
-											$followupflagged = Controller::find(
-												array('concept' => 'followupflagged'),
-												false, 
-												array('filter' => $filter, 'criteria' => array('deepness' => '2'))
-											);
-
-											if(isset($followupflagged[0]['followupflagId']))
-											{
-												$followupflag = Controller::read( array( 'concept' => 'followupflag', 'id' => $followupflagged[0]['followupflagId'] ));     
-												$followupflagged[0]['followupflag'] = $followupflag;
-												$elem['followupflagged'] = $followupflagged[0];
-
-											}	
-											$labeleds = Controller::find(
-												array('concept' => 'labeled'),
-												false, 
-												array('filter' => $filter, 'criteria' => array('deepness' => '2'))
-											);
-											foreach ($labeleds as $e){
-												$labels = Controller::read( array( 'concept' => 'label', 'id' =>  $e['labelId']));     
-												$elem['labels'][$e['labelId']] = $labels;
-}											
-                                            $retorno[] = $elem;
-                                        }
-                                    }
-				}
-			}
-		}
-		
-            imap_close($this->mbox);
-	    $num_msgs = count($retorno);
-	    /* Comparison functions, descendent is ascendent with parms inverted */
-	    function SORTDATE($a, $b){ return ($a['udatecomp'] < $b['udatecomp']); }
-	    function SORTDATE_REVERSE($b, $a) { return SORTDATE($a,$b); }
-
-	    function SORTWHO($a, $b) { return (strtoupper($a['from']) > strtoupper($b['from'])); }
-	    function SORTWHO_REVERSE($b, $a) { return SORTWHO($a,$b); }
-
-	    function SORTSUBJECT($a, $b) { return (strtoupper($a['subject']) > strtoupper($b['subject'])); }
-	    function SORTSUBJECT_REVERSE($b, $a) { return SORTSUBJECT($a,$b); }
-
-	    function SORTBOX($a, $b) { return ($a['boxname'] > $b['boxname']); }
-	    function SORTBOX_REVERSE($b, $a) { return SORTBOX($a,$b); }
-
-	    function SORTSIZE($a, $b) { return ($a['size'] > $b['size']); }
-	    function SORTSIZE_REVERSE($b, $a) { return SORTSIZE($a,$b); }
-
-	    usort( $retorno, $params['sort_type']);
-	    $pageret = array_slice( $retorno, $params['page'] * $this->prefs['max_email_per_page'], $this->prefs['max_email_per_page']);
+			}
+		}
+
+		imap_close($this->mbox);
+		$num_msgs = count($retorno);
+		/* Comparison functions, descendent is ascendent with parms inverted */
+		function SORTDATE($a, $b){ return ($a['udatecomp'] < $b['udatecomp']); }
+		function SORTDATE_REVERSE($b, $a) { return SORTDATE($a,$b); }
+
+		function SORTWHO($a, $b) { return (strtoupper($a['from']) > strtoupper($b['from'])); }
+		function SORTWHO_REVERSE($b, $a) { return SORTWHO($a,$b); }
+
+		function SORTSUBJECT($a, $b) { return (strtoupper($a['subject']) > strtoupper($b['subject'])); }
+		function SORTSUBJECT_REVERSE($b, $a) { return SORTSUBJECT($a,$b); }
+
+		function SORTBOX($a, $b) { return ($a['boxname'] > $b['boxname']); }
+		function SORTBOX_REVERSE($b, $a) { return SORTBOX($a,$b); }
+
+		function SORTSIZE($a, $b) { return ($a['size'] > $b['size']); }
+		function SORTSIZE_REVERSE($b, $a) { return SORTSIZE($a,$b); }
+
+		usort( $retorno, $params['sort_type']);
+		$pageret = array_slice( $retorno, $params['page'] * $this->prefs['max_email_per_page'], $this->prefs['max_email_per_page']);
 	    
-	    $arrayRetorno['num_msgs']	=  $num_msgs;
-	    $arrayRetorno['data']		=  $pageret;
-	    $arrayRetorno['currentTab'] =  $params['current_tab'];
-            return ($pageret) ? $arrayRetorno : 'none';
+		$arrayRetorno['num_msgs']	=  $num_msgs;
+		$arrayRetorno['data']		=  $pageret;
+		$arrayRetorno['currentTab'] =  $params['current_tab'];	
+
+		return ($pageret) ? $arrayRetorno : 'none';
 	}
 
@@ -4921,5 +5213,16 @@
 		call_user_func_array('array_multisort', $params);
 		$ret = array();
-		$keys = array();
+		$keys = array();$solrConfig = array(
+						'adapteroptions' => array(
+						'host' => '127.0.0.1',
+					        'port' => 8983,
+		        			'path' => '/solr/',
+					)
+				);
+				//echo("damn");
+				// create a client instance
+				$solariumClient = new Solarium_Client($solrConfig);
+				$solrQuery = $solariumClient->createSelect();
+				$usernameAux = $this->username;
 		$first = true;
 		foreach ($colarr as $col => $arr) {
@@ -4951,8 +5254,13 @@
 	function quickSearchMail( $params )
 	{		
-		include '../prototype/api/controller.php';			
+		include '../prototype/api/controller.php';
+		include 'solrclient/library/Solarium/Autoloader.php';
+		Solarium_Autoloader::register();
+
 		set_time_limit(270); //Aumenta o tempo limit da requisição, em algumas buscas o imap demora para retornar o resultado.
 		$return = array();
 		$return['folder'] = $params['folder'];
+		$useSolr = false;
+
 		if(!is_array($params['folder']))
 			$params['folder'] = array( $params['folder'] );
@@ -4974,5 +5282,127 @@
 			$search = $params['search'];
 		}
+		
+		if(isset($_SESSION['phpgw_info']['expresso']['expressoMail']['expressoMail_enable_solr']) && $_SESSION['phpgw_info']['expresso']['expressoMail']['expressoMail_enable_solr'] === 'true')
+		{
+			$useSolr = true;
+		}
+		
+		if($useSolr == true)
+		{
+			foreach ($params['folder'] as $folder) 
+			{
+				
+				$imap = $this->open_mbox( $folder ) ;
 	
+				//$msgIds = imap_sort( $imap , SORTDATE , 1 , SE_UID , $search ,'UTF-8');
+							
+				/*include("solrclient/init.php");*/
+			
+				$solrConfig = array(
+						'adapteroptions' => array(
+						'host' => '127.0.0.1',
+					        'port' => 8983,
+		        			'path' => '/solr/',
+					)
+				);
+				// create a client instance
+				$solariumClient = new Solarium_Client($solrConfig);
+				$solrQuery = $solariumClient->createSelect();
+				$usernameAux = $this->username;
+				$solrSearch = $params['search'];
+
+				$solrFolder = $folder;
+				if(count(split("/", $folder) ) > 1 )
+				{
+					$folderArrayAux = split("/", $folder);
+					$solrFolder = $folderArrayAux[1];
+				}
+				
+				$solrQuery->setQuery("(content:\"$solrSearch\" OR subject:\"$solrSearch\" OR from:\"$solrSearch:\") AND user:$usernameAux AND folder:$solrFolder" );
+				$solrQuery->setFields(array('id', 'msg_no'));
+				$solrQuery->addSort("sent_date", "desc");
+				// override the default row limit of 10 by setting rows to 50
+				$solrQuery->setRows(50);
+				// this executes the query and returns the result
+				$resultset = $solariumClient->select($solrQuery);
+				
+				$count += count($resultset);  
+				
+				foreach ($resultset as $document)
+				{	
+					$v = $document['msg_no'];
+					
+					$msg = imap_headerinfo ( $imap,  imap_msgno($imap, $v) );
+					if ($msg->message_id != $document['id'])
+					{
+						continue;
+					}
+	
+					if(isset($msg->from[0]))
+					{
+						$from = self::formatMailObject( $msg->from[0] );
+						$return['msgs'][$i]['from'] 	= mb_convert_encoding($from['name'] ? $from['name'] : $from['email'], 'UTF-8');
+					}
+					else
+						$return['msgs'][$i]['from'] 	= ''; 
+					
+					$return['msgs'][$i]['subject'] = ' ';
+				
+					$subject = imap_mime_header_decode($msg->subject);
+					foreach ($subject as $tmp)
+						$return['msgs'][$i]['subject'] .= mb_convert_encoding($tmp->text, 'UTF-8', 'UTF-8 , ISO-8859-1');
+				
+					$filter = array('AND', array('=', 'folderName', $folder), array('=','messageNumber', $v));
+					$followupflagged = Controller::find(
+						array('concept' => 'followupflagged' , 'folder' => $folder ),
+						false, 
+						array('filter' => $filter, 'criteria' => array('deepness' => '2'))
+					);
+
+					if(isset($followupflagged[0]['followupflagId']))
+					{
+						$followupflag = Controller::read( array( 'concept' => 'followupflag', 'id' => $followupflagged[0]['followupflagId'] ));     
+						$followupflagged[0]['followupflag'] = $followupflag;
+						$return['msgs'][$i]['followupflagged'] = $followupflagged[0];
+
+					}	
+					$labeleds = Controller::find(
+						array('concept' => 'labeled'),
+						false, 
+						array('filter' => $filter, 'criteria' => array('deepness' => '2'))
+					);
+					if(is_array($labeleds))
+						foreach ($labeleds as $e){
+							$labels = Controller::read( array( 'concept' => 'label', 'id' =>  $e['labelId']));     
+							$return['msgs'][$i]['labels'][$e['labelId']] = $labels;
+						}
+					$mimeBody = imap_body( $this->mbox, $v  , FT_UID|FT_PEEK  );	
+					$return['msgs'][$i]['flag'] = ' ';
+					$return['msgs'][$i]['flag'] .= $msg->Unseen ? $msg->Unseen : '';
+					$return['msgs'][$i]['flag'] .= $msg->Recent ? $msg->Recent : '';	
+					$return['msgs'][$i]['flag'] .= $msg->Draft ? $msg->Draft : '';	
+					$return['msgs'][$i]['flag'] .= $msg->Answered ? $msg->Answered : '';	
+					$return['msgs'][$i]['flag'] .= $msg->Deleted ? $msg->Deleted : '';	
+					$return['msgs'][$i]['flag'] .= ( preg_match('/((Content-Disposition:(.)*([\r\n\s]*filename))|(Content-Type:(.)*([\r\n\s]*name)))/i', $mimeBody) ) ? 'T': '';
+
+					$header = imap_fetchheader( $imap, $v , FT_UID ); // Necessario para recuperar se a mensagem é importante ou não.
+					$importante = array();
+				
+					if($msg->Flagged != 'F')
+						$return['msgs'][$i]['flag'] .= ( preg_match('/importance *: *(.*)\r/i', $header , $importante) === 0 ) ? '' : 'F';
+					else
+						$return['msgs'][$i]['flag'] .= $msg->Flagged ? $msg->Flagged : '';	
+					
+					$return['msgs'][$i]['udate'] = gmdate("d/m/Y",$msg->udate + $this->functions->CalculateDateOffset()); 
+					$return['msgs'][$i]['udatecomp'] = substr ($return['msgs'][$i]['udate'], -4) ."-". substr ($return['msgs'][$i]['udate'], 3, 2) ."-". substr ($return['msgs'][$i]['udate'], 0, 2);
+					$return['msgs'][$i]['date'] =   $msg->udate;
+					$return['msgs'][$i]['size'] =  $msg->Size;
+					$return['msgs'][$i]['boxname'] = $folder;
+					$return['msgs'][$i]['uid'] = $v;
+					$i++;
+				} 	
+			}
+		}
+		else
 		foreach ($params['folder'] as $folder) 
 		{
@@ -5072,5 +5502,5 @@
 			case 3 : $sA = 'subject'; break;
 			case 6 : $sA = 'size'; break;
-	} 
+		} 
 	
 			
Index: sandbox/expresso-solr/expressoMail1_2/js/abas.js
===================================================================
--- sandbox/expresso-solr/expressoMail1_2/js/abas.js	(revision 7520)
+++ sandbox/expresso-solr/expressoMail1_2/js/abas.js	(revision 8056)
@@ -225,4 +225,5 @@
 			openTab.imapBox[ID] = current_folder;
 	}
+	ID = $.trim(ID);
 	td = document.createElement("TD");
 	td.id="border_id_" + ID;
Index: sandbox/expresso-solr/expressoMail1_2/js/main.js
===================================================================
--- sandbox/expresso-solr/expressoMail1_2/js/main.js	(revision 7568)
+++ sandbox/expresso-solr/expressoMail1_2/js/main.js	(revision 8056)
@@ -5554,3 +5554,2 @@
     }
 }
-
Index: sandbox/expresso-solr/expressoMail1_2/js/search.js
===================================================================
--- sandbox/expresso-solr/expressoMail1_2/js/search.js	(revision 7561)
+++ sandbox/expresso-solr/expressoMail1_2/js/search.js	(revision 8056)
@@ -68,5 +68,6 @@
 				"Search_the_messages_in_these_folders" : get_lang('Search the messages in these folders'),
 				"In_all_the_folders"		: get_lang('In all the folders'),
-				"From_value" : (data != "undefined" ? data : "")
+				"From_value" : (data != "undefined" ? data : ""),
+				"Folders" : $.merge(cp_tree1,cp_tree2), 
 			}
 				
@@ -76,9 +77,9 @@
 			this.modal = $(div).dialog(
 			{
-				resizable	: false,
+				resizable	: true,
 				title		: get_lang("Search Email"),
 				position	: 'center',
-				width		: 795,
 				height		: 450,
+				width		: 400,
 				modal		: true,
 				buttons		: [
@@ -107,6 +108,6 @@
 				beforeClose	: function()
 				{ 
-					$("#sel_search_nm_box1")[0].parentNode.removeChild($("#sel_search_nm_box1")[0]);
-					$("#divFoldersSearch")[0].parentNode.removeChild($("#divFoldersSearch")[0]);
+					//$("#sel_search_nm_box1")[0].parentNode.removeChild($("#sel_search_nm_box1")[0]);
+					//$("#divFoldersSearch")[0].parentNode.removeChild($("#divFoldersSearch")[0]);
 					//$(this).dialog("destroy");
 					$('fieldset', div).remove();
@@ -130,6 +131,18 @@
 	
 			// Cria as caixas postais;
-			this.foldersTree();
-			
+			//this.foldersTree();
+
+			$(".search-all-folders").change(function(){
+				$(".pickList").toggle("slow");
+			});
+
+			$("#flagged").pickList({
+		        sourceListLabel:    "Itens disponíveis",
+		        targetListLabel:    "Itens selecionados"
+		    });
+
+			//$(".pickList_controlsContainer button").button().addClass("small");
+
+		    $(".pickList").hide();
 			var dates = $("#since_date, #before_date").datepicker({
 				onSelect: function( selectedDate ) {
@@ -1448,5 +1461,5 @@
 
         }
-
+        /*
         if(trim(Element("flagged").options[Element("flagged").selectedIndex].value) != "")
         {
@@ -1494,5 +1507,5 @@
             }
         }
-
+		*/
 		if(fields == "##")
 		{
@@ -1520,56 +1533,11 @@
 		{
 			var nm_box = new Array;
-			var sel_combo = Element("sel_search_nm_box1");
-			
-			if( sel_combo.options.length <= 0)
-			{
+			var folders_select = $("#flagged").find("option:checked");
+			if(folders_select.length == 0){
 				alert(get_lang("Define the boxes to search!"));
 				return false;
-			}
-
-			for(var i=0; i < sel_combo.options.length; i++)
-			{
-				sel_combo.options[i].selected = true;
-			}
-			
-			var get_children = function(folder, arr_folder){
-				for(var y = 0; y < folder.children.length; y++){
-					if(folder.children[y]){
-						arr_folder[arr_folder.length] = folder.children[y].id;
-						if (folder.children[y].children.length > 0)
-							arr_folder = get_children(folder.children[y], arr_folder);
-						
-					}
-				}
-				return arr_folder;
-			}
-			
-			for( var i=0; i < sel_combo.options.length; i++ )
-			{
-				if( sel_combo.options[i].selected == true )
-				{
-					var arr_folders = new Array();
-					if(!proxy_mensagens.is_local_folder(sel_combo.options[i].value)){
-						nm_box[nm_box.length] = sel_combo.options[i].value + fields;
-						
-						for (x in cp_tree1){
-							if(cp_tree1[x].id == sel_combo.options[i].value){
-								arr_folders = get_children(cp_tree1[x], arr_folders);
-								for (index in arr_folders){
-									nm_box[nm_box.length] = arr_folders[index] + fields;
-								}
-							}
-						}
-						for (x in cp_tree2){
-							if(cp_tree2[x].id == sel_combo.options[i].value){
-								arr_folders = get_children(cp_tree2[x], arr_folders);
-								for (index in arr_folders){
-									nm_box[nm_box.length] = arr_folders[index] + fields;
-								}
-							}
-						}
-						
-					}else
-						local_folders.push(sel_combo.options[i].value.substr(6));
+			}else{
+				for(var i=0; i < folders_select.length; i++){
+					nm_box[nm_box.length] = $(folders_select[i]).val() + fields;
 				}
 			}
@@ -1578,4 +1546,5 @@
         var handler = function( data )
         {
+        	data = jQuery.parseJSON(data.substr(0, data.length-2));
         	var allMsg 	= [3];
 			var count  	= ( data['num_msgs'] ) ?  data['num_msgs'] : "0";
@@ -1892,2 +1861,7 @@
 var EsearchE = new searchE();
 var EsearchE = new searchE();
+
+// Configuração da tela da Ajuda
+function info(){
+	alert("Preencha os Campos para realizar o filtro, o campo das pastas caso não seja alterado realizará a pesquisa em todas as pastas.");
+}
