re-implemented dia-conversion
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -10,6 +10,7 @@ import static de.srsoftware.umbrella.core.constants.Text.LONG;
|
|||||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.*;
|
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.*;
|
||||||
import static de.srsoftware.umbrella.core.model.Translatable.t;
|
import static de.srsoftware.umbrella.core.model.Translatable.t;
|
||||||
import static de.srsoftware.umbrella.files.Constants.*;
|
import static de.srsoftware.umbrella.files.Constants.*;
|
||||||
|
import static java.lang.System.Logger.Level.WARNING;
|
||||||
import static java.net.HttpURLConnection.HTTP_OK;
|
import static java.net.HttpURLConnection.HTTP_OK;
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
import static java.text.MessageFormat.format;
|
import static java.text.MessageFormat.format;
|
||||||
@@ -54,6 +55,18 @@ public class FileModule extends BaseHandler implements FileService {
|
|||||||
ModuleRegistry.add(this);
|
ModuleRegistry.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void convertDia(File source) {
|
||||||
|
if (!new File("/usr/bin/dia").exists()) return;
|
||||||
|
var dest = source+".svg";
|
||||||
|
String[] command = {"dia","-e",dest,source.toString()};
|
||||||
|
try {
|
||||||
|
Runtime.getRuntime().exec(command);
|
||||||
|
} catch (IOException e) {
|
||||||
|
LOG.log(WARNING,"Failed to convert {} to SVG file",source,e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doDelete(de.srsoftware.tools.Path path, HttpExchange ex) throws IOException {
|
public boolean doDelete(de.srsoftware.tools.Path path, HttpExchange ex) throws IOException {
|
||||||
addCors(ex);
|
addCors(ex);
|
||||||
@@ -200,6 +213,7 @@ public class FileModule extends BaseHandler implements FileService {
|
|||||||
body.transferTo(out);
|
body.transferTo(out);
|
||||||
body.close();
|
body.close();
|
||||||
out.close();
|
out.close();
|
||||||
|
if (filename.toLowerCase().endsWith(".dia")) convertDia(file);
|
||||||
} else {
|
} else {
|
||||||
if (file.exists()) throw unprocessable("{file} already exists!",FILE, filename);
|
if (file.exists()) throw unprocessable("{file} already exists!",FILE, filename);
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user