atom feed10 messages in org.xwiki.devs[xwiki-devs] Problems accessing Docum...
FromSent OnAttachments
Anamaria StoicaAug 8, 2009 5:38 pm 
Vincent MassolAug 9, 2009 1:48 am 
Anamaria StoicaAug 10, 2009 3:17 am 
Sergiu DumitriuAug 10, 2009 3:41 am 
Vincent MassolAug 10, 2009 3:45 am 
Sergiu DumitriuAug 10, 2009 4:30 am 
Vincent MassolAug 10, 2009 4:51 am 
Anamaria StoicaAug 10, 2009 6:24 am 
Anamaria StoicaAug 10, 2009 6:28 am 
Anamaria StoicaAug 12, 2009 9:15 am 
Subject:[xwiki-devs] Problems accessing DocumentAccessBridge from the XWiki implementation for Shindig PersonService
From:Anamaria Stoica (anam@gmail.com)
Date:Aug 8, 2009 5:38:54 pm
List:org.xwiki.devs

Hi,

In order to integrate Shindig with the XWiki datastore, 4 interfaces have to be implemented: PersonService, AppDataService, ActivityService and MessagesService (javadocs here [0]). To this end, I have created the xwiki-social-opensocial module [1].

While implementing PersonService (PersonServiceXW - [2]), I have encountered the following problem: As I needed to access the datastore, I also made PersonServiceXW a XWiki Component in order to gain access to the DocumentAccessBridge Component. BUT, here is the problem, the DocumentAccessBridge never gets initialized and at runtime is null.

The reason this might happen, as Sergiu suggested, is that Shindig uses Guice to bind the services implementations in its code, thus the PersonServiceXW component never gets to be registered with XWiki's Component Manager.

My question is how do I get data in and out XWiki's datastore from the PersonService implementation, if I cannot use the DocumentAccessBridge this way? Can it be registered to the Component Manager somehow, or is there a completely different way this could be achieved?

I will continue with some integration details (about the patch on xwiki-web-standard and the OpenSocial XWiki Application). At the end I included some instructions on how to build and test them.

***xwiki-web-standard patch (apply on xwiki-platform-web), consisting of: - in standard/src/main/webapps/templates: * added 3 .vm files which handles getting/adding/deleting friends: addfriend.vm, getuserfriends.vm, deletefriend.vm - in standard/src/main/webapps/resources/xwiki/opensocial: * added javascript and css files necessary for the Shindig container - in standard/src/main/webapps/WEB-INF: * modified web.xml to include all shindig servlet mappings and necessary Guice modules - in standard/src/main/webapps/WEB-INF/classes: * added container/default/container.js and shindig.properties - default Shindig container configurations. I put them in the classpath as they required modifications from the original files - in standard: * modified pom.xml, to include as a dependency xwiki-social-opensocial module

***Open Social XWiki Application, consisting of: - OpenSocial.GadgetContainerClass - the simplest OpenSocial Gadget container; has a single url property (the url of the gadget); in view mode it displays/renders it - OpenSocial.GadgetContainerClassSheet - OpenSocial.GadgetContainerClassTemplate

- OpenSocial.HelloWorld - hello world Gadget (only displays a String) - NO OpenSocial features - works - OpenSocial.LabpixiesTodo - Gadget with NO OpenSocial features 1 - works - OpenSocial.Horoscope - Gadget with NO OpenSocial features 2 - works

- OpenSocial.ListFriends - SHOULD list the friends of the currently logged in user. The friends are retrieved using the XWiki implementation of the Shindig's PersonService, which is located in the xwiki-social-opensocial module (PersonServiceXW). The service TRIES to use DocumentAccessBridge component in order to retrieve the necessary data from the XWiki datastore.

- OpenSocial.TestingGadgetsSource - used to attach gadgets XML files to the page. Their URLs can be used for GadgetContainerClass objects (e.g. ListFriends gadget)

- Panels.My Friends - panel, displays the friends of the currently logged in user - Panels.Navigation

- XWiki.FriendClass - A friend; objects of this type can be attached to user profiles; has as a single property friendName, which contains the name of the friend - XWiki.FriendClassSheet - XWiki.FriendClassTemplate - XWiki.XWikiUserSheet - to add the list of friends to profile - XWiki.MyResources - XWiki.XWikiPreferences

Instructions for testing (one possible way at least): 1. Patch xwiki-platform-web (changes are only in xwiki-web-standard), with the patch from JIRA - [3] 2. Build xwiki-web-standard 3. Build xwiki-enterprise in offline mode (-o), so it will use xwiki-web-standard from the local repository build at step 2 4. Run XWiki Enterprise. I always use xwiki-enterprise-jetty-hsqldb-2.0-SNAPSHOT from the generated distributions 5. Import opensocial XAR - [4]

What to look for while testing (working stuff): - Gadgets: - see all/add new gadgets http://localhost:8080/xwiki/bin/view/OpenSocial/GadgetContainerClass - http://localhost:8080/xwiki/bin/view/OpenSocial/HelloWorld - http://localhost:8080/xwiki/bin/view/OpenSocial/LabpixiesTodo - http://localhost:8080/xwiki/bin/view/OpenSocial/Horoscope - http://localhost:8080/xwiki/bin/view/OpenSocial/ListFriends (social features) --> as specified before, not working - While you're here, you could also: - Log in as Alice (password 'alice') - Go to profile page and edit friends list; You should have 2 friends: Jane and Bob (they have as passwords 'jane', and 'bob') - See My Friends Panel, with the friends of the current logged in user displayed

[0] - http://incubator.apache.org/shindig/shindig-1.1.x/apidocs/org/apache/shindig/social/opensocial/spi/package-summary.html [1] - https://svn.xwiki.org/svnroot/xwiki/sandbox/gsoc/opensocial/xwiki-social-opensocial/ [2] - https://svn.xwiki.org/svnroot/xwiki/sandbox/gsoc/opensocial/xwiki-social-opensocial/src/main/java/org/xwiki/opensocial/social/spi/internal/PersonServiceXW.java [3] - http://jira.xwiki.org/jira/browse/XSANDBOX-36?focusedCommentId=43674&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_43674 [4] - http://jira.xwiki.org/jira/browse/XSANDBOX-64?focusedCommentId=43675&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_43675

Other helpful links: - Guice module configuration for my service implementations https://svn.xwiki.org/svnroot/xwiki/sandbox/gsoc/opensocial/xwiki-social-opensocial/src/main/java/org/xwiki/opensocial/social/XWSocialModule.java - Exemple of PersonService being injected by Guice in Shindig's code http://svn.apache.org/repos/asf/incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/PersonHandler.java

Thanks, Anamaria