@@ -0,0 +1,2783 @@
+package fr.inria.aviz.elasticindexer;%0A%0Aimport java.io.IOException;%0Aimport java.util.List;%0Aimport java.util.Map;%0A%0Aimport com.fasterxml.jackson.core.JsonGenerationException;%0Aimport com.fasterxml.jackson.databind.JsonMappingException;%0Aimport com.fasterxml.jackson.databind.ObjectMapper;%0Aimport com.fasterxml.jackson.databind.SerializationFeature;%0A%0Aimport fr.inria.aviz.elasticindexer.ckan.CendariIndexer;%0Aimport fr.inria.aviz.elasticindexer.ckan.Resource;%0Aimport fr.inria.aviz.elasticindexer.ckan.ResourceList;%0Aimport junit.framework.TestCase;%0Aimport org.junit.Test;%0A%0A/**%0A * Class TestCendariAPI%0A * %0A * @author Jean-Daniel Fekete%0A * @version $Revision$%0A */%0Apublic class TestCendariAPI extends TestCase %7B%0A    @Test%0A    public void test() %7B%0A        Indexer indexer = Indexer.instance();%0A        ObjectMapper mapper = new ObjectMapper();%0A        mapper.enable(SerializationFeature.INDENT_OUTPUT);%0A        %0A        String location = %22http://localhost:42042/%22;%0A        String key = System.getProperty(%22key%22);%0A        if (key == null) return;%0A        CendariIndexer cendari = new CendariIndexer(location, key);%0A        List%3CObject%3E packages = cendari.getDataspaces();%0A        for (Object o: packages) %7B%0A            Map%3CString,Object%3E p = (Map%3CString,Object%3E)o;%0A            System.out.println(%22Package is:%22);%0A            try %7B%0A                System.out.println(mapper.writeValueAsString(p));%0A            %7D catch (JsonGenerationException e1) %7B%0A                // TODO Auto-generated catch block%0A                e1.printStackTrace();%0A            %7D catch (JsonMappingException e1) %7B%0A                // TODO Auto-generated catch block%0A                e1.printStackTrace();%0A            %7D catch (IOException e1) %7B%0A                // TODO Auto-generated catch block%0A                e1.printStackTrace();%0A            %7D%0A%0A            ResourceList res = cendari.getResourceList((String)p.get(%22resources%22));%0A            for (Resource r : res)%0A                try %7B%0A                    System.out.println(mapper.writeValueAsString(r));%0A                    byte%5B%5D content = cendari.getData((String)r.get(%22dataUrl%22));%0A                    if (content == null) %7B%0A                        System.out.println(%22Cannot get content of dataUrl%22+(String)r.get(%22dataUrl%22));%0A                        continue;%0A                    %7D%0A                    DocumentInfo info = indexer.parseDocument((String)r.get(%22name%22), null, content, -1);%0A                    System.out.println(mapper.writeValueAsString(info));%0A                    info.setGroups_allowed((String)p.get(%22name%22));%0A                    indexer.indexDocument(info);%0A                    %0A                %7D catch (Exception e) %7B%0A                    // TODO Auto-generated catch block%0A                    e.printStackTrace();%0A                %7D%0A        %7D%0A    %7D%0A%0A%7D%0A

add cendari api test