[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.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashSet; 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 // Not autowired - avoids a circular reference in the router - initialised on startup event
private List<CustomTransformer> customTransformers; private List<CustomTransformer> customTransformers;
private int previousLogMessageHashCode;
private static class Data extends TransformCache private static class Data extends TransformCache
{ {
private TransformConfig transformConfig; private TransformConfig transformConfig;
@@ -208,9 +211,10 @@ public class TransformRegistry extends AbstractTransformRegistry
.map(Transformer::getTransformerName) .map(Transformer::getTransformerName)
.filter(Objects::nonNull) .filter(Objects::nonNull)
.collect(Collectors.toList()); .collect(Collectors.toList());
ArrayList<String> logMessages = new ArrayList<>();
if (!nonNullTransformerNames.isEmpty()) if (!nonNullTransformerNames.isEmpty())
{ {
logger.info("Transformers (" + nonNullTransformerNames.size() + "):"); logMessages.add("Transformers (" + nonNullTransformerNames.size() + "):");
nonNullTransformerNames nonNullTransformerNames
.stream() .stream()
.sorted() .sorted()
@@ -230,7 +234,7 @@ public class TransformRegistry extends AbstractTransformRegistry
customTransformerNames.remove(name); customTransformerNames.remove(name);
return message; return message;
}) })
.forEach(logger::info); .forEach(logMessages::add);
List<String> unusedCustomTransformNames = customTransformerNames.stream() List<String> unusedCustomTransformNames = customTransformerNames.stream()
.filter(Objects::nonNull) .filter(Objects::nonNull)
@@ -238,11 +242,22 @@ public class TransformRegistry extends AbstractTransformRegistry
.collect(Collectors.toList()); .collect(Collectors.toList());
if (!unusedCustomTransformNames.isEmpty()) 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 unusedCustomTransformNames
.stream() .stream()
.map(name -> " " + name) .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.emptyMap;
import static java.util.Collections.emptySet; import static java.util.Collections.emptySet;
import static java.util.Map.Entry; 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.SOURCE_ENCODING;
import static org.alfresco.transform.common.RequestParamMap.TIMEOUT;
import static org.springframework.http.HttpStatus.BAD_REQUEST; import static org.springframework.http.HttpStatus.BAD_REQUEST;
class TransformRegistryHelper class TransformRegistryHelper
{ {
private static final String TIMEOUT = "timeout";
static Set<TransformOption> lookupTransformOptions(final Set<String> transformOptionNames, static Set<TransformOption> lookupTransformOptions(final Set<String> transformOptionNames,
final Map<String, Set<TransformOption>> transformOptions, final String readFrom, final Map<String, Set<TransformOption>> transformOptions, final String readFrom,
final Consumer<String> logError) final Consumer<String> logError)
@@ -96,13 +94,15 @@ class TransformRegistryHelper
return cachedTransformList; return cachedTransformList;
} }
// The transformOptions always contains sourceEncoding and possibly timeout when sent to a T-Engine, even though // The transformOptions sometimes contains sourceEncoding and timeout, even though they should not be used
// they should not be used to select a transformer. Would like to change this, but cannot as we need to support // to select a transformer. Would like to change this, but cannot as we need to support all ACS repo versions.
// older ACS repo versions. if (actualOptions.containsKey(SOURCE_ENCODING) || actualOptions.containsKey(TIMEOUT))
String sourceEncoding = actualOptions.remove(SOURCE_ENCODING);
String timeout = actualOptions.remove(TIMEOUT);
try
{ {
actualOptions = new HashMap<>(actualOptions);
actualOptions.remove(SOURCE_ENCODING);
actualOptions.remove(TIMEOUT);
}
final List<SupportedTransform> builtTransformList = buildTransformList(data, final List<SupportedTransform> builtTransformList = buildTransformList(data,
sourceMimetype, sourceMimetype,
targetMimetype, targetMimetype,
@@ -115,18 +115,6 @@ class TransformRegistryHelper
return builtTransformList; return builtTransformList;
} }
finally
{
if (sourceEncoding != null)
{
actualOptions.put(SOURCE_ENCODING, sourceEncoding);
}
if (timeout != null)
{
actualOptions.put(TIMEOUT, timeout);
}
}
}
private static List<SupportedTransform> buildTransformList( private static List<SupportedTransform> buildTransformList(
final TransformCache data, final String sourceMimetype, final String targetMimetype, final TransformCache data, final String sourceMimetype, final String targetMimetype,