Search in sources :

Example 6 with ImportableItem

use of org.alfresco.repo.bulkimport.ImportableItem in project alfresco-repository by Alfresco.

the class StripingBulkFilesystemImporter method bulkImportImpl.

/**
 * Method that does the work of importing a filesystem using the BatchProcessor.
 *
 * @param bulkImportParameters  The bulk import parameters to apply to this bulk import.
 * @param nodeImporter          The node importer implementation that will import each node.
 * @param lockToken             The lock token to use during the bulk import.
 */
@Override
protected void bulkImportImpl(final BulkImportParameters bulkImportParameters, final NodeImporter nodeImporter, final String lockToken) {
    super.bulkImportImpl(bulkImportParameters, nodeImporter, lockToken);
    final File sourceFolder = nodeImporter.getSourceFolder();
    final int batchSize = getBatchSize(bulkImportParameters);
    final int loggingInterval = getLoggingInterval(bulkImportParameters);
    final StripingFilesystemTracker tracker = new StripingFilesystemTracker(directoryAnalyser, bulkImportParameters.getTarget(), sourceFolder, batchSize);
    final BatchProcessor<ImportableItem> batchProcessor = getBatchProcessor(bulkImportParameters, tracker.getWorkProvider(), loggingInterval);
    final BatchProcessor.BatchProcessWorker<ImportableItem> worker = getWorker(bulkImportParameters, lockToken, nodeImporter, tracker);
    do {
        batchProcessor.process(worker, true);
        if (batchProcessor.getLastError() != null) {
            throw new AlfrescoRuntimeException(batchProcessor.getLastError());
        }
    } while (tracker.moreLevels());
}
Also used : ImportableItem(org.alfresco.repo.bulkimport.ImportableItem) BatchProcessor(org.alfresco.repo.batch.BatchProcessor) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) File(java.io.File)

Example 7 with ImportableItem

use of org.alfresco.repo.bulkimport.ImportableItem in project alfresco-repository by Alfresco.

the class DirectoryAnalyserImpl method addVersionFile.

private void addVersionFile(ImportableItem parent, AnalysedDirectory analysedDirectory, Path versionFile) {
    Path parentContentFile = getParentOfVersionFile(versionFile);
    boolean isContentVersion = false;
    if (isMetadataFile(parentContentFile)) {
        parentContentFile = getParentOfMetadatafile(parentContentFile);
        isContentVersion = false;
    } else {
        isContentVersion = true;
    }
    ImportableItem importableItem = findOrCreateImportableItem(parent, analysedDirectory, parentContentFile);
    int version = getVersionNumber(versionFile);
    ImportableItem.VersionedContentAndMetadata versionEntry = findOrCreateVersionEntry(importableItem, version);
    if (isContentVersion) {
        versionEntry.setContentFile(versionFile);
    } else {
        versionEntry.setMetadataFile(versionFile);
    }
}
Also used : Path(java.nio.file.Path) ImportableItem(org.alfresco.repo.bulkimport.ImportableItem) Constraint(org.alfresco.service.cmr.dictionary.Constraint)

Example 8 with ImportableItem

use of org.alfresco.repo.bulkimport.ImportableItem in project alfresco-repository by Alfresco.

the class DirectoryAnalyserImpl method addParentFile.

private boolean addParentFile(ImportableItem parent, AnalysedDirectory analysedDirectory, Path contentFile) {
    ImportableItem importableItem = findOrCreateImportableItem(parent, analysedDirectory, contentFile);
    importableItem.getHeadRevision().setContentFile(contentFile);
    return (importableItem.getHeadRevision().getContentFileType() == FileType.DIRECTORY);
}
Also used : ImportableItem(org.alfresco.repo.bulkimport.ImportableItem)

Example 9 with ImportableItem

use of org.alfresco.repo.bulkimport.ImportableItem in project alfresco-repository by Alfresco.

the class DirectoryAnalyserImpl method findImportableItem.

private ImportableItem findImportableItem(AnalysedDirectory analysedDirectory, Path contentFile) {
    ImportableItem result = null;
    if (contentFile == null) {
        throw new IllegalStateException("Cannot call findOrCreateImportableItem with null key");
    }
    result = analysedDirectory.findImportableItem(contentFile);
    return (result);
}
Also used : ImportableItem(org.alfresco.repo.bulkimport.ImportableItem)

Aggregations

ImportableItem (org.alfresco.repo.bulkimport.ImportableItem)9 Path (java.nio.file.Path)3 File (java.io.File)2 AnalysedDirectory (org.alfresco.repo.bulkimport.AnalysedDirectory)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)1 BatchProcessor (org.alfresco.repo.batch.BatchProcessor)1 Constraint (org.alfresco.service.cmr.dictionary.Constraint)1 ConstraintException (org.alfresco.service.cmr.dictionary.ConstraintException)1 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1 Test (org.junit.Test)1 PlatformRuntimeException (org.springframework.extensions.surf.exception.PlatformRuntimeException)1