use of play.vfs.VirtualFile in project Japid by branaway.
the class PlayExceptionUtils method mapJapidJavaCodeError.
public static Exception mapJapidJavaCodeError(Exception ex) {
if (ex instanceof CompilationException) {
CompilationException e = (CompilationException) ex;
if (!e.isSourceAvailable())
return e;
// now map java error to japidview source code
String srcFilePath = e.getSourceFile();
if (!srcFilePath.startsWith("/app/japidviews/")) {
return e;
} else if (!srcFilePath.endsWith("java")) {
return e;
}
String viewSourceFilePath = DirUtil.mapJavaToSrc(srcFilePath);
// File file = new File(viewSourceFilePath);
VirtualFile vf = VirtualFile.fromRelativePath(viewSourceFilePath);
int oriLineNumber = mapJavaErrorLineToSrcLine(e.getSourceVirtualFile().contentAsString(), e.getLineNumber());
e = new CompilationException(vf, "\"" + e.getMessage() + "\"", oriLineNumber, 0, 0);
return e;
}
return ex;
}
use of play.vfs.VirtualFile in project play-cookbook by spinscale.
the class RenderPDF method getTemplateFile.
private VirtualFile getTemplateFile(Object... args) {
final Http.Request request = Http.Request.current();
String templateName = null;
List<String> renderNames = LocalVariablesNamesTracer.getAllLocalVariableNames(args[0]);
if (args.length > 0 && args[0] instanceof String && renderNames.isEmpty()) {
templateName = args[0].toString();
} else {
templateName = request.action.replace(".", "/") + ".fo";
}
if (templateName.startsWith("@")) {
templateName = templateName.substring(1);
if (!templateName.contains(".")) {
templateName = request.controller + "." + templateName;
}
templateName = templateName.replace(".", "/") + ".fo";
}
VirtualFile file = VirtualFile.search(Play.templatesPath, templateName);
return file;
}
Aggregations