Hi Karamjit,

For an example of adding new resources to the XWiki REST API, you could look
at how the XWiki Annotation feature did it [1].

For the steps you need to take, you have to:
1. Create a new maven project that deppends on xwiki-platform-rest-server
(for xwiki >3.1) and some other dependencies that you might need. See [2]
2. Add a new resource by adding a new class that extends XWikiResource (like
[3] does) and that declares itself as a component and specifies the REST URI
that it will honor (like [4] does). As Marius pointed out, [9] helps, but by
looking at the examples pointed by [9] you will learn much faster.
3. Even if you declared your resources as components
(@Component+@Namedattributes), you still have to register them in
component.txt (like [5]
does) so that the component manager can detect them.
4. If you need to return or accept complex types (other than basic strings,
numbers, etc), you need to define your model by using a schema (like [6])
and then configure your maven artifact to run, at build time, the
'org.jvnet.jaxb2.maven2' plugin that generates java classes out of the
schema definition for you to use in your resources. You might also need to
provide a simple.jxb bindings file (like [8]) to handle dates properly.
5. Build your maven artefact containing the new resources and you get a .jar
file
6. Copy that jar file into
'<xwiki_installation_dir>/webapps/xwiki/WEB-INF/lib/'. Remember that the
installed XWiki version must match the version you developed your resources
for, otherwise the jars will risk not matching.
7. Restart XWiki and access your new resources by using the URI you
specified for them at step 2. Yor URL will be in the form of "
http://localhost:8080/xwiki/rest/<URI>".

I hope I did not miss anything and that it's clear enough.

Good luck,
Eduard

-----------------
References:
[1]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-annotations/xwiki-platform-annotation-rest/
[2]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-annotations/xwiki-platform-annotation-rest/pom.xml
[3]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-annotations/xwiki-platform-annotation-rest/src/main/java/org/xwiki/annotation/rest/internal/AbstractAnnotationRESTResource.java
[4]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-annotations/xwiki-platform-annotation-rest/src/main/java/org/xwiki/annotation/rest/internal/AnnotationsRESTResource.java
[5]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-annotations/xwiki-platform-annotation-rest/src/main/resources/META-INF/components.txt
[6]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-annotations/xwiki-platform-annotation-rest/src/main/resources/xwiki.rest.annotation.model.xsd
[7]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-annotations/xwiki-platform-annotation-rest/pom.xml
[8]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-annotations/xwiki-platform-annotation-rest/src/main/resources/simple.xjb
[9]
http://platform.xwiki.org/xwiki/bin/view/Features/XWikiRESTfulAPI#HCustomresources

On Fri, Jul 22, 2011 at 8:01 AM, Marius Dumitru Florea <
[email protected]> wrote:

