mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)
57038: Merged V4.2-BUG-FIX (4.2.1) to HEAD-BUG-FIX (Cloud/4.3) 56505: Merged HEAD-BUG-FIX to V4.2-BUG-FIX (4.2.1) 55928: <<NOT IN 4.1.6>> Merged V4.1-BUG-FIX (4.1.7) to HEAD-BUG-FIX (4.2) 55811: Merged DEV to V4.1-BUG-FIX (4.1.7) 55751: MNT-9076: Penultimate version cannot be accessed from Share when uploading using bulkimport The changes related to creating a version for HEAD revision of imported file. Added unit test. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@61672 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -52,6 +52,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.rule.RuleService;
|
||||
import org.alfresco.service.cmr.version.VersionService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.ApplicationContextHelper;
|
||||
@@ -74,6 +75,7 @@ public class AbstractBulkImportTests
|
||||
protected UserTransaction txn = null;
|
||||
protected RuleService ruleService;
|
||||
protected ActionService actionService;
|
||||
protected VersionService versionService;
|
||||
protected MultiThreadedBulkFilesystemImporter bulkImporter;
|
||||
|
||||
protected NodeRef rootNodeRef;
|
||||
@@ -107,6 +109,7 @@ public class AbstractBulkImportTests
|
||||
contentService = (ContentService)ctx.getBean("contentService");
|
||||
actionService = (ActionService)ctx.getBean("actionService");
|
||||
ruleService = (RuleService)ctx.getBean("ruleService");
|
||||
versionService = (VersionService)ctx.getBean("versionService");
|
||||
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
||||
|
||||
|
@@ -25,6 +25,8 @@
|
||||
package org.alfresco.repo.bulkimport.impl;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -45,9 +47,12 @@ import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ActionCondition;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.rule.Rule;
|
||||
import org.alfresco.service.cmr.rule.RuleType;
|
||||
import org.alfresco.service.cmr.version.Version;
|
||||
import org.alfresco.service.cmr.version.VersionHistory;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
@@ -308,4 +313,66 @@ public class BulkImportTest extends AbstractBulkImportTests
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* MNT-9076: Penultimate version cannot be accessed from Share when uploading using bulkimport
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
@Test
|
||||
public void testMNT9076() throws Throwable
|
||||
{
|
||||
txn = transactionService.getUserTransaction();
|
||||
txn.begin();
|
||||
|
||||
NodeRef folderNode = topLevelFolder.getNodeRef();
|
||||
|
||||
try
|
||||
{
|
||||
NodeImporter nodeImporter = streamingNodeImporterFactory.getNodeImporter(ResourceUtils.getFile("classpath:bulkimport2"));
|
||||
BulkImportParameters bulkImportParameters = new BulkImportParameters();
|
||||
bulkImportParameters.setTarget(folderNode);
|
||||
bulkImportParameters.setReplaceExisting(true);
|
||||
bulkImportParameters.setDisableRulesService(true);
|
||||
bulkImportParameters.setBatchSize(40);
|
||||
bulkImporter.bulkImport(bulkImportParameters, nodeImporter);
|
||||
}
|
||||
catch(Throwable e)
|
||||
{
|
||||
fail(e.getMessage());
|
||||
}
|
||||
|
||||
System.out.println(bulkImporter.getStatus());
|
||||
assertEquals(false, bulkImporter.getStatus().inProgress());
|
||||
|
||||
List<FileInfo> files = getFiles(folderNode, null);
|
||||
assertEquals("One file is expected to be imported:", 1, files.size());
|
||||
FileInfo file = files.get(0);
|
||||
assertEquals("File name is not equal:", "fileWithVersions.txt", file.getName());
|
||||
|
||||
NodeRef file0NodeRef = file.getNodeRef();
|
||||
assertTrue("Imported file should be versioned:", versionService.isVersioned(file0NodeRef));
|
||||
|
||||
VersionHistory history = versionService.getVersionHistory(file0NodeRef);
|
||||
assertEquals("Imported file should have 4 versions:", 4, history.getAllVersions().size());
|
||||
Version[] versions = history.getAllVersions().toArray(new Version[4]);
|
||||
|
||||
//compare the content of each version
|
||||
ContentReader contentReader;
|
||||
contentReader = this.contentService.getReader(versions[0].getFrozenStateNodeRef(), ContentModel.PROP_CONTENT);
|
||||
assertNotNull(contentReader);
|
||||
assertEquals("This is the final version of fileWithVersions.txt.", contentReader.getContentString());
|
||||
|
||||
contentReader = this.contentService.getReader(versions[1].getFrozenStateNodeRef(), ContentModel.PROP_CONTENT);
|
||||
assertNotNull(contentReader);
|
||||
assertEquals("This is version 3 of fileWithVersions.txt.", contentReader.getContentString());
|
||||
|
||||
contentReader = this.contentService.getReader(versions[2].getFrozenStateNodeRef(), ContentModel.PROP_CONTENT);
|
||||
assertNotNull(contentReader);
|
||||
assertEquals("This is version 2 of fileWithVersions.txt.", contentReader.getContentString());
|
||||
|
||||
contentReader = this.contentService.getReader(versions[3].getFrozenStateNodeRef(), ContentModel.PROP_CONTENT);
|
||||
assertNotNull(contentReader);
|
||||
assertEquals("This is version 1 of fileWithVersions.txt.", contentReader.getContentString());
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user