org.xwiki.rest
Class XWikiResource

java.lang.Object
  extended by org.xwiki.rest.XWikiResource
All Implemented Interfaces:
org.xwiki.component.phase.Initializable, XWikiRestComponent

@InstantiationStrategy(value=PER_LOOKUP)
public class XWikiResource
extends Object
implements XWikiRestComponent, org.xwiki.component.phase.Initializable

Base class for all XWiki-related JAX-RS resources. This class provides to subclasses a set of protected fields to access the XWiki API and a method for retrieving documents in their different incarnations.

Version:
$Id: d0804df035da4273ec4096f351d66f4da2a214af $

Nested Class Summary
protected static class XWikiResource.DocumentInfo
           A wrapper class for returning an XWiki document enriched with information about its status.
 
Field Summary
protected  org.xwiki.component.manager.ComponentManager componentManager
           The XWiki component manager that is used to lookup XWiki components and context.
protected  Logger logger
           The logger to be used to output log messages.
protected  ObjectFactory objectFactory
           The object factory for model objects to be used when creating representations.
protected  org.xwiki.query.QueryManager queryManager
           The query manager to be used to perform low-level queries for retrieving information about wiki content.
protected  javax.ws.rs.core.UriInfo uriInfo
           The actual URI information about the JAX-RS resource being called.
 
Constructor Summary
XWikiResource()
           
 
Method Summary
 XWikiResource.DocumentInfo getDocumentInfo(String wikiName, String spaceName, String pageName, String language, String version, boolean failIfDoesntExist, boolean failIfLocked)
           Retrieve a document.
 String getUriTemplate()
           A special GET method that produces the ad-hoc "uritemplate" media type used for retrieving the URI template associated to a resource.
protected  XWikiContext getXWikiContext()
          Retrieve the XWiki context from the current execution context.
 void initialize()
           Resource initialization.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

uriInfo

@Context
protected javax.ws.rs.core.UriInfo uriInfo

The actual URI information about the JAX-RS resource being called. This variable is useful when generating links to other resources in representations.


logger

protected Logger logger

The logger to be used to output log messages.


objectFactory

protected ObjectFactory objectFactory

The object factory for model objects to be used when creating representations.


componentManager

@Inject
protected org.xwiki.component.manager.ComponentManager componentManager

The XWiki component manager that is used to lookup XWiki components and context.


queryManager

@Inject
protected org.xwiki.query.QueryManager queryManager

The query manager to be used to perform low-level queries for retrieving information about wiki content.

Constructor Detail

XWikiResource

public XWikiResource()
Method Detail

initialize

public void initialize()
                throws org.xwiki.component.phase.InitializationException

Resource initialization.

Specified by:
initialize in interface org.xwiki.component.phase.Initializable
Throws:
org.xwiki.component.phase.InitializationException

getDocumentInfo

public XWikiResource.DocumentInfo getDocumentInfo(String wikiName,
                                                  String spaceName,
                                                  String pageName,
                                                  String language,
                                                  String version,
                                                  boolean failIfDoesntExist,
                                                  boolean failIfLocked)
                                           throws XWikiException

Retrieve a document. This method never returns null. If something goes wrong with respect to some precondition an exception is thrown.

Parameters:
wikiName - The wiki name. Cannot be null.
spaceName - The space name. Cannot be null.
pageName - The page name. Cannot be null.
language - The language. Null for the default language.
version - The version. Null for the latest version.
failIfDoesntExist - True if an exception should be raised whenever the page doesn't exist.
failIfLocked - True if an exception should be raised whenever the page is locked.
Returns:
A DocumentInfo structure containing the actual document and additional information about it.
Throws:
IllegalArgumentException - If a parameter has an incorrect value (e.g. null)
javax.ws.rs.WebApplicationException - NOT_FOUND if failIfDoesntExist is true and the page doesn't exist. PRECONDITION_FAILED if failIfLocked is true and the document is locked.
XWikiException

getUriTemplate

public String getUriTemplate()

A special GET method that produces the ad-hoc "uritemplate" media type used for retrieving the URI template associated to a resource. This is an auxiliary method that is used for documenting the REST API.

Returns:
The URI template string associated to the requested resource.

getXWikiContext

protected XWikiContext getXWikiContext()
Retrieve the XWiki context from the current execution context.

Returns:
the XWiki context


Copyright © 2004-2013 XWiki. All Rights Reserved.