[release] 3.0.0-HXP-A5

* Fix repo build tests were a rendition is used and it has a Timeout which cannot be removed because the t-options are read only
This commit is contained in:
alandavis
2022-09-06 17:09:23 +01:00
parent ade4b95a49
commit 4446e910f3
2 changed files with 36 additions and 33 deletions

View File

@@ -50,6 +50,7 @@ import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
@@ -89,6 +90,8 @@ public class TransformRegistry extends AbstractTransformRegistry
// Not autowired - avoids a circular reference in the router - initialised on startup event
private List<CustomTransformer> customTransformers;
private int previousLogMessageHashCode;
private static class Data extends TransformCache
{
private TransformConfig transformConfig;
@@ -208,9 +211,10 @@ public class TransformRegistry extends AbstractTransformRegistry
.map(Transformer::getTransformerName)
.filter(Objects::nonNull)
.collect(Collectors.toList());
ArrayList<String> logMessages = new ArrayList<>();
if (!nonNullTransformerNames.isEmpty())
{
logger.info("Transformers (" + nonNullTransformerNames.size() + "):");
logMessages.add("Transformers (" + nonNullTransformerNames.size() + "):");
nonNullTransformerNames
.stream()
.sorted()
@@ -230,7 +234,7 @@ public class TransformRegistry extends AbstractTransformRegistry
customTransformerNames.remove(name);
return message;
})
.forEach(logger::info);
.forEach(logMessages::add);
List<String> unusedCustomTransformNames = customTransformerNames.stream()
.filter(Objects::nonNull)
@@ -238,11 +242,22 @@ public class TransformRegistry extends AbstractTransformRegistry
.collect(Collectors.toList());
if (!unusedCustomTransformNames.isEmpty())
{
logger.info("Unused CustomTransformers (" + unusedCustomTransformNames.size() + " - name is not in the transform config):");
logMessages.add("Unused CustomTransformers (" + unusedCustomTransformNames.size() + " - name is not in the transform config):");
unusedCustomTransformNames
.stream()
.map(name -> " " + name)
.forEach(logger::info);
.forEach(logMessages::add);
}
int logMessageHashCode = logMessages.hashCode();
if (previousLogMessageHashCode != logMessageHashCode)
{
previousLogMessageHashCode = logMessageHashCode;
logMessages.stream().forEach(logger::info);
}
else
{
logger.debug("Config unchanged");
}
}
}

View File

@@ -38,14 +38,12 @@ import static java.util.Collections.emptyList;
import static java.util.Collections.emptyMap;
import static java.util.Collections.emptySet;
import static java.util.Map.Entry;
import static java.util.stream.Collectors.toMap;
import static org.alfresco.transform.common.RequestParamMap.SOURCE_ENCODING;
import static org.alfresco.transform.common.RequestParamMap.TIMEOUT;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
class TransformRegistryHelper
{
private static final String TIMEOUT = "timeout";
static Set<TransformOption> lookupTransformOptions(final Set<String> transformOptionNames,
final Map<String, Set<TransformOption>> transformOptions, final String readFrom,
final Consumer<String> logError)
@@ -96,36 +94,26 @@ class TransformRegistryHelper
return cachedTransformList;
}
// The transformOptions always contains sourceEncoding and possibly timeout when sent to a T-Engine, even though
// they should not be used to select a transformer. Would like to change this, but cannot as we need to support
// older ACS repo versions.
String sourceEncoding = actualOptions.remove(SOURCE_ENCODING);
String timeout = actualOptions.remove(TIMEOUT);
try
// The transformOptions sometimes contains sourceEncoding and timeout, even though they should not be used
// to select a transformer. Would like to change this, but cannot as we need to support all ACS repo versions.
if (actualOptions.containsKey(SOURCE_ENCODING) || actualOptions.containsKey(TIMEOUT))
{
final List<SupportedTransform> builtTransformList = buildTransformList(data,
sourceMimetype,
targetMimetype,
actualOptions);
if (renditionName != null)
{
data.cache(renditionName, sourceMimetype, builtTransformList);
}
return builtTransformList;
actualOptions = new HashMap<>(actualOptions);
actualOptions.remove(SOURCE_ENCODING);
actualOptions.remove(TIMEOUT);
}
finally
final List<SupportedTransform> builtTransformList = buildTransformList(data,
sourceMimetype,
targetMimetype,
actualOptions);
if (renditionName != null)
{
if (sourceEncoding != null)
{
actualOptions.put(SOURCE_ENCODING, sourceEncoding);
}
if (timeout != null)
{
actualOptions.put(TIMEOUT, timeout);
}
data.cache(renditionName, sourceMimetype, builtTransformList);
}
return builtTransformList;
}
private static List<SupportedTransform> buildTransformList(