REPO-4791 Use Local transforms where Legacy transforms are called. (#688)

- Improve TransformerDebug for isSupported call
This commit is contained in:
alandavis
2019-11-30 10:09:21 +00:00
committed by GitHub
parent d4cb818a8a
commit b31f8715ef
6 changed files with 47 additions and 9 deletions

View File

@@ -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);
}

View File

@@ -111,4 +111,10 @@ public class LegacySynchronousTransformClient extends ContentTransformServiceImp
throw e;
}
}
@Override
public String getName()
{
return "Legacy";
}
}

View File

@@ -140,4 +140,10 @@ public class LocalSynchronousTransformClient implements SynchronousTransformClie
throw e;
}
}
@Override
public String getName()
{
return "Local";
}
}

View File

@@ -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");
}
}

View File

@@ -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();
}

View File

@@ -1568,6 +1568,12 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest
delegate.transform(reader, writer, actualOptions, transformName, sourceNodeRef);
}
}
@Override
public String getName()
{
return delegate.getName();
}
}
/**