Search in sources :

Example 6 with HttpContextWeb

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);
    }
}
Also used : FileWriter(java.io.FileWriter) HttpContext(com.genexus.internet.HttpContext) IOException(java.io.IOException) File(java.io.File) HttpContextWeb(com.genexus.webpanels.HttpContextWeb) BufferedWriter(java.io.BufferedWriter)

Example 7 with HttpContextWeb

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));
        }
    }
}
Also used : File(java.io.File) AbstractGXFile(com.genexus.common.classes.AbstractGXFile) HttpContextWeb(com.genexus.webpanels.HttpContextWeb) URI(java.net.URI) IOException(java.io.IOException)

Example 8 with HttpContextWeb

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;
}
Also used : HttpContext(com.genexus.internet.HttpContext) HttpContextWeb(com.genexus.webpanels.HttpContextWeb)

Aggregations

HttpContextWeb (com.genexus.webpanels.HttpContextWeb)8 HttpContext (com.genexus.internet.HttpContext)3 File (java.io.File)3 IOException (java.io.IOException)3 IHttpContext (com.genexus.IHttpContext)1 AbstractGXFile (com.genexus.common.classes.AbstractGXFile)1 DocumentException (com.lowagie.text.DocumentException)1 PdfName (com.lowagie.text.pdf.PdfName)1 PdfNumber (com.lowagie.text.pdf.PdfNumber)1 BufferedWriter (java.io.BufferedWriter)1 FileWriter (java.io.FileWriter)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 UnknownHostException (java.net.UnknownHostException)1 KeyManagementException (java.security.KeyManagementException)1 KeyStoreException (java.security.KeyStoreException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 Cookie (org.apache.http.cookie.Cookie)1