diff --git a/config/alfresco/thumbnail-service-context.xml b/config/alfresco/thumbnail-service-context.xml index a1d65beac1..23887da073 100644 --- a/config/alfresco/thumbnail-service-context.xml +++ b/config/alfresco/thumbnail-service-context.xml @@ -53,6 +53,7 @@ + diff --git a/source/java/org/alfresco/repo/thumbnail/ThumbnailRegistry.java b/source/java/org/alfresco/repo/thumbnail/ThumbnailRegistry.java index 5899c6cb5c..d0e09dc996 100644 --- a/source/java/org/alfresco/repo/thumbnail/ThumbnailRegistry.java +++ b/source/java/org/alfresco/repo/thumbnail/ThumbnailRegistry.java @@ -29,6 +29,7 @@ import org.alfresco.service.cmr.rendition.RenditionDefinition; import org.alfresco.service.cmr.rendition.RenditionService; import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.thumbnail.ThumbnailException; +import org.alfresco.service.transaction.TransactionService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.BeansException; @@ -53,6 +54,9 @@ public class ThumbnailRegistry implements ApplicationContextAware, ApplicationLi /** Content service */ private ContentService contentService; + /** Transaction service */ + private TransactionService transactionService; + /** Rendition service */ private RenditionService renditionService; @@ -87,6 +91,16 @@ public class ThumbnailRegistry implements ApplicationContextAware, ApplicationLi this.contentService = contentService; } + /** + * Transaction service + * + * @param transactionService transaction service + */ + public void setTransactionService(TransactionService transactionService) + { + this.transactionService = transactionService; + } + /** * Rendition service * @@ -121,6 +135,16 @@ public class ThumbnailRegistry implements ApplicationContextAware, ApplicationLi */ private void initThumbnailDefinitions() { + // If the database is in read-only mode, then do not persist the thumbnail definitions. + if (transactionService.isReadOnly()) + { + if (logger.isDebugEnabled()) + { + logger.debug("TransactionService is in read-only mode. Therefore no thumbnail definitions have been initialised."); + } + return; + } + AuthenticationUtil.runAs(new RunAsWork() { public Void doWork() throws Exception { @@ -133,23 +157,7 @@ public class ThumbnailRegistry implements ApplicationContextAware, ApplicationLi RenditionDefinition renditionDef = thumbnailRenditionConvertor.convert(thumbnailDefinition, null); // Thumbnail definitions are saved into the repository as actions - // but only if they have not already been saved. - boolean alreadyPersisted = renditionService.loadRenditionDefinition(renditionDef.getRenditionName()) != null; - if (!alreadyPersisted) - { - if (logger.isDebugEnabled()) - { - logger.debug("Init'ing and saving thumbnail definition " + thumbnailDefName); - } - renditionService.saveRenditionDefinition(renditionDef); - } - else - { - if (logger.isDebugEnabled()) - { - logger.debug("Init'ing thumbnail definition " + thumbnailDefName); - } - } + renditionService.saveRenditionDefinition(renditionDef); } return null;