mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged BRANCHES/DEV/V4.0-BUG-FIX to HEAD:
36723: Fix for ALF-13885: "Bulk Import Tool silently ignores constraint failures" git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@36727 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -29,7 +29,6 @@ import java.io.IOException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
|
||||||
import org.alfresco.repo.bulkimport.BulkFSImportEvent;
|
import org.alfresco.repo.bulkimport.BulkFSImportEvent;
|
||||||
import org.alfresco.repo.bulkimport.BulkFilesystemImporter;
|
import org.alfresco.repo.bulkimport.BulkFilesystemImporter;
|
||||||
import org.alfresco.repo.bulkimport.BulkImportParameters;
|
import org.alfresco.repo.bulkimport.BulkImportParameters;
|
||||||
@@ -406,9 +405,8 @@ public abstract class AbstractBulkFilesystemImporter implements BulkFilesystemIm
|
|||||||
}
|
}
|
||||||
catch(Throwable e)
|
catch(Throwable e)
|
||||||
{
|
{
|
||||||
logger.error("Bulk import from '" + getFileName(sourceFolder) + "' failed.", e);
|
|
||||||
importStatus.stopImport(e);
|
importStatus.stopImport(e);
|
||||||
throw new AlfrescoRuntimeException("Bulk filesystem import failed", e);
|
throw e;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@@ -29,6 +29,9 @@ import java.io.StringWriter;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||||
|
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
|
||||||
|
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.repo.bulkimport.BulkImportStatus;
|
import org.alfresco.repo.bulkimport.BulkImportStatus;
|
||||||
@@ -96,9 +99,16 @@ public class BulkImportStatusImpl implements BulkImportStatus
|
|||||||
private AtomicLong numberOfContentVersionBytesWritten = new AtomicLong();
|
private AtomicLong numberOfContentVersionBytesWritten = new AtomicLong();
|
||||||
private AtomicLong numberOfContentVersionPropertiesWritten = new AtomicLong();
|
private AtomicLong numberOfContentVersionPropertiesWritten = new AtomicLong();
|
||||||
|
|
||||||
|
private ReadLock readLock;
|
||||||
|
private WriteLock writeLock;
|
||||||
|
|
||||||
public BulkImportStatusImpl()
|
public BulkImportStatusImpl()
|
||||||
{
|
{
|
||||||
inProgress.set(false);
|
inProgress.set(false);
|
||||||
|
|
||||||
|
ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
|
||||||
|
this.readLock = lock.readLock();
|
||||||
|
this.writeLock = lock.writeLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
// General information
|
// General information
|
||||||
@@ -144,14 +154,25 @@ public class BulkImportStatusImpl implements BulkImportStatus
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Throwable getLastException()
|
public Throwable getLastException()
|
||||||
|
{
|
||||||
|
readLock.lock();
|
||||||
|
try
|
||||||
{
|
{
|
||||||
return(lastException);
|
return(lastException);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
readLock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getLastExceptionAsString()
|
public String getLastExceptionAsString()
|
||||||
{
|
{
|
||||||
String result = null;
|
String result = null;
|
||||||
|
|
||||||
|
readLock.lock();
|
||||||
|
try
|
||||||
|
{
|
||||||
if (lastException != null)
|
if (lastException != null)
|
||||||
{
|
{
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
@@ -167,6 +188,11 @@ public class BulkImportStatusImpl implements BulkImportStatus
|
|||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
readLock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean inProgress()
|
public boolean inProgress()
|
||||||
{
|
{
|
||||||
@@ -249,8 +275,23 @@ public class BulkImportStatusImpl implements BulkImportStatus
|
|||||||
public void stopImport(final Throwable lastException)
|
public void stopImport(final Throwable lastException)
|
||||||
{
|
{
|
||||||
stopImport();
|
stopImport();
|
||||||
|
|
||||||
|
writeLock.lock();
|
||||||
|
try
|
||||||
|
{
|
||||||
this.lastException = lastException;
|
this.lastException = lastException;
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
writeLock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void reportException(final Throwable exception)
|
||||||
|
{
|
||||||
|
stopImport();
|
||||||
|
this.lastException = exception;
|
||||||
|
}
|
||||||
|
|
||||||
// Read-side information
|
// Read-side information
|
||||||
public long getNumberOfFoldersScanned() { return(numberOfFoldersScanned.longValue()); }
|
public long getNumberOfFoldersScanned() { return(numberOfFoldersScanned.longValue()); }
|
||||||
|
@@ -32,6 +32,7 @@ import org.alfresco.repo.bulkimport.BulkImportParameters;
|
|||||||
import org.alfresco.repo.bulkimport.FilesystemTracker;
|
import org.alfresco.repo.bulkimport.FilesystemTracker;
|
||||||
import org.alfresco.repo.bulkimport.ImportableItem;
|
import org.alfresco.repo.bulkimport.ImportableItem;
|
||||||
import org.alfresco.repo.bulkimport.NodeImporter;
|
import org.alfresco.repo.bulkimport.NodeImporter;
|
||||||
|
import org.alfresco.repo.node.integrity.IntegrityException;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
@@ -106,6 +107,12 @@ public abstract class MultiThreadedBulkFilesystemImporter extends AbstractBulkFi
|
|||||||
|
|
||||||
public void process(final ImportableItem importableItem) throws Throwable
|
public void process(final ImportableItem importableItem) throws Throwable
|
||||||
{
|
{
|
||||||
|
if(importStatus.getLastException() != null)
|
||||||
|
{
|
||||||
|
// bail out early if an exception occurs
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
behaviourFilter.disableBehaviour(ContentModel.ASPECT_AUDITABLE);
|
behaviourFilter.disableBehaviour(ContentModel.ASPECT_AUDITABLE);
|
||||||
|
@@ -26,6 +26,7 @@ package org.alfresco.repo.bulkimport.impl;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.repo.batch.BatchProcessor;
|
import org.alfresco.repo.batch.BatchProcessor;
|
||||||
import org.alfresco.repo.bulkimport.BulkImportParameters;
|
import org.alfresco.repo.bulkimport.BulkImportParameters;
|
||||||
import org.alfresco.repo.bulkimport.ImportableItem;
|
import org.alfresco.repo.bulkimport.ImportableItem;
|
||||||
@@ -61,6 +62,10 @@ public class StripingBulkFilesystemImporter extends MultiThreadedBulkFilesystemI
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
batchProcessor.process(worker, true);
|
batchProcessor.process(worker, true);
|
||||||
|
if(batchProcessor.getLastError() != null)
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException(batchProcessor.getLastError());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
while(tracker.moreLevels());
|
while(tracker.moreLevels());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user