swf transformer (installed swf tool requied), minor refactor of thumbnail service, thumbnailRegistry created (smallImage and webpreview thumbnail types added), start of thumbnail JS API (extensions to ScriptNode) and POST URL to create thumbnails

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9259 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2008-05-23 21:19:50 +00:00
parent 6910c48c62
commit bb3c776130
23 changed files with 1598 additions and 336 deletions

View File

@@ -40,6 +40,9 @@ import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.executer.TransformActionExecuter;
import org.alfresco.repo.content.transform.magick.ImageTransformationOptions;
import org.alfresco.repo.search.QueryParameterDefImpl;
import org.alfresco.repo.thumbnail.ThumbnailDetails;
import org.alfresco.repo.thumbnail.ThumbnailRegistry;
import org.alfresco.repo.thumbnail.script.ScriptThumbnail;
import org.alfresco.repo.version.VersionModel;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
@@ -237,6 +240,22 @@ public class ScriptNode implements Serializable, Scopeable
return this.id;
}
/**
* @return the store type for the node
*/
public String getStoreType()
{
return this.nodeRef.getStoreRef().getProtocol();
}
/**
* @return the store id for the node
*/
public String getStoreId()
{
return this.nodeRef.getStoreRef().getIdentifier();
}
/**
* @return Returns the NodeRef this Node object represents
*/
@@ -1872,6 +1891,58 @@ public class ScriptNode implements Serializable, Scopeable
return this.services.getTemplateService().processTemplateString(null, template, model);
}
// ------------------------------------------------------------------------------
// Thumbnail Methods
/**
* Creates a thumbnail for the content property of the node.
*
* The thumbnail name correspionds to pre-set thumbnail details stored in the
* repository.
*
* @param thumbnailName the name of the thumbnail
* @return ScriptThumbnail the newly create thumbnail node
*/
public ScriptThumbnail createThumbnail(String thumbnailName)
{
// Use the thumbnail registy to get the details of the thumbail
ThumbnailRegistry registry = this.services.getThumbnailService().getThumbnailRegistry();
ThumbnailDetails details = registry.getThumbnailDetails(thumbnailName);
if (details == null)
{
// Throw exception
}
NodeRef thumbnailNodeRef = this.services.getThumbnailService().createThumbnail(
this.nodeRef,
ContentModel.PROP_CONTENT,
details.getMimetype(),
details.getTransformationOptions(),
details.getName());
// Return thumbnail
return new ScriptThumbnail(thumbnailNodeRef, this.services, this.scope);
}
public ScriptThumbnail getThumbnail(String thumbnailName)
{
ScriptThumbnail result = null;
NodeRef thumbnailNodeRef = this.services.getThumbnailService().getThumbnailByName(
this.nodeRef,
ContentModel.PROP_CONTENT,
thumbnailName);
if (thumbnailNodeRef != null)
{
result = new ScriptThumbnail(thumbnailNodeRef, this.services, this.scope);
}
return result;
}
public ScriptableHashMap<String, ScriptThumbnail> getThumbnails()
{
return null;
}
// ------------------------------------------------------------------------------
// Helper methods

View File

@@ -29,6 +29,7 @@ import java.util.LinkedHashSet;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.model.Repository;
import org.alfresco.repo.search.impl.lucene.LuceneQueryParser;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.ContentReader;
@@ -64,6 +65,9 @@ public final class Search extends BaseScopableProcessorExtension
/** Default store reference */
private StoreRef storeRef;
/** Repository helper */
private Repository repository;
/**
* Set the default store reference
@@ -84,6 +88,16 @@ public final class Search extends BaseScopableProcessorExtension
{
this.services = services;
}
/**
* Set the repository helper
*
* @param repository the repository helper
*/
public void setRepositoryHelper(Repository repository)
{
this.repository = repository;
}
/**
* Find a single Node by the Node reference
@@ -118,6 +132,40 @@ public final class Search extends BaseScopableProcessorExtension
}
}
/**
* Helper to convert a Web Script Request URL to a Node Ref
*
* 1) Node - {store_type}/{store_id}/{node_id}
*
* Resolve to node via its Node Reference.
*
* 2) Path - {store_type}/{store_id}/{path}
*
* Resolve to node via its display path.
*
* 3) AVM Path - {store_id}/{path}
*
* Resolve to AVM node via its display path
*
* 4) QName - {store_type}/{store_id}/{child_qname_path}
*
* Resolve to node via its child qname path.
*
* @param referenceType one of node, path, avmpath or qname
* @param reference array of reference segments (as described above for each reference type)
* @return ScriptNode the script node
*/
public ScriptNode findNode(String referenceType, String[] reference)
{
ScriptNode result = null;
NodeRef nodeRef = this.repository.findNodeRef(referenceType, reference);
if (nodeRef != null)
{
result = new ScriptNode(nodeRef, this.services, getScope());
}
return result;
}
/**
* Execute a XPath search
*