Author: fmeschbe
Date: Mon Dec 3 05:25:55 2007
New Revision: 600525
URL: http://svn.apache.org/viewvc?rev=600525&view=rev
Log:
SLING-109 Support Resource adapter
Modified:
incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/RepositoryIOProvider.java
Modified:
incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/RepositoryIOProvider.java
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/RepositoryIOProvider.java?rev=600525&r1=600524&r2=600525&view=diff
==============================================================================
---
incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/RepositoryIOProvider.java
(original)
+++
incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/RepositoryIOProvider.java
Mon Dec 3 05:25:55 2007
@@ -39,8 +39,6 @@
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceMetadata;
import org.apache.sling.api.resource.ResourceResolver;
-import org.apache.sling.api.resource.StreamProvider;
-import org.apache.sling.api.resource.URLProvider;
import org.apache.sling.jcr.api.SlingRepository;
import org.apache.sling.scripting.jsp.jasper.IOProvider;
import org.slf4j.Logger;
@@ -95,11 +93,12 @@
throws FileNotFoundException, IOException {
try {
Resource resource = getResourceInternal(fileName);
- if (!(resource instanceof StreamProvider)) {
+ InputStream stream = resource.adaptTo(InputStream.class);
+ if (stream == null) {
throw new FileNotFoundException("Cannot find " + fileName);
}
- return ((StreamProvider) resource).getInputStream();
+ return stream;
} catch (SlingException se) {
throw (IOException) new IOException(
@@ -231,17 +230,11 @@
/* package */URL getURL(String path) throws MalformedURLException {
try {
- Resource resource = getResourceInternal(path);
- if (resource instanceof URLProvider) {
- return ((URLProvider) resource).getURL();
- }
-
+ return getResourceInternal(path).adaptTo(URL.class);
} catch (SlingException se) {
throw (MalformedURLException) new MalformedURLException(
"Cannot get URL for " + path).initCause(se);
}
-
- return null;
}
/* package */ Set<String> getResourcePaths(String path) {