Index: modules/uoa-search/trunk/src/test/java/eu/dnetlib/data/search/SSTest.java
===================================================================
--- modules/uoa-search/trunk/src/test/java/eu/dnetlib/data/search/SSTest.java	(nonexistent)
+++ modules/uoa-search/trunk/src/test/java/eu/dnetlib/data/search/SSTest.java	(revision 45684)
@@ -0,0 +1,29 @@
+package eu.dnetlib.data.search;
+
+/**
+ * Created by kiatrop on 2/12/2016.
+ */
+public class SSTest {
+
+/*    SearchServiceImpl ss = new SearchServiceImpl();
+    ServiceLocator<IndexService> mockIndexServiceServiceLocator = mock(ServiceLocator.class);
+    SolrIndexClient mockIndexService = mock(SolrIndexClient.class);
+
+    @Before
+    public void setup() {
+        BasicConfigurator.configure();
+
+        System.out.println(ss.getIndexLocator());
+        //when(ss.getIndexLocator()).thenReturn(mockIndexServiceServiceLocator);
+        when(mockIndexServiceServiceLocator.getService()).thenReturn(mockIndexService);
+        ss.setIndexLocator(mockIndexServiceServiceLocator);
+        //doNothing().when(((SearchServiceImpl) ss).getIndexLocator().getService());
+
+    }
+
+    @Test
+    public void test() throws SearchServiceException {
+        ss.search("oaftype=result", null, "", 1,1);
+    }
+*/
+}
Index: modules/uoa-search/trunk/src/main/resources/eu/dnetlib/data/search/springContext-transformation.xml
===================================================================
--- modules/uoa-search/trunk/src/main/resources/eu/dnetlib/data/search/springContext-transformation.xml	(revision 45683)
+++ modules/uoa-search/trunk/src/main/resources/eu/dnetlib/data/search/springContext-transformation.xml	(revision 45684)
@@ -56,13 +56,15 @@
 	<bean id="vocabularyManagerWrapper" class="eu.dnetlib.data.search.utils.vocabulary.VocabularyManagerWrapper" >
 		<property name="vocabularyManager" ref="vocabularyManager"/>	
 	</bean>
-	
+
+	<!--
 <!--	<bean id="resetScheduler" class="eu.dnetlib.data.search.utils.vocabulary.ResetVocabsScheduler">
         <property name="beautySleep" value="86400" />
         <property name="begin" value="18000" />
 		<property name="vManager" ref="vocabularyManager" />		
 	</bean>-->
-	
+	-->
+
 	<bean id="transformerFactory"
 		class="eu.dnetlib.data.search.transform.config.SearchRegistry">
 		<property name="config" ref="configuration"/>
Index: modules/uoa-search/trunk/pom.xml
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Index: modules/uoa-search/trunk/src/test/java/eu/dnetlib/data/search/transform/VocabularyTest.java
===================================================================
--- modules/uoa-search/trunk/src/test/java/eu/dnetlib/data/search/transform/VocabularyTest.java	(revision 45683)
+++ modules/uoa-search/trunk/src/test/java/eu/dnetlib/data/search/transform/VocabularyTest.java	(revision 45684)
@@ -32,6 +32,8 @@
 
         StaticServiceLocator<SearchService> searchServiceStaticServiceLocator = new StaticServiceLocator<eu.dnetlib.api.data.SearchService>();
         searchServiceStaticServiceLocator.setService(searchService);
+
+
     //    searchServiceStaticServiceLocator.getService().search("1", "", "", 1, 1);
 
     //    searchServiceStaticServiceLocator.getService().search("1", "", "", "", 1, 1);
Index: modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/solr/SolrClientLocator.java
===================================================================
--- modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/solr/SolrClientLocator.java	(revision 45683)
+++ modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/solr/SolrClientLocator.java	(revision 45684)
@@ -18,6 +18,8 @@
     private ServiceLocator<ISLookUpService> lookUpServiceServiceLocator = null;
     private String interpretation = null;
 
+    private String cachedUrl = null;
+
     @Override
     public IndexService getService() {
         if (indexClient == null) {
@@ -34,15 +36,20 @@
             List<String> urls = lookUpServiceServiceLocator.getService().quickSearchProfile("for $x in //RESOURCE_PROFILE//PROTOCOL[./@name='solr'] return data($x/@address)");
 
             if (urls.size() > 0) {
-                String url = chooseIndexService(urls);
+                cachedUrl = chooseIndexService(urls);
 
-                client.setSolrServerUrl(url);
-                client.setInterpretation(this.interpretation);
             } else {
+                logger.warn("Falling back to cached value for index : " + cachedUrl);
                 throw new IllegalArgumentException("Could not locate an index service with a SOLR interface");
             }
+
         } catch (ISLookUpServiceException e) {
-            logger.error("Error locating service", e);
+            logger.warn("Error locating service", e);
+
+        } finally {
+            logger.debug("cached url " + cachedUrl);
+            client.setSolrServerUrl(cachedUrl);
+            client.setInterpretation(this.interpretation);
         }
 
         return client;
@@ -67,4 +74,12 @@
     public void setInterpretation(String interpretation) {
         this.interpretation = interpretation;
     }
+
+    public String getCachedUrl() {
+        return cachedUrl;
+    }
+
+    public void setCachedUrl(String cachedUrl) {
+        this.cachedUrl = cachedUrl;
+    }
 }
Index: modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/solr/SolrResultSetFactory.java
===================================================================
--- modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/solr/SolrResultSetFactory.java	(revision 45683)
+++ modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/solr/SolrResultSetFactory.java	(revision 45684)
@@ -19,6 +19,8 @@
 
     private Map<String, CloudSolrServer> clients = new HashMap<String, CloudSolrServer>();
 
