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 fb856c8da6
commit 725497edc9
12 changed files with 409 additions and 291 deletions

View File

@@ -24,15 +24,7 @@
*/
package org.alfresco.repo.content.transform.magick;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.TransformationOptions;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
/**
* Image transformation options
@@ -41,16 +33,6 @@ import org.alfresco.service.namespace.QName;
*/
public class ImageTransformationOptions extends TransformationOptions
{
/** imageTransformOptions aspect details */
public static final QName ASPECT_IMAGE_TRANSFORATION_OPTIONS = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "imageTransformationOptions");
public static final QName PROP_COMMAND_OPTIONS = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "commandOptions");
public static final QName PROP_RESIZE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "resize");
public static final QName PROP_RESIZE_WIDTH = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "resizeWidth");
public static final QName PROP_RESIZE_HEIGHT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "resizeHeight");
public static final QName PROP_RESIZE_MAINTAIN_ASPECT_RATIO = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "resizeMaintainAspectRatio");
public static final QName PROP_RESIZE_PERCENT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "resizePercent");
public static final QName PROP_RESIZE_TO_THUMBNAIL = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "resizeToThumbnail");
/** Command string options, provided for backward compatibility */
private String commandOptions = "";
@@ -96,74 +78,4 @@ public class ImageTransformationOptions extends TransformationOptions
{
return resizeOptions;
}
/**
* Save the transformation options to the ImageTransformationOptions aspect.
*
* @see org.alfresco.service.cmr.repository.TransformationOptions#saveToNode(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeService)
*/
@Override
public void saveToNode(NodeRef nodeRef, NodeService nodeService)
{
super.saveToNode(nodeRef, nodeService);
// Create a list of the properties
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(7);
properties.put(PROP_COMMAND_OPTIONS, this.commandOptions);
if (this.resizeOptions != null)
{
properties.put(PROP_RESIZE, true);
properties.put(PROP_RESIZE_HEIGHT, this.resizeOptions.getHeight());
properties.put(PROP_RESIZE_WIDTH, this.resizeOptions.getWidth());
properties.put(PROP_RESIZE_MAINTAIN_ASPECT_RATIO, this.resizeOptions.isMaintainAspectRatio());
properties.put(PROP_RESIZE_PERCENT, this.resizeOptions.isPercentResize());
properties.put(PROP_RESIZE_TO_THUMBNAIL, this.resizeOptions.isResizeToThumbnail());
}
else
{
properties.put(PROP_RESIZE, false);
}
// Add the aspect
nodeService.addAspect(nodeRef, ASPECT_IMAGE_TRANSFORATION_OPTIONS, properties);
}
/**
* Populate the image transformation options from the node provided.
*
* @see org.alfresco.service.cmr.repository.TransformationOptions#populateFromNode(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeService)
*/
@Override
public void populateFromNode(NodeRef nodeRef, NodeService nodeService)
{
super.populateFromNode(nodeRef, nodeService);
// Check whether the node has the image transformation options aspect
if (nodeService.hasAspect(nodeRef, ASPECT_IMAGE_TRANSFORATION_OPTIONS) == true)
{
// Get the node's properties
Map<QName, Serializable> properties = nodeService.getProperties(nodeRef);
// Set the properties
this.commandOptions = (String)properties.get(PROP_COMMAND_OPTIONS);
// Set the resize properties
Boolean isResize = (Boolean)properties.get(PROP_RESIZE);
if (isResize.booleanValue() == true)
{
int height = ((Long)properties.get(PROP_RESIZE_HEIGHT)).intValue();
int width = ((Long)properties.get(PROP_RESIZE_WIDTH)).intValue();
boolean maintainAspectRatio = ((Boolean)properties.get(PROP_RESIZE_MAINTAIN_ASPECT_RATIO)).booleanValue();
boolean percentResize = ((Boolean)properties.get(PROP_RESIZE_PERCENT)).booleanValue();
boolean resizeToThumbnail = ((Boolean)properties.get(PROP_RESIZE_TO_THUMBNAIL)).booleanValue();
this.resizeOptions = new ImageResizeOptions();
this.resizeOptions.setHeight(height);
this.resizeOptions.setWidth(width);
this.resizeOptions.setMaintainAspectRatio(maintainAspectRatio);
this.resizeOptions.setPercentResize(percentResize);
this.resizeOptions.setResizeToThumbnail(resizeToThumbnail);
}
}
}
}

View File

@@ -24,15 +24,7 @@
*/
package org.alfresco.repo.content.transform.swf;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.TransformationOptions;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
/**
* SFW transformation options
@@ -41,9 +33,6 @@ import org.alfresco.service.namespace.QName;
*/
public class SWFTransformationOptions extends TransformationOptions
{
private final static QName ASPECT_SWF_TRANSFORMATION_OPTIONS = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "swfTransformationOptions");
private final static QName PROP_FLASH_VERSION = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "flashVerison");
/** The version of the flash to convert to */
private String flashVersion = "9";
@@ -56,30 +45,4 @@ public class SWFTransformationOptions extends TransformationOptions
{
return flashVersion;
}
@Override
public void saveToNode(NodeRef nodeRef, NodeService nodeService)
{
super.saveToNode(nodeRef, nodeService);
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(7);
properties.put(PROP_FLASH_VERSION, this.flashVersion);
nodeService.addAspect(nodeRef, ASPECT_SWF_TRANSFORMATION_OPTIONS, properties);
}
@Override
public void populateFromNode(NodeRef nodeRef, NodeService nodeService)
{
super.populateFromNode(nodeRef, nodeService);
// Check whether the node has the image transformation options aspect
if (nodeService.hasAspect(nodeRef, ASPECT_SWF_TRANSFORMATION_OPTIONS) == true)
{
// Get the node's properties
Map<QName, Serializable> properties = nodeService.getProperties(nodeRef);
// Set the properties
this.flashVersion = (String)properties.get(PROP_FLASH_VERSION);
}
}
}