mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ACS-938 metadata is not added when using Transform Service #176
This commit is contained in:
@@ -31,6 +31,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.action.executer.ContentMetadataExtracter;
|
||||
import org.alfresco.repo.content.transform.TransformerDebug;
|
||||
import org.alfresco.repo.rendition2.RenditionDefinitionRegistry2;
|
||||
import org.alfresco.repo.rendition2.RenditionDefinitionRegistry2Impl;
|
||||
import org.alfresco.repo.rendition2.RenditionService2;
|
||||
import org.alfresco.repo.rendition2.TransformDefinition;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
@@ -99,6 +101,7 @@ public class AsynchronousExtractor extends AbstractMappingMetadataExtracter
|
||||
private NamespacePrefixResolver namespacePrefixResolver;
|
||||
private TransformerDebug transformerDebug;
|
||||
private RenditionService2 renditionService2;
|
||||
private RenditionDefinitionRegistry2Impl renditionDefinitionRegistry2;
|
||||
private ContentService contentService;
|
||||
private TransactionService transactionService;
|
||||
private TransformServiceRegistry transformServiceRegistry;
|
||||
@@ -125,6 +128,11 @@ public class AsynchronousExtractor extends AbstractMappingMetadataExtracter
|
||||
this.renditionService2 = renditionService2;
|
||||
}
|
||||
|
||||
public void setRenditionDefinitionRegistry2(RenditionDefinitionRegistry2Impl renditionDefinitionRegistry2)
|
||||
{
|
||||
this.renditionDefinitionRegistry2 = renditionDefinitionRegistry2;
|
||||
}
|
||||
|
||||
public void setContentService(ContentService contentService)
|
||||
{
|
||||
this.contentService = contentService;
|
||||
@@ -326,9 +334,13 @@ public class AsynchronousExtractor extends AbstractMappingMetadataExtracter
|
||||
// This needs to be specific to each source mimetype and the extract or embed as the name
|
||||
// is used to cache the transform name that will be used.
|
||||
String transformName = targetMimetype + '/' + sourceMimetype;
|
||||
|
||||
TransformDefinition transformDefinition = new TransformDefinition(transformName, targetMimetype,
|
||||
options, null, null, null);
|
||||
String renditionName = TransformDefinition.convertToRenditionName(transformName);
|
||||
TransformDefinition transformDefinition = (TransformDefinition) renditionDefinitionRegistry2.getRenditionDefinition(renditionName);
|
||||
if (transformDefinition == null)
|
||||
{
|
||||
transformDefinition = new TransformDefinition(transformName, targetMimetype,
|
||||
options, null, null, null, renditionDefinitionRegistry2);
|
||||
}
|
||||
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
|
@@ -44,6 +44,9 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.alfresco.repo.rendition2.TransformDefinition.TRANSFORM_NAMESPACE;
|
||||
|
||||
/**
|
||||
* A registry of rendition definitions.
|
||||
@@ -351,7 +354,8 @@ public class RenditionDefinitionRegistry2Impl implements RenditionDefinitionRegi
|
||||
@Override
|
||||
public Set<String> getRenditionNames()
|
||||
{
|
||||
return getData().renditionDefinitions.keySet();
|
||||
// transform definitions are hidden
|
||||
return getData().renditionDefinitions.keySet().stream().filter(name -> !name.startsWith(TRANSFORM_NAMESPACE)).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -396,15 +400,18 @@ public class RenditionDefinitionRegistry2Impl implements RenditionDefinitionRegi
|
||||
for (Map.Entry<String, RenditionDefinition2> entry : data.renditionDefinitions.entrySet())
|
||||
{
|
||||
RenditionDefinition2 renditionDefinition2 = entry.getValue();
|
||||
String targetMimetype = renditionDefinition2.getTargetMimetype();
|
||||
String renditionName = renditionDefinition2.getRenditionName();
|
||||
Map<String, String> options = renditionDefinition2.getTransformOptions();
|
||||
Long maxSize = transformServiceRegistry.findMaxSize(sourceMimetype, targetMimetype, options, renditionName);
|
||||
if (maxSize != null)
|
||||
if (!renditionName.startsWith(TRANSFORM_NAMESPACE))
|
||||
{
|
||||
String renditionNameMaxSizePair = entry.getKey();
|
||||
Pair<String, Long> pair = new Pair<>(renditionNameMaxSizePair, maxSize);
|
||||
renditions.add(pair);
|
||||
String targetMimetype = renditionDefinition2.getTargetMimetype();
|
||||
Map<String, String> options = renditionDefinition2.getTransformOptions();
|
||||
Long maxSize = transformServiceRegistry.findMaxSize(sourceMimetype, targetMimetype, options, renditionName);
|
||||
if (maxSize != null)
|
||||
{
|
||||
String renditionNameMaxSizePair = entry.getKey();
|
||||
Pair<String, Long> pair = new Pair<>(renditionNameMaxSizePair, maxSize);
|
||||
renditions.add(pair);
|
||||
}
|
||||
}
|
||||
}
|
||||
return renditions;
|
||||
|
@@ -54,27 +54,28 @@ public class TransformDefinition extends RenditionDefinition2Impl
|
||||
* if the transform will take place, will be cached against the transformName.
|
||||
*/
|
||||
public TransformDefinition(String transformName, String targetMimetype, Map<String, String> transformOptions,
|
||||
String clientData, String replyQueue, String requestId)
|
||||
String clientData, String replyQueue, String requestId,
|
||||
RenditionDefinitionRegistry2Impl registry)
|
||||
{
|
||||
super(convertToRenditionName(transformName), targetMimetype, transformOptions, null);
|
||||
super(convertToRenditionName(transformName), targetMimetype, transformOptions, registry);
|
||||
this.clientData = clientData;
|
||||
this.replyQueue = replyQueue;
|
||||
this.requestId = requestId;
|
||||
this.errorMessage = null;
|
||||
}
|
||||
|
||||
static String convertToRenditionName(String transformName)
|
||||
{
|
||||
return transformName == null ? null : TRANSFORM_NAMESPACE+transformName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor where the targetMimetype and transformOptions are unlikely to be repeated.
|
||||
*/
|
||||
public TransformDefinition(String targetMimetype, Map<String, String> transformOptions,
|
||||
String clientData, String replyQueue, String requestId)
|
||||
{
|
||||
this(null, targetMimetype, transformOptions, clientData, replyQueue, requestId);
|
||||
this(null, targetMimetype, transformOptions, clientData, replyQueue, requestId, null);
|
||||
}
|
||||
|
||||
public static String convertToRenditionName(String transformName)
|
||||
{
|
||||
return transformName == null ? null : TRANSFORM_NAMESPACE+transformName;
|
||||
}
|
||||
|
||||
public String getTransformName()
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2019 Alfresco Software Limited
|
||||
* Copyright (C) 2005 - 2020 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
@@ -32,7 +32,6 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.apache.camel.Exchange;
|
||||
import org.apache.camel.NoSuchEndpointException;
|
||||
import org.apache.camel.Processor;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -125,7 +124,7 @@ public class TransformRequestProcessor implements Processor
|
||||
String requestId = event.getRequestId();
|
||||
|
||||
TransformDefinition transformDefinition = new TransformDefinition(transformName, targetMediaType, transformOptions,
|
||||
clientData, replyQueue, requestId);
|
||||
clientData, replyQueue, requestId, null);
|
||||
|
||||
NodeRef nodeRef = new NodeRef(event.getNodeRef());
|
||||
|
||||
|
@@ -295,6 +295,7 @@
|
||||
<property name="namespacePrefixResolver" ref="namespaceService" />
|
||||
<property name="transformerDebug" ref="transformerDebug" />
|
||||
<property name="renditionService2" ref="renditionService2" />
|
||||
<property name="renditionDefinitionRegistry2" ref="renditionDefinitionRegistry2" />
|
||||
<property name="contentService" ref="ContentService" />
|
||||
<property name="transactionService" ref="transactionService" />
|
||||
<property name="transformServiceRegistry" ref="transformServiceRegistry" />
|
||||
|
@@ -36,6 +36,8 @@ import org.alfresco.repo.content.transform.AbstractContentTransformerTest;
|
||||
import org.alfresco.repo.content.transform.TransformerDebug;
|
||||
import org.alfresco.repo.content.transform.UnsupportedTransformationException;
|
||||
import org.alfresco.repo.rendition2.RenditionDefinition2;
|
||||
import org.alfresco.repo.rendition2.RenditionDefinitionRegistry2;
|
||||
import org.alfresco.repo.rendition2.RenditionDefinitionRegistry2Impl;
|
||||
import org.alfresco.repo.rendition2.RenditionService2Impl;
|
||||
import org.alfresco.repo.rendition2.TransformClient;
|
||||
import org.alfresco.repo.search.impl.noindex.NoIndexCategoryServiceImpl;
|
||||
@@ -130,6 +132,7 @@ public class AsynchronousExtractorTest extends BaseSpringTest
|
||||
private TransformerDebug transformerDebug;
|
||||
private TransactionService transactionService;
|
||||
private TransformServiceRegistry transformServiceRegistry;
|
||||
private RenditionDefinitionRegistry2Impl renditionDefinitionRegistry2;
|
||||
private TaggingServiceImpl taggingService;
|
||||
private ContentMetadataExtracter contentMetadataExtracter;
|
||||
private ContentMetadataEmbedder contentMetadataEmbedder;
|
||||
@@ -186,6 +189,7 @@ public class AsynchronousExtractorTest extends BaseSpringTest
|
||||
setContentService(contentService);
|
||||
setTransactionService(transactionService);
|
||||
setTransformServiceRegistry(transformServiceRegistry);
|
||||
setRenditionDefinitionRegistry2(renditionDefinitionRegistry2);
|
||||
setEnableStringTagging(true);
|
||||
setTaggingService(taggingService);
|
||||
setRegistry(metadataExtracterRegistry);
|
||||
@@ -330,6 +334,7 @@ public class AsynchronousExtractorTest extends BaseSpringTest
|
||||
renditionService2 = (RenditionService2Impl) applicationContext.getBean("renditionService2");
|
||||
transactionService = (TransactionService) applicationContext.getBean("transactionService");
|
||||
transformServiceRegistry = (TransformServiceRegistry) applicationContext.getBean("transformServiceRegistry");
|
||||
renditionDefinitionRegistry2 = (RenditionDefinitionRegistry2Impl) applicationContext.getBean("renditionDefinitionRegistry2");
|
||||
taggingService = (TaggingServiceImpl) applicationContext.getBean("taggingService");
|
||||
transformClient = (TransformClient) applicationContext.getBean("transformClient");
|
||||
asynchronousExtractor = (AsynchronousExtractor) applicationContext.getBean("extractor.Asynchronous");
|
||||
|
Reference in New Issue
Block a user