Hi,
Now that we have a DocumentName and factory/serializer I'd like to
propose that we change all document access bridge APIs to use
DocumentName instead of String. The idea is that string way of
referencing a document should be used only at boundaries of the xwiki
system and internally we should ony use DocumentName. The reasons are
multiple:
* less errors since it's a strongly typed api
* whenever code manipulates DocumentName it can be sure it contains
valid and non null data and thus doesn't need to recheck again
Here's my +1
Thanks
-Vincent
HI,
my xwiki did not evaluate any of the snippets or groovy/velocity class that i wrote
until now not even a helloworld script he just ignore them and display the code as a simple text
the wiki syntax is 1.0
what is going wrong there??
help me with this one please thanks
--
View this message in context: http://n2.nabble.com/Problems-with-scripting-tp2580143p2580143.html
Sent from the XWiki- Dev mailing list archive at Nabble.com.
Hi developers,
I would like to refactor
String getURL(String documentName, String action, String queryString, String
anchor)
in the DocumentAccessBridge (whose documentName is actually used as a document
fullName) to
String getURL(DocumentName documentName, String action, String queryString,
String anchor)
and implement multiwiki support for it, since now it uses XWiki.getURL() which
uses current context wiki to generate the URL.
The calls to current function would be transformed in:
DocumentNameFactory docNameFactory = ...
getURL(docNameFactory.createDocumentName(fullName), ...)
which will have the same result as before.
Since we will need to change all internal reference to documents in
DocumentNames instead of fullNames as Strings, this would be a step in this
direction, facilitated by the new DocumentNameSerializer and DocumentNameFactory.
Here's my +1
WDYT?
Thanks,
Anca Luca
Hi,
Can anyone give me a part of code using XWikiXmlRpcClient in java to get
and put a XWikiPage wich is a XWikiClass (like page XWiki.XWikiSkins page).
I get Class information using :
XWikiClass xwikiClass = curClient.getClass(this.fullName);
SystemOut(xwikiClass.toMap().toString()) ;
But My problem is to put this information because I could only call the
following method wich have no information about Class:
curClient.storePage(xwikiPage);
Thanks,
Julien
Shouldn't we have only one component which do the
serialize/unserialize to make sure the same rule is applied in the two
way ? It seems weird to me to be able to change the way to parse a
document reference and let the document reference creation to another
implementation.
On Fri, Apr 3, 2009 at 22:48, vmassol <platform-notifications(a)xwiki.org> wrote:
> Author: vmassol
> Date: 2009-04-03 22:48:34 +0200 (Fri, 03 Apr 2009)
> New Revision: 18236
>
> Added:
> platform/core/branches/xwiki-core-1.8/xwiki-bridge/src/main/java/org/xwiki/bridge/DocumentNameFactory.java
> platform/core/branches/xwiki-core-1.8/xwiki-bridge/src/main/java/org/xwiki/bridge/DocumentNameSerializer.java
> platform/core/branches/xwiki-core-1.8/xwiki-core/src/main/java/com/xpn/xwiki/doc/DefaultDocumentNameFactory.java
> platform/core/branches/xwiki-core-1.8/xwiki-core/src/main/java/com/xpn/xwiki/doc/DefaultDocumentNameSerializer.java
> platform/core/branches/xwiki-core-1.8/xwiki-core/src/test/java/com/xpn/xwiki/doc/DefaultDocumentNameFactoryTest.java
> platform/core/branches/xwiki-core-1.8/xwiki-core/src/test/java/com/xpn/xwiki/doc/DefaultDocumentNameSerializerTest.java
> Modified:
> platform/core/branches/xwiki-core-1.8/xwiki-core/src/main/resources/META-INF/plexus/components.xml
> Log:
> XWIKI-3501: Add Document Name factory and serializer
>
> Merged from trunk (rev 18235)
>
>
> Added: platform/core/branches/xwiki-core-1.8/xwiki-bridge/src/main/java/org/xwiki/bridge/DocumentNameFactory.java
> ===================================================================
> --- platform/core/branches/xwiki-core-1.8/xwiki-bridge/src/main/java/org/xwiki/bridge/DocumentNameFactory.java (rev 0)
> +++ platform/core/branches/xwiki-core-1.8/xwiki-bridge/src/main/java/org/xwiki/bridge/DocumentNameFactory.java 2009-04-03 20:48:34 UTC (rev 18236)
> @@ -0,0 +1,41 @@
> +/*
> + * See the NOTICE file distributed with this work for additional
> + * information regarding copyright ownership.
> + *
> + * This is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU Lesser General Public License as
> + * published by the Free Software Foundation; either version 2.1 of
> + * the License, or (at your option) any later version.
> + *
> + * This software is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this software; if not, write to the Free
> + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
> + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
> + */
> +package org.xwiki.bridge;
> +
> +/**
> + * Generate a Document Name from a raw string reference.
> + *
> + * @version $Id: $
> + * @since 1.8.1
> + */
> +public interface DocumentNameFactory
> +{
> + /**
> + * Role for looking up implementing components.
> + */
> + String ROLE = DocumentNameFactory.class.getName();
> +
> + /**
> + * @param reference the document's name as a string using a textual format (eg {@code wiki:space.page}).
> + * The supported format is up to implementers of this method.
> + * @return the object representing a document reference
> + */
> + DocumentName createDocumentName(String reference);
> +}
>
> Added: platform/core/branches/xwiki-core-1.8/xwiki-bridge/src/main/java/org/xwiki/bridge/DocumentNameSerializer.java
> ===================================================================
> --- platform/core/branches/xwiki-core-1.8/xwiki-bridge/src/main/java/org/xwiki/bridge/DocumentNameSerializer.java (rev 0)
> +++ platform/core/branches/xwiki-core-1.8/xwiki-bridge/src/main/java/org/xwiki/bridge/DocumentNameSerializer.java 2009-04-03 20:48:34 UTC (rev 18236)
> @@ -0,0 +1,41 @@
> +/*
> + * See the NOTICE file distributed with this work for additional
> + * information regarding copyright ownership.
> + *
> + * This is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU Lesser General Public License as
> + * published by the Free Software Foundation; either version 2.1 of
> + * the License, or (at your option) any later version.
> + *
> + * This software is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this software; if not, write to the Free
> + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
> + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
> + */
> +package org.xwiki.bridge;
> +
> +/**
> + * Generate a fully qualified document reference string (ie of the form
> + * {@code wiki:space.page}) out of a {@link DocumentName}.
> + *
> + * @version $Id: $
> + * @since 1.8.1
> + */
> +public interface DocumentNameSerializer
> +{
> + /**
> + * Role for looking up implementing components.
> + */
> + String ROLE = DocumentNameSerializer.class.getName();
> +
> + /**
> + * @param documentName the document name to serialize
> + * @return the fully qualified document reference string (ie of the form {@code wiki:space.page})
> + */
> + String serialize(DocumentName documentName);
> +}
>
> Added: platform/core/branches/xwiki-core-1.8/xwiki-core/src/main/java/com/xpn/xwiki/doc/DefaultDocumentNameFactory.java
> ===================================================================
> --- platform/core/branches/xwiki-core-1.8/xwiki-core/src/main/java/com/xpn/xwiki/doc/DefaultDocumentNameFactory.java (rev 0)
> +++ platform/core/branches/xwiki-core-1.8/xwiki-core/src/main/java/com/xpn/xwiki/doc/DefaultDocumentNameFactory.java 2009-04-03 20:48:34 UTC (rev 18236)
> @@ -0,0 +1,163 @@
> +/*
> + * See the NOTICE file distributed with this work for additional
> + * information regarding copyright ownership.
> + *
> + * This is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU Lesser General Public License as
> + * published by the Free Software Foundation; either version 2.1 of
> + * the License, or (at your option) any later version.
> + *
> + * This software is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this software; if not, write to the Free
> + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
> + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
> + */
> +package com.xpn.xwiki.doc;
> +
> +import org.apache.commons.lang.StringUtils;
> +import org.xwiki.bridge.DocumentName;
> +import org.xwiki.bridge.DocumentNameFactory;
> +import org.xwiki.context.Execution;
> +
> +import com.xpn.xwiki.XWikiContext;
> +
> +/**
> + * Generate a Document Name from a raw string reference.
> + *
> + * @version $Id: $
> + * @since 1.8.1
> + */
> +public class DefaultDocumentNameFactory implements DocumentNameFactory
> +{
> + /**
> + * Default space to use when the user has not specified any space and there's no current space set in the context.
> + */
> + private static final String DEFAULT_SPACE = "XWiki";
> +
> + /**
> + * Default page name when the user has not specified the page name.
> + */
> + private static final String DEFAULT_PAGE = "WebHome";
> +
> + /**
> + * Default wiki to use when the user has not specified any wiki and there's no current wiki set in the context.
> + */
> + private static final String DEFAULT_WIKI = "xwiki";
> +
> + private static final String WIKI_SEPARATOR = ":";
> +
> + private static final String SPACE_SEPARATOR = ".";
> +
> + /**
> + * Execution context handler, needed for accessing the XWikiContext.
> + */
> + private Execution execution;
> +
> + public DocumentName createDocumentName(String reference)
> + {
> + String wiki;
> + String space;
> + String page;
> +
> + if (StringUtils.isBlank(reference)) {
> + wiki = getDefaultWikiName();
> + space = getDefaultSpaceName();
> + page = DEFAULT_PAGE;
> + } else {
> +
> + // Step 1: Extract the wiki name
> +
> + // We allow the wiki separator in wiki names and thus we look for the last wiki sep in the reference.
> + // TODO: Note that this was done to have the same behavior of XWikiDocument.setFullName() but it would
> + // seem better to me to allow the wiki sep in space names rather than in wiki names (since wiki
> + // names are constrained by database schema names).
> + int spaceSeparatorPosition;
> + int wikiSeparatorPosition = reference.lastIndexOf(WIKI_SEPARATOR);
> + if (wikiSeparatorPosition != -1) {
> + wiki = reference.substring(0, wikiSeparatorPosition);
> + if (wiki.length() == 0) {
> + wiki = getDefaultWikiName();
> + }
> +
> + spaceSeparatorPosition = reference.indexOf(SPACE_SEPARATOR, wikiSeparatorPosition);
> + } else {
> + // No wiki separator, use default wiki.
> + wiki = getDefaultWikiName();
> +
> + // We allow space sep in space names and thus we look for the last space sep in the reference.
> + // TODO: Note that this was done to have the same behavior of XWikiDocument.setFullName() but it would
> + // seem better to me to allow space sep in pages names rather than in space names (since users
> + // want more liberty in page names and usually create pages in existing spaces).
> + spaceSeparatorPosition = reference.lastIndexOf(SPACE_SEPARATOR);
> + }
> +
> + // Step 2: Extract the space and page names
> +
> + if (spaceSeparatorPosition != -1) {
> + space = reference.substring(wikiSeparatorPosition + WIKI_SEPARATOR.length(),
> + spaceSeparatorPosition);
> + if (space.length() == 0) {
> + space = getDefaultSpaceName();
> + }
> +
> + // Make sure the space separator is not the last char of the reference
> + if (spaceSeparatorPosition + SPACE_SEPARATOR.length() < reference.length()) {
> + page = reference.substring(spaceSeparatorPosition + SPACE_SEPARATOR.length());
> + } else {
> + page = DEFAULT_PAGE;
> + }
> + } else {
> + // No space separator the whole substring is thus the page.
> + space = getDefaultSpaceName();
> +
> + // Make sure the wiki separator is not the last char of the reference
> + if (wikiSeparatorPosition == -1
> + || wikiSeparatorPosition + WIKI_SEPARATOR.length() < reference.length())
> + {
> + page = reference.substring(wikiSeparatorPosition + WIKI_SEPARATOR.length());
> + } else {
> + page = DEFAULT_PAGE;
> + }
> + }
> + }
> +
> + return new DocumentName(wiki, space, page);
> + }
> +
> + private String getDefaultWikiName()
> + {
> + String wiki = getContext().getDatabase();
> + if (wiki == null) {
> + wiki = DEFAULT_WIKI;
> + }
> + return wiki;
> + }
> +
> + private String getDefaultSpaceName()
> + {
> + String space;
> + XWikiDocument currentDocument = getContext().getDoc();
> + if (currentDocument == null) {
> + space = DEFAULT_SPACE;
> + } else {
> + space = currentDocument.getSpace();
> + if (space == null) {
> + space = DEFAULT_SPACE;
> + }
> + }
> + return space;
> + }
> +
> + /**
> + * @return the XWiki Context used to bridge with the old API
> + */
> + private XWikiContext getContext()
> + {
> + return (XWikiContext) this.execution.getContext().getProperty("xwikicontext");
> + }
> +}
>
> Added: platform/core/branches/xwiki-core-1.8/xwiki-core/src/main/java/com/xpn/xwiki/doc/DefaultDocumentNameSerializer.java
> ===================================================================
> --- platform/core/branches/xwiki-core-1.8/xwiki-core/src/main/java/com/xpn/xwiki/doc/DefaultDocumentNameSerializer.java (rev 0)
> +++ platform/core/branches/xwiki-core-1.8/xwiki-core/src/main/java/com/xpn/xwiki/doc/DefaultDocumentNameSerializer.java 2009-04-03 20:48:34 UTC (rev 18236)
> @@ -0,0 +1,51 @@
> +/*
> + * See the NOTICE file distributed with this work for additional
> + * information regarding copyright ownership.
> + *
> + * This is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU Lesser General Public License as
> + * published by the Free Software Foundation; either version 2.1 of
> + * the License, or (at your option) any later version.
> + *
> + * This software is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this software; if not, write to the Free
> + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
> + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
> + */
> +package com.xpn.xwiki.doc;
> +
> +import org.xwiki.bridge.DocumentName;
> +import org.xwiki.bridge.DocumentNameSerializer;
> +
> +/**
> + * Generate a fully qualified document reference string (ie of the form
> + * {@code <wiki>:<space>.<page>} out of a {@link DocumentName}.
> + *
> + * @version $Id: $
> + * @since 1.8.1
> + */
> +public class DefaultDocumentNameSerializer implements DocumentNameSerializer
> +{
> + /**
> + * {@inheritDoc}
> + * @see DocumentNameSerializer#serialize(DocumentName)
> + */
> + public String serialize(DocumentName documentName)
> + {
> + // A valid DocumentName must not have any null value and thus we don't need to check for nulls here.
> + // It's the responsibility of creators of DocumentName factories to ensure it's valid.
> + StringBuffer result = new StringBuffer();
> + result.append(documentName.getWiki());
> + result.append(':');
> + result.append(documentName.getSpace());
> + result.append('.');
> + result.append(documentName.getPage());
> +
> + return result.toString();
> + }
> +}
>
> Modified: platform/core/branches/xwiki-core-1.8/xwiki-core/src/main/resources/META-INF/plexus/components.xml
> ===================================================================
> --- platform/core/branches/xwiki-core-1.8/xwiki-core/src/main/resources/META-INF/plexus/components.xml 2009-04-03 20:46:01 UTC (rev 18235)
> +++ platform/core/branches/xwiki-core-1.8/xwiki-core/src/main/resources/META-INF/plexus/components.xml 2009-04-03 20:48:34 UTC (rev 18236)
> @@ -51,7 +51,6 @@
> <role-hint>default</role-hint>
> <implementation>com.xpn.xwiki.doc.DefaultDocumentAccessBridge</implementation>
> <instantiation-strategy>singleton</instantiation-strategy>
> - <lifecycle-handler>xwiki</lifecycle-handler>
> <requirements>
> <requirement>
> <role>org.xwiki.context.Execution</role>
> @@ -59,11 +58,27 @@
> </requirements>
> </component>
> <component>
> + <role>org.xwiki.bridge.DocumentNameFactory</role>
> + <role-hint>default</role-hint>
> + <implementation>com.xpn.xwiki.doc.DefaultDocumentNameFactory</implementation>
> + <instantiation-strategy>singleton</instantiation-strategy>
> + <requirements>
> + <requirement>
> + <role>org.xwiki.context.Execution</role>
> + </requirement>
> + </requirements>
> + </component>
> + <component>
> + <role>org.xwiki.bridge.DocumentNameSerializer</role>
> + <role-hint>default</role-hint>
> + <implementation>com.xpn.xwiki.doc.DefaultDocumentNameSerializer</implementation>
> + <instantiation-strategy>singleton</instantiation-strategy>
> + </component>
> + <component>
> <role>org.xwiki.bridge.SkinAccessBridge</role>
> <role-hint>default</role-hint>
> <implementation>com.xpn.xwiki.DefaultSkinAccessBridge</implementation>
> <instantiation-strategy>singleton</instantiation-strategy>
> - <lifecycle-handler>xwiki</lifecycle-handler>
> <requirements>
> <requirement>
> <role>org.xwiki.context.Execution</role>
>
> Added: platform/core/branches/xwiki-core-1.8/xwiki-core/src/test/java/com/xpn/xwiki/doc/DefaultDocumentNameFactoryTest.java
> ===================================================================
> --- platform/core/branches/xwiki-core-1.8/xwiki-core/src/test/java/com/xpn/xwiki/doc/DefaultDocumentNameFactoryTest.java (rev 0)
> +++ platform/core/branches/xwiki-core-1.8/xwiki-core/src/test/java/com/xpn/xwiki/doc/DefaultDocumentNameFactoryTest.java 2009-04-03 20:48:34 UTC (rev 18236)
> @@ -0,0 +1,119 @@
> +/*
> + * See the NOTICE file distributed with this work for additional
> + * information regarding copyright ownership.
> + *
> + * This is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU Lesser General Public License as
> + * published by the Free Software Foundation; either version 2.1 of
> + * the License, or (at your option) any later version.
> + *
> + * This software is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this software; if not, write to the Free
> + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
> + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
> + */
> +package com.xpn.xwiki.doc;
> +
> +import org.xwiki.bridge.DocumentName;
> +import org.xwiki.bridge.DocumentNameFactory;
> +
> +import com.xpn.xwiki.test.AbstractBridgedXWikiComponentTestCase;
> +
> +/**
> + * Unit tests for {@link DocumentNameFactory}.
> + *
> + * @version $Id: $
> + * @since 1.8.1
> + */
> +public class DefaultDocumentNameFactoryTest extends AbstractBridgedXWikiComponentTestCase
> +{
> + private DocumentNameFactory factory;
> +
> + protected void setUp() throws Exception
> + {
> + super.setUp();
> + this.factory = (DocumentNameFactory) getComponentManager().lookup(DocumentNameFactory.ROLE);
> + }
> +
> + public void testCreateDocumentNameWhenCurrentDocSet() throws Exception
> + {
> + getContext().setDatabase("testwiki");
> + XWikiDocument document = new XWikiDocument();
> + document.setSpace("testspace");
> + getContext().setDoc(document);
> + verify("testwiki", "testspace");
> + }
> +
> + public void testCreateDocumentNameWhenNoCurrentDoc() throws Exception
> + {
> + verify("xwiki", "XWiki");
> + }
> +
> + private void verify(String expectedDefaultWiki, String expectedDefaultSpace)
> + {
> + DocumentName name = factory.createDocumentName("wiki:space.page");
> + assertEquals("wiki", name.getWiki());
> + assertEquals("space", name.getSpace());
> + assertEquals("page", name.getPage());
> +
> + name = factory.createDocumentName("wiki1:wiki2:page");
> + assertEquals("wiki1:wiki2", name.getWiki());
> + assertEquals(expectedDefaultSpace, name.getSpace());
> + assertEquals("page", name.getPage());
> +
> + name = factory.createDocumentName("wiki:");
> + assertEquals("wiki", name.getWiki());
> + assertEquals(expectedDefaultSpace, name.getSpace());
> + assertEquals("WebHome", name.getPage());
> +
> + name = factory.createDocumentName("wiki1.wiki2:page");
> + assertEquals("wiki1.wiki2", name.getWiki());
> + assertEquals(expectedDefaultSpace, name.getSpace());
> + assertEquals("page", name.getPage());
> +
> + name = factory.createDocumentName("wiki:page");
> + assertEquals("wiki", name.getWiki());
> + assertEquals(expectedDefaultSpace, name.getSpace());
> + assertEquals("page", name.getPage());
> +
> + name = factory.createDocumentName("wiki:space.");
> + assertEquals("wiki", name.getWiki());
> + assertEquals("space", name.getSpace());
> + assertEquals("WebHome", name.getPage());
> +
> + name = factory.createDocumentName("space.");
> + assertEquals(expectedDefaultWiki, name.getWiki());
> + assertEquals("space", name.getSpace());
> + assertEquals("WebHome", name.getPage());
> +
> + name = factory.createDocumentName("page");
> + assertEquals(expectedDefaultWiki, name.getWiki());
> + assertEquals(expectedDefaultSpace, name.getSpace());
> + assertEquals("page", name.getPage());
> +
> + name = factory.createDocumentName(".");
> + assertEquals(expectedDefaultWiki, name.getWiki());
> + assertEquals(expectedDefaultSpace, name.getSpace());
> + assertEquals("WebHome", name.getPage());
> +
> + name = factory.createDocumentName(":");
> + assertEquals(expectedDefaultWiki, name.getWiki());
> + assertEquals(expectedDefaultSpace, name.getSpace());
> + assertEquals("WebHome", name.getPage());
> +
> + name = factory.createDocumentName(null);
> + assertEquals(expectedDefaultWiki, name.getWiki());
> + assertEquals(expectedDefaultSpace, name.getSpace());
> + assertEquals("WebHome", name.getPage());
> +
> + name = factory.createDocumentName("");
> + assertEquals(expectedDefaultWiki, name.getWiki());
> + assertEquals(expectedDefaultSpace, name.getSpace());
> + assertEquals("WebHome", name.getPage());
> + }
> +}
>
> Added: platform/core/branches/xwiki-core-1.8/xwiki-core/src/test/java/com/xpn/xwiki/doc/DefaultDocumentNameSerializerTest.java
> ===================================================================
> --- platform/core/branches/xwiki-core-1.8/xwiki-core/src/test/java/com/xpn/xwiki/doc/DefaultDocumentNameSerializerTest.java (rev 0)
> +++ platform/core/branches/xwiki-core-1.8/xwiki-core/src/test/java/com/xpn/xwiki/doc/DefaultDocumentNameSerializerTest.java 2009-04-03 20:48:34 UTC (rev 18236)
> @@ -0,0 +1,41 @@
> +/*
> + * See the NOTICE file distributed with this work for additional
> + * information regarding copyright ownership.
> + *
> + * This is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU Lesser General Public License as
> + * published by the Free Software Foundation; either version 2.1 of
> + * the License, or (at your option) any later version.
> + *
> + * This software is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this software; if not, write to the Free
> + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
> + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
> + */
> +package com.xpn.xwiki.doc;
> +
> +import org.xwiki.bridge.DocumentName;
> +import org.xwiki.bridge.DocumentNameSerializer;
> +import org.xwiki.test.AbstractXWikiComponentTestCase;
> +
> +/**
> + * Unit tests for {@link DocumentNameSerializer}.
> + *
> + * @version $Id: $
> + * @since 1.8.1
> + */
> +public class DefaultDocumentNameSerializerTest extends AbstractXWikiComponentTestCase
> +{
> + public void testSerialize() throws Exception
> + {
> + DocumentNameSerializer serializer =
> + (DocumentNameSerializer) getComponentManager().lookup(DocumentNameSerializer.ROLE);
> + DocumentName name = new DocumentName("wiki", "space", "page");
> + assertEquals("wiki:space.page", serializer.serialize(name));
> + }
> +}
>
> _______________________________________________
> notifications mailing list
> notifications(a)xwiki.org
> http://lists.xwiki.org/mailman/listinfo/notifications
>
--
Thomas Mortagne
Hi
I have already submitted a proposal for Xwiki Photo Album Application.
As Sergiu specified in the mail "To Antivandalism project GSOC
candidates" i would like to look into the Integration of Mozilla
Bespin as a core Script editor in XWiki too. So it is better to have a
quick impression on this as we have a limited time.
Indeed Bespin provides an open standard based extensible web-based
framework for code editing , hence it is really worth integrating it
as a core Script editor in Xwiki.Currently Bespin supports syntax
highlighting for HTML, CSS, PHP, Arduino, and JavaScript. So in this
project i have to facilitate Bespin with groovy language.Correct me if
i am wrong. Velocity will benefit from HTML coloration.
I found that Skin Editor application is currently having the benefit
of Bespin editor as the script editor of XWiki's platform. So could
you please let me know in brief how this integration has happened ,at
least point me out some worth readings on this as soon as possible,
this would be really helpful to me just to have a good confidence and
submit a good proposal.
Thanks in advance
harsha
hi i want to developp a plugin of streaming on xwiki
and i want to know the scripting language groovy and velocity
so i tried to write the HelloWorld Class
i followed the steps in the xwiki tutorial but i have an error :here is the stacktrace :
[CODE]Error number 4001 in 4: Error while parsing velocity page Main.HelloWorldFromVelocity
Wrapped Exception: Failed to evaluate content with id Hello World From Velocity
com.xpn.xwiki.XWikiException: Error number 4001 in 4: Error while parsing velocity page Main.HelloWorldFromVelocity
Wrapped Exception: Failed to evaluate content with id Hello World From Velocity
at com.xpn.xwiki.render.XWikiVelocityRenderer.evaluate(XWikiVelocityRenderer.java:114)
at com.xpn.xwiki.render.XWikiVelocityRenderer.render(XWikiVelocityRenderer.java:85)
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:470)
at com.xpn.xwiki.api.Document.getRenderedContent(Document.java:365)
at sun.reflect.GeneratedMethodAccessor264.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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:108)
at com.xpn.xwiki.XWiki.parseTemplate(XWiki.java:1612)
at com.xpn.xwiki.api.XWiki.parseTemplate(XWiki.java:655)
at sun.reflect.GeneratedMethodAccessor168.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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:108)
at com.xpn.xwiki.XWiki.parseTemplate(XWiki.java:1612)
at com.xpn.xwiki.web.Utils.parseTemplate(Utils.java:124)
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:596)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:428)
at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:830)
at com.xpn.xwiki.plugin.webdav.DavFilter.doFilter(DavFilter.java:68)
at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:821)
at com.xpn.xwiki.wysiwyg.server.filter.ConversionFilter.doFilter(ConversionFilter.java:96)
at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:821)
at com.xpn.xwiki.web.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:287)
at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:821)
at com.xpn.xwiki.web.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:112)
at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:821)
at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:471)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:568)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1565)
at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:633)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1517)
at org.mortbay.http.HttpServer.service(HttpServer.java:954)
at org.mortbay.http.HttpConnection.service(HttpConnection.java:816)
at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:983)
at org.mortbay.http.HttpConnection.handle(HttpConnection.java:833)
at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:244)
at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357)
at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
Wrapped Exception:
org.apache.velocity.exception.MethodInvocationException: Invocation of method 'parseGroovyFromPage' in class com.xpn.xwiki.api.XWiki threw exception com.xpn.xwiki.XWikiException: Error number 14001 in 14: Failed compiling groovy script Wrapped Exception: startup failed, script1238667520150.groovy: 1: unexpected token: < @ line 1, column 1.
error
@ Main.HelloWorldFromVelocity1,29? at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:286) 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:108) at com.xpn.xwiki.render.XWikiVelocityRenderer.render(XWikiVelocityRenderer.java:85) 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:470) at com.xpn.xwiki.api.Document.getRenderedContent(Document.java:365) at sun.reflect.GeneratedMethodAccessor264.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) 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:108) at com.xpn.xwiki.XWiki.parseTemplate(XWiki.java:1612) at com.xpn.xwiki.api.XWiki.parseTemplate(XWiki.java:655) at sun.reflect.GeneratedMethodAccessor168.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) 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:108) at com.xpn.xwiki.XWiki.parseTemplate(XWiki.java:1612) at com.xpn.xwiki.web.Utils.parseTemplate(Utils.java:124) 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:596) at javax.servlet.http.HttpServlet.service(HttpServlet.java:689) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:428) at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:830) at com.xpn.xwiki.plugin.webdav.DavFilter.doFilter(DavFilter.java:68) at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:821) at com.xpn.xwiki.wysiwyg.server.filter.ConversionFilter.doFilter(ConversionFilter.java:96) at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:821) at com.xpn.xwiki.web.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:287) at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:821) at com.xpn.xwiki.web.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:112) at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:821) at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:471) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:568) at org.mortbay.http.HttpContext.handle(HttpContext.java:1565) at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:633) at org.mortbay.http.HttpContext.handle(HttpContext.java:1517) at org.mortbay.http.HttpServer.service(HttpServer.java:954) at org.mortbay.http.HttpConnection.service(HttpConnection.java:816) at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:983) at org.mortbay.http.HttpConnection.handle(HttpConnection.java:833) at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:244) at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357) at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534) Caused by: com.xpn.xwiki.XWikiException: Error number 14001 in 14: Failed compiling groovy script Wrapped Exception: startup failed, script1238667520150.groovy: 1: unexpected token: < @ line 1, column 1.
error
at com.xpn.xwiki.render.groovy.XWikiGroovyRenderer.parseGroovyFromString(XWikiGroovyRenderer.java:385) at com.xpn.xwiki.XWiki.parseGroovyFromString(XWiki.java:5792) at com.xpn.xwiki.api.XWiki.parseGroovyFromPage(XWiki.java:2227) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:295) at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:245) … 79 more
[/CODE]
did i missed something?
--
View this message in context: http://n2.nabble.com/HelloWorld-Class-tp2574406p2574406.html
Sent from the XWiki- Dev mailing list archive at Nabble.com.
Hi All,
I'm currently investigating using XWiki to create a custom application, for
this application I'll need to create a CSS based ImageMap plugin, where when
you move over a certain area a popup note will be displayed.
I guess from an architcture perspective I need to create a custom object
which contains the functionality to display itself, and query another custom
object which contains co-ordinates and text details which are attached to
this object. That bit I get, however the bit I'm having some trouble with
is how I would go about adding css details to the custom object for display
purposes, if anyone could point me in the direction of a tutorial or give me
some guidance I'd really appreciate it ?
At the moment I'm not so worried about creating an editor for mapping notes
to co-ordinates, it's probably something to look at for the future tho, I
also need to be able to export the details to XML, again, this step I'm not
sure of since I can't find any tutorials or information on modifying the
exports...
Any help or links to good information are much appreciated....
Thanks,
Derek
Hi Dear,
I am working on calendar application application and for last few days I am
studying the working of XWiki. Now I have an idea that how things are going
on.
but as per my requirements I am not yet sure about-
1. How JavaScript can be used?
2. Can I use my own JavaScript library?
3. How AJAX is implemented within XWiki?
I am to finalize my proposal today. So please be quick..
cheers..
--
Apurv Gupta
Indian School of Mines University
Hello,
Is there any way to add some code without recompiling xwiki-core
(plugin? component?) that could register a listener for any changes in
documents (preferably by mask / type, as in "listen for added comments
on Main.* and Blog.*") and optionally veto (and/or flag for review?) them?
If not, please consider adding it - it would be a very nice way to make
writing things like spam- and vandal- filters easier.
It would also allow making such things more modular - if any plugin
could register such a listener, then there could be (for example) two
independent plugins running at once, one handling scenarios like "bad
source" - "bad ip", "possible anonymous proxy", the other "bad content"
- "bad words", "structure looks like spam" or "too many links".
Greetings, Lilianne