mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
Merged 5.2.N (5.2.1) to HEAD (5.2)
128569 adavis: MNT-16381 Transformers must validate the content stream mimetype - Ensure error when indexer is the caller includes the file name rather than null. NodeContentGet now calls transform method with TransformationOptions parameter and the original transformer method was deprecated as it should be been when this extra parameter was added. - Set the strictMimeTypeCheck and retryTransformOnDifferentMimeType properties on dynamically created pipeline and fail over transformers from global properties as is don for static transformers. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@129293 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -656,7 +656,12 @@ public abstract class AbstractContentTransformer2 extends AbstractContentTransfo
|
||||
transformerConfig.getStatistics(null, sourceMimetype, targetMimetype, true).recordError(transformationTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Object getRetryTransformOnDifferentMimeType()
|
||||
{
|
||||
return retryTransformOnDifferentMimeType;
|
||||
}
|
||||
|
||||
public void setRetryTransformOnDifferentMimeType(boolean retryTransformOnDifferentMimeType)
|
||||
{
|
||||
this.retryTransformOnDifferentMimeType = retryTransformOnDifferentMimeType;
|
||||
|
@@ -138,7 +138,10 @@ public interface ContentTransformer extends ContentWorker
|
||||
public long getTransformationTime(String sourceMimetype, String targetMimetype);
|
||||
|
||||
/**
|
||||
* @see #transform(ContentReader, ContentWriter, TransformationOptions)
|
||||
* @see #transform(ContentReader, ContentWriter, TransformationOptions)
|
||||
*
|
||||
* @deprecated
|
||||
* Deprecated use {link {@link #transform(ContentReader, ContentWriter, TransformationOptions)}.
|
||||
*/
|
||||
public void transform(ContentReader reader, ContentWriter writer) throws ContentIOException;
|
||||
|
||||
|
@@ -36,8 +36,9 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.service.cmr.module.ModuleService;
|
||||
@@ -60,15 +61,17 @@ public class TransformerConfigDynamicTransformers extends TransformerPropertyNam
|
||||
|
||||
public TransformerConfigDynamicTransformers(TransformerConfig transformerConfig, TransformerProperties transformerProperties,
|
||||
MimetypeService mimetypeService, ContentService contentService, ContentTransformerRegistry transformerRegistry,
|
||||
TransformerDebug transformerDebug, ModuleService moduleService, DescriptorService descriptorService)
|
||||
TransformerDebug transformerDebug, ModuleService moduleService, DescriptorService descriptorService,
|
||||
Properties globalProperties)
|
||||
{
|
||||
createDynamicTransformers(transformerConfig, transformerProperties, mimetypeService, contentService,
|
||||
transformerRegistry, transformerDebug, moduleService, descriptorService);
|
||||
transformerRegistry, transformerDebug, moduleService, descriptorService, globalProperties);
|
||||
}
|
||||
|
||||
private void createDynamicTransformers(TransformerConfig transformerConfig, TransformerProperties transformerProperties,
|
||||
MimetypeService mimetypeService, ContentService contentService, ContentTransformerRegistry transformerRegistry,
|
||||
TransformerDebug transformerDebug, ModuleService moduleService, DescriptorService descriptorService)
|
||||
TransformerDebug transformerDebug, ModuleService moduleService, DescriptorService descriptorService,
|
||||
Properties globalProperties)
|
||||
{
|
||||
Collection<String> SUFFIXES = Arrays.asList(new String [] {
|
||||
FAILOVER,
|
||||
@@ -118,9 +121,11 @@ public class TransformerConfigDynamicTransformers extends TransformerPropertyNam
|
||||
|
||||
AbstractContentTransformer2 transformer = property.suffix.equals(PIPELINE)
|
||||
? createComplexTransformer(property, transformerConfig, mimetypeService,
|
||||
contentService, transformerRegistry, transformerDebug, available)
|
||||
contentService, transformerRegistry, transformerDebug, available,
|
||||
globalProperties)
|
||||
: createFailoverTransformer(property, transformerConfig, mimetypeService,
|
||||
contentService, transformerRegistry, transformerDebug, available);
|
||||
contentService, transformerRegistry, transformerDebug, available,
|
||||
globalProperties);
|
||||
transformer.register();
|
||||
processed.add(property);
|
||||
dynamicTransformers.add(transformer);
|
||||
@@ -168,7 +173,7 @@ public class TransformerConfigDynamicTransformers extends TransformerPropertyNam
|
||||
TransformerConfig transformerConfig,
|
||||
MimetypeService mimetypeService, ContentService contentService,
|
||||
ContentTransformerRegistry transformerRegistry, TransformerDebug transformerDebug,
|
||||
boolean available)
|
||||
boolean available, Properties globalProperties)
|
||||
{
|
||||
List<ContentTransformer> transformers = new ArrayList<ContentTransformer>();
|
||||
List<String> intermediateMimetypes = new ArrayList<String>();
|
||||
@@ -185,7 +190,7 @@ public class TransformerConfigDynamicTransformers extends TransformerPropertyNam
|
||||
}
|
||||
};
|
||||
setupContentTransformer2(property, transformerConfig, mimetypeService, contentService,
|
||||
transformerRegistry, transformerDebug, available, transformer, transformers);
|
||||
transformerRegistry, transformerDebug, available, transformer, transformers, globalProperties);
|
||||
|
||||
// baseComplexContentTransformer
|
||||
transformer.setContentService(contentService);
|
||||
@@ -201,7 +206,7 @@ public class TransformerConfigDynamicTransformers extends TransformerPropertyNam
|
||||
TransformerConfig transformerConfig,
|
||||
MimetypeService mimetypeService, ContentService contentService,
|
||||
ContentTransformerRegistry transformerRegistry, TransformerDebug transformerDebug,
|
||||
boolean available)
|
||||
boolean available, Properties globalProperties)
|
||||
{
|
||||
List<ContentTransformer> transformers = new ArrayList<ContentTransformer>();
|
||||
|
||||
@@ -217,7 +222,7 @@ public class TransformerConfigDynamicTransformers extends TransformerPropertyNam
|
||||
}
|
||||
};
|
||||
setupContentTransformer2(property, transformerConfig, mimetypeService, contentService,
|
||||
transformerRegistry, transformerDebug, available, transformer, transformers);
|
||||
transformerRegistry, transformerDebug, available, transformer, transformers, globalProperties);
|
||||
|
||||
// FailoverContentTransformer
|
||||
transformer.setTransformers(transformers);
|
||||
@@ -286,7 +291,8 @@ public class TransformerConfigDynamicTransformers extends TransformerPropertyNam
|
||||
TransformerConfig transformerConfig, MimetypeService mimetypeService,
|
||||
ContentService contentService, ContentTransformerRegistry transformerRegistry,
|
||||
TransformerDebug transformerDebug, boolean available,
|
||||
AbstractContentTransformer2 transformer, List<ContentTransformer> transformers)
|
||||
AbstractContentTransformer2 transformer, List<ContentTransformer> transformers,
|
||||
Properties globalProperties)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -311,9 +317,17 @@ public class TransformerConfigDynamicTransformers extends TransformerPropertyNam
|
||||
|
||||
// AbstractContentTransformer2
|
||||
transformer.setBeanName(property.transformerName);
|
||||
transformer.setRegisterTransformer(available);
|
||||
transformer.setRegisterTransformer(available);
|
||||
transformer.setStrictMimeTypeCheck(getBoolean(globalProperties, "content.transformer.strict.mimetype.check"));
|
||||
transformer.setRetryTransformOnDifferentMimeType(getBoolean(globalProperties, "content.transformer.retryOn.different.mimetype"));
|
||||
}
|
||||
|
||||
private boolean getBoolean(Properties properties, String name)
|
||||
{
|
||||
String value = properties == null ? null : properties.getProperty(name);
|
||||
return "true".equalsIgnoreCase(value);
|
||||
}
|
||||
|
||||
private void error(String msg)
|
||||
{
|
||||
errorCount++;
|
||||
|
@@ -168,7 +168,7 @@ public class TransformerConfigImpl extends AbstractLifecycleBean implements Tran
|
||||
transformerProperties = new TransformerProperties(subsystem, globalProperties);
|
||||
|
||||
dynamicTransformers = new TransformerConfigDynamicTransformers(this, transformerProperties, mimetypeService,
|
||||
contentService, transformerRegistry, transformerDebug, moduleService, descriptorService);
|
||||
contentService, transformerRegistry, transformerDebug, moduleService, descriptorService, globalProperties);
|
||||
statistics= new TransformerConfigStatistics(this, mimetypeService);
|
||||
limits = new TransformerConfigLimits(transformerProperties, mimetypeService);
|
||||
supported = new TransformerConfigSupported(transformerProperties, mimetypeService);
|
||||
|
Reference in New Issue
Block a user