diff --git a/source/java/org/alfresco/repo/bulkimport/ImportableItem.java b/source/java/org/alfresco/repo/bulkimport/ImportableItem.java index 6523966243..2503950806 100644 --- a/source/java/org/alfresco/repo/bulkimport/ImportableItem.java +++ b/source/java/org/alfresco/repo/bulkimport/ImportableItem.java @@ -1,20 +1,20 @@ /* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. @@ -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 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); + } } } } diff --git a/source/test-java/org/alfresco/repo/bulkimport/impl/BulkImportTest.java b/source/test-java/org/alfresco/repo/bulkimport/impl/BulkImportTest.java index 3695af97ca..302cc2eac3 100644 --- a/source/test-java/org/alfresco/repo/bulkimport/impl/BulkImportTest.java +++ b/source/test-java/org/alfresco/repo/bulkimport/impl/BulkImportTest.java @@ -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)},