[xwiki-devs] Problems creating a query using the QueryManager
Hi, I'm currently implementing the last things to finish OpenID authentication support but I have some problems with the query manager. I'm trying to get the document (should be only one) which an attached OpenIdIdentifier object whose "identifier" string property's value has some specific value. I didn't found any documentation apart http://markmail.org/message/jt6m2huqr4r6hvk6 and http://dev.xwiki.org/xwiki/bin/view/Design/XWiki+Query+Language+Specificatio.... I tried to achieve this by the following code: public static String findOpenIDUser(String openid_identifier, XWikiContext context) throws XWikiException { XWiki xwiki = context.getWiki(); QueryManager qm = xwiki.getStore().getQueryManager(); Query search_user; if (qm.hasLanguage(Query.HQL)) { search_user = qm.createQuery(", BaseObject as obj, StringProperty as prop where doc.fullName = obj.name and obj.className = 'XWiki.OpenIdIdentifier' and obj.id=prop.id.id and prop.id.name='identifier' and prop.value = ':identifier'", Query.HQL); } else if (qm.hasLanguage(Query.XPATH)) { search_user = qm.createQuery("/*/*[obj/XWiki/OpenIdIdentifier/@xp:identifier = ':identifier'] ", Query.XPATH); } else throw new RuntimeException(); search_user.bindValue("identifier", openid_identifier); List<XWikiDocument> found_users = search_user.setLimit(1).execute(); if (found_users.size() > 0) { if (log.isDebugEnabled()) { log.debug("OpenID " + openid_identifier + " already registered."); } return found_users.get(0).getFullName(); } return null; } but all I get is a NullPointerException when qm.createQuery(..., Query.HQL) is called. What's wrong with my code? java.lang.NullPointerException at com.xpn.xwiki.store.query.AbstractQueryManager.createQuery(AbstractQueryManager.java:73) at com.xpn.xwiki.user.impl.openid.OpenIDHelper.findOpenIDUser(OpenIDHelper.java:109) at com.xpn.xwiki.user.impl.xwiki.MyFormAuthenticator.processLogin(MyFormAuthenticator.java:201) at com.xpn.xwiki.user.impl.xwiki.MyFormAuthenticator.processLogin(MyFormAuthenticator.java:178) at com.xpn.xwiki.user.impl.xwiki.XWikiAuthServiceImpl.checkAuth(XWikiAuthServiceImpl.java:205) at com.xpn.xwiki.XWiki.checkAuth(XWiki.java:3518) at com.xpn.xwiki.user.impl.xwiki.XWikiRightServiceImpl.checkAccess(XWikiRightServiceImpl.java:139) at com.xpn.xwiki.XWiki.checkAccess(XWiki.java:3526) at com.xpn.xwiki.XWiki.prepareDocuments(XWiki.java:4432) at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:190) at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:115) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.xpn.xwiki.web.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:287) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.xpn.xwiki.web.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:112) 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:175) 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:844) 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)
Hi Markus, On Mon, Jul 28, 2008 at 11:23 AM, Markus Lanthaler <[email protected]> wrote:
Hi,
I'm currently implementing the last things to finish OpenID authentication support but I have some problems with the query manager. I'm trying to get the document (should be only one) which an attached OpenIdIdentifier object whose "identifier" string property's value has some specific value. I didn't found any documentation apart http://markmail.org/message/jt6m2huqr4r6hvk6 and http://dev.xwiki.org/xwiki/bin/view/Design/XWiki+Query+Language+Specificatio....
I tried to achieve this by the following code:
public static String findOpenIDUser(String openid_identifier, XWikiContext context) throws XWikiException { XWiki xwiki = context.getWiki();
QueryManager qm = xwiki.getStore().getQueryManager(); Query search_user;
if (qm.hasLanguage(Query.HQL)) { search_user = qm.createQuery(", BaseObject as obj, StringProperty as prop where doc.fullName = obj.name and obj.className = 'XWiki.OpenIdIdentifier' and obj.id=prop.id.id and prop.id.name='identifier' and prop.value = ':identifier'", Query.HQL);
I think it's "prop.value =:identifier" (not ':identifier') otherwise hibernate will consider you use the value ":identifier" and will not replace it.
} else if (qm.hasLanguage(Query.XPATH)) { search_user = qm.createQuery("/*/*[obj/XWiki/OpenIdIdentifier/@xp:identifier = ':identifier'] ", Query.XPATH); } else throw new RuntimeException();
search_user.bindValue("identifier", openid_identifier);
List<XWikiDocument> found_users = search_user.setLimit(1).execute(); if (found_users.size() > 0) { if (log.isDebugEnabled()) { log.debug("OpenID " + openid_identifier + " already registered."); } return found_users.get(0).getFullName(); }
return null; }
but all I get is a NullPointerException when qm.createQuery(..., Query.HQL) is called. What's wrong with my code?
java.lang.NullPointerException at com.xpn.xwiki.store.query.AbstractQueryManager.createQuery(AbstractQueryManager.java:73)
Looks like the component manager is not initialized when you are trying to use Query Manager. You are working in a specific servlet ? In that case you have to initialize it. You can look at shared-test, webdav work made by Asiri (in sandbox) or at standard sevlet initialization.
at com.xpn.xwiki.user.impl.openid.OpenIDHelper.findOpenIDUser(OpenIDHelper.java:109) at com.xpn.xwiki.user.impl.xwiki.MyFormAuthenticator.processLogin(MyFormAuthenticator.java:201) at com.xpn.xwiki.user.impl.xwiki.MyFormAuthenticator.processLogin(MyFormAuthenticator.java:178) at com.xpn.xwiki.user.impl.xwiki.XWikiAuthServiceImpl.checkAuth(XWikiAuthServiceImpl.java:205) at com.xpn.xwiki.XWiki.checkAuth(XWiki.java:3518) at com.xpn.xwiki.user.impl.xwiki.XWikiRightServiceImpl.checkAccess(XWikiRightServiceImpl.java:139) at com.xpn.xwiki.XWiki.checkAccess(XWiki.java:3526) at com.xpn.xwiki.XWiki.prepareDocuments(XWiki.java:4432) at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:190) at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:115) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.xpn.xwiki.web.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:287) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.xpn.xwiki.web.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:112) 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:175) 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:844) 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)
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
Hi Markus, Line 73 of AbstractQueryManager query = (Query) componentManager.lookup(Query.ROLE, language); Your componentManager is null.. This probably means that you have not activated the component manager from plexus properly. Probably Vincent can help, but he will probably need to know how you have build your code. Ludovic Markus Lanthaler wrote:
Hi,
I'm currently implementing the last things to finish OpenID authentication support but I have some problems with the query manager. I'm trying to get the document (should be only one) which an attached OpenIdIdentifier object whose "identifier" string property's value has some specific value. I didn't found any documentation apart http://markmail.org/message/jt6m2huqr4r6hvk6 and http://dev.xwiki.org/xwiki/bin/view/Design/XWiki+Query+Language+Specificatio....
I tried to achieve this by the following code:
public static String findOpenIDUser(String openid_identifier, XWikiContext context) throws XWikiException { XWiki xwiki = context.getWiki();
QueryManager qm = xwiki.getStore().getQueryManager(); Query search_user;
if (qm.hasLanguage(Query.HQL)) { search_user = qm.createQuery(", BaseObject as obj, StringProperty as prop where doc.fullName = obj.name and obj.className = 'XWiki.OpenIdIdentifier' and obj.id=prop.id.id and prop.id.name='identifier' and prop.value = ':identifier'", Query.HQL); } else if (qm.hasLanguage(Query.XPATH)) { search_user = qm.createQuery("/*/*[obj/XWiki/OpenIdIdentifier/@xp:identifier = ':identifier'] ", Query.XPATH); } else throw new RuntimeException();
search_user.bindValue("identifier", openid_identifier);
List<XWikiDocument> found_users = search_user.setLimit(1).execute(); if (found_users.size() > 0) { if (log.isDebugEnabled()) { log.debug("OpenID " + openid_identifier + " already registered."); } return found_users.get(0).getFullName(); }
return null; }
but all I get is a NullPointerException when qm.createQuery(..., Query.HQL) is called. What's wrong with my code?
java.lang.NullPointerException at com.xpn.xwiki.store.query.AbstractQueryManager.createQuery(AbstractQueryManager.java:73) at com.xpn.xwiki.user.impl.openid.OpenIDHelper.findOpenIDUser(OpenIDHelper.java:109) at com.xpn.xwiki.user.impl.xwiki.MyFormAuthenticator.processLogin(MyFormAuthenticator.java:201) at com.xpn.xwiki.user.impl.xwiki.MyFormAuthenticator.processLogin(MyFormAuthenticator.java:178) at com.xpn.xwiki.user.impl.xwiki.XWikiAuthServiceImpl.checkAuth(XWikiAuthServiceImpl.java:205) at com.xpn.xwiki.XWiki.checkAuth(XWiki.java:3518) at com.xpn.xwiki.user.impl.xwiki.XWikiRightServiceImpl.checkAccess(XWikiRightServiceImpl.java:139) at com.xpn.xwiki.XWiki.checkAccess(XWiki.java:3526) at com.xpn.xwiki.XWiki.prepareDocuments(XWiki.java:4432) at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:190) at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:115) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.xpn.xwiki.web.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:287) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.xpn.xwiki.web.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:112) 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:175) 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:844) 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)
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Ludovic Dubost Blog: http://blog.ludovic.org/ XWiki: http://www.xwiki.com Skype: ldubost GTalk: ldubost
Hi Ludovic, I just created a class OpenIDHelper which has a static method findOpenIDUser(). That method is called in the already existent class MyFormAuthenticator which I extended a bit. Shouldn't the component manager be set up already in that "context"? Do you need any other details?
I think it's "prop.value =:identifier" (not ':identifier') otherwise hibernate will consider you use the value ":identifier" and will not replace it.
OK Thomas, I fixed that. Thanks! ----- Original Message ----- From: "Ludovic Dubost" <[email protected]> To: "XWiki Developers" <[email protected]> Sent: Monday, July 28, 2008 11:53 AM Subject: [gsoc] Re: [xwiki-devs] Problems creating a query using the QueryManager
Hi Markus,
Line 73 of AbstractQueryManager
query = (Query) componentManager.lookup(Query.ROLE, language);
Your componentManager is null.. This probably means that you have not activated the component manager from plexus properly. Probably Vincent can help, but he will probably need to know how you have build your code.
Ludovic
Markus Lanthaler wrote:
Hi,
I'm currently implementing the last things to finish OpenID authentication support but I have some problems with the query manager. I'm trying to get the document (should be only one) which an attached OpenIdIdentifier object whose "identifier" string property's value has some specific value. I didn't found any documentation apart http://markmail.org/message/jt6m2huqr4r6hvk6 and http://dev.xwiki.org/xwiki/bin/view/Design/XWiki+Query+Language+Specificatio....
I tried to achieve this by the following code:
public static String findOpenIDUser(String openid_identifier, XWikiContext context) throws XWikiException { XWiki xwiki = context.getWiki();
QueryManager qm = xwiki.getStore().getQueryManager(); Query search_user;
if (qm.hasLanguage(Query.HQL)) { search_user = qm.createQuery(", BaseObject as obj, StringProperty as prop where doc.fullName = obj.name and obj.className = 'XWiki.OpenIdIdentifier' and obj.id=prop.id.id and prop.id.name='identifier' and prop.value = ':identifier'", Query.HQL); } else if (qm.hasLanguage(Query.XPATH)) { search_user = qm.createQuery("/*/*[obj/XWiki/OpenIdIdentifier/@xp:identifier = ':identifier'] ", Query.XPATH); } else throw new RuntimeException();
search_user.bindValue("identifier", openid_identifier);
List<XWikiDocument> found_users = search_user.setLimit(1).execute(); if (found_users.size() > 0) { if (log.isDebugEnabled()) { log.debug("OpenID " + openid_identifier + " already registered."); } return found_users.get(0).getFullName(); }
return null; }
but all I get is a NullPointerException when qm.createQuery(..., Query.HQL) is called. What's wrong with my code?
java.lang.NullPointerException at com.xpn.xwiki.store.query.AbstractQueryManager.createQuery(AbstractQueryManager.java:73) at com.xpn.xwiki.user.impl.openid.OpenIDHelper.findOpenIDUser(OpenIDHelper.java:109) at com.xpn.xwiki.user.impl.xwiki.MyFormAuthenticator.processLogin(MyFormAuthenticator.java:201) at com.xpn.xwiki.user.impl.xwiki.MyFormAuthenticator.processLogin(MyFormAuthenticator.java:178) at com.xpn.xwiki.user.impl.xwiki.XWikiAuthServiceImpl.checkAuth(XWikiAuthServiceImpl.java:205) at com.xpn.xwiki.XWiki.checkAuth(XWiki.java:3518) at com.xpn.xwiki.user.impl.xwiki.XWikiRightServiceImpl.checkAccess(XWikiRightServiceImpl.java:139) at com.xpn.xwiki.XWiki.checkAccess(XWiki.java:3526) at com.xpn.xwiki.XWiki.prepareDocuments(XWiki.java:4432) at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:190) at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:115) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.xpn.xwiki.web.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:287) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.xpn.xwiki.web.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:112) 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:175) 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:844) 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)
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Ludovic Dubost Blog: http://blog.ludovic.org/ XWiki: http://www.xwiki.com Skype: ldubost GTalk: ldubost
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Hi Markus, On Jul 28, 2008, at 12:17 PM, Markus Lanthaler wrote:
Hi Ludovic,
I just created a class OpenIDHelper which has a static method findOpenIDUser(). That method is called in the already existent class MyFormAuthenticator which I extended a bit. Shouldn't the component manager be set up already in that "context"? Do you need any other details?
If you're using the default xwiki servlet (the struts one) then yes it should be already set. If you have created your own entry point (servlet, other) then you'll need to set it up as described by Thomas. Thanks -Vincent
I think it's "prop.value =:identifier" (not ':identifier') otherwise hibernate will consider you use the value ":identifier" and will not replace it.
OK Thomas, I fixed that. Thanks!
----- Original Message ----- From: "Ludovic Dubost" <[email protected]> To: "XWiki Developers" <[email protected]> Sent: Monday, July 28, 2008 11:53 AM Subject: [gsoc] Re: [xwiki-devs] Problems creating a query using the QueryManager
Hi Markus,
Line 73 of AbstractQueryManager
query = (Query) componentManager.lookup(Query.ROLE, language);
Your componentManager is null.. This probably means that you have not activated the component manager from plexus properly. Probably Vincent can help, but he will probably need to know how you have build your code.
Ludovic
Markus Lanthaler wrote:
Hi,
I'm currently implementing the last things to finish OpenID authentication support but I have some problems with the query manager. I'm trying to get the document (should be only one) which an attached OpenIdIdentifier object whose "identifier" string property's value has some specific value. I didn't found any documentation apart http://markmail.org/message/jt6m2huqr4r6hvk6 and http://dev.xwiki.org/xwiki/bin/view/Design/XWiki+Query+Language+Specificatio... .
I tried to achieve this by the following code:
public static String findOpenIDUser(String openid_identifier, XWikiContext context) throws XWikiException { XWiki xwiki = context.getWiki();
QueryManager qm = xwiki.getStore().getQueryManager(); Query search_user;
if (qm.hasLanguage(Query.HQL)) { search_user = qm.createQuery(", BaseObject as obj, StringProperty as prop where doc.fullName = obj.name and obj.className = 'XWiki.OpenIdIdentifier' and obj.id=prop.id.id and prop.id.name='identifier' and prop.value = ':identifier'", Query.HQL); } else if (qm.hasLanguage(Query.XPATH)) { search_user = qm.createQuery("/*/*[obj/XWiki/OpenIdIdentifier/@xp:identifier = ':identifier'] ", Query.XPATH); } else throw new RuntimeException();
search_user.bindValue("identifier", openid_identifier);
List<XWikiDocument> found_users = search_user.setLimit(1).execute(); if (found_users.size() > 0) { if (log.isDebugEnabled()) { log.debug("OpenID " + openid_identifier + " already registered."); } return found_users.get(0).getFullName(); }
return null; }
but all I get is a NullPointerException when qm.createQuery(..., Query.HQL) is called. What's wrong with my code?
java.lang.NullPointerException at com .xpn .xwiki .store .query.AbstractQueryManager.createQuery(AbstractQueryManager.java: 73) at com .xpn .xwiki .user.impl.openid.OpenIDHelper.findOpenIDUser(OpenIDHelper.java:109) at com .xpn .xwiki .user .impl .xwiki.MyFormAuthenticator.processLogin(MyFormAuthenticator.java: 201) at com .xpn .xwiki .user .impl .xwiki.MyFormAuthenticator.processLogin(MyFormAuthenticator.java: 178) at com .xpn .xwiki .user .impl .xwiki.XWikiAuthServiceImpl.checkAuth(XWikiAuthServiceImpl.java:205) at com.xpn.xwiki.XWiki.checkAuth(XWiki.java:3518) at com .xpn .xwiki .user .impl .xwiki .XWikiRightServiceImpl.checkAccess(XWikiRightServiceImpl.java:139) at com.xpn.xwiki.XWiki.checkAccess(XWiki.java:3526) at com.xpn.xwiki.XWiki.prepareDocuments(XWiki.java:4432) at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:190) at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:115) at org .apache .struts .action .RequestProcessor.processActionPerform(RequestProcessor.java:431) at org .apache .struts.action.RequestProcessor.process(RequestProcessor.java:236) at org.apache.struts.action.ActionServlet.process(ActionServlet.java: 1196) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java: 432) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org .apache .catalina .core .ApplicationFilterChain .internalDoFilter(ApplicationFilterChain.java:290) at org .apache .catalina .core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java: 206) at com .xpn .xwiki .web .SavedRequestRestorerFilter .doFilter(SavedRequestRestorerFilter.java:287) at org .apache .catalina .core .ApplicationFilterChain .internalDoFilter(ApplicationFilterChain.java:235) at org .apache .catalina .core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java: 206) at com .xpn .xwiki .web .SetCharacterEncodingFilter .doFilter(SetCharacterEncodingFilter.java:112) 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:175) 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: 844) 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)
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Ludovic Dubost Blog: http://blog.ludovic.org/ XWiki: http://www.xwiki.com Skype: ldubost GTalk: ldubost
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
On Mon, Jul 28, 2008 at 12:17 PM, Markus Lanthaler <[email protected]> wrote:
Hi Ludovic,
I just created a class OpenIDHelper which has a static method findOpenIDUser(). That method is called in the already existent class MyFormAuthenticator which I extended a bit. Shouldn't the component manager be set up already in that "context"? Do you need any other details?
Yes i did not look close enough the stack trace. So I don't understand why this is not already initialized...
I think it's "prop.value =:identifier" (not ':identifier') otherwise hibernate will consider you use the value ":identifier" and will not replace it.
OK Thomas, I fixed that. Thanks!
----- Original Message ----- From: "Ludovic Dubost" <[email protected]> To: "XWiki Developers" <[email protected]> Sent: Monday, July 28, 2008 11:53 AM Subject: [gsoc] Re: [xwiki-devs] Problems creating a query using the QueryManager
Hi Markus,
Line 73 of AbstractQueryManager
query = (Query) componentManager.lookup(Query.ROLE, language);
Your componentManager is null.. This probably means that you have not activated the component manager from plexus properly. Probably Vincent can help, but he will probably need to know how you have build your code.
Ludovic
Markus Lanthaler wrote:
Hi,
I'm currently implementing the last things to finish OpenID authentication support but I have some problems with the query manager. I'm trying to get the document (should be only one) which an attached OpenIdIdentifier object whose "identifier" string property's value has some specific value. I didn't found any documentation apart http://markmail.org/message/jt6m2huqr4r6hvk6 and http://dev.xwiki.org/xwiki/bin/view/Design/XWiki+Query+Language+Specificatio....
I tried to achieve this by the following code:
public static String findOpenIDUser(String openid_identifier, XWikiContext context) throws XWikiException { XWiki xwiki = context.getWiki();
QueryManager qm = xwiki.getStore().getQueryManager(); Query search_user;
if (qm.hasLanguage(Query.HQL)) { search_user = qm.createQuery(", BaseObject as obj, StringProperty as prop where doc.fullName = obj.name and obj.className = 'XWiki.OpenIdIdentifier' and obj.id=prop.id.id and prop.id.name='identifier' and prop.value = ':identifier'", Query.HQL); } else if (qm.hasLanguage(Query.XPATH)) { search_user = qm.createQuery("/*/*[obj/XWiki/OpenIdIdentifier/@xp:identifier = ':identifier'] ", Query.XPATH); } else throw new RuntimeException();
search_user.bindValue("identifier", openid_identifier);
List<XWikiDocument> found_users = search_user.setLimit(1).execute(); if (found_users.size() > 0) { if (log.isDebugEnabled()) { log.debug("OpenID " + openid_identifier + " already registered."); } return found_users.get(0).getFullName(); }
return null; }
but all I get is a NullPointerException when qm.createQuery(..., Query.HQL) is called. What's wrong with my code?
java.lang.NullPointerException at com.xpn.xwiki.store.query.AbstractQueryManager.createQuery(AbstractQueryManager.java:73) at com.xpn.xwiki.user.impl.openid.OpenIDHelper.findOpenIDUser(OpenIDHelper.java:109) at com.xpn.xwiki.user.impl.xwiki.MyFormAuthenticator.processLogin(MyFormAuthenticator.java:201) at com.xpn.xwiki.user.impl.xwiki.MyFormAuthenticator.processLogin(MyFormAuthenticator.java:178) at com.xpn.xwiki.user.impl.xwiki.XWikiAuthServiceImpl.checkAuth(XWikiAuthServiceImpl.java:205) at com.xpn.xwiki.XWiki.checkAuth(XWiki.java:3518) at com.xpn.xwiki.user.impl.xwiki.XWikiRightServiceImpl.checkAccess(XWikiRightServiceImpl.java:139) at com.xpn.xwiki.XWiki.checkAccess(XWiki.java:3526) at com.xpn.xwiki.XWiki.prepareDocuments(XWiki.java:4432) at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:190) at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:115) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.xpn.xwiki.web.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:287) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.xpn.xwiki.web.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:112) 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:175) 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:844) 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)
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Ludovic Dubost Blog: http://blog.ludovic.org/ XWiki: http://www.xwiki.com Skype: ldubost GTalk: ldubost
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
On Jul 28, 2008, at 12:53 PM, Thomas Mortagne wrote:
On Mon, Jul 28, 2008 at 12:17 PM, Markus Lanthaler <[email protected]> wrote:
Hi Ludovic,
I just created a class OpenIDHelper which has a static method findOpenIDUser(). That method is called in the already existent class MyFormAuthenticator which I extended a bit. Shouldn't the component manager be set up already in that "context"? Do you need any other details?
Yes i did not look close enough the stack trace. So I don't understand why this is not already initialized...
I think I know why: because the code doesn't work :) The AbstractQueryManager should implement Composable. I'm looking into it. Thanks -Vincent
I think it's "prop.value =:identifier" (not ':identifier') otherwise hibernate will consider you use the value ":identifier" and will not replace it.
OK Thomas, I fixed that. Thanks!
----- Original Message ----- From: "Ludovic Dubost" <[email protected]> To: "XWiki Developers" <[email protected]> Sent: Monday, July 28, 2008 11:53 AM Subject: [gsoc] Re: [xwiki-devs] Problems creating a query using the QueryManager
Hi Markus,
Line 73 of AbstractQueryManager
query = (Query) componentManager.lookup(Query.ROLE, language);
Your componentManager is null.. This probably means that you have not activated the component manager from plexus properly. Probably Vincent can help, but he will probably need to know how you have build your code.
Ludovic
Markus Lanthaler wrote:
Hi,
I'm currently implementing the last things to finish OpenID authentication support but I have some problems with the query manager. I'm trying to get the document (should be only one) which an attached OpenIdIdentifier object whose "identifier" string property's value has some specific value. I didn't found any documentation apart http://markmail.org/message/jt6m2huqr4r6hvk6 and http://dev.xwiki.org/xwiki/bin/view/Design/XWiki+Query+Language+Specificatio... .
I tried to achieve this by the following code:
public static String findOpenIDUser(String openid_identifier, XWikiContext context) throws XWikiException { XWiki xwiki = context.getWiki();
QueryManager qm = xwiki.getStore().getQueryManager(); Query search_user;
if (qm.hasLanguage(Query.HQL)) { search_user = qm.createQuery(", BaseObject as obj, StringProperty as prop where doc.fullName = obj.name and obj.className = 'XWiki.OpenIdIdentifier' and obj.id=prop.id.id and prop.id.name='identifier' and prop.value = ':identifier'", Query.HQL); } else if (qm.hasLanguage(Query.XPATH)) { search_user = qm.createQuery("/*/*[obj/XWiki/OpenIdIdentifier/@xp:identifier = ':identifier'] ", Query.XPATH); } else throw new RuntimeException();
search_user.bindValue("identifier", openid_identifier);
List<XWikiDocument> found_users = search_user.setLimit(1).execute(); if (found_users.size() > 0) { if (log.isDebugEnabled()) { log.debug("OpenID " + openid_identifier + " already registered."); } return found_users.get(0).getFullName(); }
return null; }
but all I get is a NullPointerException when qm.createQuery(..., Query.HQL) is called. What's wrong with my code?
java.lang.NullPointerException at com .xpn .xwiki .store .query.AbstractQueryManager.createQuery(AbstractQueryManager.java: 73) at com .xpn .xwiki .user.impl.openid.OpenIDHelper.findOpenIDUser(OpenIDHelper.java: 109) at com .xpn .xwiki .user .impl .xwiki.MyFormAuthenticator.processLogin(MyFormAuthenticator.java: 201) at com .xpn .xwiki .user .impl .xwiki.MyFormAuthenticator.processLogin(MyFormAuthenticator.java: 178) at com .xpn .xwiki .user .impl .xwiki.XWikiAuthServiceImpl.checkAuth(XWikiAuthServiceImpl.java: 205) at com.xpn.xwiki.XWiki.checkAuth(XWiki.java:3518) at com .xpn .xwiki .user .impl .xwiki .XWikiRightServiceImpl.checkAccess(XWikiRightServiceImpl.java:139) at com.xpn.xwiki.XWiki.checkAccess(XWiki.java:3526) at com.xpn.xwiki.XWiki.prepareDocuments(XWiki.java:4432) at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:190) at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:115) at org .apache .struts .action .RequestProcessor.processActionPerform(RequestProcessor.java:431) at org .apache .struts.action.RequestProcessor.process(RequestProcessor.java:236) at org.apache.struts.action.ActionServlet.process(ActionServlet.java: 1196) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java: 432) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org .apache .catalina .core .ApplicationFilterChain .internalDoFilter(ApplicationFilterChain.java:290) at org .apache .catalina .core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java: 206) at com .xpn .xwiki .web .SavedRequestRestorerFilter .doFilter(SavedRequestRestorerFilter.java:287) at org .apache .catalina .core .ApplicationFilterChain .internalDoFilter(ApplicationFilterChain.java:235) at org .apache .catalina .core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java: 206) at com .xpn .xwiki .web .SetCharacterEncodingFilter .doFilter(SetCharacterEncodingFilter.java:112) 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:175) 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:844) 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)
On Jul 28, 2008, at 1:02 PM, Vincent Massol wrote:
On Jul 28, 2008, at 12:53 PM, Thomas Mortagne wrote:
On Mon, Jul 28, 2008 at 12:17 PM, Markus Lanthaler <[email protected]> wrote:
Hi Ludovic,
I just created a class OpenIDHelper which has a static method findOpenIDUser(). That method is called in the already existent class MyFormAuthenticator which I extended a bit. Shouldn't the component manager be set up already in that "context"? Do you need any other details?
Yes i did not look close enough the stack trace. So I don't understand why this is not already initialized...
I think I know why: because the code doesn't work :)
The AbstractQueryManager should implement Composable.
I'm looking into it.
Markus, Could you svn up, rebuild and try again. I think I've fixed it but since this is not code I know well (it's just been added by Artem) I haven't tested my change. I'm not even sure the Query Manager is working at all since the issue isn't closed: http://jira.xwiki.org/jira/browse/XWIKI-2444 Artem, could you please let us know the status? Thanks -Vincent
I think it's "prop.value =:identifier" (not ':identifier') otherwise hibernate will consider you use the value ":identifier" and will not replace it.
OK Thomas, I fixed that. Thanks!
----- Original Message ----- From: "Ludovic Dubost" <[email protected]> To: "XWiki Developers" <[email protected]> Sent: Monday, July 28, 2008 11:53 AM Subject: [gsoc] Re: [xwiki-devs] Problems creating a query using the QueryManager
Hi Markus,
Line 73 of AbstractQueryManager
query = (Query) componentManager.lookup(Query.ROLE, language);
Your componentManager is null.. This probably means that you have not activated the component manager from plexus properly. Probably Vincent can help, but he will probably need to know how you have build your code.
Ludovic
Markus Lanthaler wrote:
Hi,
I'm currently implementing the last things to finish OpenID authentication support but I have some problems with the query manager. I'm trying to get the document (should be only one) which an attached OpenIdIdentifier object whose "identifier" string property's value has some specific value. I didn't found any documentation apart http://markmail.org/message/jt6m2huqr4r6hvk6 and http://dev.xwiki.org/xwiki/bin/view/Design/XWiki+Query+Language+Specificatio... .
I tried to achieve this by the following code:
public static String findOpenIDUser(String openid_identifier, XWikiContext context) throws XWikiException { XWiki xwiki = context.getWiki();
QueryManager qm = xwiki.getStore().getQueryManager(); Query search_user;
if (qm.hasLanguage(Query.HQL)) { search_user = qm.createQuery(", BaseObject as obj, StringProperty as prop where doc.fullName = obj.name and obj.className = 'XWiki.OpenIdIdentifier' and obj.id=prop.id.id and prop.id.name='identifier' and prop.value = ':identifier'", Query.HQL); } else if (qm.hasLanguage(Query.XPATH)) { search_user = qm.createQuery("/*/*[obj/XWiki/OpenIdIdentifier/@xp:identifier = ':identifier'] ", Query.XPATH); } else throw new RuntimeException();
search_user.bindValue("identifier", openid_identifier);
List<XWikiDocument> found_users = search_user.setLimit(1).execute(); if (found_users.size() > 0) { if (log.isDebugEnabled()) { log.debug("OpenID " + openid_identifier + " already registered."); } return found_users.get(0).getFullName(); }
return null; }
but all I get is a NullPointerException when qm.createQuery(..., Query.HQL) is called. What's wrong with my code?
java.lang.NullPointerException at com .xpn .xwiki .store .query .AbstractQueryManager.createQuery(AbstractQueryManager.java:73) at com .xpn .xwiki .user.impl.openid.OpenIDHelper.findOpenIDUser(OpenIDHelper.java: 109) at com .xpn .xwiki .user .impl .xwiki.MyFormAuthenticator.processLogin(MyFormAuthenticator.java: 201) at com .xpn .xwiki .user .impl .xwiki.MyFormAuthenticator.processLogin(MyFormAuthenticator.java: 178) at com .xpn .xwiki .user .impl .xwiki.XWikiAuthServiceImpl.checkAuth(XWikiAuthServiceImpl.java: 205) at com.xpn.xwiki.XWiki.checkAuth(XWiki.java:3518) at com .xpn .xwiki .user .impl .xwiki .XWikiRightServiceImpl.checkAccess(XWikiRightServiceImpl.java:139) at com.xpn.xwiki.XWiki.checkAccess(XWiki.java:3526) at com.xpn.xwiki.XWiki.prepareDocuments(XWiki.java:4432) at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:190) at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:115) at org .apache .struts .action .RequestProcessor.processActionPerform(RequestProcessor.java:431) at org .apache .struts.action.RequestProcessor.process(RequestProcessor.java:236) at org .apache.struts.action.ActionServlet.process(ActionServlet.java: 1196) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java: 432) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org .apache .catalina .core .ApplicationFilterChain .internalDoFilter(ApplicationFilterChain.java:290) at org .apache .catalina .core .ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com .xpn .xwiki .web .SavedRequestRestorerFilter .doFilter(SavedRequestRestorerFilter.java:287) at org .apache .catalina .core .ApplicationFilterChain .internalDoFilter(ApplicationFilterChain.java:235) at org .apache .catalina .core .ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com .xpn .xwiki .web .SetCharacterEncodingFilter .doFilter(SetCharacterEncodingFilter.java:112) 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:175) 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:844) 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)
Hi, Vincent. Vincent Massol wrote:
On Jul 28, 2008, at 1:02 PM, Vincent Massol wrote:
On Jul 28, 2008, at 12:53 PM, Thomas Mortagne wrote:
On Mon, Jul 28, 2008 at 12:17 PM, Markus Lanthaler <[email protected]> wrote:
Hi Ludovic,
I just created a class OpenIDHelper which has a static method findOpenIDUser(). That method is called in the already existent class MyFormAuthenticator which I extended a bit. Shouldn't the component manager be set up already in that "context"? Do you need any other details? Yes i did not look close enough the stack trace. So I don't understand why this is not already initialized... I think I know why: because the code doesn't work :)
The AbstractQueryManager should implement Composable.
Yes. I forgot to add QueryManager as <requirement> while moving code to clean svn workcopy. But Composable it fine also. It is affect only to #createQuery, but not to #getNamedQuery.
I'm looking into it.
Markus,
Could you svn up, rebuild and try again. I think I've fixed it but since this is not code I know well (it's just been added by Artem) I haven't tested my change. I'm not even sure the Query Manager is working at all since the issue isn't closed: http://jira.xwiki.org/jira/browse/XWIKI-2444
Artem, could you please let us know the status?
[Hibernate]QueryManager is already working. There are some named queries used in XWiki class. XWIKI-2444 is still open for testing in case of some issues. -- Artem Melentyev
Hi, Markus. Markus Lanthaler wrote:
... if (qm.hasLanguage(Query.HQL)) { search_user = qm.createQuery(", BaseObject as obj, StringProperty as prop where doc.fullName = obj.name and obj.className = 'XWiki.OpenIdIdentifier' and obj.id=prop.id.id and prop.id.name='identifier' and prop.value = ':identifier'", Query.HQL);
query statement should be full HQL statement (not such as in store#search* methods), so it should be "from XWikiDocument as doc, BaseObject as obj, StringProperty as prop where doc.fullName = obj.name and obj.className = 'XWiki.OpenIdIdentifier' and obj.id=prop.id.id and prop.id.name='identifier' and prop.value = :identifier", Query.HQL);"
} else if (qm.hasLanguage(Query.XPATH)) { search_user = qm.createQuery("/*/*[obj/XWiki/OpenIdIdentifier/@xp:identifier = ':identifier'] ", Query.XPATH); } else throw new RuntimeException();
Query.XPATH parameters should be with braces: ":{identifier}". (It is difficult to use ":identifier" because of ambiguous with xml namespaces (ex: "xwiki:document", "xp:property") in XPath language. There is no xpath parameters in JCR v1 standard, so I implement it by self.)
search_user.bindValue("identifier", openid_identifier);
List<XWikiDocument> found_users = search_user.setLimit(1).execute(); if (found_users.size() > 0) { if (log.isDebugEnabled()) { log.debug("OpenID " + openid_identifier + " already registered."); } return found_users.get(0).getFullName(); }
return null; }
I recommend you to use named queries. See http://xwiki.markmail.org/message/tui6w6d5d27tirda You need to move hql statements to queries.hbm.xml, xpath statements to JcrQueries.properties, and use queryManager.getNamedQuery(qname). Don't worry about XPath queries, I'll add them by self after JcrStore will work fine. So you can write only hql queries.
but all I get is a NullPointerException when qm.createQuery(..., Query.HQL) is called. What's wrong with my code?
This should work after Vincent fix. -- Artem Melentyev
Sorry for the late answer but I had problems with my installation after the SVN update. Now I don't get any exception anymore - but also no result. I tried both, creating a named query by adding the following code to queries.hbm.xml and creating the query directly. <query name="getUserDocByOpenIdIdentifier"> select doc.fullName from XWikiDocument as doc, BaseObject as obj, StringProperty as prop where doc.fullName=obj.name and obj.className='XWiki.OpenIdIdentifier' and obj.id=prop.id.id and prop.id.name='identifier' and prop.value=:identifier </query> This sets the statement member in the returned query qm.getNamedQuery("getUserDocByOpenIdIdentifier") to "getUserDocByOpenIdIdentifier". Is that right!? I tried also to create the query directly (also including "select doc.fullName"): Query search_user2 = qm.getNamedQuery("getUserDocByOpenIdIdentifier"); search_user2 = qm.createQuery("from XWikiDocument as doc, BaseObject as obj, StringProperty as prop where doc.fullName = obj.name and obj.className = 'XWiki.OpenIdIdentifier' and obj.id=prop.id.id and prop.id.name='identifier' and prop.value = :identifier", Query.HQL); search_user2.bindValue("identifier", openid_identifier); List<XWikiDocument> found_users2 = search_user2.setLimit(1).execute(); if (found_users2.size() > 0) { return found_users2.get(0).getFullName(); } Both queries returned empty lists. I checked the DB with the MySQL Query Browser and saw that there are the right entries in xwikistrings, xwikiobjects and xwikidoc so they are saved in the right way. Are the table names converted automatically? There is no table XWikiDocument in my DB but just xwikidoc for instance. ----- Original Message ----- From: "Artem Melentyev" <[email protected]> To: "XWiki Developers" <[email protected]> Sent: Monday, July 28, 2008 3:47 PM Subject: [gsoc] Re: [xwiki-devs] Problems creating a query using the QueryManager
Hi, Markus.
Markus Lanthaler wrote:
... if (qm.hasLanguage(Query.HQL)) { search_user = qm.createQuery(", BaseObject as obj, StringProperty as prop where doc.fullName = obj.name and obj.className = 'XWiki.OpenIdIdentifier' and obj.id=prop.id.id and prop.id.name='identifier' and prop.value = ':identifier'", Query.HQL);
query statement should be full HQL statement (not such as in store#search* methods), so it should be "from XWikiDocument as doc, BaseObject as obj, StringProperty as prop where doc.fullName = obj.name and obj.className = 'XWiki.OpenIdIdentifier' and obj.id=prop.id.id and prop.id.name='identifier' and prop.value = :identifier", Query.HQL);"
} else if (qm.hasLanguage(Query.XPATH)) { search_user = qm.createQuery("/*/*[obj/XWiki/OpenIdIdentifier/@xp:identifier = ':identifier'] ", Query.XPATH); } else throw new RuntimeException();
Query.XPATH parameters should be with braces: ":{identifier}". (It is difficult to use ":identifier" because of ambiguous with xml namespaces (ex: "xwiki:document", "xp:property") in XPath language. There is no xpath parameters in JCR v1 standard, so I implement it by self.)
search_user.bindValue("identifier", openid_identifier);
List<XWikiDocument> found_users = search_user.setLimit(1).execute(); if (found_users.size() > 0) { if (log.isDebugEnabled()) { log.debug("OpenID " + openid_identifier + " already registered."); } return found_users.get(0).getFullName(); }
return null; }
I recommend you to use named queries. See http://xwiki.markmail.org/message/tui6w6d5d27tirda You need to move hql statements to queries.hbm.xml, xpath statements to JcrQueries.properties, and use queryManager.getNamedQuery(qname).
Don't worry about XPath queries, I'll add them by self after JcrStore will work fine. So you can write only hql queries.
but all I get is a NullPointerException when qm.createQuery(..., Query.HQL) is called. What's wrong with my code?
This should work after Vincent fix.
-- Artem Melentyev _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Hi, Markus. I tired it and it work fine for me. I created XWiki.OpenIdIdentifier class with StringProperty field. Added it to XWiki.Admin user page (identifier='someurl') and used this groovy script inside xwiki page for test: <% println xwiki.xWiki.store.queryManager.createQuery("select doc.fullName" +" from XWikiDocument as doc, BaseObject as obj, StringProperty as prop" +" where doc.fullName = obj.name and obj.className = 'XWiki.OpenIdIdentifier' " +" and obj.id=prop.id.id and prop.id.name='identifier' and prop.value = :identifier", "hql").bindValue("identifier", "someurl").execute() %> named query also works for me. I recently commit some fix for hibernate queries. Maybe it will fix your problem. Please svn up and try again. Try also old XWikiStoreInterface#search* methods if QueryManager will not work. Markus Lanthaler wrote:
Sorry for the late answer but I had problems with my installation after the SVN update. Now I don't get any exception anymore - but also no result. I tried both, creating a named query by adding the following code to queries.hbm.xml and creating the query directly.
<query name="getUserDocByOpenIdIdentifier"> select doc.fullName from XWikiDocument as doc, BaseObject as obj, StringProperty as prop where doc.fullName=obj.name and obj.className='XWiki.OpenIdIdentifier' and obj.id=prop.id.id and prop.id.name='identifier' and prop.value=:identifier </query>
This sets the statement member in the returned query qm.getNamedQuery("getUserDocByOpenIdIdentifier") to "getUserDocByOpenIdIdentifier". Is that right!?
I tried also to create the query directly (also including "select doc.fullName"):
Query search_user2 = qm.getNamedQuery("getUserDocByOpenIdIdentifier"); search_user2 = qm.createQuery("from XWikiDocument as doc, BaseObject as obj, StringProperty as prop where doc.fullName = obj.name and obj.className = 'XWiki.OpenIdIdentifier' and obj.id=prop.id.id and prop.id.name='identifier' and prop.value = :identifier", Query.HQL);
search_user2.bindValue("identifier", openid_identifier);
List<XWikiDocument> found_users2 = search_user2.setLimit(1).execute(); if (found_users2.size() > 0) { return found_users2.get(0).getFullName(); }
Both queries returned empty lists.
I checked the DB with the MySQL Query Browser and saw that there are the right entries in xwikistrings, xwikiobjects and xwikidoc so they are saved in the right way. Are the table names converted automatically? There is no table XWikiDocument in my DB but just xwikidoc for instance.
Hibernate automatically transform class names to its db tables. Look xwiki.hbm.xml for mapping.
...
-- Artem Melentyev
Hi Artem, Now it works! Another SVN update this morning fixed it. Thank you very much for your help! ----- Original Message ----- From: "Artem Melentyev" <[email protected]> To: "XWiki Developers" <[email protected]> Sent: Tuesday, July 29, 2008 9:46 PM Subject: [gsoc] Re: [xwiki-devs] Problems creating a query using the QueryManager
Hi, Markus.
I tired it and it work fine for me.
I created XWiki.OpenIdIdentifier class with StringProperty field. Added it to XWiki.Admin user page (identifier='someurl') and used this groovy script inside xwiki page for test: <% println xwiki.xWiki.store.queryManager.createQuery("select doc.fullName" +" from XWikiDocument as doc, BaseObject as obj, StringProperty as prop" +" where doc.fullName = obj.name and obj.className = 'XWiki.OpenIdIdentifier' " +" and obj.id=prop.id.id and prop.id.name='identifier' and prop.value = :identifier", "hql").bindValue("identifier", "someurl").execute() %> named query also works for me.
I recently commit some fix for hibernate queries. Maybe it will fix your problem. Please svn up and try again.
Try also old XWikiStoreInterface#search* methods if QueryManager will not work.
Markus Lanthaler wrote:
Sorry for the late answer but I had problems with my installation after the SVN update. Now I don't get any exception anymore - but also no result. I tried both, creating a named query by adding the following code to queries.hbm.xml and creating the query directly.
<query name="getUserDocByOpenIdIdentifier"> select doc.fullName from XWikiDocument as doc, BaseObject as obj, StringProperty as prop where doc.fullName=obj.name and obj.className='XWiki.OpenIdIdentifier' and obj.id=prop.id.id and prop.id.name='identifier' and prop.value=:identifier </query>
This sets the statement member in the returned query qm.getNamedQuery("getUserDocByOpenIdIdentifier") to "getUserDocByOpenIdIdentifier". Is that right!?
I tried also to create the query directly (also including "select doc.fullName"):
Query search_user2 = qm.getNamedQuery("getUserDocByOpenIdIdentifier"); search_user2 = qm.createQuery("from XWikiDocument as doc, BaseObject as obj, StringProperty as prop where doc.fullName = obj.name and obj.className = 'XWiki.OpenIdIdentifier' and obj.id=prop.id.id and prop.id.name='identifier' and prop.value = :identifier", Query.HQL);
search_user2.bindValue("identifier", openid_identifier);
List<XWikiDocument> found_users2 = search_user2.setLimit(1).execute(); if (found_users2.size() > 0) { return found_users2.get(0).getFullName(); }
Both queries returned empty lists.
I checked the DB with the MySQL Query Browser and saw that there are the right entries in xwikistrings, xwikiobjects and xwikidoc so they are saved in the right way. Are the table names converted automatically? There is no table XWikiDocument in my DB but just xwikidoc for instance.
Hibernate automatically transform class names to its db tables. Look xwiki.hbm.xml for mapping.
...
-- Artem Melentyev _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
participants (5)
-
Artem Melentyev -
Ludovic Dubost -
Markus Lanthaler -
Thomas Mortagne -
Vincent Massol