try
{
if (contentPath.formName.equals(SINGLE_MODULE_REQUEST))
{
SourceModule jsModule = (SourceModule)bundleSet.getBundlableNode().getLinkedAsset(contentPath.properties.get("module"));
return new CharResponseContent(brjs, jsModule.getReader());
}
else if (contentPath.formName.equals(BUNDLE_REQUEST))
{
List<Reader> readerList = new ArrayList<Reader>();
StringBuffer contentBuffer = new StringBuffer();
for (SourceModule sourceModule : bundleSet.getSourceModules())
{
if (sourceModule instanceof NamespacedJsSourceModule)
{
contentBuffer.append("// " + sourceModule.getPrimaryRequirePath() + "\n");
Reader reader = sourceModule.getReader();
readerList.add(reader);
contentBuffer.append("\n\n");
}
}
List<SourceModule> processedGlobalizedSourceModules = new ArrayList<SourceModule>();
String globalizedClasses = getGlobalizedClassesContent(bundleSet, processedGlobalizedSourceModules);
Map<String, Map<String, ?>> packageStructure = createPackageStructureForNamespacedJsClasses(bundleSet, processedGlobalizedSourceModules);
Reader structureRreader = getPackageStructureReader(packageStructure);
if(structureRreader != null){
readerList.add(structureRreader);
}
readerList.add(new StringReader("\n"));
String content = contentBuffer.toString();
readerList.add(new StringReader(content));
readerList.add(new StringReader("\n"));
readerList.add(new StringReader(globalizedClasses));
return new CharResponseContent( brjs, readerList );
}
else if (contentPath.formName.equals(PACKAGE_DEFINITIONS_REQUEST))
{
// call globalizeExtraClasses here so it pushes more classes onto processedGlobalizedSourceModules so we create the package structure for these classes
List<SourceModule> processedGlobalizedSourceModules = new ArrayList<SourceModule>();
getGlobalizedClassesContent(bundleSet, processedGlobalizedSourceModules);
Map<String, Map<String, ?>> packageStructure = createPackageStructureForNamespacedJsClasses(bundleSet, processedGlobalizedSourceModules);
return new CharResponseContent(brjs, getPackageStructureReader(packageStructure) );
}
else if (contentPath.formName.equals(GLOBALIZE_EXTRA_CLASSES_REQUEST))
{
// call globalizeExtraClasses here so it pushes more classes onto processedGlobalizedSourceModules so we create the package structure for these classes
List<SourceModule> processedGlobalizedSourceModules = new ArrayList<SourceModule>();
return new CharResponseContent(brjs, getGlobalizedClassesContent(bundleSet, processedGlobalizedSourceModules));
}
else
{
throw new ContentProcessingException("unknown request form '" + contentPath.formName + "'.");
}