Properly handling contextRoot when retrieving dojo and extension resources

git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@916514 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
lresende 2010-02-26 00:58:02 +00:00
commit b4b2a2b6e8
3 changed files with 7 additions and 2 deletions

View file

@ -22,3 +22,4 @@ Bundle-DocURL: http://www.apache.org/
Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6

View file

@ -111,5 +111,4 @@
</plugin>
</plugins>
</build>
</project>

View file

@ -30,6 +30,7 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.tuscany.sca.common.http.HTTPConstants;
import org.apache.tuscany.sca.common.http.HTTPContentTypeMapper;
import org.apache.tuscany.sca.common.http.HTTPUtil;
/**
@ -46,14 +47,18 @@ public class DojoResourceServlet extends HttpServlet {
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
String contextRoot = URLDecoder.decode(HTTPUtil.getContextRoot(request), HTTPConstants.CHARACTER_ENCODING_UTF8);
String path = URLDecoder.decode(request.getRequestURI(), HTTPConstants.CHARACTER_ENCODING_UTF8);
if( path.startsWith("/dojo") ) {
if( path.startsWith(contextRoot + "/dojo") ) {
if( ! path.contains("tuscany/AtomService.js")) {
//this is a workaround where we need to have dojo files in its own folder
//to avoid clean target to clean other non dojo resources
path = path.substring(contextRoot.length());
path = "/dojo" + path;
}
} else if (path.startsWith(contextRoot)) {
path = path.substring(contextRoot.length() + 1);
} else if( path.startsWith("/")) {
path = path.substring(1);
}