Author: [email protected] Date: Wed Mar 30 09:06:13 2011 New Revision: 924
Log: AMDATU-283 added Felix http base default mimetype resolving Modified: branches/AMDATU-283-dev/amdatu-web/httpcontext/pom.xml branches/AMDATU-283-dev/amdatu-web/httpcontext/src/main/java/org/amdatu/web/httpcontext/context/DelegatingHttpContext.java Modified: branches/AMDATU-283-dev/amdatu-web/httpcontext/pom.xml ============================================================================== --- branches/AMDATU-283-dev/amdatu-web/httpcontext/pom.xml (original) +++ branches/AMDATU-283-dev/amdatu-web/httpcontext/pom.xml Wed Mar 30 09:06:13 2011 @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.amdatu</groupId> @@ -11,7 +12,14 @@ <packaging>bundle</packaging> <name>Amdatu Web - HTTP Context</name> <description>Provides a HTTPContext implementation</description> - + <dependencies> + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.apache.felix.http.base</artifactId> + <version>${org.apache.felix.http.version}</version> + <scope>compile</scope> + </dependency> + </dependencies> <build> <plugins> <plugin> @@ -25,11 +33,11 @@ <Export-Package> org.amdatu.web.httpcontext, org.amdatu.web.httpcontext.context </Export-Package> + <Embed-Dependency>*;scope=compile;inline=org/apache/felix/http/base/internal/util/**</Embed-Dependency> + <Embed-Transitive>true</Embed-Transitive> </instructions> </configuration> </plugin> - </plugins> - </build> </project> Modified: branches/AMDATU-283-dev/amdatu-web/httpcontext/src/main/java/org/amdatu/web/httpcontext/context/DelegatingHttpContext.java ============================================================================== --- branches/AMDATU-283-dev/amdatu-web/httpcontext/src/main/java/org/amdatu/web/httpcontext/context/DelegatingHttpContext.java (original) +++ branches/AMDATU-283-dev/amdatu-web/httpcontext/src/main/java/org/amdatu/web/httpcontext/context/DelegatingHttpContext.java Wed Mar 30 09:06:13 2011 @@ -26,6 +26,7 @@ import org.amdatu.web.httpcontext.MimeTypeResolver; import org.amdatu.web.httpcontext.ResourceProvider; import org.amdatu.web.httpcontext.SecurityHandler; +import org.apache.felix.http.base.internal.util.MimeTypes; import org.osgi.service.http.HttpContext; public class DelegatingHttpContext implements HttpContext { @@ -73,33 +74,32 @@ public boolean handleSecurity(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException { - boolean doHandle = true; for (SecurityHandler securityHandler : m_securityHandlers) { - doHandle = securityHandler.handleSecurity(httpServletRequest, - httpServletResponse); - if (!doHandle) - break; + if (!securityHandler.handleSecurity(httpServletRequest, + httpServletResponse)) { + return false; + } } - return doHandle; + return true; } public URL getResource(String name) { - URL resourceUrl = null; for (ResourceProvider resourceProvider : m_resourceProviders) { - resourceUrl = resourceProvider.getResource(name); - if (resourceUrl != null) - break; + URL resourceUrl = resourceProvider.getResource(name); + if (resourceUrl != null) { + return resourceUrl; + } } - return resourceUrl; + return null; } public String getMimeType(String name) { - String mimeType = null; for (MimeTypeResolver mimeTypeResolver : m_mimeTypeResolvers) { - mimeType = mimeTypeResolver.getMimetype(name); - if (mimeType != null) - break; + String mimeType = mimeTypeResolver.getMimetype(name); + if (mimeType != null) { + return mimeType; + } } - return mimeType; + return MimeTypes.get().getByFile(name); } } _______________________________________________ Amdatu-commits mailing list [email protected] http://lists.amdatu.org/mailman/listinfo/amdatu-commits
