|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.modeshape.web.jcr.rest.AbstractJcrResource
org.modeshape.web.jcr.rest.ItemsResource
@Immutable public class ItemsResource

RESTEasy handler to provide the JCR resources at the URIs below. Please note that these URIs assume a context of /resources for the web application.
| URI Pattern | Description | Supported Methods |
|---|---|---|
| /resources/{repositoryName}/{workspaceName}/item/{path} | accesses the item (node or property) at the path | ALL |
There are several ways to transfer binary property values, but all involve encoding the binary value into ASCII characters
using a Base64 notation and denoting this by adding annotating the property name with a suffix defining the type of
encoding. Currently, only "base64" encoding is supported.
For example, if the "jcr:data" property contains a single binary value of "propertyValue", then the JSON object representing that property will be:
"jcr:data/base64/" : "cHJvcGVydHlWYWx1ZQ=="Likewise, if the "jcr:data" property contains two binary values each being "propertyValue", then the JSON object representing that property will be:
"jcr:data/base64/" : [ "cHJvcGVydHlWYWx1ZQ==", "cHJvcGVydHlWYWx1ZQ==" ]Note that JCR 1.0.1 does not allow property names to and with a '/' character (among others), while JCR 2.0 does not allow property names to contain an unescaped or unencoded '/' character. Therefore, the "/{encoding}/" suffix can never appear in a valid JCR property name, and will always identify an encoded property.
Here are the details:
GET /resources/{repositoryName}/item/{pathToNode} obtains the JSON object representing the
node, and each property is represented as a nested JSON object where the name is the property name and the value(s) are
represented as either a single string value or an array of string values. If the property has a binary value, then the property
name is appended with "/base64/" and the string representation of each value is encoded in Base64.GET /resources/{repositoryName}/item/{pathToProperty} allows only the value(s) for the
one property to be included in the response. If any of the values is a binary value, then all of the values will be
encoded in Base64.PUT /resources/{repositoryName}/item/{pathToProperty} allows setting the property to a
single value, and only that value needs to be included in the body of the request. If the value is binary, the value
must be encoded by the client and the "Content-Transfer-Encoding" header must be set to "base64" (case
does not matter). When the request is received, the value is decoded before the property value is updated on the node.POST /resources/{repositoryName}/item/{pathToNode} requires a request that is structured
in the same way as the response from getting a node: the resulting JSON object represents the node, with nested JSON objects
for the properties and children. If any property of the new node has a binary value, then the name of the property must
be appended with "/base64/" and the string representation of each value are to be encoded in Base64.PUT /resources/{repositoryName}/item/{pathToNode} requires a request that is structured
in the same way as the response from getting or posting a node: the resulting JSON object represents the node, with nested JSON
objects for the properties and children. If any property of the new node has a binary value, then the name of the property
must be appended with "/base64/" and the string representation of each value are to be encoded in Base64.
| Field Summary |
|---|
| Fields inherited from class org.modeshape.web.jcr.rest.AbstractJcrResource |
|---|
EMPTY_REPOSITORY_NAME, EMPTY_WORKSPACE_NAME, URL_ENCODER |
| Constructor Summary | |
|---|---|
ItemsResource()
|
|
| Method Summary | |
|---|---|
void |
deleteItem(HttpServletRequest request,
String rawRepositoryName,
String rawWorkspaceName,
String path)
Deletes the item at path. |
String |
getItem(HttpServletRequest request,
String rawRepositoryName,
String rawWorkspaceName,
String path,
int depth)
Handles GET requests for an item in a workspace. |
javax.ws.rs.core.Response |
postItem(HttpServletRequest request,
String rawRepositoryName,
String rawWorkspaceName,
String path,
String requestContent)
Adds the content of the request as a node (or subtree of nodes) at the location specified by path. |
String |
putItem(HttpServletRequest request,
String rawRepositoryName,
String rawWorkspaceName,
String path,
String requestContent)
Updates the properties at the path. |
| Methods inherited from class org.modeshape.web.jcr.rest.AbstractJcrResource |
|---|
getSession |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ItemsResource()
| Method Detail |
|---|
public String getItem(@Context
HttpServletRequest request,
String rawRepositoryName,
String rawWorkspaceName,
String path,
int depth)
throws org.codehaus.jettison.json.JSONException,
org.jboss.resteasy.spi.UnauthorizedException,
javax.jcr.RepositoryException
request - the servlet request; may not be null or unauthenticatedrawRepositoryName - the URL-encoded repository namerawWorkspaceName - the URL-encoded workspace namepath - the path to the itemdepth - the depth of the node graph that should be returned if path refers to a node. @{code 0} means return
the requested node only. A negative value indicates that the full subgraph under the node should be returned. This
parameter defaults to 0 and is ignored if path refers to a property.
depth)
org.jboss.resteasy.spi.NotFoundException - if the named repository does not exists, the named workspace does not exist, or the user does not
have access to the named workspace
org.codehaus.jettison.json.JSONException - if there is an error encoding the node
org.jboss.resteasy.spi.UnauthorizedException - if the given login information is invalid
javax.jcr.RepositoryException - if any other error occursAbstractJcrResource.EMPTY_REPOSITORY_NAME,
AbstractJcrResource.EMPTY_WORKSPACE_NAME,
Session.getItem(String)
public javax.ws.rs.core.Response postItem(@Context
HttpServletRequest request,
String rawRepositoryName,
String rawWorkspaceName,
String path,
String requestContent)
throws org.jboss.resteasy.spi.NotFoundException,
org.jboss.resteasy.spi.UnauthorizedException,
javax.jcr.RepositoryException,
org.codehaus.jettison.json.JSONException
path.
The primary type and mixin type(s) may optionally be specified through the jcr:primaryType and jcr:mixinTypes properties.
request - the servlet request; may not be null or unauthenticatedrawRepositoryName - the URL-encoded repository namerawWorkspaceName - the URL-encoded workspace namepath - the path to the itemrequestContent - the JSON-encoded representation of the node or nodes to be added
requestContent
in that auto-created and protected properties (e.g., jcr:uuid) will be populated.
org.jboss.resteasy.spi.NotFoundException - if the parent of the item to be added does not exist
org.jboss.resteasy.spi.UnauthorizedException - if the user does not have the access required to create the node at this path
org.codehaus.jettison.json.JSONException - if there is an error encoding the node
javax.jcr.RepositoryException - if any other error occurs
public void deleteItem(@Context
HttpServletRequest request,
String rawRepositoryName,
String rawWorkspaceName,
String path)
throws org.jboss.resteasy.spi.NotFoundException,
org.jboss.resteasy.spi.UnauthorizedException,
javax.jcr.RepositoryException
path.
request - the servlet request; may not be null or unauthenticatedrawRepositoryName - the URL-encoded repository namerawWorkspaceName - the URL-encoded workspace namepath - the path to the item
org.jboss.resteasy.spi.NotFoundException - if no item exists at path
org.jboss.resteasy.spi.UnauthorizedException - if the user does not have the access required to delete the item at this path
javax.jcr.RepositoryException - if any other error occurs
public String putItem(@Context
HttpServletRequest request,
String rawRepositoryName,
String rawWorkspaceName,
String path,
String requestContent)
throws org.jboss.resteasy.spi.UnauthorizedException,
org.codehaus.jettison.json.JSONException,
javax.jcr.RepositoryException,
IOException
If path points to a property, this method expects the request content to be either a JSON array or a JSON string. The array or string will become the values or value of the property. If path points to a node, this method expects the request content to be a JSON object. The keys of the objects correspond to property names that will be set and the values for the keys correspond to the values that will be set on the properties.
request - the servlet request; may not be null or unauthenticatedrawRepositoryName - the URL-encoded repository namerawWorkspaceName - the URL-encoded workspace namepath - the path to the itemrequestContent - the JSON-encoded representation of the values and, possibly, properties to be set
org.jboss.resteasy.spi.NotFoundException - if the parent of the item to be added does not exist
org.jboss.resteasy.spi.UnauthorizedException - if the user does not have the access required to create the node at this path
org.codehaus.jettison.json.JSONException - if there is an error encoding the node
javax.jcr.RepositoryException - if any other error occurs
IOException - if there is a problem reading the value
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||