mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Thumbnail Service: removed unessesary code to store transformation options on node, added GET for thumbnail collection resource, created thumbnails are kept in sync with the master file asynchronously
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9452 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
<#macro thumbnailJSON node thumbnailName>
|
||||
{
|
||||
"thumbnailName" : "${thumbnailName}",
|
||||
"url" : "${url.serviceContext}/api/node/${node.storeType}/${node.storeId}/${node.id}/content/thumbnails/${thumbnailName}"
|
||||
}
|
||||
</#macro>
|
@@ -0,0 +1,23 @@
|
||||
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;
|
||||
}
|
||||
|
||||
// Get the thumbnails
|
||||
var thumbnails = node.getThumbnails();
|
||||
|
||||
// Add them to the model
|
||||
model.node = node;
|
||||
model.thumbnails = thumbnails;
|
||||
}
|
||||
|
||||
main();
|
@@ -0,0 +1,8 @@
|
||||
<#import "thumbnail.lib.ftl" as thumbnailLib/>
|
||||
|
||||
[
|
||||
<#list thumbnails as thumbnail>
|
||||
<@thumbnailLib.thumbnailJSON node=node thumbnailName=thumbnail.properties.thumbnailName/>
|
||||
<#if thumbnail_has_next>,</#if>
|
||||
</#list>
|
||||
]
|
@@ -1,6 +1,5 @@
|
||||
<#import "thumbnail.lib.ftl" as thumbnailLib/>
|
||||
|
||||
<#if node?exists>
|
||||
{
|
||||
"thumbnailName" : "${thumbnailName}",
|
||||
"url" : "${url.serviceContext}/api/node/${node.storeType}/${node.storeId}/${node.id}/content/thumbnails/${thumbnailName}"
|
||||
}
|
||||
<@thumbnailLib.thumbnailJSON node=node thumbnailName=thumbnailName/>
|
||||
</#if>
|
@@ -38,6 +38,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.apache.tools.ant.taskdefs.Sleep;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.mock.web.MockHttpServletResponse;
|
||||
|
||||
@@ -115,6 +116,12 @@ public class ThumbnailServiceTest extends BaseWebScriptTest
|
||||
System.out.println(response.getContentAsString());
|
||||
}
|
||||
|
||||
// Check getAll whilst we are here
|
||||
MockHttpServletResponse getAllResp = this.getRequest(getThumbnailsURL(jpgNode), 200);
|
||||
JSONArray getArr = new JSONArray(getAllResp.getContentAsString());
|
||||
assertNotNull(getArr);
|
||||
assertEquals(0, getArr.length());
|
||||
|
||||
// Do a image transformation (medium)
|
||||
String url = "/api/node/" + jpgNode.getStoreRef().getProtocol() + "/" + jpgNode.getStoreRef().getIdentifier() + "/" + jpgNode.getId() + "/content/thumbnails";
|
||||
JSONObject tn = new JSONObject();
|
||||
@@ -127,6 +134,13 @@ public class ThumbnailServiceTest extends BaseWebScriptTest
|
||||
System.out.println(thumbnailUrl);
|
||||
response = getRequest(thumbnailUrl, 200);
|
||||
|
||||
// Check getAll whilst we are here
|
||||
getAllResp = this.getRequest(getThumbnailsURL(jpgNode), 200);
|
||||
getArr = new JSONArray(getAllResp.getContentAsString());
|
||||
assertNotNull(getArr);
|
||||
assertEquals(1, getArr.length());
|
||||
assertEquals("medium", getArr.getJSONObject(0).get("thumbnailName"));
|
||||
|
||||
}
|
||||
|
||||
public void testCreateAsyncThumbnail() throws Exception
|
||||
@@ -154,7 +168,6 @@ public class ThumbnailServiceTest extends BaseWebScriptTest
|
||||
getWait(jpgNode, "medium");
|
||||
}
|
||||
|
||||
|
||||
private void getWait(NodeRef node, String thumbnailName)
|
||||
throws Exception
|
||||
{
|
||||
|
Reference in New Issue
Block a user