mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
Transformation service changes to support thumbnail service, shell of thumbnail service API
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8658 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -147,6 +147,7 @@ public interface ContentService
|
||||
|
||||
/**
|
||||
* @see org.aflresco.service.cmr.repository.ContentService.transform(ContentReader, ContentReader)
|
||||
* @see org.aflresco.service.cmr.repository.ContentService.transform(ContentReader, ContentWriter, TransformationOptions)
|
||||
*
|
||||
* A map of transform options can be provided.
|
||||
*
|
||||
@@ -156,24 +157,68 @@ public interface ContentService
|
||||
* @throws NoTransformerException if no transformer exists for the
|
||||
* given source and target mimetypes of the reader and writer
|
||||
* @throws ContentIOException if the transformation fails
|
||||
*
|
||||
* @depricated
|
||||
* As of release 3.0 the TransformOptions class should be used to pass transformation options
|
||||
* to a transformation execution.
|
||||
*/
|
||||
@Auditable(parameters = {"reader", "writer", "options"})
|
||||
@Deprecated
|
||||
public void transform(ContentReader reader, ContentWriter writer, Map<String, Object> options)
|
||||
throws NoTransformerException, ContentIOException;
|
||||
|
||||
/**
|
||||
* @see org.aflresco.service.cmr.repository.ContentService.transform(ContentReader, ContentReader)
|
||||
*
|
||||
* A transformation options can be provided.
|
||||
*
|
||||
* @param reader the source content location and mimetype
|
||||
* @param writer the target content location and mimetype
|
||||
* @param options the options for the transformation
|
||||
* @throws NoTransformerException if no transformer exists for the
|
||||
* given source and target mimetypes of the reader and writer
|
||||
* @throws ContentIOException if the transformation fails
|
||||
*/
|
||||
@Auditable(parameters = {"reader", "writer", "options"})
|
||||
public void transform(ContentReader reader, ContentWriter writer, TransformationOptions options)
|
||||
throws NoTransformerException, ContentIOException;
|
||||
|
||||
/**
|
||||
* Fetch the transformer that is capable of transforming the content in the
|
||||
* given source mimetype to the given target mimetype.
|
||||
* <p>
|
||||
* Since no transformation options are provided only the source and destination mimetypes are
|
||||
* considered when getting the correct transformer.
|
||||
*
|
||||
* @param the source mimetype
|
||||
* @param the target mimetype
|
||||
* @return Returns a transformer that can be used, or null if one was not available
|
||||
*
|
||||
* @see org.alfresco.service.cmr.respository.ContentService.getTransformer(String, String, TransformationOptions)
|
||||
* @see ContentAccessor#getMimetype()
|
||||
*/
|
||||
@Auditable(parameters = {"sourceMimetype", "targetMimetype"})
|
||||
public ContentTransformer getTransformer(String sourceMimetype, String targetMimetype);
|
||||
|
||||
/**
|
||||
* Fetch the transformer that is capable of transforming the content in the
|
||||
* given source mimetype to the given target mimetype with the provided transformation
|
||||
* options.
|
||||
* <p>
|
||||
* The transformation options provide a finer grain way of discoving the correct transformer,
|
||||
* since the values and type of the options provided are considered by the transformer when
|
||||
* deciding whether it can satisfy the transformation request.
|
||||
*
|
||||
* @param sourceMimetype the source mimetype
|
||||
* @param targetMimetype the target mimetype
|
||||
* @param options the transformation options
|
||||
* @return ContentTransformer a transformer that can be used, or null if one was not available
|
||||
*
|
||||
* @see ContentAccessor#getMimetype()
|
||||
*/
|
||||
@Auditable(parameters = {"sourceMimetype", "targetMimetype", "options"})
|
||||
public ContentTransformer getTransformer(String sourceMimetype, String targetMimetype, TransformationOptions options);
|
||||
|
||||
/**
|
||||
* Fetch the transformer that is capable of transforming image content.
|
||||
*
|
||||
@@ -186,6 +231,9 @@ public interface ContentService
|
||||
* Returns whether a transformer exists that can read the content from
|
||||
* the reader and write the content back out to the writer.
|
||||
* <p>
|
||||
* Since no transformation options are specified, only the source and target
|
||||
* mimetypes will be considered when making this decision.
|
||||
* <p>
|
||||
* The mimetypes used for the transformation must be set both on
|
||||
* the {@link ContentAccessor#getMimetype() reader} and on the
|
||||
* {@link ContentAccessor#getMimetype() writer}.
|
||||
@@ -194,7 +242,26 @@ public interface ContentService
|
||||
* @param writer the target content location and mimetype
|
||||
*
|
||||
* @return true if a transformer exists, false otherwise
|
||||
*
|
||||
* @see org.alfresco.service.cmr.repository.ContentService.isTransformable(ContentReader, ContentWriter, TransformationOptions)
|
||||
*/
|
||||
@Auditable(parameters = {"reader", "writer"})
|
||||
public boolean isTransformable(ContentReader reader, ContentWriter writer);
|
||||
|
||||
/**
|
||||
* Returns whether a transformer exists that can read the content from
|
||||
* the reader and write the content back out to the writer with the
|
||||
* provided tranformation options.
|
||||
* <p>
|
||||
* The mimetypes used for the transformation must be set both on
|
||||
* the {@link ContentAccessor#getMimetype() reader} and on the
|
||||
* {@link ContentAccessor#getMimetype() writer}.
|
||||
*
|
||||
* @param reader the source content location and mimetype
|
||||
* @param writer the target content location and mimetype
|
||||
* @param options the transformation options
|
||||
* @return boolean true if a transformer exists, false otherwise
|
||||
*/
|
||||
@Auditable(parameters = {"reader", "writer", "options"})
|
||||
public boolean isTransformable(ContentReader reader, ContentWriter writer, TransformationOptions options);
|
||||
}
|
||||
|
@@ -0,0 +1,201 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 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
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.service.cmr.repository;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Tansformation options.
|
||||
* <p>
|
||||
* Class containing values of options that are passed to content transformers. These options
|
||||
* are used to determine the applicability of a content transformer and also during the
|
||||
* transformation process to provide context or parameter values.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class TransformationOptions
|
||||
{
|
||||
/** Option map names to preserve backward compatibility */
|
||||
public static final String OPT_SOURCE_NODEREF = "sourceNodeRef";
|
||||
public static final String OPT_SOURCE_CONTENT_PROPERTY = "sourceContentProperty";
|
||||
public static final String OPT_TARGET_NODEREF = "targetNodeRef";
|
||||
public static final String OPT_TARGET_CONTENT_PROPERTY = "targetContentProperty";
|
||||
|
||||
/** The source node reference */
|
||||
private NodeRef sourceNodeRef;
|
||||
|
||||
/** The source content property */
|
||||
private QName sourceContentProperty;
|
||||
|
||||
/** The target node reference */
|
||||
private NodeRef targetNodeRef;
|
||||
|
||||
/** The target content property */
|
||||
private QName targetContentProperty;
|
||||
|
||||
/**
|
||||
* Default construtor
|
||||
*/
|
||||
public TransformationOptions()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param sourceNodeRef the source node reference
|
||||
* @param sourceContentProperty the source content property
|
||||
* @param targetNodeRef the target node reference
|
||||
* @param targetContentProperty the target content property
|
||||
*/
|
||||
public TransformationOptions(NodeRef sourceNodeRef, QName sourceContentProperty, NodeRef targetNodeRef, QName targetContentProperty)
|
||||
{
|
||||
this.sourceNodeRef = sourceNodeRef;
|
||||
this.sourceContentProperty = sourceContentProperty;
|
||||
this.targetNodeRef = targetNodeRef;
|
||||
this.targetContentProperty = targetContentProperty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constrcutor. Creates a transformation options object from a map.
|
||||
* Provided for back ward compatibility.
|
||||
*
|
||||
* @param optionsMap options map
|
||||
*/
|
||||
public TransformationOptions(Map<String, Object> optionsMap)
|
||||
{
|
||||
fromMapImpl(optionsMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the source node reference
|
||||
*
|
||||
* @param sourceNodeRef the source node reference
|
||||
*/
|
||||
public void setSourceNodeRef(NodeRef sourceNodeRef)
|
||||
{
|
||||
this.sourceNodeRef = sourceNodeRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the source node reference
|
||||
*
|
||||
* @return NodeRef the source node reference
|
||||
*/
|
||||
public NodeRef getSourceNodeRef()
|
||||
{
|
||||
return sourceNodeRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the source content property
|
||||
*
|
||||
* @param sourceContentProperty the source content property
|
||||
*/
|
||||
public void setSourceContentProperty(QName sourceContentProperty)
|
||||
{
|
||||
this.sourceContentProperty = sourceContentProperty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the source content property
|
||||
*
|
||||
* @return the source content property
|
||||
*/
|
||||
public QName getSourceContentProperty()
|
||||
{
|
||||
return sourceContentProperty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the taget node reference
|
||||
*
|
||||
* @param targetNodeRef the target node reference
|
||||
*/
|
||||
public void setTargetNodeRef(NodeRef targetNodeRef)
|
||||
{
|
||||
this.targetNodeRef = targetNodeRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the target node reference
|
||||
*
|
||||
* @return the target node reference
|
||||
*/
|
||||
public NodeRef getTargetNodeRef()
|
||||
{
|
||||
return targetNodeRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the target content property
|
||||
*
|
||||
* @param targetContentProperty the target content property
|
||||
*/
|
||||
public void setTargetContentProperty(QName targetContentProperty)
|
||||
{
|
||||
this.targetContentProperty = targetContentProperty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the target content property
|
||||
*
|
||||
* @return the target property
|
||||
*/
|
||||
public QName getTargetContentProperty()
|
||||
{
|
||||
return targetContentProperty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the transformation options object into an equivalent map
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> toMap()
|
||||
{
|
||||
return new HashMap<String, Object>(10);
|
||||
}
|
||||
|
||||
protected void toMapImpl(Map<String, Object> optionsMap)
|
||||
{
|
||||
optionsMap.put(OPT_SOURCE_NODEREF, getSourceNodeRef());
|
||||
optionsMap.put(OPT_SOURCE_CONTENT_PROPERTY, getSourceContentProperty());
|
||||
optionsMap.put(OPT_TARGET_NODEREF, getTargetNodeRef());
|
||||
optionsMap.put(OPT_TARGET_CONTENT_PROPERTY, getTargetContentProperty());
|
||||
}
|
||||
|
||||
protected void fromMapImpl(Map<String, Object> optionsMap)
|
||||
{
|
||||
this.sourceNodeRef = (NodeRef)optionsMap.get(OPT_SOURCE_NODEREF);
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user