Return-Path: Delivered-To: apmail-incubator-sling-commits-archive@locus.apache.org Received: (qmail 2851 invoked from network); 6 Nov 2008 04:29:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Nov 2008 04:29:57 -0000 Received: (qmail 26491 invoked by uid 500); 6 Nov 2008 04:30:03 -0000 Delivered-To: apmail-incubator-sling-commits-archive@incubator.apache.org Received: (qmail 26477 invoked by uid 500); 6 Nov 2008 04:30:03 -0000 Mailing-List: contact sling-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: sling-dev@incubator.apache.org Delivered-To: mailing list sling-commits@incubator.apache.org Received: (qmail 26468 invoked by uid 99); 6 Nov 2008 04:30:03 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Nov 2008 20:30:03 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.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, 06 Nov 2008 04:28:54 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 68C4F238889E; Wed, 5 Nov 2008 20:29:06 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r711770 - in /incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp: JspScriptEngineFactory.java SlingIOProvider.java Date: Thu, 06 Nov 2008 04:29:05 -0000 To: sling-commits@incubator.apache.org From: fmeschbe@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081106042906.68C4F238889E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: fmeschbe Date: Wed Nov 5 20:29:05 2008 New Revision: 711770 URL: http://svn.apache.org/viewvc?rev=711770&view=rev Log: Sling-720 Try to assign a well-known MIME type derived from the filename extension Modified: incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/SlingIOProvider.java Modified: incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java?rev=711770&r1=711769&r2=711770&view=diff ============================================================================== --- incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java (original) +++ incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java Wed Nov 5 20:29:05 2008 @@ -190,7 +190,7 @@ // prepare some classes prepareJasperClasses(); - ioProvider = new SlingIOProvider(repository); + ioProvider = new SlingIOProvider(repository, slingServletContext); tldLocationsCache = new SlingTldLocationsCache(slingServletContext, componentContext.getBundleContext()); Modified: incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/SlingIOProvider.java URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/SlingIOProvider.java?rev=711770&r1=711769&r2=711770&view=diff ============================================================================== --- incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/SlingIOProvider.java (original) +++ incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/SlingIOProvider.java Wed Nov 5 20:29:05 2008 @@ -32,6 +32,7 @@ import javax.jcr.Node; import javax.jcr.RepositoryException; import javax.jcr.Session; +import javax.servlet.ServletContext; import org.apache.sling.api.SlingException; import org.apache.sling.api.resource.Resource; @@ -52,15 +53,19 @@ private final SlingRepository repository; - private ThreadLocal requestResourceResolver; + private final ThreadLocal requestResourceResolver; // private session for write access - private ThreadLocal privateSession; + private final ThreadLocal privateSession; + + // used to find out about the mime type for created files + private final ServletContext servletContext; - SlingIOProvider(SlingRepository repository) { + SlingIOProvider(SlingRepository repository, ServletContext servletContext) { this.repository = repository; this.requestResourceResolver = new ThreadLocal(); this.privateSession = new ThreadLocal(); + this.servletContext = servletContext; } void setRequestResourceResolver(ResourceResolver resolver) { @@ -80,6 +85,10 @@ } } + ServletContext getServletContext() { + return servletContext; + } + // ---------- IOProvider interface ----------------------------------------- /** @@ -377,12 +386,17 @@ contentNode = fileNode.addNode("jcr:content", "nt:resource"); } + String mimeType = repositoryOutputProvider.getServletContext().getMimeType( + fileName); + if (mimeType == null) { + mimeType = "application/octet-stream"; + } + contentNode.setProperty("jcr:lastModified", System.currentTimeMillis()); contentNode.setProperty("jcr:data", new ByteArrayInputStream( buf, 0, size())); - contentNode.setProperty("jcr:mimeType", - "application/octet-stream"); + contentNode.setProperty("jcr:mimeType", mimeType); parentNode.save(); } catch (RepositoryException re) {