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
*/
private static final long serialVersionUID = 4336392868488634875L;
//TODO rename to renditionDefinitionName
protected static final String RENDITION_DEFINITION_NAME = "renderingActionName";
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.repository.ContentService;
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.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
@@ -45,6 +47,9 @@ import org.springframework.extensions.surf.util.AbstractLifecycleBean;
*/
public class ThumbnailRegistry implements ApplicationContextAware, ApplicationListener<ApplicationContextEvent>
{
/** Logger */
private static Log logger = LogFactory.getLog(ThumbnailRegistry.class);
/** Content service */
private ContentService contentService;
@@ -127,8 +132,25 @@ public class ThumbnailRegistry implements ApplicationContextAware, ApplicationLi
// for the ThumbnailParentAssociationDetails object. Hence the null
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);
}
}
}
return null;
}