On Fri, Sep 19, 2008 at 7:54 PM, mh <mhendred(a)gmail.com> wrote:
Hi, Thanks for the response. But there are still a
couple issues. Here
is a review of my setup again. I have a xwiki manager with a couple
wikis on it. ill call the xem controller wiki "controllerwiki", and
the virtual wikis "wikiA" and "wikiB" This is the code im using:
-------------------------------
#set ($WikiManager = $xwiki.wikimanager)
#set($wikiDesc = $WikiManager.getWikiFromName("wikiA"))
#set($wikiAlias = $wikiDesc.firstWikiAlias)
$wikiAlias
------------------------------
When I put this code in a page called "Test" on the controller wiki, i
get the following:
XWiki.XWikiServerWikiA,wikiA.domain.net,XWiki.Admin
but when i put this code in a page called "Test" in wikiA I get a
stack trace. here it is:
Error number 4001 in 4: Error while parsing velocity page Main.Test
Wrapped Exception: Failed to evaluate content with id Test
com.xpn.xwiki.XWikiException: Error number 4001 in 4: Error while
parsing velocity page Main.Test
Wrapped Exception: Failed to evaluate content with id Test
at
com.xpn.xwiki.render.XWikiVelocityRenderer.evaluate(XWikiVelocityRenderer.java:112)
at
com.xpn.xwiki.render.XWikiVelocityRenderer.render(XWikiVelocityRenderer.java:87)
at
com.xpn.xwiki.render.DefaultXWikiRenderingEngine.renderText(DefaultXWikiRenderingEngine.java:272)
at
com.xpn.xwiki.render.DefaultXWikiRenderingEngine.renderText(DefaultXWikiRenderingEngine.java:202)
at
com.xpn.xwiki.render.DefaultXWikiRenderingEngine.renderText(DefaultXWikiRenderingEngine.java:170)
at
com.xpn.xwiki.render.DefaultXWikiRenderingEngine.renderDocument(DefaultXWikiRenderingEngine.java:159)
at com.xpn.xwiki.doc.XWikiDocument.getRenderedContent(XWikiDocument.java:430)
at com.xpn.xwiki.api.Document.getRenderedContent(Document.java:371)
at sun.reflect.GeneratedMethodAccessor263.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:295)
at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:245)
at
org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:203)
at
org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:294)
at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:318)
at
org.xwiki.velocity.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:178)
at
org.xwiki.velocity.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:143)
at
com.xpn.xwiki.render.XWikiVelocityRenderer.evaluate(XWikiVelocityRenderer.java:107)
at com.xpn.xwiki.XWiki.parseTemplate(XWiki.java:1596)
at com.xpn.xwiki.api.XWiki.parseTemplate(XWiki.java:608)
at sun.reflect.GeneratedMethodAccessor150.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:295)
at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:245)
at
org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:203)
at
org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:294)
at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:318)
at
org.apache.velocity.runtime.directive.VelocimacroProxy.render(VelocimacroProxy.java:194)
at
org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:170)
at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:74)
at
org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:88)
at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:74)
at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:318)
at
org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:107)
at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:318)
at
org.xwiki.velocity.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:178)
at
org.xwiki.velocity.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:143)
at
com.xpn.xwiki.render.XWikiVelocityRenderer.evaluate(XWikiVelocityRenderer.java:107)
at com.xpn.xwiki.XWiki.parseTemplate(XWiki.java:1596)
at com.xpn.xwiki.web.Utils.parseTemplate(Utils.java:125)
at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:226)
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.doGet(ActionServlet.java:414)
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
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: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.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:697)
at
org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:889)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
at java.lang.Thread.run(Thread.java:595)
Wrapped Exception:
org.apache.velocity.exception.MethodInvocationException: Invocation of
method 'getFirstWikiAlias' in class
com.xpn.xwiki.plugin.wikimanager.doc.Wiki threw exception
java.lang.NullPointerException @ Main.Test3,29? at
org.apache.velocity.runtime.parser.node.ASTIdentifier.execute(ASTIdentifier.java:205)
at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:203)
at org.apache.velocity.runtime.parser.node.ASTReference.value(ASTReference.java:419)
at org.apache.velocity.runtime.parser.node.ASTExpression.value(ASTExpression.java:73)
at
org.apache.velocity.runtime.parser.node.ASTSetDirective.render(ASTSetDirective.java:125)
at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:318)
at org.xwiki.velocity.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:178)
at org.xwiki.velocity.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:143)
at com.xpn.xwiki.render.XWikiVelocityRenderer.evaluate(XWikiVelocityRenderer.java:107)
at com.xpn.xwiki.render.XWikiVelocityRenderer.render(XWikiVelocityRenderer.java:87)
at
com.xpn.xwiki.render.DefaultXWikiRenderingEngine.renderText(DefaultXWikiRenderingEngine.java:272)
at
com.xpn.xwiki.render.DefaultXWikiRenderingEngine.renderText(DefaultXWikiRenderingEngine.java:202)
at
com.xpn.xwiki.render.DefaultXWikiRenderingEngine.renderText(DefaultXWikiRenderingEngine.java:170)
at
com.xpn.xwiki.render.DefaultXWikiRenderingEngine.renderDocument(DefaultXWikiRenderingEngine.java:159)
at com.xpn.xwiki.doc.XWikiDocument.getRenderedContent(XWikiDocument.java:430)
at com.xpn.xwiki.api.Document.getRenderedContent(Document.java:371) at
sun.reflect.GeneratedMethodAccessor263.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585) at
org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:295)
at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:245)
at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:203)
at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:294)
at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:318)
at org.xwiki.velocity.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:178)
at org.xwiki.velocity.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:143)
at com.xpn.xwiki.render.XWikiVelocityRenderer.evaluate(XWikiVelocityRenderer.java:107)
at com.xpn.xwiki.XWiki.parseTemplate(XWiki.java:1596) at
com.xpn.xwiki.api.XWiki.parseTemplate(XWiki.java:608) at
sun.reflect.GeneratedMethodAccessor150.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585) at
org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:295)
at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:245)
at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:203)
at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:294)
at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:318)
at
org.apache.velocity.runtime.directive.VelocimacroProxy.render(VelocimacroProxy.java:194)
at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:170)
at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:74)
at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:88)
at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:74)
at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:318)
at
org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:107)
at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:318)
at org.xwiki.velocity.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:178)
at org.xwiki.velocity.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:143)
at com.xpn.xwiki.render.XWikiVelocityRenderer.evaluate(XWikiVelocityRenderer.java:107)
at com.xpn.xwiki.XWiki.parseTemplate(XWiki.java:1596) at
com.xpn.xwiki.web.Utils.parseTemplate(Utils.java:125) at
com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:226) 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.doGet(ActionServlet.java:414)
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
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: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.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:697)
at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:889)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
at java.lang.Thread.run(Thread.java:595) Caused by:
java.lang.NullPointerException at
com.xpn.xwiki.plugin.wikimanager.doc.Wiki.getFirstWikiAlias(Wiki.java:163)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585) at
org.apache.velocity.runtime.parser.node.PropertyExecutor.execute(PropertyExecutor.java:137)
at
org.apache.velocity.util.introspection.UberspectImpl$VelGetterImpl.invoke(UberspectImpl.java:350)
at org.apache.velocity.runtime.parser.node.ASTIdentifier.execute(ASTIdentifier.java:180)
… 78 more
I think this is a bug in wikimanager.getWikiFromName("wikiA"), it
seems it looks in current wiki in place of forcing search in main wiki
for the wiki descriptor (I just added a jira issue
http://jira.xwiki.org/jira/browse/XAWM-88).
1 - A workaround is to get the descriptor "by hand": all wikis
descriptor are in the main wiki with the name
xwiki:XWiki.XWikiServer<Wikiname> with an upper case for the first
character of the wiki name. The velocity code to get the current wiki
descriptor is something like:
#set($wikidescriptor =
$xwiki.getDocument("xwiki:XWiki.XWikiServer${context.database.substring(0,
1).toUpperCase()}${context.database.substring(1).toLowerCase()}"))
and then $wikidescriptor.server give the domain of the first alias (To
get other alias you have to list document's objects of type
"XWiki.XWikiServerClass")
2 - Another solution if your have progrmming rights is simply to
switch to main wiki using $context.setDatabase() before executing
wikimanager plugin code and restore current wiki when it's done:
#set($currentDatabase = $context.database)
$context.setDatabase($context.mainWikiName)
[...]
$context.setDatabase($currentDatabase)
i really need to be able to get the domain name of the wiki im on with
out knowing its name too, so something that takes the name of the wiki
as an arg probably wont work for me. And suggestions? Thanks.
The current wiki is in $context.database
On Fri, Sep 19, 2008 at 1:39 AM, Vincent Massol <vincent(a)massol.net> wrote:
A good faq entry or even better a good code
snippet example for a
tutorial on XEM development.
-Vincent
On Sep 19, 2008, at 10:26 AM, Thomas Mortagne wrote:
Hi,
On Thu, Sep 18, 2008 at 12:55 AM, mh <mhendred(a)gmail.com> wrote:
---------- Forwarded message ----------
From: mh <mhendred(a)gmail.com>
Date: Wed, Sep 17, 2008 at 11:44 AM
Subject: Getting the domain name of a virtual wiki through velocity
To: XWiki Developers <devs(a)xwiki.org>
Hi,
I have an XEM set up with with several virtual wikis on it. I'm
trying
to get the name of the virtual xwiki though velocity. For example,
say
that I have a XEM instance running two virtual wikis:
1)
wikiA.domain.org
2)
wikiB.domain.org
on a XEM called
xem.domain.org
Im looking for the velocity code that will return the name (domain
name) when embedded in a page of one of the virtual wikis. Something
like: $xwiki.getServerName()
if i put that in a page in wikiA, it should return
"wikiA.domain.org".
Likewise, if i put the same code in wikiB, it should return
"wikiB.domain.org"
I looked at the velocity code for
xem.doman.org/xwiki/bin/view/WikiManager/ because it lists the actual
domain names under the "Domain Names" column. But it just gets a list
of any virtual wikis available and lists them out. This page uses the
xwikimanager plugin. I looked at the api and didn't see a way to
directly get the domain name of the wiki in question. Could someone
please point me in the right direction? Thanks in advanced and have a
great day!
The domain name of a wiki is part of it's descriptor (like the owner
of the wiki etc.) and you can get the descriptor using
$wikimanager.getWikiFromName("wikiName"). Then this Wiki object
contains the list of aliasses of this wiki you can get using
getWikiAliasList() if you want them all or getFirstWikiAlias() if you
just want the one generally used when generating URLs like
[wikiname:Sapce.Page]. Here you can find all you see when you look at
XWiki/XWikiServerWikiname : owner, server, description... and some
helper like serverUrl, homePageUrl etc.
So to sumurize your use case in velocity (given that your wiki name is
"wikiname"):
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#set($wikiDesc = $wikimanager.getWikiFromName("wikiname"))
#set($wikiAlias = $wikiDesc.firstWikiAlias)
the server url of wiki "wikiname" is $wikiAlias.serverUrl and it's
home page is at $wikiAlias.homePageUrl
<
<
<
<
<
<
<
<
<
<
<
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
> -mh
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
--
Thomas Mortagne