mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
REPO-4791 Use Local transforms where Legacy transforms are called. (#688)
- Improve TransformerDebug for isSupported call
This commit is contained in:
@@ -1556,9 +1556,8 @@ public class TransformerDebug implements ApplicationContextAware
|
||||
debug(getMimetypeExt(sourceMimetype)+getMimetypeExt(targetMimetype) +
|
||||
((fileName != null) ? fileName+' ' : "")+
|
||||
((sourceSize >= 0) ? fileSize(sourceSize)+' ' : "") +
|
||||
(renditionName != null ? "-- "+renditionName+" -- " : "") + " RenditionService2");
|
||||
(renditionName != null ? "-- "+renditionName+" -- " : "") + " TransformService");
|
||||
debug(sourceNodeRef.toString() + ' ' +contentHashcode);
|
||||
debug(" **a) [01] TransformService");
|
||||
return pop(Call.AVAILABLE, true, false);
|
||||
}
|
||||
|
||||
|
@@ -111,4 +111,10 @@ public class LegacySynchronousTransformClient extends ContentTransformServiceImp
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "Legacy";
|
||||
}
|
||||
}
|
||||
|
@@ -140,4 +140,10 @@ public class LocalSynchronousTransformClient implements SynchronousTransformClie
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "Local";
|
||||
}
|
||||
}
|
||||
|
@@ -64,18 +64,27 @@ public class SwitchingSynchronousTransformClient implements SynchronousTransform
|
||||
public boolean isSupported(String sourceMimetype, long sourceSizeInBytes, String contentUrl, String targetMimetype,
|
||||
Map<String, String> actualOptions, String transformName, NodeRef sourceNodeRef)
|
||||
{
|
||||
boolean supported =
|
||||
primary.isSupported(sourceMimetype, sourceSizeInBytes, contentUrl, targetMimetype, actualOptions,
|
||||
transformName, sourceNodeRef) ||
|
||||
secondary.isSupported(sourceMimetype, sourceSizeInBytes, contentUrl, targetMimetype, actualOptions,
|
||||
transformName, sourceNodeRef);
|
||||
SynchronousTransformClient client = null;
|
||||
|
||||
if (primary.isSupported(sourceMimetype, sourceSizeInBytes, contentUrl, targetMimetype, actualOptions,
|
||||
transformName, sourceNodeRef))
|
||||
{
|
||||
client = primary;
|
||||
}
|
||||
else if (secondary.isSupported(sourceMimetype, sourceSizeInBytes, contentUrl, targetMimetype, actualOptions,
|
||||
transformName, sourceNodeRef))
|
||||
{
|
||||
client = secondary;
|
||||
}
|
||||
|
||||
if (transformerDebug.isEnabled())
|
||||
{
|
||||
String renditionName = TransformDefinition.convertToRenditionName(transformName);
|
||||
transformerDebug.debug(sourceMimetype, targetMimetype, sourceNodeRef, sourceSizeInBytes, renditionName,
|
||||
" is "+(supported ? "" : "not ")+"supported");
|
||||
"synchronous transform is "+
|
||||
(client == null ? "NOT supported" : "supported by "+client.getName()));
|
||||
}
|
||||
return supported;
|
||||
return client != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -98,4 +107,11 @@ public class SwitchingSynchronousTransformClient implements SynchronousTransform
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
// If we start nesting SwitchingSynchronousTransformClients, we will need to get the current client from a ThreadLocal
|
||||
throw new UnsupportedOperationException("SwitchingSynchronousTransformClients cannot be nested");
|
||||
}
|
||||
}
|
||||
|
@@ -81,4 +81,9 @@ public interface SynchronousTransformClient
|
||||
void transform(ContentReader reader, ContentWriter writer, Map<String, String> actualOptions,
|
||||
String transformName, NodeRef sourceNodeRef)
|
||||
throws UnsupportedTransformationException, ContentIOException;
|
||||
|
||||
/**
|
||||
* @return type of transform (Local, Legacy) for use in debug.
|
||||
*/
|
||||
String getName();
|
||||
}
|
||||
|
@@ -1568,6 +1568,12 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest
|
||||
delegate.transform(reader, writer, actualOptions, transformName, sourceNodeRef);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return delegate.getName();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user