mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Reimplementation of ALF-2220 fix. The ThumbnailRegistry.initThumbnailDefinitions method now detects if the transaction service is read-only and if it is it does not persist any thumbnail definitions. This behaviour fixes ALF-2220.
As part of this change, I have reverted the behaviour so that (for write-mode databases) thumbnail definitions will be persisted on startup even if they have already been persisted. In this way, we can support 3rd party developers who are changing their thumbnail definitions during development. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19953 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -53,6 +53,7 @@
|
|||||||
<bean id="thumbnailRegistry" class="org.alfresco.repo.thumbnail.ThumbnailRegistry">
|
<bean id="thumbnailRegistry" class="org.alfresco.repo.thumbnail.ThumbnailRegistry">
|
||||||
<property name="contentService" ref="ContentService"/>
|
<property name="contentService" ref="ContentService"/>
|
||||||
<property name="renditionService" ref="renditionService" />
|
<property name="renditionService" ref="renditionService" />
|
||||||
|
<property name="transactionService" ref="TransactionService" />
|
||||||
<property name="thumbnailDefinitions">
|
<property name="thumbnailDefinitions">
|
||||||
<list>
|
<list>
|
||||||
<!-- Small image thumbnail options -->
|
<!-- Small image thumbnail options -->
|
||||||
|
@@ -29,6 +29,7 @@ import org.alfresco.service.cmr.rendition.RenditionDefinition;
|
|||||||
import org.alfresco.service.cmr.rendition.RenditionService;
|
import org.alfresco.service.cmr.rendition.RenditionService;
|
||||||
import org.alfresco.service.cmr.repository.ContentService;
|
import org.alfresco.service.cmr.repository.ContentService;
|
||||||
import org.alfresco.service.cmr.thumbnail.ThumbnailException;
|
import org.alfresco.service.cmr.thumbnail.ThumbnailException;
|
||||||
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
@@ -53,6 +54,9 @@ public class ThumbnailRegistry implements ApplicationContextAware, ApplicationLi
|
|||||||
/** Content service */
|
/** Content service */
|
||||||
private ContentService contentService;
|
private ContentService contentService;
|
||||||
|
|
||||||
|
/** Transaction service */
|
||||||
|
private TransactionService transactionService;
|
||||||
|
|
||||||
/** Rendition service */
|
/** Rendition service */
|
||||||
private RenditionService renditionService;
|
private RenditionService renditionService;
|
||||||
|
|
||||||
@@ -87,6 +91,16 @@ public class ThumbnailRegistry implements ApplicationContextAware, ApplicationLi
|
|||||||
this.contentService = contentService;
|
this.contentService = contentService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transaction service
|
||||||
|
*
|
||||||
|
* @param transactionService transaction service
|
||||||
|
*/
|
||||||
|
public void setTransactionService(TransactionService transactionService)
|
||||||
|
{
|
||||||
|
this.transactionService = transactionService;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rendition service
|
* Rendition service
|
||||||
*
|
*
|
||||||
@@ -121,6 +135,16 @@ public class ThumbnailRegistry implements ApplicationContextAware, ApplicationLi
|
|||||||
*/
|
*/
|
||||||
private void initThumbnailDefinitions()
|
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<Void>() {
|
AuthenticationUtil.runAs(new RunAsWork<Void>() {
|
||||||
public Void doWork() throws Exception
|
public Void doWork() throws Exception
|
||||||
{
|
{
|
||||||
@@ -133,23 +157,7 @@ public class ThumbnailRegistry implements ApplicationContextAware, ApplicationLi
|
|||||||
RenditionDefinition renditionDef = thumbnailRenditionConvertor.convert(thumbnailDefinition, null);
|
RenditionDefinition renditionDef = thumbnailRenditionConvertor.convert(thumbnailDefinition, null);
|
||||||
|
|
||||||
// Thumbnail definitions are saved into the repository as actions
|
// Thumbnail definitions are saved into the repository as actions
|
||||||
// but only if they have not already been saved.
|
renditionService.saveRenditionDefinition(renditionDef);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
Reference in New Issue
Block a user