Hello "query.setMaxResults(20000);" only sets the maximum number of results,
I only have about 1200 registered contacts. Because default maximum result
is 25, raised to have a safety margin.

"or modify it to request only 1 contact as the only information you're
interested in is the number of contacts in the group which will be returned
either way."
How exactly I do this? if I ask just one contact, as I will answer only one
contact, correct?

Removed "query.setMaxResults (20000);" and this error occurred:

*java.lang.IllegalStateException: Uninitialized version registry*
        at
com.google.gdata.util.VersionRegistry.get(VersionRegistry.java:121)
        at com.google.gdata.client.Service.endVersionScope(Service.java:613)
        at com.google.gdata.client.Service.getFeed(Service.java:1138)
        at com.google.gdata.client.Service.getFeed(Service.java:1077)
        at
com.google.gdata.client.GoogleService.getFeed(GoogleService.java:662)
        at com.google.gdata.client.Service.query(Service.java:1237)
        at com.google.gdata.client.Service.query(Service.java:1178)
        *at
google.controller.GoogleContactsController.numeroDeContatos(GoogleContactsController.java:76)
*
        at
google.controller.GoogleContactsController.listarGrupos(GoogleContactsController.java:115)
        at servlet.cursoServlet.setListaGrupo(cursoServlet.java:111)
        at servlet.cursoServlet.showCursosView(cursoServlet.java:117)
        at servlet.cursoServlet.processRequest(cursoServlet.java:43)
        at servlet.cursoServlet.doGet(cursoServlet.java:83)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at filtro.authFilter.doFilter(authFilter.java:119)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at filtro.servletFilter.doFilter(servletFilter.java:107)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:619)

The line where the error occurs is precisely that executes the query:

*ContactFeed resultado = servico.query(query, ContactFeed.class);*


I changed the number of request and the slowness continues. My code
currently looks like:

[code]
private Integer numeroDeContatos(String idGrupo) {
        try {
            URL feedURL = new URL("http://www.google.com/m8/feeds/contacts/";
+ usuarioCorrente + "/full");

            Query query = new Query(feedURL);
            query.setMaxResults(5000); // por default são 25 resultados.
            query.setStringCustomParameter("group", idGrupo);

            ContactFeed resultado = servico.query(query, ContactFeed.class);
            return resultado.getTotalResults();

        } catch (MalformedURLException e) {
            throw new RuntimeException("URL inválida", e);
        } catch (IOException e) {
            throw new RuntimeException("Erro geral de I/O", e);
        } catch (ServiceException e) {
            throw new RuntimeException("Erro interno do serviço", e);
        }
*[/code]*
*
*
*Carlos Santos*
www.drdesigns.com.br



2011/5/5 Alain <[email protected]>

> Hello Carlos,
>
> The reason it's taking so long is because you are requesting 20000
> contacts: that may take a while for the API to process and for the response
> to get back to your client.
> You shouldn't have to ask for 20000 contacts as the response feed will
> contain a 
> "totalResult<http://www.opensearch.org/Specifications/OpenSearch/1.1#The_.22totalResults.22_element>"
> element showing how many entries there should be in total:
>
> [CODE]
>
>     listaContatos.getTotalResults();
> [/CODE]
>
> You should remove the line which sets the max-results query parameter to
> 20000, or modify it to request only 1 contact as the only information you're
> interested in is the number of contacts in the group which will be returned
> either way.
>
> Best,
> Alain
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Google Contacts, Shared Contacts and User Profiles APIs" group.
> To post to this group, send email to
> [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://code.google.com/apis/contacts/community/forum.html
>

-- 
You received this message because you are subscribed to the Google
Groups "Google Contacts, Shared Contacts and User Profiles APIs" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://code.google.com/apis/contacts/community/forum.html

Reply via email to