[xwiki-users] [xwiki-user] How can I get the Wiki (XWiki object) from Execution context?
Hi users, I am developing a Java Component that offers APIs through a script service. Those APIs have to modify space and pages' contents of a wiki, thus I was wondering on how to do that....I already know that if I want to perform modifications to a Wiki I must add the "xwiki-platform-oldcore" (in my case the version 7.3) dependency to my pom.xml but I can't still access the Classes and methods that I need. Meaning that I can't get the wiki from the context, and this blocks everything because (if i am not wrong) then I can't get the DocumentReference and the XWikiDocument that allow me to perfom modification to the Wiki. It is something related to the *settings.xml* file in the *.m2* folder? What I've written in there is the same that i found at this page http://dev.xwiki.org/xwiki/bin/view/Community/Building# but the "xwiki-platform-oldcore" doesn't appear nor in the repository folder neither in the Maven Dependencies....either the dependecy is written in the pom.... Hope to find some help! Giordano.
You get the XWiki object from the XWikiContext object usually. And if you have oldcore in your dependencies already the best to get a XWikiContext is usually to inject the XWikiContext provider like in: @Inject private Provider<XWikiContext> xcontextProvider; See http://platform.xwiki.org/xwiki/bin/view/DevGuide/WritingComponents#HTheXWik... for more about XWikiContext in components. On Mon, Dec 14, 2015 at 10:53 AM, Giordano Ninonà <[email protected]> wrote:
Hi users,
I am developing a Java Component that offers APIs through a script service. Those APIs have to modify space and pages' contents of a wiki, thus I was wondering on how to do that....I already know that if I want to perform modifications to a Wiki I must add the "xwiki-platform-oldcore" (in my case the version 7.3) dependency to my pom.xml but I can't still access the Classes and methods that I need. Meaning that I can't get the wiki from the context, and this blocks everything because (if i am not wrong) then I can't get the DocumentReference and the XWikiDocument that allow me to perfom modification to the Wiki.
It is something related to the *settings.xml* file in the *.m2* folder? What I've written in there is the same that i found at this page http://dev.xwiki.org/xwiki/bin/view/Community/Building# but the "xwiki-platform-oldcore" doesn't appear nor in the repository folder neither in the Maven Dependencies....either the dependecy is written in the pom....
Hope to find some help!
Giordano. _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne
Thanks a lot, but when I write *@Inject private Provider<XWikiContext> xwikiContextProvider;* I get an error because *"XWikiContext cannot be resovled to a type".... *that's why I've suppoed that it should be a problem with the dependencies. This is my pom.xml: *<project xmlns="http://maven.apache.org/POM/4.0.0 <http://maven.apache.org/POM/4.0.0>" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance <http://www.w3.org/2001/XMLSchema-instance>" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 <http://maven.apache.org/POM/4.0.0> http://maven.apache.org/maven-v4_0_0.xsd <http://maven.apache.org/maven-v4_0_0.xsd>"> <modelVersion>4.0.0</modelVersion> <groupId>org.xwiki.commons</groupId> <artifactId>xwiki-commons-component-evolver</artifactId> <version>0.0.1-SNAPSHOT</version> <name>XWiki Evolver Component</name> <description>XWiki Evolver Component</description> <properties> <xwiki.version>7.3</xwiki.version> </properties> <packaging>jar</packaging> <build> <defaultGoal>compile</defaultGoal> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>org.xwiki.commons</groupId> <artifactId>xwiki-commons-component-api</artifactId> <version>${xwiki.version}</version> </dependency> <dependency> <groupId>org.xwiki.platform</groupId> <artifactId>xwiki-platform-oldcore</artifactId> <version>${xwiki.version}</version> </dependency> <!-- Only needed if some of the component's APIs must be made visible to scripting in wiki pages --> <dependency> <groupId>org.xwiki.commons</groupId> <artifactId>xwiki-commons-script</artifactId> <version>${xwiki.version}</version> </dependency> <!-- Testing dependencies --> <dependency> <groupId>org.xwiki.commons</groupId> <artifactId>xwiki-commons-tool-test-component</artifactId> <version>${xwiki.version}</version> <scope>test</scope> </dependency> </dependencies></project>* Moreover in the "Project Explorer" side menu, if I click on "Maven Dependencies" I don't see anything related to "xwiki-platform-oldcore". Giordano. 2015-12-14 10:57 GMT+01:00 Thomas Mortagne <[email protected]>:
You get the XWiki object from the XWikiContext object usually.
And if you have oldcore in your dependencies already the best to get a XWikiContext is usually to inject the XWikiContext provider like in:
@Inject private Provider<XWikiContext> xcontextProvider;
See http://platform.xwiki.org/xwiki/bin/view/DevGuide/WritingComponents#HTheXWik... for more about XWikiContext in components.
On Mon, Dec 14, 2015 at 10:53 AM, Giordano Ninonà <[email protected]> wrote:
Hi users,
I am developing a Java Component that offers APIs through a script service. Those APIs have to modify space and pages' contents of a wiki, thus I was wondering on how to do that....I already know that if I want to perform modifications to a Wiki I must add the "xwiki-platform-oldcore" (in my case the version 7.3) dependency to my pom.xml but I can't still access the Classes and methods that I need. Meaning that I can't get the wiki from the context, and this blocks everything because (if i am not wrong) then I can't get the DocumentReference and the XWikiDocument that allow me to perfom modification to the Wiki.
It is something related to the *settings.xml* file in the *.m2* folder? What I've written in there is the same that i found at this page http://dev.xwiki.org/xwiki/bin/view/Community/Building# but the "xwiki-platform-oldcore" doesn't appear nor in the repository folder neither in the Maven Dependencies....either the dependecy is written in the pom....
Hope to find some help!
Giordano. _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
It doesn't matter, I have cleaned my project and updated Maven dependencies and now it works :P Thanks again. 2015-12-14 11:10 GMT+01:00 Giordano Ninonà <[email protected]>:
Thanks a lot, but when I write
*@Inject private Provider<XWikiContext> xwikiContextProvider;* I get an error because *"XWikiContext cannot be resovled to a type".... *that's why I've suppoed that it should be a problem with the dependencies.
This is my pom.xml:
*<project xmlns="http://maven.apache.org/POM/4.0.0 <http://maven.apache.org/POM/4.0.0>" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance <http://www.w3.org/2001/XMLSchema-instance>" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 <http://maven.apache.org/POM/4.0.0> http://maven.apache.org/maven-v4_0_0.xsd <http://maven.apache.org/maven-v4_0_0.xsd>"> <modelVersion>4.0.0</modelVersion> <groupId>org.xwiki.commons</groupId> <artifactId>xwiki-commons-component-evolver</artifactId> <version>0.0.1-SNAPSHOT</version> <name>XWiki Evolver Component</name> <description>XWiki Evolver Component</description> <properties> <xwiki.version>7.3</xwiki.version> </properties> <packaging>jar</packaging> <build> <defaultGoal>compile</defaultGoal> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>org.xwiki.commons</groupId> <artifactId>xwiki-commons-component-api</artifactId> <version>${xwiki.version}</version> </dependency> <dependency> <groupId>org.xwiki.platform</groupId> <artifactId>xwiki-platform-oldcore</artifactId> <version>${xwiki.version}</version> </dependency> <!-- Only needed if some of the component's APIs must be made visible to scripting in wiki pages --> <dependency> <groupId>org.xwiki.commons</groupId> <artifactId>xwiki-commons-script</artifactId> <version>${xwiki.version}</version> </dependency> <!-- Testing dependencies --> <dependency> <groupId>org.xwiki.commons</groupId> <artifactId>xwiki-commons-tool-test-component</artifactId> <version>${xwiki.version}</version> <scope>test</scope> </dependency> </dependencies></project>* Moreover in the "Project Explorer" side menu, if I click on "Maven Dependencies" I don't see anything related to "xwiki-platform-oldcore".
Giordano.
2015-12-14 10:57 GMT+01:00 Thomas Mortagne <[email protected]>:
You get the XWiki object from the XWikiContext object usually.
And if you have oldcore in your dependencies already the best to get a XWikiContext is usually to inject the XWikiContext provider like in:
@Inject private Provider<XWikiContext> xcontextProvider;
See http://platform.xwiki.org/xwiki/bin/view/DevGuide/WritingComponents#HTheXWik... for more about XWikiContext in components.
On Mon, Dec 14, 2015 at 10:53 AM, Giordano Ninonà <[email protected]> wrote:
Hi users,
I am developing a Java Component that offers APIs through a script service. Those APIs have to modify space and pages' contents of a wiki, thus I was wondering on how to do that....I already know that if I want to perform modifications to a Wiki I must add the "xwiki-platform-oldcore" (in my case the version 7.3) dependency to my pom.xml but I can't still access the Classes and methods that I need. Meaning that I can't get the wiki from the context, and this blocks everything because (if i am not wrong) then I can't get the DocumentReference and the XWikiDocument that allow me to perfom modification to the Wiki.
It is something related to the *settings.xml* file in the *.m2* folder? What I've written in there is the same that i found at this page http://dev.xwiki.org/xwiki/bin/view/Community/Building# but the "xwiki-platform-oldcore" doesn't appear nor in the repository folder neither in the Maven Dependencies....either the dependecy is written in the pom....
Hope to find some help!
Giordano. _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
There is a mistake in your pom, you tell Maven that you want to use Java 6 (in maven-compiler-plugin plugin setup) but XWiki 7.x require Java 7 so you'd better use Java 7. On Mon, Dec 14, 2015 at 11:15 AM, Giordano Ninonà <[email protected]> wrote:
It doesn't matter, I have cleaned my project and updated Maven dependencies and now it works :P
Thanks again.
2015-12-14 11:10 GMT+01:00 Giordano Ninonà <[email protected]>:
Thanks a lot, but when I write
*@Inject private Provider<XWikiContext> xwikiContextProvider;* I get an error because *"XWikiContext cannot be resovled to a type".... *that's why I've suppoed that it should be a problem with the dependencies.
This is my pom.xml:
*<project xmlns="http://maven.apache.org/POM/4.0.0 <http://maven.apache.org/POM/4.0.0>" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance <http://www.w3.org/2001/XMLSchema-instance>" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 <http://maven.apache.org/POM/4.0.0> http://maven.apache.org/maven-v4_0_0.xsd <http://maven.apache.org/maven-v4_0_0.xsd>"> <modelVersion>4.0.0</modelVersion> <groupId>org.xwiki.commons</groupId> <artifactId>xwiki-commons-component-evolver</artifactId> <version>0.0.1-SNAPSHOT</version> <name>XWiki Evolver Component</name> <description>XWiki Evolver Component</description> <properties> <xwiki.version>7.3</xwiki.version> </properties> <packaging>jar</packaging> <build> <defaultGoal>compile</defaultGoal> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>org.xwiki.commons</groupId> <artifactId>xwiki-commons-component-api</artifactId> <version>${xwiki.version}</version> </dependency> <dependency> <groupId>org.xwiki.platform</groupId> <artifactId>xwiki-platform-oldcore</artifactId> <version>${xwiki.version}</version> </dependency> <!-- Only needed if some of the component's APIs must be made visible to scripting in wiki pages --> <dependency> <groupId>org.xwiki.commons</groupId> <artifactId>xwiki-commons-script</artifactId> <version>${xwiki.version}</version> </dependency> <!-- Testing dependencies --> <dependency> <groupId>org.xwiki.commons</groupId> <artifactId>xwiki-commons-tool-test-component</artifactId> <version>${xwiki.version}</version> <scope>test</scope> </dependency> </dependencies></project>* Moreover in the "Project Explorer" side menu, if I click on "Maven Dependencies" I don't see anything related to "xwiki-platform-oldcore".
Giordano.
2015-12-14 10:57 GMT+01:00 Thomas Mortagne <[email protected]>:
You get the XWiki object from the XWikiContext object usually.
And if you have oldcore in your dependencies already the best to get a XWikiContext is usually to inject the XWikiContext provider like in:
@Inject private Provider<XWikiContext> xcontextProvider;
See http://platform.xwiki.org/xwiki/bin/view/DevGuide/WritingComponents#HTheXWik... for more about XWikiContext in components.
On Mon, Dec 14, 2015 at 10:53 AM, Giordano Ninonà <[email protected]> wrote:
Hi users,
I am developing a Java Component that offers APIs through a script service. Those APIs have to modify space and pages' contents of a wiki, thus I was wondering on how to do that....I already know that if I want to perform modifications to a Wiki I must add the "xwiki-platform-oldcore" (in my case the version 7.3) dependency to my pom.xml but I can't still access the Classes and methods that I need. Meaning that I can't get the wiki from the context, and this blocks everything because (if i am not wrong) then I can't get the DocumentReference and the XWikiDocument that allow me to perfom modification to the Wiki.
It is something related to the *settings.xml* file in the *.m2* folder? What I've written in there is the same that i found at this page http://dev.xwiki.org/xwiki/bin/view/Community/Building# but the "xwiki-platform-oldcore" doesn't appear nor in the repository folder neither in the Maven Dependencies....either the dependecy is written in the pom....
Hope to find some help!
Giordano. _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne
Oh thanks, I didn't see it....I've changed both to 1.7 :D 2015-12-14 11:21 GMT+01:00 Thomas Mortagne <[email protected]>:
There is a mistake in your pom, you tell Maven that you want to use Java 6 (in maven-compiler-plugin plugin setup) but XWiki 7.x require Java 7 so you'd better use Java 7.
On Mon, Dec 14, 2015 at 11:15 AM, Giordano Ninonà <[email protected]> wrote:
It doesn't matter, I have cleaned my project and updated Maven dependencies and now it works :P
Thanks again.
2015-12-14 11:10 GMT+01:00 Giordano Ninonà <[email protected]>:
Thanks a lot, but when I write
*@Inject private Provider<XWikiContext> xwikiContextProvider;* I get an error because *"XWikiContext cannot be resovled to a type".... *that's why I've suppoed that it should be a problem with the dependencies.
This is my pom.xml:
*<project xmlns="http://maven.apache.org/POM/4.0.0 <http://maven.apache.org/POM/4.0.0>" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance <http://www.w3.org/2001/XMLSchema-instance>" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 <http://maven.apache.org/POM/4.0.0> http://maven.apache.org/maven-v4_0_0.xsd <http://maven.apache.org/maven-v4_0_0.xsd>"> <modelVersion>4.0.0</modelVersion> <groupId>org.xwiki.commons</groupId> <artifactId>xwiki-commons-component-evolver</artifactId> <version>0.0.1-SNAPSHOT</version> <name>XWiki Evolver Component</name> <description>XWiki Evolver Component</description> <properties> <xwiki.version>7.3</xwiki.version> </properties> <packaging>jar</packaging> <build> <defaultGoal>compile</defaultGoal> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>org.xwiki.commons</groupId> <artifactId>xwiki-commons-component-api</artifactId> <version>${xwiki.version}</version> </dependency> <dependency> <groupId>org.xwiki.platform</groupId> <artifactId>xwiki-platform-oldcore</artifactId> <version>${xwiki.version}</version> </dependency> <!-- Only needed if some of the component's APIs must be made visible to scripting in wiki pages --> <dependency> <groupId>org.xwiki.commons</groupId> <artifactId>xwiki-commons-script</artifactId> <version>${xwiki.version}</version> </dependency> <!-- Testing dependencies --> <dependency> <groupId>org.xwiki.commons</groupId> <artifactId>xwiki-commons-tool-test-component</artifactId> <version>${xwiki.version}</version> <scope>test</scope> </dependency> </dependencies></project>* Moreover in the "Project Explorer" side menu, if I click on "Maven Dependencies" I don't see anything related to "xwiki-platform-oldcore".
Giordano.
2015-12-14 10:57 GMT+01:00 Thomas Mortagne <[email protected]>:
You get the XWiki object from the XWikiContext object usually.
And if you have oldcore in your dependencies already the best to get a XWikiContext is usually to inject the XWikiContext provider like in:
@Inject private Provider<XWikiContext> xcontextProvider;
See
http://platform.xwiki.org/xwiki/bin/view/DevGuide/WritingComponents#HTheXWik...
for more about XWikiContext in components.
On Mon, Dec 14, 2015 at 10:53 AM, Giordano Ninonà <[email protected]> wrote:
Hi users,
I am developing a Java Component that offers APIs through a script service. Those APIs have to modify space and pages' contents of a wiki, thus I was wondering on how to do that....I already know that if I want to perform modifications to a Wiki I must add the "xwiki-platform-oldcore" (in my case the version 7.3) dependency to my pom.xml but I can't still access the Classes and methods that I need. Meaning that I can't get the wiki from the context, and this blocks everything because (if i am not wrong) then I can't get the DocumentReference and the XWikiDocument that allow me to perfom modification to the Wiki.
It is something related to the *settings.xml* file in the *.m2* folder? What I've written in there is the same that i found at this page http://dev.xwiki.org/xwiki/bin/view/Community/Building# but the "xwiki-platform-oldcore" doesn't appear nor in the repository folder neither in the Maven Dependencies....either the dependecy is written in the pom....
Hope to find some help!
Giordano. _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
participants (2)
-
Giordano Ninonà -
Thomas Mortagne