+    //private static int Rsets = 0;
+
     @Override
     public ResultSet<String> createResultSet(EPR epr) {
         try {
@@ -34,6 +36,9 @@
                 clients.put(epr.getAddress(), solrClient);
             }
 
+            logger.debug("Address " + epr.getAddress());
+            //Rsets++;
+            //System.out.println("Created Results sets " + Rsets);
             return new SolrResultSet(epr, solrClient);
         } catch (Exception e) {
             logger.error("Error creating solr client", e);
Index: modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/solr/SolrResultSet.java
===================================================================
--- modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/solr/SolrResultSet.java	(revision 45683)
+++ modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/solr/SolrResultSet.java	(revision 45684)
@@ -36,9 +36,12 @@
 
 
     public SolrResultSet(EPR epr, CloudSolrServer solrClient) throws IOException, CQLParseException {
+
         this.epr = epr;
         this.solrClient = solrClient;
+        //solrClient.getLbServer().setConnectionTimeout(10000);
 
+
         CqlTranslator translator = new CqlTranslatorImpl();
         String cqlQuery = epr.getParameter("query");
         //logger.debug("epr query param: " + cqlQuery);
@@ -116,10 +119,9 @@
     private int getSize() throws SolrServerException {
         //logger.debug("Query opts" + queryOpts);
         QueryResponse rsp = null;
-
-        synchronized (solrClient) {
+        //synchronized (solrClient) {
             rsp = solrClient.query(SolrParams.toSolrParams(queryOpts));
-        }
+        //}
 
         //logger.debug(queryOpts);
 
@@ -164,44 +166,45 @@
 
     private List<String> getBrowseResults(int from, int to) {
         List<String> res = new ArrayList<String>();
+        //TODO add here logs
 
-
         if (facetFields == null) {
             try {
-                QueryResponse rsp = null;
+                QueryResponse rsp = solrClient.query(SolrParams.toSolrParams(queryOpts));
+                facetFields = rsp.getFacetFields();
 
-                synchronized (solrClient) {
-                    rsp = solrClient.query(SolrParams.toSolrParams(queryOpts));
-                }
-
-                facetFields = rsp.getFacetFields();
-            } catch (SolrServerException e) {
-                e.printStackTrace();
+            } catch (SolrServerException sse) {
+                logger.error("Faceted fields caused exception. ", sse);
             }
 
-
             for (int i = from - 1; i < to; i++) {
                 StringBuilder sb = new StringBuilder();
 
                 sb.append("<row>");
-
                 for (FacetField field:facetFields) {
                     if (field.getValueCount() > i) {
                         sb.append("<groupresult field=\"").append(field.getName()).append("\">");
                         sb.append("<count>").append(field.getValues().get(i).getCount()).append("</count>");
-                        sb.append("<value>").append(StringEscapeUtils.escapeXml(field.getValues().get(i).getName())).append("</value>");
+                        sb.append("<originalValue>").append(StringEscapeUtils.escapeXml(field.getValues().get(i).getName())).append("</originalValue>");
+
+                        String[] facetValues = field.getValues().get(i).getName().split("\\|\\|");
+                        if(facetValues.length > 1) {
+                            sb.append("<value>").append(StringEscapeUtils.escapeXml(facetValues[1])).append("</value>");
+                        } else {
+                            sb.append("<value>").append(StringEscapeUtils.escapeXml(facetValues[0])).append("</value>");
+                        }
                         sb.append("</groupresult>");
                     }
                 }
-
                 sb.append("</row>");
 
-            //    logger.debug("row: " + sb.toString());
-
+                logger.debug("row: " + sb.toString());
                 res.add(sb.toString());
             }
         }
 
+        logger.debug("res: " + res);
+
         return res;
     }
 
@@ -214,9 +217,10 @@
             extraOpts.add("rows", (to - from) + 1 + "");
             extraOpts.addAll(queryOpts);
 
-            synchronized (solrClient) {
+            //solrClient.setZkClientTimeout(20000);
+            //synchronized (solrClient) {
                 rsp = solrClient.query(SolrParams.toSolrParams(extraOpts));
-            }
+            //}
 
             SolrDocumentList docs = rsp.getResults();
 
@@ -239,50 +243,59 @@
         return Collections.EMPTY_LIST;
     }
 
-    public static void main(String[] args) throws IOException, CQLParseException, SolrServerException {
-        CloudSolrServer solrClient = new CloudSolrServer("beta.solr.openaire.eu:9983");
-        NamedList<String> queryOpts = new NamedList<String>();
+    public static void main2(String[] args) throws IOException, CQLParseException, SolrServerException {
+        try {
 
-        //queryOpts.put("q", new CqlTranslatorImpl().getTranslatedQuery("oaftype exact result").asLucene());
-       // queryOpts.add("facet", "true");
-        TranslatedQuery translatedQuery = new CqlTranslatorImpl().getTranslatedQuery("oaftype=result sortBy resultdateofacceptance/sort.descending");
 
-        queryOpts.add("q", translatedQuery.asLucene());
+            CloudSolrServer solrClient = new CloudSolrServer("beta.solr.openaire.eu:9983");
+            solrClient.getLbServer().setConnectionTimeout(13);
+
+            NamedList<String> queryOpts = new NamedList<String>();
+
+            //queryOpts.put("q", new CqlTranslatorImpl().getTranslatedQuery("oaftype exact result").asLucene());
+            // queryOpts.add("facet", "true");
+            TranslatedQuery translatedQuery = new CqlTranslatorImpl().getTranslatedQuery("oaftype=result sortBy resultdateofacceptance/sort.descending");
+
+            queryOpts.add("q", translatedQuery.asLucene());
 //        queryOpts.put("fq", new CqlTranslatorImpl().getTranslatedQuery("").asLucene());
-       // queryOpts.add("facet.field", "contextid");
-       //  queryOpts.add("facet.field", "contextname");
-       //  queryOpts.add("facet.mincount", "1");
-       //  queryOpts.add("facet.threads", "10");
-        System.out.println(translatedQuery.getOptions().getSort().getMode());
-        System.out.println(translatedQuery.getOptions().getSort().getField());
+            // queryOpts.add("facet.field", "contextid");
+            //  queryOpts.add("facet.field", "contextname");
+            //  queryOpts.add("facet.mincount", "1");
+            //  queryOpts.add("facet.threads", "10");
+            System.out.println(translatedQuery.getOptions().getSort().getMode());
+            System.out.println(translatedQuery.getOptions().getSort().getField());
 
-        queryOpts.add("sort", translatedQuery.getOptions().getSort().getField() + " " + translatedQuery.getOptions().getSort().getMode() );
+            queryOpts.add("sort", translatedQuery.getOptions().getSort().getField() + " " + translatedQuery.getOptions().getSort().getMode());
 
-        solrClient.setDefaultCollection("DMF-index-openaire");
+            solrClient.setDefaultCollection("DMF-index-openaire");
 
-        QueryResponse resp = null;
-        synchronized (solrClient) {
-            resp = solrClient.query(SolrParams.toSolrParams(queryOpts));
-        }
-        System.out.println("time: " + resp.getElapsedTime());
-        System.out.println("time: " + resp.getResults());
+            QueryResponse resp = null;
+            synchronized (solrClient) {
+                resp = solrClient.query(SolrParams.toSolrParams(queryOpts));
+            }
+            System.out.println("time: " + resp.getElapsedTime());
+            System.out.println("time: " + resp.getResults());
 
-        System.out.println(resp.getFacetField("contextname").getValueCount());
+            System.out.println(resp.getFacetField("contextname").getValueCount());
 
-        for (FacetField.Count count:resp.getFacetField("contextname").getValues())
-            System.out.println(count.getName() + " : " +  count.getCount());
+            for (FacetField.Count count : resp.getFacetField("contextname").getValues())
+                System.out.println(count.getName() + " : " + count.getCount());
 
 
-        int max = -12;
+            int max = -12;
 
-        for (FacetField field:resp.getFacetFields()) {
-            if (field.getValueCount() > max)
-                max = field.getValueCount();
+            for (FacetField field : resp.getFacetFields()) {
+                if (field.getValueCount() > max)
+                    max = field.getValueCount();
 
+            }
+
+            System.out.println("max: " + max);
+
+        } catch (org.apache.solr.client.solrj.SolrServerException sse) {
+            System.out.println("NNNOOOOOO");
         }
 
-        System.out.println("max: " + max);
-
     }
 
     @Override
@@ -289,4 +302,13 @@
     public EPR getEpr() {
         return epr;
     }
+
+    public static void main(String[] args) {
+        String s = "ec__________::EC::FP7::SP4::REGIONS";
+        String[] k = s.split("_\\:\\:");
+
+        System.out.println(k.length);
+        System.out.println(s.split("_\\:\\:")[1]);
+        System.out.println(s.split("_\\:\\:")[0]);
+    }
 }
\ No newline at end of file
Index: modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/solr/CqlSolrTransform.java
===================================================================
--- modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/solr/CqlSolrTransform.java	(revision 45683)
+++ modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/solr/CqlSolrTransform.java	(revision 45684)
@@ -1,7 +1,7 @@
 package eu.dnetlib.data.search.solr;
 
-import eu.dnetlib.functionality.cql.CqlTranslator;
-import eu.dnetlib.functionality.cql.CqlTranslatorImpl;
+import eu.dnetlib.functionality.index.cql.CqlTranslator;
+import eu.dnetlib.functionality.index.cql.CqlTranslatorImpl;
 import org.z3950.zing.cql.CQLParseException;
 
 import java.io.*;
Index: modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/app/SearchServiceImpl.java
===================================================================
--- modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/app/SearchServiceImpl.java	(revision 45683)
+++ modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/app/SearchServiceImpl.java	(revision 45684)
@@ -28,7 +28,6 @@
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 import org.xml.sax.InputSource;
-import org.z3950.zing.cql.CQLParseException;
 import org.z3950.zing.cql.CQLParser;
 
 import javax.xml.parsers.DocumentBuilder;
@@ -37,7 +36,6 @@
 import javax.xml.xpath.XPathConstants;
 import javax.xml.xpath.XPathExpression;
 import javax.xml.xpath.XPathFactory;
-import java.io.IOException;
 import java.io.StringReader;
 import java.util.*;
 
@@ -50,7 +48,7 @@
     @Deprecated
     private static Logger tlogger = Logger.getLogger("eu.dnetlib.data.search.app.Timer");
 
-    private String mdFormat = "DMF";
+    private String mdFormat = "TMF";
     private String indexLayout = "index";
 
     private ServiceLocator<IndexService> indexLocator = null;
@@ -73,7 +71,7 @@
 
         this.subscribe(
                 ActionType.UPDATE,
-                ResourceType.SEARCHSERVICERESOURCETYPE,
+                ResourceType.ANY.SEARCHSERVICERESOURCETYPE,
                 serviceId,
                 "RESOURCE_PROFILE/BODY/BLACKBOARD/LAST_REQUEST",
                 new NotificationListener() {
@@ -101,7 +99,7 @@
                 XPath xpath = factory.newXPath();
 
                 XPathExpression searchMdFormatExpression = xpath.compile("//SERVICE_PROPERTIES/PROPERTY[@key='mdformat']");
-                Node node = (Node) searchMdFormatExpression.evaluate(doc,XPathConstants.NODE);
+                Node node = (Node) searchMdFormatExpression.evaluate(doc, XPathConstants.NODE);
 
                 if (node != null){
                     String profileMdFormat = node.getAttributes().getNamedItem("value").getTextContent();
@@ -117,8 +115,6 @@
             logger.error("Fail to load search service profile with id " + serviceId + " from IS.", e);
         }
 
-
-
     }
 
     @Override
@@ -126,39 +122,6 @@
             throws SearchServiceException {
 
         throw new UnimplementedException();
-	/*	logger.debug("running suggestive search for " + query);
-
-		SuggestiveResult suggestiveResult = new SuggestiveResult();
-		IndexService index = getIndexLocator().getService();
-		try {
-			Hint hint = index.suggestiveSearch("all", "query=" + text, mdFormat, "index", "SimpleRatioHeuristics");
-			String alternateTerm = hint.getAlternateTerm();
-			boolean autofollow = hint.isAutoFollowHint();
-			logger.debug("alternateTerm " + alternateTerm + " autofollow " + autofollow);
-
-			if (alternateTerm != null) {
-				suggestiveResult.setAlternativeTerm(alternateTerm);
-				suggestiveResult.setAutofollow(autofollow);
-
-				if (autofollow) {
-					logger.debug("getting epr for " + alternateTerm);
-					suggestiveResult.setEpr(search(alternateTerm));
-
-				} else {
-					logger.debug("getting epr for " + query);
-					suggestiveResult.setEpr(search(query));
-				}
-
-			} else {
-				logger.debug("getting epr for " + query);
-				suggestiveResult.setEpr(search(query));
-			}
-
- 		} catch (IndexServiceException ise) {
-			logger.error("Error calling index", ise);
-			throw new SearchServiceException("Error calling index.");
-		}
-		return suggestiveResult; */
     }
 
     private String getCorrectLocale(String givenLocaleName){
@@ -169,9 +132,9 @@
             correctLocale = givenLocaleName;
         }
 
-        //get the locale
-        StringTokenizer tokenizer = new StringTokenizer(correctLocale, "_");
-        Locale requestLocale = new Locale(tokenizer.nextToken(), tokenizer.nextToken());
+        //get the locale TODO maybe we need it?
+        //StringTokenizer tokenizer = new StringTokenizer(correctLocale, "_");
+        Locale requestLocale = new Locale("en_GB");//new Locale(tokenizer.nextToken(), tokenizer.nextToken());
 
         if(requestLocale == null || !transformerFactory.getConfig().getLocales().contains(requestLocale)){
             correctLocale = transformerFactory.getConfig().getDefaultLocale().getLanguage() + "_" + transformerFactory.getConfig().getDefaultLocale().getCountry();
@@ -182,20 +145,19 @@
 
     @Override
     public SearchResult search(String text, String transformer, String locale, int page, int size) throws SearchServiceException {
-        logger.info("Received search request for: '" + text + "'");
+        logger.info("search: Received search request for: '" + text + "'");
+        //System.out.println("search: Received search request for: '" + text + "'");
+        
+        long time = System.nanoTime();
 
         IndexService index = getIndexLocator().getService();
         EPR epr = null;
         String query = rewrite(text);
-
         List<String> searchResults = null;
 
         try {
-            long time = System.currentTimeMillis();
 
-            cqlParser = new CQLParser();
-            query = cqlParser.parse(query).toCQL();
-            logger.info("Performing search for: '" + query + "'");
+            logger.info("search: Performing search for: '" + query + "'");
 
             if (logger.isDebugEnabled()) {
                 logger.debug("index lookup (all, query=" + query + ", " + mdFormat + ", index)");
@@ -211,22 +173,15 @@
                 logger.debug("epr = " + epr);
             }
 
-            time = System.currentTimeMillis() - time;
-            logger.info("Got epr for query " + query);
-            logger.debug("index epr response lasted " + time + " msec");
+            //time = System.currentTimeMillis() - time;
+            //logger.info("search:  Got epr for query " + query);
+            //logger.debug("index epr response lasted " + time + " msec");
             tlogger.debug("Got index epr response for query " + query);
 
         } catch (IndexServiceException ise) {
             logger.error("Error calling index.", ise);
-            throw new SearchServiceException("Error calling index.");
+            throw new SearchServiceException("Error calling index.", ise);
 
-        } catch (CQLParseException cqle) {
-            logger.error("Bad CQL query.", cqle);
-            throw new SearchServiceException("Error calling index.");
-
-        } catch (IOException ioe) {
-            logger.error("Bad CQL query.", ioe);
-            throw new SearchServiceException("Error calling index.");
         }
 
         if (epr == null) {
@@ -239,22 +194,23 @@
         /**
          * Read ResultSet for search
          */
-        logger.info("Creating result set...");
+        //logger.info("search: Creating result set for query " + query);
         ResultSet<String> rs = rsFactory.createResultSet(epr);
 
+        logger.debug("epr again:" + rs.getEpr());
+
         try {
             int rsSize = rs.size();
             int from = (page-1)*size + 1;
             int to = (page*size < rsSize) ? page*size : rsSize;
 
-            logger.info("Reading result set elements...");
-            long startTime = System.nanoTime();
             List<String> xmls = rs.getElements(from, to);
-            long estimatedTime = System.nanoTime() - startTime;
-            logger.info("Reading results for search query " + query + " took " + estimatedTime/1000000 + " milliseconds - page: " + page + ", size: " + size);
+            //long estimatedTime = System.nanoTime() - startTime;
+            //logger.info("search: Reading results for search query " + query + " took " + estimatedTime/1000000 + " milliseconds - page: " + page + ", size: " + size);
             searchResults = new ArrayList<String>();
 
-            logger.info("Transforming result set elements...");
+            //logger.info("search:  Transforming result set elements...");
+            //startTime = System.nanoTime();
             Transformer tr = transformerFactory.getTransformer(transformer, requestLocale);
             /**
              * Transform the search records xmls
@@ -270,24 +226,36 @@
                 }
             }
 
+
+            //logger.info("search:  Transforming result set elements took " + estimatedTime/1000000 + " milliseconds - page: " + page + ", size: " + size);
+
         } catch (TransformerException te) {
             logger.error("Error transforming search results.", te);
             throw new SearchServiceException("Error transforming search results.", te);
         }
 
-        logger.debug("Search results for query "+ query + " created.");
-        logger.info("Returned search results for query '" + query +"'");
+        long estimatedTime = System.nanoTime() - time;
 
+        //logger.debug("Search results for query "+ query + " created.");
+        Runtime runtime = Runtime.getRuntime();
+        //long memory = runtime.totalMemory() - runtime.freeMemory();
+        //System.out.println("search: memory used: " + memory/ (1024L * 1024L)+ " with threads " + Thread.activeCount());
+
+        logger.info("search: Returned search results for query '" + query +"'" + " after " + estimatedTime/1000000 + " miliseconds.") ;
+        //System.out.println("search: Returned search results for query '" + query +"'" + " after " + estimatedTime/1000000 + ". \nsearch: " + estimatedTime/1000000 + " milliseconds");
         return new SearchResult(query, correctLocale, rs.size(), page, size, searchResults);
     }
 
     @Override
     public SearchResult refine(String text, String transformer, String locale, Collection<String> fields) throws SearchServiceException {
-        logger.info("Received refine request for: '" + text + "' and fields " + fields);
+        logger.info("refine: Received refine request for: '" + text + "' and fields " + fields);
+        //System.out.println("refine: Received refine request for: '" + text + "' and fields " + fields);
+
+        long time = System.nanoTime();
+
         IndexService index = getIndexLocator().getService();
         EPR epr = null;
         String query = rewrite(text);
-
         List<String> browseResults = null;
         ResultSet<String> rs = null;
 
@@ -295,13 +263,7 @@
          * For refine
          */
         try {
-            long time = System.currentTimeMillis();
 
-            cqlParser = new CQLParser();
-            query = cqlParser.parse(query).toCQL();
-            logger.debug("The refine query " + query);
-            logger.info("Performing refine query for: '"+query+"' and refine fields " + fields);
-
             StringBuffer buffer = new StringBuffer();
             buffer.append("query=").append(query).append("&groupby=");
             for (Iterator<String> iter = fields.iterator(); iter.hasNext();) {
@@ -320,18 +282,12 @@
 
             epr = index.getBrowsingStatistics(buffer.toString(), "all", mdFormat, indexLayout);
             time = System.currentTimeMillis() - time;
-            logger.debug("index epr response lasted " + time + " msec");
-            logger.info("Got epr index response for refine query '" + query + "' and fields " + fields);
+        //    logger.info("refine: index epr response  for refine query '\" + query + \"' and fields \" + fields lasted " + time + " msec");
+         //   logger.info("refine: Got epr index response for refine query '" + query + "' and fields " + fields);
 
-        } catch (CQLParseException cqle) {
-            logger.error("Bad CQL query.", cqle);
-            throw new SearchServiceException("Error calling index.");
         } catch (IndexServiceException ise) {
             logger.error("Error getting refine results.", ise);
             throw new SearchServiceException("Error getting refine results.", ise);
-        } catch (IOException ioe) {
-            logger.error("Bad CQL query.", ioe);
-            throw new SearchServiceException("Error calling index.");
         }
 
         if (epr == null) {
@@ -344,7 +300,7 @@
         Locale requestLocale = new Locale(tokenizer.nextToken(), tokenizer.nextToken());
 
         try{
-            logger.info("Creating result set...");
+         //   logger.info("refine: Creating result set for refine query '" + query + "' and fields " + fields);
             rs = rsFactory.createResultSet(epr);
 
             if (logger.isDebugEnabled()) {
@@ -351,18 +307,19 @@
                 logger.debug("EPR : " + epr.getEpr());
             }
 
-            long startTime = System.nanoTime();
-            logger.info("Reading result set elements...");
+        //    long startTime = System.nanoTime();
+        //    logger.info("refine: Reading result set elements for refine query '" + query + "' and fields " + fields);
             List<String> list = rs.getElements(1, rs.size());
-            long estimatedTime = System.nanoTime() - startTime;
-            logger.info("Reading results for refine query " + query + " took " + estimatedTime/1000000 +  " milliseconds");
+            //long estimatedTime = System.nanoTime() - startTime;
+            //  logger.info("refine: Reading results for refine query " + query + " and fields " + fields + " took " + estimatedTime/1000000 +  " milliseconds");
 
-            logger.debug("record list size " + list.size());
+        //    logger.debug("record list size " + list.size());
 
             /**
              * Transform each refine row
              */
-            logger.info("Transforming result set elements...");
+            //logger.info("refine: transforming result set elements for refine query '" + query + "' and fields " + fields);
+            //startTime = System.nanoTime();
             Transformer tr = transformerFactory.getTransformer(transformer, requestLocale);
             browseResults = new ArrayList<String>();
             for (String row: list) {
@@ -369,12 +326,21 @@
                 browseResults.add(tr.transform(row));
             }
 
+            //logger.info("refine: Tansforming results for refine query " + query + " and fields " + fields + " took " + estimatedTime/1000000);
+
         } catch (TransformerException te) {
             logger.error("Error transforming refine results.", te);
             throw new SearchServiceException("Error transforming refine results.", te);
         }
 
-        logger.info("Returned results for refine query '" + query + "' and fields " + fields);
+        Runtime runtime = Runtime.getRuntime();
+        //long memory = runtime.totalMemory() - runtime.freeMemory();
+        //System.out.println("refine: memory used: " + memory/ (1024L * 1024L) + " with threads " + Thread.activeCount());
+
+        long estimatedTime = System.nanoTime() - time;
+        logger.info("refine: Returned results for refine query '" + query + "' and fields " + fields + " after " + estimatedTime/1000000 + " miliseconds.") ;
+        //System.out.println("refine: Returned results for refine query '" + query + "' and fields " + fields + " after " + estimatedTime/1000000 + ". \nrefine: " +
+        //        estimatedTime/1000000 +" milliseconds.");
         return new SearchResult(query, correctLocale, fields, browseResults);
     }
 
@@ -381,8 +347,11 @@
     @Override
     public SearchResult searchNrefine(String text, String searchTransformer, String browseTransformer,
                                       String locale, int page, int size, Collection<String> fields) throws SearchServiceException {
-        logger.info("Received request for search for query: '" + text +"' and refine for fields " + fields);
+        logger.info("searchNrefine: Received request for search for query: '" + text +"' and refine for fields " + fields);
+        //System.out.println("searchNrefine: Received request for search for query: '" + text +"' and refine for fields " + fields);
 
+        long time = System.currentTimeMillis();
+
         IndexService index = getIndexLocator().getService();
         EPR epr = null;
         String query = rewrite(text);
@@ -398,13 +367,7 @@
         List<String> searchResults = null;
 
         try {
-            long time = System.currentTimeMillis();
 
-            cqlParser = new CQLParser();
-            query = cqlParser.parse(query).toCQL();
-            logger.debug("cqlParser returned query: " + query);
-            logger.info("Performing search for: '" + query + "'");
-
             if (logger.isDebugEnabled()) {
                 logger.debug("index lookup (all, query=" + query + ", " + mdFormat + ", index)");
             }
@@ -419,20 +382,13 @@
             }
 
             time = System.currentTimeMillis() - time;
-            logger.debug("index epr response " + time + " msec");
-            logger.info("Got index epr response for query '" + query + "'");
+           // logger.debug("searchNrefine: index epr response for search " + time + " msec");
+           // logger.info("searchNrefine Got index epr response for search query '" + query + "'");
 
         } catch (IndexServiceException ise) {
             logger.error("Error calling index.", ise);
-            throw new SearchServiceException("Error calling index.");
+            throw new SearchServiceException("Error calling index.", ise);
 
-        } catch (CQLParseException cqle) {
-            logger.error("Bad CQL query.", cqle);
-            throw new SearchServiceException("Error calling index.");
-
-        } catch (IOException ioe) {
-            logger.error("Bad CQL query.", ioe);
-            throw new SearchServiceException("Error calling index.");
         }
 
         if (epr == null) {
@@ -444,7 +400,7 @@
         /**
          * Read ResultSet for search
          */
-        logger.info("Creating result set...");
+       // logger.info("searchNrefine: Creating result set for search query " + query);
         ResultSet<String> rs = rsFactory.createResultSet(epr);
         try {
             rsSize = rs.size();
@@ -451,13 +407,14 @@
             int from = (page-1)*size + 1;
             int to = (page*size < rsSize) ? page*size : rsSize;
 
-            logger.info("Reading result set elements...");
-            long startTime = System.nanoTime();
+          //  logger.info("searchNrefine: Reading result set elements for search query" + query);
+            //long startTime = System.nanoTime();
             List<String> xmls = rs.getElements(from, to);
-            long estimatedTime = System.nanoTime() - startTime;
-            logger.info("Reading results for search query " + query + " took " + estimatedTime/1000000 + " milliseconds - page: " + page + ", size: " + size);
+            //long estimatedTime = System.nanoTime() - startTime;
+         //   logger.info("searchNrefine: Reading results for search query " + query + " took " + estimatedTime/1000000 + " milliseconds - page: " + page + ", size: " + size);
 
-            logger.info("Transforming result set response...");
+         //   logger.info("searchNrefine: Transforming result set response for search query " + query);
+            //startTime = System.nanoTime();
             Transformer tr = transformerFactory.getTransformer(searchTransformer, requestLocale);
             searchResults = new ArrayList<String>();
             /**
@@ -466,6 +423,8 @@
             for (String xml:xmls) {
                 searchResults.add(tr.transform(xml));
             }
+            //estimatedTime = System.nanoTime() - startTime;
+         //   logger.info("searchNrefine: Transforming result set response for search query " + query + " took " + estimatedTime/1000000);
 
         } catch (TransformerException te) {
             logger.error("Error transforming search results.", te);
@@ -477,12 +436,8 @@
         List<String> browseResults = null;
 
         try {
-            long time = System.currentTimeMillis();
+         //   long time = System.currentTimeMillis();
 
-            cqlParser = new CQLParser();
-            query = cqlParser.parse(query).toCQL();
-            logger.info("Performing refine query for refine fields " + fields);
-
             StringBuffer buffer = new StringBuffer();
             buffer.append("query=").append(query).append("&groupby=");
             for (Iterator<String> iter = fields.iterator(); iter.hasNext();) {
@@ -501,15 +456,9 @@
             epr = index.getBrowsingStatistics(buffer.toString(), "all", mdFormat, "index");
 
             time = System.currentTimeMillis() - time;
-            logger.info("Index returned epr for query '" + query +"'");
-            logger.debug("index epr response lasted " + time + " msec");
+          //  logger.info("searchNrefine: Index returned epr for refine query '" + query +"' and fields " + fields);
+          //  logger.debug("searchNrefine: index epr response for refine lasted " + time + " msec");
 
-        } catch (CQLParseException cqle) {
-            logger.error("Bad CQL query.", cqle);
-            throw new SearchServiceException("Error calling index.");
-        } catch (IOException ioe) {
-            logger.error("Bad CQL query.", ioe);
-            throw new SearchServiceException("Error calling index.");
         } catch (IndexServiceException ise) {
             logger.error("Error getting refine results.", ise);
             throw new SearchServiceException("Error getting refine results.", ise);
@@ -521,7 +470,7 @@
 
 
         try{
-            logger.info("Creating result set...");
+         //   logger.info("searchNrefine: Creating result set for refine query '" + query +"' and fields " + fields);
             rs = rsFactory.createResultSet(epr);
 
             if (logger.isDebugEnabled()) {
@@ -528,15 +477,16 @@
                 logger.debug("EPR : " + epr.getEpr());
             }
 
-            logger.info("Reading result set...");
-            long startTime = System.nanoTime();
+       //     logger.info("searchNrefine: Reading result set for refine query " + query + " fields " + fields);
+//            long startTime = System.nanoTime();
             List<String> list = rs.getElements(1, rs.size());
-            long estimatedTime = System.nanoTime() - startTime;
-            logger.info("Reading results for refine query " + query + " took " + estimatedTime/1000000 + " milliseconds");
+    //        long estimatedTime = System.nanoTime() - startTime;
+  //          logger.info("searchNrefine: Reading results for refine query " + query + " fields " + fields + " took " + estimatedTime/1000000 + " milliseconds");
 
-            logger.debug("record list size " + list.size());
+  //          logger.debug("record list size " + list.size());
 
-            logger.info("Transforming result set...");
+    //        logger.info("searchNrefine: Transforming result set for refine query " + query + " fields " + fields);
+      //      startTime = System.nanoTime();
             Transformer tr = transformerFactory.getTransformer(browseTransformer, requestLocale);
             browseResults = new ArrayList<String>();
             for (String row: list) {
@@ -543,6 +493,8 @@
                 browseResults.add(tr.transform(row));
             }
 
+            //logger.info("searchNrefine: Transforming result set for refine query " + query + " fields " + fields +  " took " + estimatedTime/1000000 + " milliseconds");
+
         } catch (TransformerException te) {
             logger.error("Error transforming refine results.", te);
             throw new SearchServiceException("Error transforming refine results.", te);
@@ -549,7 +501,14 @@
 
         }
 
-        logger.info("Returned search results for query '" + query +"' and fields " + fields);
+        Runtime runtime = Runtime.getRuntime();
+        //long memory = runtime.totalMemory() - runtime.freeMemory();
+        //System.out.println("searchNrefine: memory used: " + memory/ (1024L * 1024L) + " with threads " + Thread.activeCount());
+
+        long estimatedTime = System.nanoTime() - time;
+        logger.info("searchNrefine: Returned search results for query '" + query +"' and fields " + fields + "  after " + estimatedTime/1000000 + " miliseconds.");
+       // System.out.println("searchNrefine: Returned search results for query '" + query +"' and fields " + fields + "  after " + estimatedTime/1000000 + "\nserchNrefine: " +
+       //         estimatedTime/1000000 + " milliseconds.");
         return new SearchResult(query,  correctLocale, rsSize, page, size, searchResults, browseResults, fields);
 
     }
Index: modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/utils/vocabulary/VocabularyManager.java
===================================================================
--- modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/utils/vocabulary/VocabularyManager.java	(revision 45683)
+++ modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/utils/vocabulary/VocabularyManager.java	(revision 45684)
@@ -1,11 +1,11 @@
 package eu.dnetlib.data.search.utils.vocabulary;
 
+import eu.dnetlib.domain.enabling.Vocabulary;
+
 import java.util.List;
 import java.util.Locale;
 import java.util.Set;
 
-import eu.dnetlib.domain.enabling.Vocabulary;
-
 public interface VocabularyManager {
 	
 	/**
Index: modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/utils/vocabulary/VocabularyManagerImpl.java
===================================================================
--- modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/utils/vocabulary/VocabularyManagerImpl.java	(revision 45683)
+++ modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/utils/vocabulary/VocabularyManagerImpl.java	(revision 45684)
@@ -11,7 +11,8 @@
 	
 	//key-> vocabulary name, value-> vocabulary loader
 	private Map<String, VocabularyLoader> vocabularyLoaderMap = new HashMap<String, VocabularyLoader>();
-	
+
+	private Map<String, String> underCreation = new HashMap<String, String>();
 	//key-> vocabulary name, value-> vocabulary item
 	//this vocabulary class contains the  fields needed to load the domain.Vocab object
 	private Map<String, Vocabulary> vocabularyMap = new HashMap<String, Vocabulary>();
@@ -44,23 +45,19 @@
 			vocabularyLoaderMap.put(vocabularyName, localVocabularyLoader);	
 			vocabularyMap.put(vocabularyName, config.getLocalVocabularyMap().get(vocabularyName));
 		}
-		
-		for (String v: vocabularyMap.keySet()) {
-			logger.debug("vocabulary names " + vocabularyMap.get(v).getName());
-		}
+
 	}
 	
 	public String translate(String name, String l, String encoding, String default_value){
 		Locale locale = new Locale(l);
-        //logger.debug("Translating... " + name);
 		eu.dnetlib.domain.enabling.Vocabulary vocabulary = getVocabulary(name, locale);
-		
+
 		if(vocabulary == null) {	
 			return (default_value.length() == 0)? encoding: default_value;
 		}
 		
 		String term = vocabulary.getEnglishName(encoding);
-		if(term != null && term != "") {
+		if(term != null && term.trim().isEmpty()) {
 			return term;
 		}
 		
@@ -71,10 +68,13 @@
 		}
 		term = vocabulary.getEnglishName(encoding);
 
-		if(term != null && term != ""){
+		if(term != null && term.trim().isEmpty()){
+			logger.debug("Returned term: " + term);
 			return term;
 		}
-			
+
+		logger.debug("Returned:" + (default_value.length() == 0));
+
 		return (default_value.length() == 0)? encoding: default_value;
 	}
 	
@@ -102,16 +102,21 @@
 		Map<Locale, eu.dnetlib.domain.enabling.Vocabulary> localePathMap = pathMap.get(vocabularyName);
 		
 		try {
-			if (localePathMap == null) { //first time to load the vocabulary
+			if (localePathMap == null && underCreation.get(vocabularyName+locale) == null) { //first time to load the vocabulary
+				logger.info("Request for vocabulary " + vocabularyName + locale + " for the first time");
+				underCreation.put(vocabularyName+locale,"");
 				localePathMap = new HashMap<Locale, eu.dnetlib.domain.enabling.Vocabulary>();				
 				myVocabulary = vocabularyLoader.loadVocabulary(vocabulary, locale);
+
 				localePathMap.put(locale, myVocabulary);
 				pathMap.put(vocabularyName, localePathMap);
 			
-			} else { 
+			} else {
+				logger.info("Request for vocabulary " + vocabularyName + locale + " in this locale");
+
 				myVocabulary = localePathMap.get(locale);
-				
-				if (myVocabulary == null) { //first time to load the vocabulary for this locale					
+				if (myVocabulary == null && underCreation.get(vocabularyName + locale) == null) { //first time to load the vocabulary for this locale
+					underCreation.put(vocabularyName+locale,"");
 					myVocabulary = vocabularyLoader.loadVocabulary(vocabulary, locale);
 					localePathMap.put(locale, myVocabulary);
 				}
@@ -118,9 +123,25 @@
 			}
 			
 		} catch (Exception e) {
-			logger.error("Cannot load vocabulary " + vocabularyName + " with locale " + locale, e);
+			logger.error("Cannot load vocabulary " + vocabularyName + locale, e);
+
+		} finally {
+			logger.info("I am in finally for " + vocabularyName+locale);
+			if (underCreation.get(vocabularyName+locale) != null && !underCreation.get(vocabularyName+locale).isEmpty()) {
+				underCreation.put(vocabularyName+locale, null);
+			}
+
+			//logger.info("underCreation map " + underCreation);
 		}
 
+		logger.info("Vocabulary " + vocabularyName + locale + "was created");
+		if(myVocabulary!=null && myVocabulary.getEncodings()!=null)
+			logger.info("number of encodings: " + myVocabulary.getEncodings().size());
+		else
+			logger.info("This is null!!");
+
+		logger.info("and locale path " + localePathMap);
+
 		return myVocabulary;
 	}
 	
Index: modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/utils/vocabulary/IndexVocabularyLoader.java
===================================================================
--- modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/utils/vocabulary/IndexVocabularyLoader.java	(revision 45683)
+++ modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/utils/vocabulary/IndexVocabularyLoader.java	(revision 45684)
@@ -26,7 +26,6 @@
 
 	private Logger logger = Logger.getLogger(IndexVocabularyLoader.class);
 
-	@Override
 	public String getVocabularyXml(Vocabulary vocabulary, Locale locale) {
 		logger.debug("Getting vocabulary with name " + vocabulary.getName() + " and locale " + locale);
 
@@ -73,5 +72,10 @@
 			ServiceLocator<SearchService> searchServiceLocator) {
 		this.searchServiceLocator = searchServiceLocator;
 	}
+
+	@Override
+	protected eu.dnetlib.domain.enabling.Vocabulary getVocabulary(Vocabulary vocabulary, Locale locale) {
+		return null;
+	}
 }
  
\ No newline at end of file
Index: modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/utils/vocabulary/LocalVocabularyLoader.java
===================================================================
--- modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/utils/vocabulary/LocalVocabularyLoader.java	(revision 45683)
+++ modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/utils/vocabulary/LocalVocabularyLoader.java	(revision 45684)
@@ -1,8 +1,10 @@
 package eu.dnetlib.data.search.utils.vocabulary;
 
+import gr.uoa.di.driver.xml.VocabularyXmlConverter;
 import org.apache.commons.io.IOUtils;
 import org.apache.log4j.Logger;
 
+import javax.xml.bind.JAXBException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Locale;
@@ -18,7 +20,7 @@
 	private static final Logger logger = Logger.getLogger(LocalVocabularyLoader.class);
 	
 	@Override
-	public String getVocabularyXml(Vocabulary vocabulary, Locale locale) {
+	public eu.dnetlib.domain.enabling.Vocabulary getVocabulary(Vocabulary vocabulary, Locale locale) {
 		logger.debug("Getting vocabulary with name " + vocabulary.getName() + " and locale " + locale);
 		
 		String xml = null;
@@ -35,18 +37,29 @@
 		
 		if (xmlInputStream == null) {
 			logger.warn("The " + ((LocalVocabulary)vocabulary).getFileName() + " does not exist in classpath.");
-			return xml; //null
+			return null; //null
 		}
 		
 		try {
 			xml = IOUtils.toString(xmlInputStream, "UTF-8");
+
+			if (xml!=null && !xml.trim().isEmpty()) {
+				VocabularyXmlConverter converter = null;
+
+				converter = new VocabularyXmlConverter();
+				return converter.XmlToObject(xml);
+			}
 			
 		} catch (IOException ioe) {
 			logger.debug("Problem loading " + localizedVocabularyName + " from classpath", ioe);
+
+		} catch (JAXBException jaxbe) {
+			logger.error("Unable to load vocabulary " + vocabulary.getName(), jaxbe);
+
 		} finally {
             IOUtils.closeQuietly(xmlInputStream);
         }
 
-		return xml;
+		return null;
 	}
 }
Index: modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/utils/vocabulary/ISVocabularyLoader.java
===================================================================
--- modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/utils/vocabulary/ISVocabularyLoader.java	(revision 45683)
+++ modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/utils/vocabulary/ISVocabularyLoader.java	(revision 45684)
@@ -5,8 +5,10 @@
 import gr.uoa.di.driver.enabling.ISLookUpException;
 import gr.uoa.di.driver.enabling.resultset.ResultSet;
 import gr.uoa.di.driver.enabling.resultset.ResultSetFactory;
+import gr.uoa.di.driver.xml.VocabularyXmlConverter;
 import org.apache.log4j.Logger;
 
+import javax.xml.bind.JAXBException;
 import java.util.Locale;
 
 public class ISVocabularyLoader extends VocabularyLoader {
@@ -17,7 +19,7 @@
 	private static Logger logger = Logger.getLogger(ISVocabularyLoader.class);
 	
 	@Override
-	public String getVocabularyXml(Vocabulary vocabulary, Locale locale) {
+	public eu.dnetlib.domain.enabling.Vocabulary getVocabulary(Vocabulary vocabulary, Locale locale) {
 		logger.debug("Getting vocabulary with name " + vocabulary.getName() + " and locale " + locale);
 		String localizedResourceName = ((ISVocabulary)vocabulary).getResourceName() + "_" +
 					locale.getLanguage() + "_" + locale.getCountry();
@@ -47,10 +49,21 @@
 //            rs.close();
 		} catch (ISLookUpException ise) {
 			logger.warn("Problem loading " + vocabulary.getName() + " from IS.", ise);
-			return xml; //null
+			//return xml; //null
 		}
-			 		
-		return xml;
+
+		if (xml!=null && !xml.trim().isEmpty()) {
+			VocabularyXmlConverter converter = null;
+			try {
+				converter = new VocabularyXmlConverter();
+				return converter.XmlToObject(xml);
+
+			} catch (JAXBException jaxbe) {
+				logger.error("Unable to load vocabulary " + vocabulary.getName(), jaxbe);
+			}
+		}
+
+		return null;
 	}
 
 	public ISLookUp<eu.dnetlib.domain.enabling.Vocabulary> getLookup() {
Index: modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/utils/vocabulary/VocabularyLoader.java
===================================================================
--- modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/utils/vocabulary/VocabularyLoader.java	(revision 45683)
+++ modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/utils/vocabulary/VocabularyLoader.java	(revision 45684)
@@ -1,11 +1,9 @@
 package eu.dnetlib.data.search.utils.vocabulary;
 
-import gr.uoa.di.driver.xml.VocabularyXmlConverter;
+import org.apache.log4j.Logger;
 
 import java.util.Locale;
 
-import org.apache.log4j.Logger;
-
 abstract class VocabularyLoader {
 	
 	//the local path where vocabularies are saved
@@ -16,9 +14,10 @@
 	private static Logger logger = Logger.getLogger(VocabularyLoader.class);  
 	
 	public eu.dnetlib.domain.enabling.Vocabulary loadVocabulary(Vocabulary vocabulary, Locale locale) throws Exception {
-		String xml = getVocabularyXml(vocabulary, locale);
+		return  getVocabulary(vocabulary, locale);
+		/*String xml = getVocabularyXml(vocabulary, locale);
 		VocabularyXmlConverter converter = new  VocabularyXmlConverter();
-		return converter.XmlToObject(xml);
+		return converter.XmlToObject(xml);*/
 	}
 	
 	/**
@@ -27,8 +26,8 @@
 	 * @param locale
 	 * @return the path of the vocabulary xml file
 	 */
-	protected abstract String getVocabularyXml(Vocabulary vocabulary, Locale locale);
-	
+	protected abstract eu.dnetlib.domain.enabling.Vocabulary getVocabulary(Vocabulary vocabulary, Locale locale);
+
 	/**
 	 * Returns the vocabulary name
 	 * @param vocabulary
Index: modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/transform/formatter/SimpleFormatter.java
===================================================================
--- modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/transform/formatter/SimpleFormatter.java	(revision 45683)
+++ modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/transform/formatter/SimpleFormatter.java	(revision 45684)
@@ -122,7 +122,10 @@
 				context.put("bresults", clearDeclarations(result.getBrowseResults()));
 			
 			StringWriter writer = new StringWriter();
-            //logger.debug("formating with " + t.getName() + "and results " + result.getSearchResults());
+			if(result!=null)
+            logger.debug("formating with " + "and results " + result.getBrowseResults());
+			else
+			logger.debug("the result was null!");
 
 			t.merge(context, writer);
 
@@ -147,8 +150,8 @@
 				xmlTransformer.transform(new StreamSource(new StringReader(result)), new StreamResult(xmlResultResource));
 				
 			} catch (Exception e) {
-				logger.warn("Error transforming xml.", e);
-				throw new FormatterException();
+				logger.warn("Error transforming xml: " + result, e);
+				throw new FormatterException(e);
 			}
 			
 			cleared.add(xmlResultResource.getBuffer().toString());
Index: modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/transform/formatter/XSLTFormatter.java
===================================================================
--- modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/transform/formatter/XSLTFormatter.java	(revision 45683)
+++ modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/transform/formatter/XSLTFormatter.java	(revision 45684)
@@ -49,17 +49,14 @@
         StringWriter xmlResultResource = new StringWriter();
 
         try {
-			logger.debug("The xsl to transform with " + xslt);
-            logger.debug("before: " + result.getSearchResults());
             xmlTransformer.transform(new StreamSource(new StringReader(input)), new StreamResult(xmlResultResource));
 
 
         } catch (Exception e) {
-            logger.warn("Error transforming xml.", e);
-            throw new FormatterException();
+            logger.warn("Error transforming xml: " + result, e);
+            throw new FormatterException(e);
         }
 
-        logger.debug("Transformer returns " + xmlResultResource.toString());
         return xmlResultResource.toString();
     }
 
Index: modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/transform/config/ConfigurationFactory.java
===================================================================
--- modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/transform/config/ConfigurationFactory.java	(revision 45683)
+++ modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/transform/config/ConfigurationFactory.java	(revision 45684)
@@ -5,7 +5,6 @@
 import eu.dnetlib.data.search.utils.vocabulary.IndexVocabulary;
 import eu.dnetlib.data.search.utils.vocabulary.LocalVocabulary;
 import eu.dnetlib.data.search.utils.vocabulary.Vocabulary;
-import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.log4j.Logger;
 import org.springframework.core.io.Resource;
@@ -14,7 +13,10 @@
 import org.xml.sax.InputSource;
 
 import javax.xml.xpath.*;
-import java.io.*;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.List;
@@ -66,7 +68,8 @@
 		Configuration configuration = new Configuration(id);  
 		XPathFactory factory = XPathFactory.newInstance();
 		XPath xPath = factory.newXPath();
-		  
+
+		/*
 		try {
 			//clean vocabularies folder
 			FileUtils.deleteDirectory(new File(vocabulariesPath));
@@ -77,7 +80,8 @@
 		} finally {		
 			new File(vocabulariesPath).mkdir();
 		}
-		
+		*/
+
 		try {
 			readLocales(xPath, configuration);
 			readVocabularies(xPath, configuration);
Index: modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/transform/config/SearchRegistry.java
===================================================================
--- modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/transform/config/SearchRegistry.java	(revision 45683)
+++ modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/transform/config/SearchRegistry.java	(revision 45684)
@@ -42,7 +42,7 @@
 				tx = this.transformers.get(locale).get(name);
 				
 			} else { //not map for locale
-				logger.debug("Transofrmation map " + config.getTransformationsMap().keySet());
+				logger.info("Transofrmation map " + config.getTransformationsMap().keySet());
 				tx = createChainTransformer(name, locale,  config.getTransformationsMap().get(name));
 				Map<String, Transformer> map = new HashMap<String, Transformer>();
 				map.put(name, tx);
@@ -101,14 +101,14 @@
 			if (tr instanceof XSLTTransformation) {
 				try {
 					if (!temp.isEmpty()){
-						forChaining.add(createTransformer("", locale, temp));
+						forChaining.add(createTransformer(locale, temp));
 					}
 					temp.clear();
-					forChaining.add(createTransformer("",(XSLTTransformation)tr));
+					forChaining.add(createTransformer((XSLTTransformation)tr));
 				}
 				catch (Exception e) {
 					logger.warn("Error creating a transformer with name: "+name+" and locale: "+locale.getDisplayName(), e);
-					throw new SearchFactoryException();
+					throw new SearchFactoryException(e);
 				}
 			}
 			else {
@@ -117,17 +117,17 @@
 		}
 		if (!temp.isEmpty()){
 			try {
-				forChaining.add(createTransformer("", locale, temp));
+				forChaining.add(createTransformer(locale, temp));
 			}
 			catch (Exception e) {
 				logger.warn("Error creating a transformer with name: " + name + " and locale: "+locale.getDisplayName(), e);
-				throw new SearchFactoryException();
+				throw new SearchFactoryException(e);
 			}
 		}
 		return new ChainTransformer(name, forChaining);
 	}
 
-	private Transformer createTransformer(String transformerName, XSLTTransformation transformation) throws Exception {
+	private Transformer createTransformer(XSLTTransformation transformation) throws Exception {
 		String xsl_file = transformation.getXslt();
 		InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(xsl_file);
 		StringWriter writer = new StringWriter();
@@ -142,7 +142,7 @@
 		return OptimusPrime;			
 	}
 	
-	private Transformer createTransformer(String transformerName, Locale locale, List<XPathTrasformation> transformations) throws Exception {
+	private Transformer createTransformer(Locale locale, List<XPathTrasformation> transformations) throws Exception {
 		VelocityEngine ve = VelocityUtil.getEngine();
 		
 		Template t = ve.getTemplate("/eu/dnetlib/data/search/transform/config/velocity.vm", "UTF-8");
Index: modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/transform/XsltTransformer.java
===================================================================
--- modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/transform/XsltTransformer.java	(revision 45683)
+++ modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/transform/XsltTransformer.java	(revision 45684)
@@ -38,8 +38,7 @@
 			xmlTransformer.transform(new StreamSource(new StringReader(input)), new StreamResult(xmlResultResource));
             
 		} catch (Exception e) {
-			logger.warn("Error transforming xml.", e);
-			throw new TransformerException();
+			throw new TransformerException(e);
 		}
 		return xmlResultResource.getBuffer().toString();		
 	}
Index: modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/web/servlet/SearchServlet.java
===================================================================
--- modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/web/servlet/SearchServlet.java	(revision 45683)
+++ modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/web/servlet/SearchServlet.java	(revision 45684)
@@ -1,11 +1,9 @@
 package eu.dnetlib.data.search.web.servlet;
 
-import eu.dnetlib.api.data.SearchService;
 import eu.dnetlib.data.search.app.SearchServiceImpl;
 import eu.dnetlib.domain.data.FormattedSearchResult;
 import org.apache.commons.lang.IncompleteArgumentException;
 import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.log4j.Logger;
 import org.springframework.context.ApplicationContext;
 import org.springframework.web.context.support.WebApplicationContextUtils;
 
@@ -23,7 +21,7 @@
 
 	private SearchServiceImpl searchService = null;
 	private ApplicationContext context = null;
-	private static Logger logger = Logger.getLogger(SearchService.class); 
+	//private static Logger logger = Logger.getLogger(SearchService.class);
 	
 	public void init(ServletConfig config) throws ServletException {
 		super.init(config);
Index: modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/web/api/SearchRequestController.java
===================================================================
--- modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/web/api/SearchRequestController.java	(revision 45683)
+++ modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/web/api/SearchRequestController.java	(revision 45684)
@@ -44,9 +44,9 @@
     private static final String TSV_CONTENT_TYPE = "text/tab-separated-values;charset=UTF-8;";
     private static final String HTML_CONTENT_TYPE = "text/html;charset=UTF-8;";
 
-    private final String PUBLICATION_BASIC_QUERY = "(oaftype exact result) and (resulttypeid exact publication)";
-    private final String DATASET_BASIC_QUERY = "(oaftype exact result) and (resulttypeid exact dataset)";
-    private final String PROJECT_BASIC_QUERY = "(oaftype exact project)";
+    private static final String PUBLICATION_BASIC_QUERY = "(oaftype exact result) and (resulttypeid exact publication)";
+    private static final String DATASET_BASIC_QUERY = "(oaftype exact result) and (resulttypeid exact dataset)";
+    private static final String PROJECT_BASIC_QUERY = "(oaftype exact project)";
 
     private final List<String> GLOBAL_PARAMETERS = Arrays.asList("page", "size", "format", "sortBy");
 
@@ -82,7 +82,7 @@
 		}
 
 		String format = (request.getParameter("format") != null) ? request.getParameter("format") : "xml";
-        createResponseMeta(response, format, "UTF-8");
+        createResponseMeta(response, format);
 
 		String locale = request.getParameter("locale");
 
@@ -185,7 +185,7 @@
 
             String format = (request.getParameter("format") != null) ? request.getParameter("format") : "xml";
             checkFormatParameter(PUB_N_DATASET_FORMATS, format);
-            createResponseMeta(response, format, "UTF-8");
+            createResponseMeta(response, format);
 
             String locale = request.getParameter("locale");
 
@@ -240,7 +240,7 @@
             checkRequestSize(page, size);
 
             String format = (request.getParameter("format") != null) ? request.getParameter("format") : "xml";
-            createResponseMeta(response, format, "UTF-8");
+            createResponseMeta(response, format);
 
             checkFormatParameter(PUB_N_DATASET_FORMATS, format);
 
@@ -302,7 +302,7 @@
 
             String format = (request.getParameter("format") != null) ? request.getParameter("format") : "xml";
             checkFormatParameter(PROJECT_FORMATS, format);
-            createResponseMeta(response, format, "UTF-8");
+            createResponseMeta(response, format);
 
             format = finalFormat(format);
 
@@ -365,11 +365,12 @@
         return format;
     }
 
+    //TODO check if needed
     /**
      * Based on the given model the transformer to be used is defined
      * @param model
      * @return
-     */
+
     private String defineTransformer(String model) {
         if (model!=null && !model.trim().isEmpty()) {
             if (model.equals("openaire")) {
@@ -388,7 +389,9 @@
             return null;
         }
     }
+     */
 
+    //TODO: check if needed
  private String defineTransformer(String model, String format) {
    if (model!=null && !model.trim().isEmpty()) {
             if (model.equals("openaire")) {
@@ -491,19 +494,19 @@
 
 	private String defineContentType(String format) {
 		if (format != null) {
-			if (format.toLowerCase().equals("xml")) {
+			if (format.equalsIgnoreCase("xml")) {
 				return XML_CONTENT_TYPE;
 
-			} else if (format.toLowerCase().equals("json")) {
+			} else if (format.equalsIgnoreCase("json")) {
 				return JSON_CONTENT_TYPE;
 
-			} else if (format.toLowerCase().equals("csv")) {
+			} else if (format.equalsIgnoreCase("csv")) {
                 return CSV_CONTENT_TYPE;
 
-            } else if (format.toLowerCase().equals("tsv")) {
+            } else if (format.equalsIgnoreCase("tsv")) {
                 return TSV_CONTENT_TYPE;
 
-            } else if (format.toLowerCase().equals("html")){
+            } else if (format.equalsIgnoreCase("html")){
                 return HTML_CONTENT_TYPE;
             }
 		}
@@ -552,7 +555,7 @@
         return true;
     }
 
-    private void createResponseMeta( HttpServletResponse response, String format, String encoding) {
+    private void createResponseMeta( HttpServletResponse response, String format) {
         response.setContentType(defineContentType(format));
         response.setCharacterEncoding("UTF-8");
 
Index: modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/web/api/QueryEnhancer.java
===================================================================
--- modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/web/api/QueryEnhancer.java	(revision 45683)
+++ modules/uoa-search/trunk/src/main/java/eu/dnetlib/data/search/web/api/QueryEnhancer.java	(revision 45684)
@@ -31,7 +31,7 @@
 
         if(isModelSygma) {
             if (funder != null) {
-                if(!funder.toUpperCase().equals("WT")) {
+                if(!funder.equalsIgnoreCase("WT")) {
                     Vocabulary sygmaFundersVocabulary = vocabularyManager.getVocabulary("sygma_funders", Locale.ROOT);
                     addExactQueryTerm("relfundinglevel0_id", devocabularizedTerm(funder.toUpperCase(), sygmaFundersVocabulary), queryBuilder);
                 } else {
@@ -174,7 +174,7 @@
                 sYear = Integer.parseInt(startYear);
 
             } catch(NumberFormatException e) {
-                throw new IllegalArgumentException("startYear parameter must be a numeric value.");
+                throw new IllegalArgumentException("startYear parameter must be a numeric value.", e);
             }
         }
 
@@ -184,7 +184,7 @@
                 eYear = Integer.parseInt(endYear);
 
             } catch(NumberFormatException e) {
-                throw new IllegalArgumentException("endYear parameter must be a numeric value.");
+                throw new IllegalArgumentException("endYear parameter must be a numeric value.", e);
             }
         }
 
@@ -518,9 +518,12 @@
      * @return
      */
     public static String devocabularizedTerm(String value, Vocabulary vocabulary) {
+
+        /*
         logger.debug("Vocabulary name " + vocabulary.getName() );
         logger.debug("Vocabulary English names " + vocabulary.getEnglishNames());
-        
+        */
+
         if (vocabulary != null) {
             String term = vocabulary.getEncoding(value);
             if (term == null) {
Index: modules/uoa-search/trunk/src/main/resources/project_mini.xsl
===================================================================
--- modules/uoa-search/trunk/src/main/resources/project_mini.xsl	(revision 45683)
+++ modules/uoa-search/trunk/src/main/resources/project_mini.xsl	(revision 45684)
@@ -13,11 +13,9 @@
 </xsl:template>
 
 <xsl:template match = "header">
-	<field name="encoding" multiplicity="false" indexId="objIdentifier" label="Object id">
-		<xsl:attribute name="value">
+	<encoding>
 			<xsl:value-of select='./dri:objIdentifier'/>
-		</xsl:attribute>
-	</field>
+		</encoding>
 </xsl:template>
 
 
@@ -25,18 +23,14 @@
 <xsl:template match = "oaf:project">
 	<xsl:choose>
 		<xsl:when test="./acronym != '' and ./acronym != 'UNKNOWN'">
-			<field name="value" multiplicity="true" indexId="relprojectid" label="Project name">
-				<xsl:attribute name="value">
-                    <xsl:value-of select="./acronym"/>
-                </xsl:attribute>
-			</field>
+			<value>
+				<xsl:value-of select="./acronym"/>
+			</value>
 		</xsl:when>
 		<xsl:otherwise>
-				<field name="value" multiplicity="true" indexId="relprojectid" label="Project name">
-                    <xsl:attribute name="value">
-                           <xsl:value-of select="./title"/>
-                    </xsl:attribute>
-				</field>
+				<value>
+					<xsl:value-of select="./title"/>
+				</value>
 		</xsl:otherwise>
 	</xsl:choose>				
 </xsl:template>
Index: modules/uoa-search/trunk/src/main/resources/browse.xsl
===================================================================
--- modules/uoa-search/trunk/src/main/resources/browse.xsl	(revision 45683)
+++ modules/uoa-search/trunk/src/main/resources/browse.xsl	(revision 45684)
@@ -38,7 +38,7 @@
                             <xsl:value-of select="./value"/>
                         </xsl:attribute>
                         <xsl:attribute name="value_original">
-                            <xsl:value-of select="./value"/>
+                            <xsl:value-of select="./originalValue"/>
                         </xsl:attribute>
                     </xsl:otherwise>
                 </xsl:choose>
Index: modules/uoa-search/trunk/src/main/resources/configuration.xml
===================================================================
--- modules/uoa-search/trunk/src/main/resources/configuration.xml	(revision 45683)
+++ modules/uoa-search/trunk/src/main/resources/configuration.xml	(revision 45684)
@@ -13,8 +13,6 @@
         <is_vocabulary name="taxonomy" xml_name="dnet:subject_classification_typologies" />
 		<is_vocabulary name="datasource_type" xml_name="dnet:datasource_typologies" />
 
-    	<index_vocabulary name="datasources" query="oaftype=datasource" transformer="datasourceVocabularyTransformer"/>
-		<index_vocabulary name="projects" query="oaftype=project" transformer="projectVocabularyTransformer"/>
         <local_vocabulary name="funders" file="funders.xml" />
 		<local_vocabulary name="funding_level0" file="funding_level0.xml" />
         <local_vocabulary name="funders_simple" file="funders_simple.xml" />
@@ -29,6 +27,7 @@
 	</vocabularies>
 
 	<transformers>
+<!--
 		<transformer name="datasourceVocabularyTransformer">
 			<transformation xslt="datasource_mini.xsl" />
 		</transformer>
@@ -36,14 +35,12 @@
 		<transformer name="projectVocabularyTransformer">
 			<transformation xslt="project_mini.xsl" />
 		</transformer>
+-->
 
 		<transformer name="results_openaire">
             <transformation xslt="result.xsl" />    
 	 		<transformation match="language" change="value" vocabulary="languages" />
             <transformation match="funding.funder" change="value" vocabulary="funders" />
-            <!--
-			<transformation match="funding.funding_level_0" change="value" vocabulary="funders" />
-			-->
             <transformation match="funding.funding_level_1" change="value" vocabulary="programmes" />
             <transformation match="funding.funding_level_2" change="value" vocabulary="areas" />
 			<transformation match="datasource.hostedby" change="value" vocabulary="datasources" />
@@ -70,8 +67,8 @@
 			<transformation match="organizationcountryid.value" change="value" vocabulary="countries" />
 			<transformation match="instancetypenameid.value" change="value" vocabulary="documenttype" />
 
-            <transformation match="relfunderid.value" change="value" vocabulary="funders" />
-            <transformation match="funderid.value" change="value" vocabulary="funders" />
+<!--            <transformation match="relfunderid.value" change="value" vocabulary="funders" />
+            <transformation match="funderid.value" change="value" vocabulary="funders" />-->
 
             <transformation match="relfundinglevel0_id.value" change="value" vocabulary="funding_level0" />
             <transformation match="relfundinglevel1_id.value" change="value" vocabulary="programmes" />
@@ -89,12 +86,8 @@
 
 			<transformation match="datasourcecompatibilityid.value" change="value" vocabulary="compatibility"/>
 			<transformation match="resultrightsid.value" change="value" vocabulary="accessModes" />
-			<transformation match="relprojectid.value" change="value" vocabulary="projects" />
             <transformation match="projectecsc39.value" change="value" vocabulary="sc39" />
 			<transformation match="datasourcetypeuiid.value" change="value" vocabulary="datasource_type" />
-
-		<!--	<transformation match="fundinglevel0_id.value" change="value" vocabulary="project_funders" /> -->
-
 		</transformer>
 
 		<transformer name="persons_openaire">
Index: modules/uoa-search/trunk/src/main/resources/eu/dnetlib/data/search/solr/springContext-searchService-solr.xml
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Index: modules/uoa-search/trunk/src/main/resources/datasource_mini.xsl
===================================================================
--- modules/uoa-search/trunk/src/main/resources/datasource_mini.xsl	(revision 45683)
+++ modules/uoa-search/trunk/src/main/resources/datasource_mini.xsl	(revision 45684)
@@ -13,21 +13,17 @@
 </xsl:template>
 
 <xsl:template match = "header">
-	<field name="encoding" multiplicity="false" indexId="objIdentifier" label="Object id">
-		<xsl:attribute name="value">
-			<xsl:value-of select='./dri:objIdentifier'/>
-		</xsl:attribute>
-	</field>
+	<encoding>
+		<xsl:value-of select='./dri:objIdentifier'/>
+	</encoding>
 </xsl:template>
 
 
 <xsl:template match = "oaf:datasource">
 	<xsl:for-each select = "./officialname">
-		<field name="value" indexId = "datasourceofficialname" multiplicity="true" label="Official name">
-			<xsl:attribute name="value">
-				<xsl:value-of select='.'/>
-			</xsl:attribute>
-		</field>
+		<value>
+			<xsl:value-of select='.'/>
+		</value>
 	</xsl:for-each>
 </xsl:template>
 