> Hi Karamjit,
>
> On 07/21/2011 09:49 PM, Karamjit Singh wrote:
> > Hi Team,
> >
> > I just imported maven  xwiki-core-rest (download code from svn)  in
> eclipse
> > and getting following error message :-
> >
> > Description Resource Path Location Type
> > Project build error: Non-resolvable parent POM for
> > org.xwiki.platform:xwiki-core-parent:3.1-SNAPSHOT: Could not find
> artifact
> > org.xwiki.commons:xwiki-commons:pom:42-SNAPSHOT and 'parent.relativePath'
> > points at wrong local POM pom.xml /xwiki-core-rest line 1 Maven Problem
>
> The code from SVN trunks is not maintained any more after we moved it to
> GitHub. There are lots of Git tutorials on the web so it shouldn't be
> that difficult to clone xwiki-platform sources and play with them.
>
> If you really don't want to learn Git then the only option is to use a
> tag from SVN, like
>
> http://svn.xwiki.org/svnroot/xwiki/platform/core/tags/xwiki-core-3.0/xwiki-rest/
> (this will work only if you use a version of XWiki Enterprise <= 3.0,
> because otherwise older version jars are not necessarily compatible with
> the newest ones, >3.0).
>
> >
> >
> > Its very urgent as I am unable to build the project in eclipse. Please
> help
> > me to solve this problem. Also please share some restful service
> > implementation guide and how to deploy/test new xwiki restful service.
>
> You should probably start with
> http://platform.xwiki.org/xwiki/bin/view/Features/XWikiRESTfulAPI
>
> Hope this helps,
> Marius
>
> >
> > Thanks
> > Karamjit.
> >
> > On Thu, Jul 21, 2011 at 10:14 PM, Eduard Moraru<[email protected]
> >wrote:
> >
> >> Hi Karamjit,
> >>
> >> Here's a pretty complete tutorial made by Sergiu for GIT made specially
> >> with
> >> XWiki in mind:
> >>
> >> http://incubator.myxwiki.org/xwiki/bin/view/Main/UsingGitHub
> >>
> >> Good luck,
> >> Eduard
> >>
> >> On Thu, Jul 21, 2011 at 7:41 PM, Karamjit Singh<[email protected]
> >>> wrote:
> >>
> >>> Hi Marius
> >>>
> >>> Thanks for your quick response. I don't have experience on GIT. Before
> >>> downloading the code from SVN, I tried GIT first using below command
> >>> git clone git://urlofcode , This command just created the skeleton and
> >> did
> >>> not download the source code. Could you please share some more
> >> information
> >>> like how to download code from GIT and building the code.
> >>>
> >>> Thanks
> >>> Karamjit.
> >>>
> >>> On Thu, Jul 21, 2011 at 10:01 PM, Marius Dumitru Florea<
> >>> [email protected]>  wrote:
> >>>
> >>>> Hi Karamjit,
> >>>>
> >>>> You should go through http://dev.xwiki.org/xwiki/bin/view/Community/
> >>>> (especially Source Repository, Building and Debugging sections).
> >>>>
> >>>> We moved our code to GitHub ( https://github.com/xwiki/ ) and you can
> >>>> find the REST module at
> >>>>
> >>>>
> >>>
> >>
> https://github.com/xwiki/xwiki-platform/tree/master/xwiki-platform-core/xwiki-platform-rest
> >>>> .
> >>>>
> >>>> Hope this helps,
> >>>> Marius
> >>>>
> >>>> On 07/21/2011 07:13 PM, Karamjit Singh wrote:
> >>>>> Hi Team,
> >>>>>
> >>>>> I need to implement restful web service for xwiki user creation and
> >>>>> aothorization. I have downloaded the code from SVN but unable to
> >> build
> >>>> the
> >>>>> xwiki source code from eclipse. I did not find any document related
> >> to
> >>>> this
> >>>>> in manual.  Could you please help me on this and let me know which
> >>> module
> >>>> I
> >>>>> should download for restful web service customization.
> >>>>>
> >>>>> Its very urgent as I am stuck here.
> >>>>>
> >>>>> Thanks
> >>>>> Karamjit
> >>>>> _______________________________________________
> >>>>> devs mailing list
> >>>>> [email protected]
> >>>>> http://lists.xwiki.org/mailman/listinfo/devs
> >>>> _______________________________________________
> >>>> devs mailing list
> >>>> [email protected]
> >>>> http://lists.xwiki.org/mailman/listinfo/devs
> >>>>
> >>> _______________________________________________
> >>> devs mailing list
> >>> [email protected]
> >>> http://lists.xwiki.org/mailman/listinfo/devs
> >>>
> >> _______________________________________________
> >> devs mailing list
> >> [email protected]
> >> http://lists.xwiki.org/mailman/listinfo/devs
> >>
> > _______________________________________________
> > devs mailing list
> > [email protected]
> > http://lists.xwiki.org/mailman/listinfo/devs
> _______________________________________________
> devs mailing list
> [email protected]
> http://lists.xwiki.org/mailman/listinfo/devs
>
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to