Index: docs/reference/src/main/docbook/en-US/content/jcr/web_access.xml
===================================================================
--- docs/reference/src/main/docbook/en-US/content/jcr/web_access.xml (revision 2501)
+++ docs/reference/src/main/docbook/en-US/content/jcr/web_access.xml (working copy)
@@ -654,7 +654,29 @@ POST http://www.example.com/resources/modeshape%3arepository/default/items/newNo
]]>
Note that protected properties like jcr:uuid are not provided but that the primary type and mixin types are
provided as properties. The REST server will translate these into the appropriate calls behind the
- scenes. The response from the request will be empty by convention.
+ scenes. The JSON-encoded response from the request will contain the node that you just posted, including
+ any autocreated properties and child nodes.
+
+
+ If you do not need this information, add mode:includeNode=false
+ as a query parameter to your URL.
+
+ This will instruct the REST server to only return the path of the newly-created node in the response.
The PUT method allows for updates of nodes and properties. If the URI points to a property, the body of the
Index: web/modeshape-web-jcr-rest-client/src/main/java/org/modeshape/web/jcr/rest/client/json/JsonRestClient.java
===================================================================
--- web/modeshape-web-jcr-rest-client/src/main/java/org/modeshape/web/jcr/rest/client/json/JsonRestClient.java (revision 2501)
+++ web/modeshape-web-jcr-rest-client/src/main/java/org/modeshape/web/jcr/rest/client/json/JsonRestClient.java (working copy)
@@ -96,7 +96,9 @@ public final class JsonRestClient implements IRestClient {
File file ) throws Exception {
LOGGER.trace("createFileNode: workspace={0}, path={1}, file={2}", workspace.getName(), path, file.getAbsolutePath());
FileNode fileNode = new FileNode(workspace, path, file);
- HttpClientConnection connection = connect(workspace.getServer(), fileNode.getUrl(), RequestMethod.POST);
+ URL fileNodeUrl = fileNode.getUrl();
+ URL fileNodeUrlWithTerseResponse = new URL(fileNodeUrl.toString() + "?mode:includeNode=false");
+ HttpClientConnection connection = connect(workspace.getServer(), fileNodeUrlWithTerseResponse, RequestMethod.POST);
try {
LOGGER.trace("createFileNode: create node={0}", fileNode);
Index: web/modeshape-web-jcr-rest-client/src/test/java/org/modeshape/web/jcr/rest/client/json/JsonRestClientTest.java
===================================================================
--- web/modeshape-web-jcr-rest-client/src/test/java/org/modeshape/web/jcr/rest/client/json/JsonRestClientTest.java (revision 2501)
+++ web/modeshape-web-jcr-rest-client/src/test/java/org/modeshape/web/jcr/rest/client/json/JsonRestClientTest.java (working copy)
@@ -193,7 +193,6 @@ public final class JsonRestClientTest {
assertThat(actual, is(expected));
}
- @Ignore
@FixFor( "MODE-919" )
@Test
public void shouldPublishDdlResource() throws Exception {
Index: web/modeshape-web-jcr-rest/src/main/java/org/modeshape/web/jcr/rest/ItemHandler.java
===================================================================
--- web/modeshape-web-jcr-rest/src/main/java/org/modeshape/web/jcr/rest/ItemHandler.java (revision 2501)
+++ web/modeshape-web-jcr-rest/src/main/java/org/modeshape/web/jcr/rest/ItemHandler.java (working copy)
@@ -236,6 +236,8 @@ class ItemHandler extends AbstractHandler {
* @param rawRepositoryName the URL-encoded repository name
* @param rawWorkspaceName the URL-encoded workspace name
* @param path the path to the item
+ * @param fullNodeInResponse if true, indicates that a representation of the created node (including all properties and
+ * children) should be returned; otherwise, only the path to the new node will be returned
* @param requestContent the JSON-encoded representation of the node or nodes to be added
* @return the JSON-encoded representation of the node or nodes that were added. This will differ from {@code requestContent}
* in that auto-created and protected properties (e.g., jcr:uuid) will be populated.
@@ -248,6 +250,7 @@ class ItemHandler extends AbstractHandler {
String rawRepositoryName,
String rawWorkspaceName,
String path,
+ boolean fullNodeInResponse,
String requestContent )
throws NotFoundException, UnauthorizedException, RepositoryException, JSONException {
@@ -268,8 +271,14 @@ class ItemHandler extends AbstractHandler {
session.save();
- String json = jsonFor(newNode, -1).toString();
- return Response.status(Status.CREATED).entity(json).build();
+ if (fullNodeInResponse) {
+
+ String json = jsonFor(newNode, -1).toString();
+ return Response.status(Status.CREATED).entity(json).build();
+ }
+
+ return Response.status(Status.CREATED).entity(newNode.getPath()).build();
+
}
/**
Index: web/modeshape-web-jcr-rest/src/main/java/org/modeshape/web/jcr/rest/JcrResources.java
===================================================================
--- web/modeshape-web-jcr-rest/src/main/java/org/modeshape/web/jcr/rest/JcrResources.java (revision 2501)
+++ web/modeshape-web-jcr-rest/src/main/java/org/modeshape/web/jcr/rest/JcrResources.java (working copy)
@@ -236,6 +236,9 @@ public class JcrResources extends AbstractHandler {
* @param rawRepositoryName the URL-encoded repository name
* @param rawWorkspaceName the URL-encoded workspace name
* @param path the path to the item
+ * @param fullNodeInResponse if {@code fullNodeInResponse == null || Boolean.valueOf(fullNodeInResponse)}, indicates that a
+ * representation of the created node (including all properties and children) should be returned; otherwise, only the
+ * path to the new node will be returned
* @param requestContent the JSON-encoded representation of the node or nodes to be added
* @return the JSON-encoded representation of the node or nodes that were added. This will differ from {@code requestContent}
* in that auto-created and protected properties (e.g., jcr:uuid) will be populated.
@@ -251,9 +254,15 @@ public class JcrResources extends AbstractHandler {
@PathParam( "repositoryName" ) String rawRepositoryName,
@PathParam( "workspaceName" ) String rawWorkspaceName,
@PathParam( "path" ) String path,
+ @QueryParam( "mode:includeNode" ) String fullNodeInResponse,
String requestContent )
throws NotFoundException, UnauthorizedException, RepositoryException, JSONException {
- return itemHandler.postItem(request, rawRepositoryName, rawWorkspaceName, path, requestContent);
+ return itemHandler.postItem(request,
+ rawRepositoryName,
+ rawWorkspaceName,
+ path,
+ fullNodeInResponse == null || Boolean.valueOf(fullNodeInResponse),
+ requestContent);
}
/**