Fixes for supporting full repository export/import.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2625 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2006-04-05 19:14:20 +00:00
parent 9b22810956
commit 166de93b48
10 changed files with 175 additions and 44 deletions

View File

@@ -74,11 +74,12 @@ public interface ImportNode
public Map<QName,Serializable> getProperties();
/**
* Gets all property datatypes for the node
* Gets the property data type
*
* @return the property datatypes
* @param propertyName name of property
* @return data type of named property
*/
public Map<QName,DataTypeDefinition> getPropertyDatatypes();
public DataTypeDefinition getPropertyDataType(QName propertyName);
/**
* @return the aspects of this node

View File

@@ -36,7 +36,6 @@ import org.alfresco.service.cmr.dictionary.ChildAssociationDefinition;
import org.alfresco.service.cmr.dictionary.ClassDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
import org.alfresco.service.cmr.dictionary.TypeDefinition;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentData;
@@ -548,8 +547,9 @@ public class ImporterComponent
// import content, if applicable
for (Map.Entry<QName,Serializable> property : context.getProperties().entrySet())
{
PropertyDefinition propertyDef = dictionaryService.getProperty(property.getKey());
if (propertyDef != null && propertyDef.getDataType().getName().equals(DataTypeDefinition.CONTENT))
// filter out content properties (they're imported later)
DataTypeDefinition valueDataType = context.getPropertyDataType(property.getKey());
if (valueDataType != null && valueDataType.getName().equals(DataTypeDefinition.CONTENT))
{
importContent(nodeRef, property.getKey(), (String)property.getValue());
}
@@ -627,10 +627,10 @@ public class ImporterComponent
private void importContent(NodeRef nodeRef, QName propertyName, String importContentData)
{
// bind import content data description
DataTypeDefinition dataTypeDef = dictionaryService.getDataType(DataTypeDefinition.CONTENT);
importContentData = bindPlaceHolder(importContentData, binding);
if (importContentData != null && importContentData.length() > 0)
{
DataTypeDefinition dataTypeDef = dictionaryService.getDataType(DataTypeDefinition.CONTENT);
ContentData contentData = (ContentData)DefaultTypeConverter.INSTANCE.convert(dataTypeDef, importContentData);
String contentUrl = contentData.getContentUrl();
if (contentUrl != null && contentUrl.length() > 0)
@@ -898,29 +898,20 @@ public class ImporterComponent
private Map<QName, Serializable> bindProperties(ImportNode context)
{
Map<QName, Serializable> properties = context.getProperties();
Map<QName, DataTypeDefinition> datatypes = context.getPropertyDatatypes();
Map<QName, Serializable> boundProperties = new HashMap<QName, Serializable>(properties.size());
for (QName property : properties.keySet())
{
// get property value
Serializable value = properties.get(property);
// get property datatype
DataTypeDefinition valueDataType = datatypes.get(property);
if (valueDataType == null)
{
PropertyDefinition propDef = dictionaryService.getProperty(property);
if (propDef != null)
{
valueDataType = propDef.getDataType();
}
}
DataTypeDefinition valueDataType = context.getPropertyDataType(property);
// filter out content properties (they're imported later)
if (valueDataType != null && valueDataType.getName().equals(DataTypeDefinition.CONTENT))
{
continue;
}
// get property value
Serializable value = properties.get(property);
// bind property value to configuration and convert to appropriate type
if (value instanceof Collection)

View File

@@ -61,6 +61,7 @@ public class ImporterComponentTest extends BaseSpringTest
super.onTearDownInTransaction();
}
public void testImport()
throws Exception
{

View File

@@ -246,7 +246,7 @@ public class NodeContext extends ElementContext
PropertyDefinition propDef = getDictionaryService().getProperty(property);
// Process Alfresco UUID
if (propDef != null && propDef.getName().equals(ContentModel.PROP_NODE_UUID))
if (uuid == null && propDef != null && propDef.getName().equals(ContentModel.PROP_NODE_UUID))
{
uuid = value;
}
@@ -311,6 +311,25 @@ public class NodeContext extends ElementContext
return nodeProperties;
}
/*
* (non-Javadoc)
* @see org.alfresco.repo.importer.ImportNode#getPropertyDataType(org.alfresco.service.namespace.QName)
*/
public DataTypeDefinition getPropertyDataType(QName propertyName)
{
// get property datatype
DataTypeDefinition valueDataType = propertyDatatypes.get(propertyName);
if (valueDataType == null)
{
PropertyDefinition propDef = getDictionaryService().getProperty(propertyName);
if (propDef != null)
{
valueDataType = propDef.getDataType();
}
}
return valueDataType;
}
/**
* Adds an aspect to the node
*
@@ -517,5 +536,5 @@ public class NodeContext extends ElementContext
return null;
}
}
}