Search in sources :

Example 16 with SystemService

use of org.eclipse.kura.system.SystemService in project kura by eclipse.

the class UploadRequest method getFileUploadSizeMax.

static long getFileUploadSizeMax() {
    ServiceLocator locator = ServiceLocator.getInstance();
    long sizeMax = -1;
    try {
        SystemService systemService = locator.getService(SystemService.class);
        sizeMax = Long.parseLong(systemService.getProperties().getProperty("file.upload.size.max", "-1"));
    } catch (GwtKuraException e) {
        s_logger.error("Error locating SystemService", e);
    }
    return sizeMax;
}
Also used : ServiceLocator(org.eclipse.kura.web.server.util.ServiceLocator) GwtKuraException(org.eclipse.kura.web.shared.GwtKuraException) SystemService(org.eclipse.kura.system.SystemService)

Example 17 with SystemService

use of org.eclipse.kura.system.SystemService in project kura by eclipse.

the class SkinServlet method streamBinary.

private void streamBinary(String resourceName, OutputStream o) throws ServletException, IOException {
    FileInputStream in = null;
    try {
        // check to see if we have an external resource directory configured
        SystemService systemService = ServiceLocator.getInstance().getService(SystemService.class);
        File fResourceDir = checkDir(systemService.getKuraStyleDirectory());
        if (fResourceDir == null) {
            return;
        }
        File fResourceFile = checkFile(fResourceDir, resourceName);
        if (fResourceFile == null) {
            return;
        }
        // write the requested resource
        in = new FileInputStream(fResourceFile);
        byte[] buf = new byte[1024];
        int len = 0;
        while ((len = in.read(buf)) >= 0) {
            o.write(buf, 0, len);
        }
    } catch (Exception e) {
        s_logger.error("Error loading skin resource", e);
    } finally {
        if (in != null) {
            in.close();
        }
        if (o != null) {
            o.close();
        }
    }
}
Also used : SystemService(org.eclipse.kura.system.SystemService) File(java.io.File) FileInputStream(java.io.FileInputStream) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Example 18 with SystemService

use of org.eclipse.kura.system.SystemService in project kura by eclipse.

the class SkinServlet method streamText.

private void streamText(String resourceName, PrintWriter w) throws ServletException, IOException {
    FileReader fr = null;
    try {
        // check to see if we have an external resource directory configured
        SystemService systemService = ServiceLocator.getInstance().getService(SystemService.class);
        File fResourceDir = checkDir(systemService.getKuraStyleDirectory());
        if (fResourceDir == null) {
            return;
        }
        File fResourceFile = checkFile(fResourceDir, resourceName);
        if (fResourceFile == null) {
            return;
        }
        // write the requested resource
        fr = new FileReader(fResourceFile);
        char[] buffer = new char[1024];
        int iRead = fr.read(buffer);
        while (iRead != -1) {
            w.write(buffer, 0, iRead);
            iRead = fr.read(buffer);
        }
    } catch (Exception e) {
        s_logger.error("Error loading skin resource", e);
    } finally {
        if (fr != null) {
            fr.close();
        }
        if (w != null) {
            w.close();
        }
    }
}
Also used : SystemService(org.eclipse.kura.system.SystemService) FileReader(java.io.FileReader) File(java.io.File) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Aggregations

SystemService (org.eclipse.kura.system.SystemService)18 GwtKuraException (org.eclipse.kura.web.shared.GwtKuraException)8 ServiceLocator (org.eclipse.kura.web.server.util.ServiceLocator)6 ArrayList (java.util.ArrayList)5 File (java.io.File)3 IOException (java.io.IOException)3 Properties (java.util.Properties)3 ServletException (javax.servlet.ServletException)3 SystemAdminService (org.eclipse.kura.system.SystemAdminService)3 GwtGroupedNVPair (org.eclipse.kura.web.shared.model.GwtGroupedNVPair)3 Bundle (org.osgi.framework.Bundle)3 BundleException (org.osgi.framework.BundleException)3 ConfigurationService (org.eclipse.kura.configuration.ConfigurationService)2 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 FileReader (java.io.FileReader)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Iterator (java.util.Iterator)1 SortedSet (java.util.SortedSet)1 TreeSet (java.util.TreeSet)1