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;
}
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();
}
}
}
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();
}
}
}
Aggregations