Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)

80349: MNT-11779 Cannot create dynamic transformer transformer.complex.JodConverter... ERRORs in log
      - Allow Enterprise or AMP specific transformers to be ignored.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@82735 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Will Abson
2014-09-03 15:26:04 +00:00
parent d588638ae9
commit 10ff05205d
6 changed files with 190 additions and 33 deletions

View File

@@ -121,6 +121,21 @@ public interface TransformerConfig
*/
static final String PRIORITY = ".priority";
/**
* The suffix to property names to indicate which Alfresco version the transformer is
* available with. If not specified it is not restricted. So if set to "Enterprise" it
* is not available to Community.
* @see AMP
*/
static final String EDITION = ".edition";
/**
* The suffix to property names to indicate which Alfresco AMPs the transformer is
* available with. The value should be the AMP's ID. If not specified it is not restricted.
* @see #EDITION
*/
static final String AMP = ".amp";
/**
* The suffix to property names for the threshold count.
*/

View File

@@ -18,7 +18,9 @@
*/
package org.alfresco.repo.content.transform;
import static org.alfresco.repo.content.transform.TransformerConfig.AMP;
import static org.alfresco.repo.content.transform.TransformerConfig.AVAILABLE;
import static org.alfresco.repo.content.transform.TransformerConfig.EDITION;
import static org.alfresco.repo.content.transform.TransformerConfig.FAILOVER;
import static org.alfresco.repo.content.transform.TransformerConfig.PIPE;
import static org.alfresco.repo.content.transform.TransformerConfig.PIPELINE;
@@ -31,8 +33,10 @@ import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.service.cmr.module.ModuleService;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.MimetypeService;
import org.alfresco.service.descriptor.DescriptorService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -49,19 +53,22 @@ public class TransformerConfigDynamicTransformers extends TransformerPropertyNam
public TransformerConfigDynamicTransformers(TransformerConfig transformerConfig, TransformerProperties transformerProperties,
MimetypeService mimetypeService, ContentService contentService, ContentTransformerRegistry transformerRegistry,
TransformerDebug transformerDebug)
TransformerDebug transformerDebug, ModuleService moduleService, DescriptorService descriptorService)
{
createDynamicTransformers(transformerConfig, transformerProperties, mimetypeService, contentService, transformerRegistry, transformerDebug);
createDynamicTransformers(transformerConfig, transformerProperties, mimetypeService, contentService,
transformerRegistry, transformerDebug, moduleService, descriptorService);
}
private void createDynamicTransformers(TransformerConfig transformerConfig, TransformerProperties transformerProperties,
MimetypeService mimetypeService, ContentService contentService, ContentTransformerRegistry transformerRegistry,
TransformerDebug transformerDebug)
TransformerDebug transformerDebug, ModuleService moduleService, DescriptorService descriptorService)
{
Collection<String> SUFFIXES = Arrays.asList(new String [] {
FAILOVER,
PIPELINE,
AVAILABLE
AVAILABLE,
EDITION,
AMP
});
Map<TransformerSourceTargetSuffixKey, TransformerSourceTargetSuffixValue>
@@ -82,18 +89,36 @@ public class TransformerConfigDynamicTransformers extends TransformerPropertyNam
{
try
{
String availableStr = getProperty(property.transformerName, null, null, AVAILABLE, null, transformerSourceTargetSuffixValues);
boolean available = availableStr == null || "true".equalsIgnoreCase(availableStr);
AbstractContentTransformer2 transformer = property.suffix.equals(PIPELINE)
? createComplexTransformer(property, transformerConfig, mimetypeService,
contentService, transformerRegistry, transformerDebug, available)
: createFailoverTransformer(property, transformerConfig, mimetypeService,
contentService, transformerRegistry, transformerDebug, available);
transformer.register();
processed.add(property);
dynamicTransformers.add(transformer);
logger.debug(property.transformerName+" added");
String edition = getProperty(property.transformerName, null, null, EDITION,
null, transformerSourceTargetSuffixValues);
String moduleId = getProperty(property.transformerName, null, null, AMP,
null, transformerSourceTargetSuffixValues);
if (!supportedEdition(descriptorService, edition))
{
processed.add(property);
logger.debug(property.transformerName+" ignored. As it is an "+edition+" only transformer.");
}
else if (!supportedModule(moduleService, moduleId))
{
processed.add(property);
logger.debug(property.transformerName+" ignored. As the AMP "+moduleId+" is not installed.");
}
else
{
String availableStr = getProperty(property.transformerName, null, null, AVAILABLE,
null, transformerSourceTargetSuffixValues);
boolean available = availableStr == null || "true".equalsIgnoreCase(availableStr);
AbstractContentTransformer2 transformer = property.suffix.equals(PIPELINE)
? createComplexTransformer(property, transformerConfig, mimetypeService,
contentService, transformerRegistry, transformerDebug, available)
: createFailoverTransformer(property, transformerConfig, mimetypeService,
contentService, transformerRegistry, transformerDebug, available);
transformer.register();
processed.add(property);
dynamicTransformers.add(transformer);
logger.debug(property.transformerName+" added");
}
}
catch (IllegalArgumentException e)
{
@@ -120,6 +145,18 @@ public class TransformerConfigDynamicTransformers extends TransformerPropertyNam
}
}
private boolean supportedEdition(DescriptorService descriptorService, String edition)
{
return descriptorService == null || edition == null ||
descriptorService.getServerDescriptor().getEdition().equals(edition);
}
private boolean supportedModule(ModuleService moduleService, String moduleId)
{
return moduleService == null || moduleId == null ||
moduleService.getModule(moduleId) != null;
}
private AbstractContentTransformer2 createComplexTransformer(TransformerSourceTargetSuffixValue property,
TransformerConfig transformerConfig,
MimetypeService mimetypeService, ContentService contentService,

View File

@@ -21,10 +21,13 @@ package org.alfresco.repo.content.transform;
import java.util.Properties;
import org.alfresco.repo.management.subsystems.ChildApplicationContextFactory;
import org.alfresco.service.cmr.module.ModuleDetails;
import org.alfresco.service.cmr.module.ModuleService;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.MimetypeService;
import org.alfresco.service.cmr.repository.TransformationOptionLimits;
import org.alfresco.service.cmr.repository.TransformationOptions;
import org.alfresco.service.descriptor.DescriptorService;
import org.springframework.context.ApplicationEvent;
import org.springframework.extensions.surf.util.AbstractLifecycleBean;
@@ -85,6 +88,10 @@ public class TransformerConfigImpl extends AbstractLifecycleBean implements Tran
// Needed to read global properties.
private Properties globalProperties;
private ModuleService moduleService;
private DescriptorService descriptorService;
private TransformerProperties transformerProperties;
private TransformerConfigDynamicTransformers dynamicTransformers;
@@ -129,6 +136,16 @@ public class TransformerConfigImpl extends AbstractLifecycleBean implements Tran
this.globalProperties = globalProperties;
}
public void setModuleService(ModuleService moduleService)
{
this.moduleService = moduleService;
}
public void setDescriptorService(DescriptorService descriptorService)
{
this.descriptorService = descriptorService;
}
/**
* Called by spring after bean is initialised.
*/
@@ -138,7 +155,7 @@ public class TransformerConfigImpl extends AbstractLifecycleBean implements Tran
transformerProperties = new TransformerProperties(subsystem, globalProperties);
dynamicTransformers = new TransformerConfigDynamicTransformers(this, transformerProperties, mimetypeService,
contentService, transformerRegistry, transformerDebug);
contentService, transformerRegistry, transformerDebug, moduleService, descriptorService);
statistics= new TransformerConfigStatistics(this, mimetypeService);
limits = new TransformerConfigLimits(transformerProperties, mimetypeService);
supported = new TransformerConfigSupported(transformerProperties, mimetypeService);