diff --git a/source/java/org/alfresco/repo/content/AbstractContentWriter.java b/source/java/org/alfresco/repo/content/AbstractContentWriter.java
index b9ab6e8ac7..b49f195d9d 100644
--- a/source/java/org/alfresco/repo/content/AbstractContentWriter.java
+++ b/source/java/org/alfresco/repo/content/AbstractContentWriter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2010 Alfresco Software Limited.
+ * Copyright (C) 2005-2016 Alfresco Software Limited.
*
* This file is part of Alfresco
*
@@ -613,11 +613,18 @@ public abstract class AbstractContentWriter extends AbstractContentAccessor impl
guessingOnCloseListener.filename = filename;
}
}
+
private void doGuessMimetype(String filename)
{
- String mimetype = mimetypeService.guessMimetype(
- filename, getReader()
- );
+ String mimetype;
+ if (filename.startsWith(MimetypeMap.MACOS_RESOURCE_FORK_FILE_NAME_PREFIX))
+ {
+ mimetype = MimetypeMap.MIMETYPE_APPLEFILE;
+ }
+ else
+ {
+ mimetype = mimetypeService.guessMimetype(filename, getReader());
+ }
setMimetype(mimetype);
}
diff --git a/source/test-java/org/alfresco/repo/content/ContentFullContextTestSuite.java b/source/test-java/org/alfresco/repo/content/ContentFullContextTestSuite.java
index d4cec1fdc9..78ee8d134c 100644
--- a/source/test-java/org/alfresco/repo/content/ContentFullContextTestSuite.java
+++ b/source/test-java/org/alfresco/repo/content/ContentFullContextTestSuite.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2010 Alfresco Software Limited.
+ * Copyright (C) 2005-2016 Alfresco Software Limited.
*
* This file is part of Alfresco
*
@@ -58,6 +58,7 @@ public class ContentFullContextTestSuite extends TestSuite
//suite.addTestSuite(MimetypeMapTest.class);
suite.addTestSuite(RoutingContentServiceTest.class);
suite.addTest(new JUnit4TestAdapter(RoutingContentStoreTest.class));
+ suite.addTestSuite(GuessMimetypeTest.class);
try
{
diff --git a/source/test-java/org/alfresco/repo/content/GuessMimetypeTest.java b/source/test-java/org/alfresco/repo/content/GuessMimetypeTest.java
new file mode 100644
index 0000000000..467ad740f9
--- /dev/null
+++ b/source/test-java/org/alfresco/repo/content/GuessMimetypeTest.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2005-2016 Alfresco Software Limited.
+ *
+ * This file is part of Alfresco
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ */
+package org.alfresco.repo.content;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.alfresco.model.ContentModel;
+import org.alfresco.repo.security.authentication.AuthenticationUtil;
+import org.alfresco.repo.transaction.RetryingTransactionHelper;
+import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
+import org.alfresco.service.cmr.repository.ContentService;
+import org.alfresco.service.cmr.repository.ContentWriter;
+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.namespace.QName;
+import org.alfresco.util.ApplicationContextHelper;
+import org.springframework.context.ApplicationContext;
+
+/**
+ * Tests for guess mimetype for file
+ *
+ * This includes a test for apple specific hidden files
+ *
+ * @author rneamtu
+ */
+
+public class GuessMimetypeTest extends TestCase
+{
+ private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
+
+ private NodeService nodeService;
+ private ContentService contentService;
+ private RetryingTransactionHelper retryingTransactionHelper;
+ private StoreRef storeRef;
+ private NodeRef rootNodeRef;
+ private NodeRef nodeRef;
+
+ @Override
+ public void setUp() throws Exception
+ {
+ this.nodeService = (NodeService) ctx.getBean("nodeService");
+ this.contentService = (ContentService) ctx.getBean("ContentService");
+
+ this.retryingTransactionHelper = (RetryingTransactionHelper) ctx.getBean("retryingTransactionHelper");
+
+ retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback