Merged V3.0 to HEAD

12297: Fix mysql config instructions for case sensitive user names - DOC-68
  12298: Merged V2.2 to V3.0
    12257: Fixed ETWOTWO-952: MLText properties not intercepted when calling addAspect and createNode
    12270: Fixed RhinoScriptTest to propogate exceptions for full recording by Junit
    12271: Fixed NPE in ML interceptor when null node properties are passed to createNode
    12282: Merged V2.1 to V2.2
      11616: Fix for ETWOONE-218: Common.js function needs to be changed to support root context
    12287: Merged V2.1 to V2.2
      12229: WCM - disable/hide link validation by defrault (ETWOONE-106, ETWOONE-392)
  12301: Merged V2.2 to V3.0
    12288: Merged V2.1 to V2.2
      12233: Fixed ETWOONE-124: Add the property UUIDBinding to ImporterBootstrap


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12530 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2008-12-22 12:17:00 +00:00
parent eca46db62b
commit 38ba58dede
9 changed files with 284 additions and 69 deletions

View File

@@ -83,9 +83,10 @@ public class ImporterBootstrap extends AbstractLifecycleBean
private static final Log logger = LogFactory.getLog(ImporterBootstrap.class);
private boolean logEnabled = false;
// Dependencies
private boolean allowWrite = true;
private boolean useExistingStore = false;
private UUID_BINDING uuidBinding = null;
// Dependencies
private TransactionService transactionService;
private NamespaceService namespaceService;
private NodeService nodeService;
@@ -125,6 +126,19 @@ public class ImporterBootstrap extends AbstractLifecycleBean
this.useExistingStore = useExistingStore;
}
/**
* Set the behaviour for generating UUIDs in the import. Values are set by the
* {@link UUID_BINDING} enum and default to {@link UUID_BINDING#CREATE_NEW_WITH_UUID}.
* <p/>
* This setting overrides the UUID binding behaviour specified in the view properties.
*
* @param uuidBinding the UUID generation behaviour
*/
public void setUuidBinding(UUID_BINDING uuidBinding)
{
this.uuidBinding = uuidBinding;
}
/**
* Sets the Transaction Service
*
@@ -420,18 +434,23 @@ public class ImporterBootstrap extends AbstractLifecycleBean
binding.setResourceBundle(bundle);
}
String uuidBinding = bootstrapView.getProperty(VIEW_UUID_BINDING);
if (uuidBinding != null && uuidBinding.length() > 0)
String viewUuidBinding = bootstrapView.getProperty(VIEW_UUID_BINDING);
if (viewUuidBinding != null && viewUuidBinding.length() > 0)
{
try
{
binding.setUUIDBinding(UUID_BINDING.valueOf(UUID_BINDING.class, uuidBinding));
binding.setUUIDBinding(UUID_BINDING.valueOf(UUID_BINDING.class, viewUuidBinding));
}
catch(IllegalArgumentException e)
{
throw new ImporterException("The value " + uuidBinding + " is an invalid uuidBinding");
throw new ImporterException("The value " + viewUuidBinding + " is an invalid uuidBinding");
}
}
}
// Override the UUID binding with the bean's
if (this.uuidBinding != null)
{
binding.setUUIDBinding(this.uuidBinding);
}
// Now import...
ImporterProgress importProgress = null;
@@ -539,14 +558,13 @@ public class ImporterBootstrap extends AbstractLifecycleBean
private Properties configuration = null;
private ResourceBundle resourceBundle = null;
private Location bootstrapLocation = null;
/** by default, use create new strategy for bootstrap import */
private UUID_BINDING uuidBinding = UUID_BINDING.CREATE_NEW_WITH_UUID;
private static final String IMPORT_LOCATION_UUID = "bootstrap.location.uuid";
private static final String IMPORT_LOCATION_NODEREF = "bootstrap.location.noderef";
private static final String IMPORT_LOCATION_PATH = "bootstrap.location.path";
// by default, use create new strategy for bootstrap import
private UUID_BINDING uuidBinding = UUID_BINDING.CREATE_NEW_WITH_UUID;
/**
* Set Import Configuration
*
@@ -620,10 +638,6 @@ public class ImporterBootstrap extends AbstractLifecycleBean
return value;
}
/*
* (non-Javadoc)
* @see org.alfresco.service.cmr.view.ImporterBinding#getUUIDBinding()
*/
public UUID_BINDING getUUIDBinding()
{
return uuidBinding;
@@ -639,19 +653,11 @@ public class ImporterBootstrap extends AbstractLifecycleBean
this.uuidBinding = uuidBinding;
}
/*
* (non-Javadoc)
* @see org.alfresco.service.cmr.view.ImporterBinding#searchWithinTransaction()
*/
public boolean allowReferenceWithinTransaction()
{
return true;
}
/*
* (non-Javadoc)
* @see org.alfresco.service.cmr.view.ImporterBinding#getExcludedClasses()
*/
public QName[] getExcludedClasses()
{
// Note: Do not exclude any classes, we want to import all

View File

@@ -33,6 +33,7 @@ import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.view.ImporterService;
import org.alfresco.service.cmr.view.Location;
import org.alfresco.service.cmr.view.ImporterBinding.UUID_BINDING;
import org.alfresco.util.BaseSpringTest;
import org.alfresco.util.debug.NodeStoreInspector;
@@ -80,6 +81,54 @@ public class ImporterComponentTest extends BaseSpringTest
System.out.println(NodeStoreInspector.dumpNodeStore(nodeService, storeRef));
}
public void testImportWithUuidBinding() throws Exception
{
Location location = new Location(storeRef);
// First pass must succeed
InputStream test1 = getClass().getClassLoader().getResourceAsStream("org/alfresco/repo/importer/importercomponent_test.xml");
InputStreamReader testReader1 = new InputStreamReader(test1, "UTF-8");
try
{
importerService.importView(testReader1, location, null, new ImportTimerProgress());
}
finally
{
testReader1.close();
}
// Second pass must succeed (defaults to CREATE_NEW)
InputStream test2 = getClass().getClassLoader().getResourceAsStream("org/alfresco/repo/importer/importercomponent_test.xml");
InputStreamReader testReader2 = new InputStreamReader(test2, "UTF-8");
try
{
importerBootstrap.setUuidBinding(UUID_BINDING.CREATE_NEW_WITH_UUID);
importerService.importView(testReader2, location, null, new ImportTimerProgress());
}
finally
{
testReader2.close();
}
// Set the UUID binding to guarantee a failure
InputStream test3 = getClass().getClassLoader().getResourceAsStream("org/alfresco/repo/importer/importercomponent_test.xml");
InputStreamReader testReader3 = new InputStreamReader(test3, "UTF-8");
try
{
importerBootstrap.setUuidBinding(UUID_BINDING.THROW_ON_COLLISION);
importerService.importView(testReader3, location, null, new ImportTimerProgress());
fail("Failed to detected collision of UUID on import with THROW_ON_COLLISION");
}
catch (Throwable e)
{
// Expected
}
finally
{
importerBootstrap.setUuidBinding(UUID_BINDING.CREATE_NEW_WITH_UUID);
testReader3.close();
}
System.out.println(NodeStoreInspector.dumpNodeStore(nodeService, storeRef));
}
public void testBootstrap()
{
StoreRef bootstrapStoreRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());

View File

@@ -22,6 +22,7 @@
<cm:auditable/>
</view:aspects>
<view:properties>
<sys:node-uuid>05efa5db-2817-4ada-a0dc-657db2b2a0ac</sys:node-uuid>
<cm:name>`¬¦!£$%^&amp;()-_=+tnu0000[]{};'#@~,</cm:name>
<cm:creator>testuser</cm:creator>
<cm:modifier>testuser</cm:modifier>