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:
Roy Wetherall
2008-06-11 15:27:03 +00:00
parent 7bea34b914
commit 132c0af749
5 changed files with 54 additions and 5 deletions

View File

@@ -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>

View File

@@ -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();

View File

@@ -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>
]

View File

@@ -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>

View File

@@ -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
{