ALF-2220 fix. Rendition Definitions should only be persisted on startup if they have not already been persisted.

Also removed an unnecessary TODO.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19914 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Neil McErlean
2010-04-20 12:54:54 +00:00
parent da9a7ec3fe
commit 4d60018f0c
2 changed files with 25 additions and 3 deletions

View File

@@ -37,7 +37,7 @@ public class RenditionDefinitionImpl extends ActionImpl implements RenditionDefi
* Serial version UID * Serial version UID
*/ */
private static final long serialVersionUID = 4336392868488634875L; private static final long serialVersionUID = 4336392868488634875L;
//TODO rename to renditionDefinitionName
protected static final String RENDITION_DEFINITION_NAME = "renderingActionName"; protected static final String RENDITION_DEFINITION_NAME = "renderingActionName";
public NodeRef renditionParent; public NodeRef renditionParent;

View File

@@ -29,6 +29,8 @@ 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.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware; import org.springframework.context.ApplicationContextAware;
@@ -44,7 +46,10 @@ import org.springframework.extensions.surf.util.AbstractLifecycleBean;
* @author Neil McErlean * @author Neil McErlean
*/ */
public class ThumbnailRegistry implements ApplicationContextAware, ApplicationListener<ApplicationContextEvent> public class ThumbnailRegistry implements ApplicationContextAware, ApplicationListener<ApplicationContextEvent>
{ {
/** Logger */
private static Log logger = LogFactory.getLog(ThumbnailRegistry.class);
/** Content service */ /** Content service */
private ContentService contentService; private ContentService contentService;
@@ -127,7 +132,24 @@ public class ThumbnailRegistry implements ApplicationContextAware, ApplicationLi
// for the ThumbnailParentAssociationDetails object. Hence the null // for the ThumbnailParentAssociationDetails object. Hence the null
RenditionDefinition renditionDef = thumbnailRenditionConvertor.convert(thumbnailDefinition, null); RenditionDefinition renditionDef = thumbnailRenditionConvertor.convert(thumbnailDefinition, null);
renditionService.saveRenditionDefinition(renditionDef); // 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);
}
}
} }
return null; return null;