Return-Path: X-Original-To: apmail-manifoldcf-commits-archive@www.apache.org Delivered-To: apmail-manifoldcf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 30DD7E1C1 for ; Thu, 17 Jan 2013 14:49:54 +0000 (UTC) Received: (qmail 29201 invoked by uid 500); 17 Jan 2013 14:49:53 -0000 Delivered-To: apmail-manifoldcf-commits-archive@manifoldcf.apache.org Received: (qmail 29155 invoked by uid 500); 17 Jan 2013 14:49:53 -0000 Mailing-List: contact commits-help@manifoldcf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@manifoldcf.apache.org Delivered-To: mailing list commits@manifoldcf.apache.org Received: (qmail 29147 invoked by uid 99); 17 Jan 2013 14:49:53 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Jan 2013 14:49:53 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Jan 2013 14:49:52 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id E42CC2388A2C; Thu, 17 Jan 2013 14:49:32 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1434701 - in /manifoldcf/branches/release-1.1-branch: ./ connectors/filesystem/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/filesystem/ connectors/jcifs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/s... Date: Thu, 17 Jan 2013 14:49:32 -0000 To: commits@manifoldcf.apache.org From: kwright@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130117144932.E42CC2388A2C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kwright Date: Thu Jan 17 14:49:32 2013 New Revision: 1434701 URL: http://svn.apache.org/viewvc?rev=1434701&view=rev Log: Second part of CONNECTORS-613. Modified: manifoldcf/branches/release-1.1-branch/ (props changed) manifoldcf/branches/release-1.1-branch/connectors/filesystem/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/filesystem/FileConnector.java manifoldcf/branches/release-1.1-branch/connectors/jcifs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharedrive/SharedDriveConnector.java Propchange: manifoldcf/branches/release-1.1-branch/ ------------------------------------------------------------------------------ Merged /manifoldcf/trunk:r1434697 Modified: manifoldcf/branches/release-1.1-branch/connectors/filesystem/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/filesystem/FileConnector.java URL: http://svn.apache.org/viewvc/manifoldcf/branches/release-1.1-branch/connectors/filesystem/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/filesystem/FileConnector.java?rev=1434701&r1=1434700&r2=1434701&view=diff ============================================================================== --- manifoldcf/branches/release-1.1-branch/connectors/filesystem/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/filesystem/FileConnector.java (original) +++ manifoldcf/branches/release-1.1-branch/connectors/filesystem/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/filesystem/FileConnector.java Thu Jan 17 14:49:32 2013 @@ -279,6 +279,7 @@ public class FileConnector extends org.a RepositoryDocument data = new RepositoryDocument(); data.setBinary(is,fileBytes); data.setFileName(file.getName()); + data.setMimeType(mapExtensionToMimeType(file.getName())); data.addField("uri",file.toString()); // MHL for other metadata activities.ingestDocument(documentIdentifier,version,convertToURI(documentIdentifier),data); @@ -308,6 +309,31 @@ public class FileConnector extends org.a } } + protected final static Map mimeMap; + static { + mimeMap = new HashMap(); + mimeMap.put("txt","text/plain"); + mimeMap.put(".pdf","application/pdf"); + mimeMap.put(".doc","application/msword"); + mimeMap.put(".docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"); + mimeMap.put(".ppt","application/vnd.ms-powerpoint"); + mimeMap.put(".pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"); + mimeMap.put(".xls","application/vnd.ms-excel"); + mimeMap.put(".xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + } + + /** Map an extension to a mime type */ + protected static String mapExtensionToMimeType(String fileName) + { + int slashIndex = fileName.lastIndexOf("/"); + if (slashIndex != -1) + fileName = fileName.substring(slashIndex+1); + int dotIndex = fileName.lastIndexOf("."); + if (dotIndex == -1) + return null; + return mimeMap.get(fileName.substring(dotIndex+1).toLowerCase(java.util.Locale.ROOT)); + } + // UI support methods. // // These support methods come in two varieties. The first bunch is involved in setting up connection configuration information. The second bunch Modified: manifoldcf/branches/release-1.1-branch/connectors/jcifs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharedrive/SharedDriveConnector.java URL: http://svn.apache.org/viewvc/manifoldcf/branches/release-1.1-branch/connectors/jcifs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharedrive/SharedDriveConnector.java?rev=1434701&r1=1434700&r2=1434701&view=diff ============================================================================== --- manifoldcf/branches/release-1.1-branch/connectors/jcifs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharedrive/SharedDriveConnector.java (original) +++ manifoldcf/branches/release-1.1-branch/connectors/jcifs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharedrive/SharedDriveConnector.java Thu Jan 17 14:49:32 2013 @@ -778,6 +778,9 @@ public class SharedDriveConnector extend RepositoryDocument rd = new RepositoryDocument(); rd.setBinary(inputStream, tempFile.length()); rd.setFileName(file.getName()); + String contentType = mapExtensionToMimeType(file.getName()); + if (contentType != null) + rd.setMimeType(contentType); rd.addField("lastModified", new Date(file.lastModified()).toString()); int index = 0; index = setDocumentSecurity(rd,version,index); @@ -832,6 +835,9 @@ public class SharedDriveConnector extend RepositoryDocument rd = new RepositoryDocument(); rd.setBinary(inputStream, fileLength(file)); rd.setFileName(file.getName()); + String contentType = mapExtensionToMimeType(file.getName()); + if (contentType != null) + rd.setMimeType(contentType); rd.addField("lastModified", new Date(file.lastModified()).toString()); int index = 0; index = setDocumentSecurity(rd,version,index); @@ -976,8 +982,31 @@ public class SharedDriveConnector extend } - - + protected final static Map mimeMap; + static { + mimeMap = new HashMap(); + mimeMap.put("txt","text/plain"); + mimeMap.put(".pdf","application/pdf"); + mimeMap.put(".doc","application/msword"); + mimeMap.put(".docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"); + mimeMap.put(".ppt","application/vnd.ms-powerpoint"); + mimeMap.put(".pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"); + mimeMap.put(".xls","application/vnd.ms-excel"); + mimeMap.put(".xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + } + + /** Map an extension to a mime type */ + protected static String mapExtensionToMimeType(String fileName) + { + int slashIndex = fileName.lastIndexOf("/"); + if (slashIndex != -1) + fileName = fileName.substring(slashIndex+1); + int dotIndex = fileName.lastIndexOf("."); + if (dotIndex == -1) + return null; + return mimeMap.get(fileName.substring(dotIndex+1).toLowerCase(java.util.Locale.ROOT)); + } + /** This method calculates an ACL string based on whether there are forced acls and also based on * the acls in place for a file. */