Updated image transformers to have formalised parameters, support for resize image transformations, get and update thumbnail implementation

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8779 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2008-04-15 14:14:43 +00:00
parent 5dfd4e413e
commit e943d32b38
16 changed files with 1058 additions and 199 deletions

View File

@@ -206,5 +206,29 @@ public class TransformationOptions
this.sourceContentProperty = (QName)optionsMap.get(OPT_SOURCE_CONTENT_PROPERTY);
this.targetNodeRef = (NodeRef)optionsMap.get(OPT_TARGET_NODEREF);
this.targetContentProperty = (QName)optionsMap.get(OPT_TARGET_CONTENT_PROPERTY);
}
}
/**
* Save the transformation options to the given node by applying the appropriate aspect
* and setting the meta data from the transformation options
*
* @param nodeRef the node reference
* @param nodeService the node service
*/
public void saveToNode(NodeRef nodeRef, NodeService nodeService)
{
// Do nothing for default transformation options
}
/**
* Populate the transformation options from the meta data present on the appropraite
* aspect on the passed node.
*
* @param nodeRef the node reference
* @param nodeService the node service
*/
public void populateFromNode(NodeRef nodeRef, NodeService nodeService)
{
// Do nothing for the detauls transformation options
}
}

View File

@@ -25,15 +25,16 @@
package org.alfresco.service.cmr.thumbnail;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.TransformationOptions;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.ParameterCheck;
/**
* This class provides the thumbnail generate options to the thumbnail service.
* This class provides the thumbnail create options to the thumbnail service.
*
* @author Roy Wetherall
*/
public class GenerateOptions
public class CreateOptions
{
/** Parent association details */
private ParentAssociationDetails assocDetails;
@@ -41,11 +42,19 @@ public class GenerateOptions
/** Name of the thumbnail */
private String thumbnailName;
/** The destination mimetype */
private String destinationMimetype;
/** Transformation options */
private TransformationOptions options;
/**
* Default constructor.
*/
public GenerateOptions()
public CreateOptions(String destinationMimetype, TransformationOptions options)
{
this.destinationMimetype = destinationMimetype;
this.options = options;
}
/**
@@ -53,8 +62,9 @@ public class GenerateOptions
*
* @param thumbnailName the name of the thumbnail, can be null
*/
public GenerateOptions(String thumbnailName)
public CreateOptions(String destinationMimetype, TransformationOptions options, String thumbnailName)
{
this(destinationMimetype, options);
this.thumbnailName= thumbnailName;
}
@@ -66,9 +76,60 @@ public class GenerateOptions
* @param assocType the child association type
* @param asscoName the child association name
*/
public GenerateOptions(String thumbnailName, NodeRef parent, QName assocType, QName assocName)
public CreateOptions(String destinationMimetype, TransformationOptions options, String thumbnailName,
NodeRef parent, QName assocType, QName assocName)
{
this(destinationMimetype, options, thumbnailName);
this.assocDetails = new ParentAssociationDetails(parent, assocType, assocName);
}
/**
* Set the destination mimetype
*
* @param destinationMimetype the destination minetype
*/
public void setDestinationMimetype(String destinationMimetype)
{
this.destinationMimetype = destinationMimetype;
}
/**
* Get the destination mimetype
*
* @return the destination mimetype
*/
public String getDestinationMimetype()
{
return destinationMimetype;
}
/**
* Set the transformation options
*
* @param options the transformation options
*/
public void setTransformationOptions(TransformationOptions options)
{
this.options = options;
}
/**
* Get the transformation options
*
* @return the transformation options
*/
public TransformationOptions getTransformationOptions()
{
return options;
}
/**
* Sets the name of the thumbnail
*
* @param thumbnailName the thumbnail name
*/
public void setThumbnailName(String thumbnailName)
{
this.assocDetails = new ParentAssociationDetails(parent, assocType, assocName);
this.thumbnailName = thumbnailName;
}
@@ -80,6 +141,16 @@ public class GenerateOptions
public String getThumbnailName()
{
return thumbnailName;
}
/**
* Sets the details of the thumnails parent association
*
* @param assocDetails the parent association details
*/
public void setParentAssociationDetails(ParentAssociationDetails assocDetails)
{
this.assocDetails = assocDetails;
}
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2008 Alfresco Software Limited.
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -24,11 +24,37 @@
*/
package org.alfresco.service.cmr.thumbnail;
import org.alfresco.error.AlfrescoRuntimeException;
/**
* Thumbnail service exception class
*
* @author Roy Wetherall
*/
public class AcceptOptions
public class ThumbnailException extends AlfrescoRuntimeException
{
/**
* Serial version UID
*/
private static final long serialVersionUID = 3257571685241467958L;
public ThumbnailException(String msgId)
{
super(msgId);
}
public ThumbnailException(String msgId, Object[] msgParams)
{
super(msgId, msgParams);
}
public ThumbnailException(String msgId, Object[] msgParams, Throwable cause)
{
super(msgId, msgParams, cause);
}
public ThumbnailException(String msgId, Throwable cause)
{
super(msgId, cause);
}
}

View File

@@ -28,6 +28,7 @@ import java.util.List;
import org.alfresco.service.Auditable;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.TransformationOptions;
import org.alfresco.service.namespace.QName;
/**
@@ -57,7 +58,7 @@ public interface ThumbnailService
* @return NodeRef node reference to the newly created thumbnail
*/
@Auditable(key = Auditable.Key.ARG_0, parameters = {"node", "contentProperty", "createOptions"})
NodeRef createThumbnail(NodeRef node, QName contentProperty, GenerateOptions createOptions);
NodeRef createThumbnail(NodeRef node, QName contentProperty, CreateOptions createOptions);
/**
* Updates the content of a thumbnail.
@@ -73,25 +74,37 @@ public interface ThumbnailService
void updateThumbnail(NodeRef thumbnail);
/**
* Gets a list of the thumbnails that are available for the node's content property, given a
* the accept options.
*
* The accept options contain details about the desired mimetypes, size and other parameters of
* a potential thumbnail. If any of the nodes thumbnails match these accept options they are
* added to the return list.
*
* The list of returned thumbnails is ordered, with the most appropriate thumbnail first. If no
* appropriate thumbnails are found then the list is returned empty.
*
* When no accept options are provided all available thumbnails are returned.
*
* @see org.alfresco.service.cmr.thumbnail.AcceptOptions
*
* @param node the content node
* @param contentProperty the content property
* @param acceptOptions the accept options
* @return List<NodeRef> list of thumbnails that match the accept options
* @param node
* @param contentProperty
* @param thumbnailName
* @return
*/
@Auditable(key = Auditable.Key.ARG_0, parameters = {"node", "contentProperty", "acceptOptions"})
List<NodeRef> getThumbnails(NodeRef node, QName contentProperty, AcceptOptions acceptOptions);
@Auditable(key = Auditable.Key.ARG_0, parameters = {"node", "contentProperty", "thumbnailName"})
NodeRef getThumbnailByName(NodeRef node, QName contentProperty, String thumbnailName);
/**
*
* @param node
* @param contentProperty
* @param mimetype
* @param options
* @return
*/
@Auditable(key = Auditable.Key.ARG_0, parameters = {"node", "contentProperty", "mimetype", "options"})
List<NodeRef> getThumbnails(NodeRef node, QName contentProperty, String mimetype, TransformationOptions options);
/**
* @see ThumbnailService#getThumbnails(NodeRef, QName, String, TransformationOptions)
*
* Transformation options defaulted to null.
*
* @param node
* @param contentProperty
* @param mimetype
* @return
*/
@Auditable(key = Auditable.Key.ARG_0, parameters = {"node", "contentProperty", "mimetype"})
List<NodeRef> getThumbnails(NodeRef node, QName contentProperty, String mimetype);
}