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:
Neil McErlean
2010-04-22 13:58:15 +00:00
parent f5e487cc96
commit c3e0afa696
2 changed files with 26 additions and 17 deletions

View File

@@ -53,6 +53,7 @@
<bean id="thumbnailRegistry" class="org.alfresco.repo.thumbnail.ThumbnailRegistry">
<property name="contentService" ref="ContentService"/>
<property name="renditionService" ref="renditionService" />
<property name="transactionService" ref="TransactionService" />
<property name="thumbnailDefinitions">
<list>
<!-- Small image thumbnail options -->

View File

@@ -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<Void>() {
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;