From 104a97f9347a2b91fb534ee0c3b5e14a6e6e8360 Mon Sep 17 00:00:00 2001 From: Derek Hulley Date: Wed, 24 Jun 2009 11:45:36 +0000 Subject: [PATCH] Old versioning NodeService can now handle new content references (for test) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@14886 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/core-services-context.xml | 3 ++ .../repo/version/NodeServiceImpl.java | 43 +++++++++++-------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/config/alfresco/core-services-context.xml b/config/alfresco/core-services-context.xml index b08aaabeda..e7089f4da4 100644 --- a/config/alfresco/core-services-context.xml +++ b/config/alfresco/core-services-context.xml @@ -847,6 +847,9 @@ + + + diff --git a/source/java/org/alfresco/repo/version/NodeServiceImpl.java b/source/java/org/alfresco/repo/version/NodeServiceImpl.java index c130c1f3bb..6bd663c356 100644 --- a/source/java/org/alfresco/repo/version/NodeServiceImpl.java +++ b/source/java/org/alfresco/repo/version/NodeServiceImpl.java @@ -34,7 +34,9 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.model.ContentModel; +import org.alfresco.repo.domain.contentdata.ContentDataDAO; import org.alfresco.repo.version.common.VersionUtil; import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.dictionary.DictionaryService; @@ -79,22 +81,11 @@ public class NodeServiceImpl implements NodeService, VersionModel */ private static final QName rootAssocName = QName.createQName(VersionModel.NAMESPACE_URI, "versionedState"); - /** - * The db node service, used as the version store implementation - */ protected NodeService dbNodeService; - - /** - * The repository searcher - */ @SuppressWarnings("unused") private SearchService searcher; - - /** - * The dictionary service - */ protected DictionaryService dicitionaryService; - + protected ContentDataDAO contentDataDAO; /** * Sets the db node service, used as the version store implementation @@ -108,8 +99,6 @@ public class NodeServiceImpl implements NodeService, VersionModel /** * Sets the searcher - * - * @param searcher the searcher */ public void setSearcher(SearchService searcher) { @@ -118,14 +107,20 @@ public class NodeServiceImpl implements NodeService, VersionModel /** * Sets the dictionary service - * - * @param dictionaryService the dictionary service */ public void setDictionaryService(DictionaryService dictionaryService) { this.dicitionaryService = dictionaryService; } + /** + * Set the DAO to resolved content data reference IDs into ContentData instances + */ + public void setContentDataDAO(ContentDataDAO contentDataDAO) + { + this.contentDataDAO = contentDataDAO; + } + /** * No-op */ @@ -360,7 +355,21 @@ public class NodeServiceImpl implements NodeService, VersionModel DataTypeDefinition dataTypeDef = propDef.getDataType(); if (dataTypeDef != null) { - value = (Serializable)DefaultTypeConverter.INSTANCE.convert(dataTypeDef, value); + if (dataTypeDef.getName().equals(DataTypeDefinition.CONTENT) && value instanceof Long) + { + try + { + value = contentDataDAO.getContentData((Long)value).getSecond(); + } + catch (AlfrescoRuntimeException e) + { + logger.warn("ContentData with ID " + value + " no longer exists for versioned node " + nodeRef); + } + } + else + { + value = (Serializable)DefaultTypeConverter.INSTANCE.convert(dataTypeDef, value); + } } else {