Sergiu Dumitriu,
Using this tip, i had print the className and got this result :
System.out.println("search return (" + searchResult.getClass() +
")");
[stdout] search return (class [Ljava.lang.Object;)
I was wrong because i was thinking that this was a basic Object but
it's an array of Object (not a List)...
So proceeding this way i got my array of results (Map []) with
confluence "SearchResult" attributes)
Here is a sample wich display the first result title (assume that
there is one result) :
Object searchResult = client.execute("confluence1.search",
new Object[] { p_token, p_query, new Integer(p_maxResults) });
// System.out.println("search return (" + searchResult.getClass() +
")");
// searchResult != null
Object[] searchResults = (Object[]) searchResult;
// searchResult != null && searchResults.length > 0
String firstObjectTitle = (String) ((Map)searchResults[0]).get("title");
System.out.println("firstObjectTitle =" + firstObjectTitle);
Relevant (confluence) SearchResult attributes :
Key Type Value
title String the feed's title
url String the remote URL needed to view this search result online
excerpt String a short excerpt of this result if it makes sense
type String the type of this result - page, comment, spacedesc,
attachment, userinfo, blogpost
id String the long ID of this result (if the type has one)
FYI, here is a test result :
[stdout] search return (class [Ljava.lang.Object;)
[stdout] firstObjectTitle=Main.WebHome
[stdout] firstObjectUrl=
[stdout] firstObjectExcerpt=
[stdout] firstObjectType=pageid
[stdout] firstObjectId=Main.WebHome
Thanks :)
Regards
Brice Vandeputte
-----Message d'origine-----
De : users-bounces(a)xwiki.org [mailto:users-bounces@xwiki.org] De la
part de Sergiu Dumitriu
Envoyé : jeudi 6 novembre 2008 04:53
À : XWiki Users
Objet : Re: [xwiki-users] [XML/RPC] trying execute
"confluence1.search"without success
VANDEPUTTE Brice ITLABS wrote:
Hi all,
i'm trying to create a Java XML-RPC Client of my Xwiki instance
(for now i'm using xwikie1_6m2)
Documentation used :
- Xwiki XML/RPC doc :
http://platform.xwiki.org/xwiki/bin/view/Features/XMLRPC
- Confluence API Specification :
http://confluence.atlassian.com/display/DOC/Remote+API+Specification
I success with this methods : confluence1.login,
confluence1.logout, confluence1.getPage, confluence1.storePage,
confluence1.renderContent
but i got a problem with this one : confluence1.search
Confluence API talk about two ways to use search :
1) Vector search(String token, String query, int maxResults) -
return a list of SearchResults which match a given search query
(including pages and other content types). This is the same as a
performing a parameterised search (see below) with an empty
parameter map.
2) Vector search(String token, String query, Map parameters, int
maxResults) - (since 1.3) like the previous search, but you can
optionally limit your search by adding parameters to the parameter
map. If you do not include a parameter, the default is used instead.
The second way (with parameters) is not implemented on Xwiki (cf.
http://jira.xwiki.org/jira/browse/XWIKI-1559 )
So how must we use the first search method (without Map parameters) ?
I'm trying this :
Vector searchResult = (Vector) client.execute("confluence1.search",
new Object[] { p_token, p_query,new Integer(p_maxResults) });
This code return a "ClassCastException" : it's like the returned
object were not a "Vector".. If then what is it ?
I don't know what it is. In Java, the method returns List<String>. To
see what you have there, just use reflection:
Object searchResult = client.execute...
System.out.println(searchResult.getClass())
// Or whatever logging method you use
This will print the exact classname, and from there you can procede further.
--
Sergiu Dumitriu
http://purl.org/net/sergiu/
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users