use of com.genexus.webpanels.HttpContextWeb in project JavaClasses by genexuslabs.
the class GXReportText method setOutput.
protected void setOutput(String fileName) {
try {
this.fileName = fileName;
if (!printAtClient) {
if (!new File(fileName).isAbsolute()) {
if (ModelContext.getModelContext() != null) {
HttpContext webContext = (HttpContext) ModelContext.getModelContext().getHttpContext();
if ((webContext != null) && (webContext instanceof HttpContextWeb)) {
this.fileName = com.genexus.ModelContext.getModelContext().getHttpContext().getDefaultPath() + File.separator + fileName;
}
}
}
}
out = new AsciiPrintWriter(new BufferedWriter(new FileWriter(this.fileName)));
} catch (IOException e) {
System.err.println("Can't open file " + this.fileName);
setOutput(System.out);
}
}
use of com.genexus.webpanels.HttpContextWeb in project JavaClasses by genexuslabs.
the class GXFile method setSource.
public void setSource(String FileName) {
boolean isUpload = com.genexus.CommonUtil.isUploadPrefix(FileName);
if (isUpload) {
uploadFileId = FileName;
FileName = SpecificImplementation.GXutil.getUploadValue(FileName);
}
if (Application.getGXServices().get(GXServices.STORAGE_SERVICE) != null && (isUpload || isExternal)) {
FileSource = new GXExternalFileInfo(FileName, Application.getExternalProvider());
} else {
String absoluteFileName = FileName;
try {
if (ModelContext.getModelContext() != null && !new File(absoluteFileName).isAbsolute()) {
IHttpContext webContext = ModelContext.getModelContext().getHttpContext();
if ((webContext != null) && (webContext instanceof HttpContextWeb || !webContext.getDefaultPath().isEmpty()) && !FileName.isEmpty()) {
absoluteFileName = ModelContext.getModelContext().getHttpContext().getDefaultPath() + File.separator + FileName;
}
}
URI uriFile = URI.create(absoluteFileName);
FileSource = new GXFileInfo(new File(uriFile));
} catch (Exception e) {
FileSource = new GXFileInfo(new File(absoluteFileName));
}
}
}
use of com.genexus.webpanels.HttpContextWeb in project JavaClasses by genexuslabs.
the class GXServices method configBaseDirectory.
private String configBaseDirectory() {
String baseDir = "";
String envVariable = System.getenv("LAMBDA_TASK_ROOT");
if (envVariable != null && envVariable.length() > 0)
return envVariable + File.separator;
if (ModelContext.getModelContext() != null) {
HttpContext webContext = (HttpContext) ModelContext.getModelContext().getHttpContext();
if ((webContext != null) && (webContext instanceof HttpContextWeb)) {
baseDir = com.genexus.ModelContext.getModelContext().getHttpContext().getDefaultPath() + File.separator + "WEB-INF" + File.separatorChar;
}
}
if (baseDir.equals("")) {
String servletPath = com.genexus.ApplicationContext.getInstance().getServletEngineDefaultPath();
if (servletPath != null && !servletPath.equals("")) {
baseDir = servletPath + File.separator + "WEB-INF" + File.separatorChar;
}
}
return baseDir;
}
Aggregations