mirror of
https://github.com/Alfresco/alfresco-transform-core.git
synced 2025-08-14 17:58:27 +00:00
[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:
@@ -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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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,36 +94,26 @@ 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
|
|
||||||
{
|
{
|
||||||
final List<SupportedTransform> builtTransformList = buildTransformList(data,
|
actualOptions = new HashMap<>(actualOptions);
|
||||||
sourceMimetype,
|
actualOptions.remove(SOURCE_ENCODING);
|
||||||
targetMimetype,
|
actualOptions.remove(TIMEOUT);
|
||||||
actualOptions);
|
|
||||||
|
|
||||||
if (renditionName != null)
|
|
||||||
{
|
|
||||||
data.cache(renditionName, sourceMimetype, builtTransformList);
|
|
||||||
}
|
|
||||||
|
|
||||||
return builtTransformList;
|
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
|
final List<SupportedTransform> builtTransformList = buildTransformList(data,
|
||||||
|
sourceMimetype,
|
||||||
|
targetMimetype,
|
||||||
|
actualOptions);
|
||||||
|
|
||||||
|
if (renditionName != null)
|
||||||
{
|
{
|
||||||
if (sourceEncoding != null)
|
data.cache(renditionName, sourceMimetype, builtTransformList);
|
||||||
{
|
|
||||||
actualOptions.put(SOURCE_ENCODING, sourceEncoding);
|
|
||||||
}
|
|
||||||
if (timeout != null)
|
|
||||||
{
|
|
||||||
actualOptions.put(TIMEOUT, timeout);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return builtTransformList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<SupportedTransform> buildTransformList(
|
private static List<SupportedTransform> buildTransformList(
|
||||||
|
Reference in New Issue
Block a user