mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.1/Cloud)
96317: Merged 5.0.N (5.0.1) to HEAD-BUG-FIX (5.1/Cloud) 96272: Merged V4.2-BUG-FIX (4.2.5) to 5.0.N (5.0.1) 96106: Merged V4.1-BUG-FIX (4.1.10) to V4.2-BUG-FIX (4.2.5) 96045: Merged DEV to V4.1-BUG-FIX (4.1.10) 94227 : MNT-12569: Problems with org/alfresco/repository/thumbnail scripts - Added a test 94339 : MNT-12569: Problems with org/alfresco/repository/thumbnail scripts - Implemented 'PUT' method git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@96483 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,45 @@
|
|||||||
|
function main()
|
||||||
|
{
|
||||||
|
// Get the node from the URL
|
||||||
|
var pathSegments = url.match.split("/");
|
||||||
|
var reference = [ url.templateArgs.store_type, url.templateArgs.store_id ].concat(url.templateArgs.id.split("/"));
|
||||||
|
var node = search.findNode(pathSegments[2], reference);
|
||||||
|
|
||||||
|
// 404 if the node to thumbnail is not found
|
||||||
|
if (node == null)
|
||||||
|
{
|
||||||
|
status.setCode(status.STATUS_NOT_FOUND, "The thumbnail source node could not be found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 400 if the node is not a subtype of cm:content
|
||||||
|
if (!node.isSubType("cm:content"))
|
||||||
|
{
|
||||||
|
status.setCode(status.STATUS_BAD_REQUEST, "The thumbnail source node is not a subtype of cm:content");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the thumbnail name from the JSON content
|
||||||
|
var thumbnailName = url.templateArgs.thumbnailname;
|
||||||
|
|
||||||
|
// 404 if no thumbnail name found
|
||||||
|
if (thumbnailName == null)
|
||||||
|
{
|
||||||
|
status.setCode(status.STATUS_NOT_FOUND, "Thumbnail name was not provided");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the thumbnail
|
||||||
|
var thumbnail = node.getThumbnail(thumbnailName);
|
||||||
|
|
||||||
|
if (thumbnail != null)
|
||||||
|
{
|
||||||
|
thumbnail.update();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
status.setCode(status.STATUS_NOT_FOUND, "Thumbnail with name '" + thumbnailName + "' not found");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main();
|
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"Status Code": ${status.code}
|
||||||
|
}
|
@@ -42,6 +42,7 @@ import org.json.JSONArray;
|
|||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest;
|
import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest;
|
||||||
import org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest;
|
import org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest;
|
||||||
|
import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest;
|
||||||
import org.springframework.extensions.webscripts.TestWebScriptServer.Response;
|
import org.springframework.extensions.webscripts.TestWebScriptServer.Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -212,6 +213,31 @@ public class ThumbnailServiceTest extends BaseWebScriptTest
|
|||||||
assertEquals(0, getArr.length());
|
assertEquals(0, getArr.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testUpdateThumbnail() throws Exception
|
||||||
|
{
|
||||||
|
// Do a image transformation
|
||||||
|
String url = "/api/node/" + jpgNode.getStoreRef().getProtocol() + "/" + jpgNode.getStoreRef().getIdentifier() + "/" + jpgNode.getId() + "/content/thumbnails";
|
||||||
|
JSONObject tn = new JSONObject();
|
||||||
|
tn.put("thumbnailName", "doclib");
|
||||||
|
Response response = sendRequest(new PostRequest(url, tn.toString(), "application/json"), 200);
|
||||||
|
System.out.println(response.getContentAsString());
|
||||||
|
|
||||||
|
// Check getAll whilst we are here
|
||||||
|
Response getAllResp = sendRequest(new GetRequest(getThumbnailsURL(jpgNode)), 200);
|
||||||
|
JSONArray getArr = new JSONArray(getAllResp.getContentAsString());
|
||||||
|
assertNotNull(getArr);
|
||||||
|
assertEquals(1, getArr.length());
|
||||||
|
assertEquals("doclib", getArr.getJSONObject(0).get("thumbnailName"));
|
||||||
|
//Now we know that thumbnail was created
|
||||||
|
|
||||||
|
|
||||||
|
sendRequest(new GetRequest(getThumbnailsURL(jpgNode) + "/incorrectname"), 404);
|
||||||
|
//Request for update of thumbnail, that is absent
|
||||||
|
sendRequest(new PutRequest(getThumbnailsURL(jpgNode) + "/incorrectname", "", "application/json"), 404);
|
||||||
|
//Request for update of correct thumbnail
|
||||||
|
sendRequest(new PutRequest(getThumbnailsURL(jpgNode) + "/doclib", "", "application/json"), 200);
|
||||||
|
}
|
||||||
|
|
||||||
public void testThumbnailDefinitions() throws Exception
|
public void testThumbnailDefinitions() throws Exception
|
||||||
{
|
{
|
||||||
// Check for pdfToSWF transformation before doing test
|
// Check for pdfToSWF transformation before doing test
|
||||||
|
Reference in New Issue
Block a user