Created
July 25, 2010 00:32
-
-
Save lenards/489143 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void doGetPublicFile(HttpServletRequest request, | |
HttpServletResponse response, TreeLogger logger, String partialPath, | |
String moduleName) throws IOException { | |
// Create a logger branch for this request. | |
String msg = "The development shell servlet received a request for '" | |
+ partialPath + "' in module '" + moduleName + "' "; | |
logger = logger.branch(TreeLogger.TRACE, msg, null); | |
// ... | |
URL foundResource; | |
try { | |
// Look for the requested file on the public path. | |
// | |
ModuleDef moduleDef = getModuleDef(logger, moduleName); | |
foundResource = moduleDef.findPublicFile(partialPath); | |
if (foundResource == null) { | |
// Look in the place where we write compiled output. | |
File moduleDir = new File(getOutputDir(), moduleName); | |
File requestedFile = new File(moduleDir, partialPath); | |
if (requestedFile.exists()) { | |
try { | |
foundResource = requestedFile.toURI().toURL(); | |
} catch (MalformedURLException e) { | |
// ignore since it was speculative anyway | |
} | |
} | |
if (foundResource == null) { | |
msg = "Resource not found: " + partialPath; | |
logger.log(TreeLogger.WARN, msg, null); | |
throw new UnableToCompleteException(); | |
} | |
} | |
} catch (UnableToCompleteException e) { | |
sendErrorResponse(response, HttpServletResponse.SC_NOT_FOUND, | |
"Cannot find resource '" + partialPath | |
+ "' in the public path of module '" + moduleName + "'"); | |
return; | |
} | |
// ... omitted | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment