mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Added client and server side support for transient properties
- As long as a template for a control is configured fields without a definition can now be displayed - Added 3 well known transient properties; mimetype, encoding and size (these are similar to the propertyResolvers we had in the JSF client) - Added explicit persistence handling for the new transient properties, the name property and adds aspect if title/description and/or author property is present - Added saveForm test git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13693 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -28,6 +28,8 @@ import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.web.scripts.TestWebScriptServer.GetRequest;
|
||||
import org.alfresco.web.scripts.TestWebScriptServer.PostRequest;
|
||||
import org.alfresco.web.scripts.TestWebScriptServer.Response;
|
||||
@@ -37,6 +39,7 @@ import org.json.JSONObject;
|
||||
public class FormRestApiJsonPost_Test extends AbstractTestFormRestApi
|
||||
{
|
||||
private static final String PROP_CM_DESCRIPTION = "prop_cm_description";
|
||||
private static final String PROP_MIMETYPE = "prop_mimetype";
|
||||
private static final String APPLICATION_JSON = "application/json";
|
||||
|
||||
public void testSimpleJsonPostRequest() throws IOException, JSONException
|
||||
@@ -46,10 +49,19 @@ public class FormRestApiJsonPost_Test extends AbstractTestFormRestApi
|
||||
nodeService.getProperty(testNodeRef, ContentModel.PROP_DESCRIPTION);
|
||||
assertEquals(TEST_FORM_DESCRIPTION, originalDescription);
|
||||
|
||||
// get the original mimetype
|
||||
String originalMimetype = null;
|
||||
ContentData content = (ContentData)this.nodeService.getProperty(testNodeRef, ContentModel.PROP_CONTENT);
|
||||
if (content != null)
|
||||
{
|
||||
originalMimetype = content.getMimetype();
|
||||
}
|
||||
|
||||
// Construct some JSON to represent a new value.
|
||||
JSONObject jsonPostData = new JSONObject();
|
||||
final String proposedNewDescription = "Modified Description";
|
||||
jsonPostData.put(PROP_CM_DESCRIPTION, proposedNewDescription);
|
||||
jsonPostData.put(PROP_MIMETYPE, MimetypeMap.MIMETYPE_HTML);
|
||||
|
||||
// Submit the JSON request.
|
||||
Response ignoredRsp = sendRequest(new PostRequest(testNodeUrl, jsonPostData.toString(),
|
||||
@@ -59,6 +71,15 @@ public class FormRestApiJsonPost_Test extends AbstractTestFormRestApi
|
||||
Serializable modifiedDescription =
|
||||
nodeService.getProperty(testNodeRef, ContentModel.PROP_DESCRIPTION);
|
||||
assertEquals(proposedNewDescription, modifiedDescription);
|
||||
|
||||
// get the original mimetype
|
||||
String modifiedMimetype = null;
|
||||
content = (ContentData)this.nodeService.getProperty(testNodeRef, ContentModel.PROP_CONTENT);
|
||||
if (content != null)
|
||||
{
|
||||
modifiedMimetype = content.getMimetype();
|
||||
}
|
||||
assertEquals(MimetypeMap.MIMETYPE_HTML, modifiedMimetype);
|
||||
|
||||
// The Rest API should also give us the modified property.
|
||||
Response response = sendRequest(new GetRequest(testNodeUrl), 200);
|
||||
@@ -70,5 +91,7 @@ public class FormRestApiJsonPost_Test extends AbstractTestFormRestApi
|
||||
assertNotNull(formData);
|
||||
String retrievedValue = (String)formData.get(PROP_CM_DESCRIPTION);
|
||||
assertEquals(modifiedDescription, retrievedValue);
|
||||
String retrievedMimetype = (String)formData.get(PROP_MIMETYPE);
|
||||
assertEquals(MimetypeMap.MIMETYPE_HTML, modifiedMimetype);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user