Merged 5.0.N (5.0.4) to 5.1.N (5.1.2)

129111 adavis: Merged 5.0.2 (5.0.2.23) to 5.0.N (5.0.4)
      120632 amorarasu: MNT-15367: Unable to bulk import filenames with portuguese characters in a linux environment.
         - Fixed empty catch blocks and added some comments as per review.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.1.N/root@129115 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2016-08-04 15:54:23 +00:00
parent 268e8eb9e1
commit fc60b50f9c
2 changed files with 33 additions and 20 deletions

View File

@@ -36,8 +36,11 @@ import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import org.alfresco.repo.bulkimport.impl.FileUtils;
import org.alfresco.service.cmr.repository.NodeRef;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* This class is a DTO that represents an "importable item" - a series of files
@@ -55,6 +58,8 @@ public final class ImportableItem
OTHER
};
protected static final Log logger = LogFactory.getLog(ImportableItem.class);
private ContentAndMetadata headRevision = new ContentAndMetadata();
private SortedSet<VersionedContentAndMetadata> versionEntries = null;
private NodeRef nodeRef;
@@ -193,6 +198,7 @@ public final class ImportableItem
}
catch (IOException e)
{
logger.error("Attributes for file '" + FileUtils.getFileName(contentFile) + "' could not be read.", e);
}
}
}
@@ -269,6 +275,10 @@ public final class ImportableItem
}
catch (IOException e)
{
if (logger.isWarnEnabled())
{
logger.warn("Size for the metadata file '" + FileUtils.getFileName(metadataFile) + "' could not be retrieved.", e);
}
}
}
}

View File

@@ -34,6 +34,7 @@ import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Serializable;
import java.nio.charset.Charset;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -271,7 +272,7 @@ public class BulkImportTest extends AbstractBulkImportTests
System.out.println(bulkImporter.getStatus());
assertEquals("", 74, bulkImporter.getStatus().getNumberOfContentNodesCreated());
assertEquals(74, bulkImporter.getStatus().getNumberOfContentNodesCreated());
checkFiles(folderNode, null, 2, 9, new ExpectedFile[] {
new ExpectedFile("quickImg1.xls", MimetypeMap.MIMETYPE_EXCEL),
@@ -627,8 +628,9 @@ public class BulkImportTest extends AbstractBulkImportTests
NodeImporter nodeImporter = null;
File source = ResourceUtils.getFile("classpath:bulkimport4");
String fileName = new String("135 CarbonÔÇô13 NMR spectroscopy_DS_NS_final_cau.txt".getBytes("ISO-8859-1"), "UTF-8");
//Simulate the name of the file with an invalid encoding.
String fileName = new String("135 CarbonÔÇô13 NMR spectroscopy_DS_NS_final_cau.txt".getBytes(Charset.forName("ISO-8859-1")),
Charset.forName("UTF-8"));
Path dest = source.toPath().resolve("encoding");
try
{
@@ -636,6 +638,7 @@ public class BulkImportTest extends AbstractBulkImportTests
}
catch (FileAlreadyExistsException ex)
{
//It is fine if the folder already exists, though it should not.
}
Path destFile = dest.resolve(fileName);
@@ -653,7 +656,7 @@ public class BulkImportTest extends AbstractBulkImportTests
bulkImportParameters.setBatchSize(40);
bulkImporter.bulkImport(bulkImportParameters, nodeImporter);
assertEquals("", 1, bulkImporter.getStatus().getNumberOfContentNodesCreated());
assertEquals(1, bulkImporter.getStatus().getNumberOfContentNodesCreated());
checkFiles(folderNode, null, 0, 1,
new ExpectedFile[] { new ExpectedFile(fileName, MimetypeMap.MIMETYPE_TEXT_PLAIN)},