*/
public final class FileUtil {
- private static boolean fileNameMapLoaded = false;
- private static FileNameMap fileNameMap;
- private static String producerStorageRoot;
-
- //
- // Initialisierung
-
- static {
- System.setProperty("content.types.user.table", MirConfig.getProp("Home")+"content-types.properties");
- fileNameMap = sun.net.www.MimeTable.loadTable();
- producerStorageRoot = MirConfig.getProp("Producer.StorageRoot");
- }
+ private static boolean fileNameMapLoaded = false;
+ private static FileNameMap fileNameMap;
+ private static String producerStorageRoot;
+
+ //
+ // Initialisierung
+
+ static {
+ System.setProperty("content.types.user.table", MirConfig.getProp("Home")+
+ "content-types.properties");
+ fileNameMap = sun.net.www.MimeTable.loadTable();
+ producerStorageRoot = MirConfig.getProp("Producer.StorageRoot");
+ }
/**
* Privater Konstruktor, um versehentliche Instantiierung zu verhindern
if (in!=null) {
try {
- File f = null;
- f = new File(filename);
+ File f = null;
+ f = new File(filename);
File dir = new File(f.getParent());
dir.mkdirs();
outStream.close();
retVal = true;
} catch(IOException e) {
- throw new IOException(e.toString());
- }
- }
+ throw new IOException(e.toString());
+ }
+ }
return retVal;
}
public static boolean read(String filename, byte out[])
throws IOException {
- File f = null;
- f = new File(filename);
+ File f = null;
+ f = new File(filename);
if (f.exists()) {
try {
- if (out.length != f.length())
- return false;
+ if (out.length != f.length())
+ return false;
FileInputStream inStream;
inStream = new FileInputStream(f);
inStream.read(out);
inStream.close();
} catch(IOException e) {
- throw new IOException(e.toString());
- }
- } else {
- return false;
- }
- return true;
- }
+ throw new IOException(e.toString());
+ }
+ } else {
+ return false;
+ }
+ return true;
+ }
- public static long getSize(String filename) {
- File f = null;
- f = new File(filename);
- long l=0;
-
- if (f.exists()) {
- return f.length();
- } else {
- return -1;
- }
+ public static long getSize(String filename) {
+ File f = null;
+ f = new File(filename);
+ long l=0;
+
+ if (f.exists()) {
+ return f.length();
+ } else {
+ return -1;
}
+ }
- private static FileNameMap getFileNameMap() {
- if ((fileNameMap == null) && !fileNameMapLoaded) {
- fileNameMap = sun.net.www.MimeTable.loadTable();
- fileNameMapLoaded = true;
- }
-
- return new FileNameMap() {
- private FileNameMap map = fileNameMap;
- public String getContentTypeFor(String fileName) {
- return map.getContentTypeFor(fileName);
- }
- };
+ private static FileNameMap getFileNameMap() {
+ if ((fileNameMap == null) && !fileNameMapLoaded) {
+ fileNameMap = sun.net.www.MimeTable.loadTable();
+ fileNameMapLoaded = true;
}
- public static void setFileNameMap(FileNameMap map) {
- fileNameMap = map;
- }
+ return new FileNameMap() {
+ private FileNameMap map = fileNameMap;
+ public String getContentTypeFor(String fileName) {
+ return map.getContentTypeFor(fileName);
+ }
+ };
+ }
- public static String guessContentTypeFromName(String fname) {
- String contentType = null;
-
- contentType = getFileNameMap().getContentTypeFor(fname);
-
- return contentType;
- }
+ public static void setFileNameMap(FileNameMap map) {
+ fileNameMap = map;
+ }
+
+ public static String guessContentTypeFromName(String fname) {
+ String contentType = null;
+
+ contentType = getFileNameMap().getContentTypeFor(fname);
+
+ return contentType;
+ }
if (rs.next()) {
LargeObject lob = lom.open(rs.getInt(1));
img_data = lob.read(lob.size());
- System.err.println("LOB IMG SIZE: "+lob.size());
lob.close();
- System.err.println("res set img NOT NULL2");
//img_data = rs.getBytes(1);
}
rs.close();
byte[] iconData = webdbImage.getIcon();
theLog.printDebugInfo("settimage :: getIcon");
+
if (iconData!=null && imageData!=null) {
con = theStorageObject.getPooledCon();
con.setAutoCommit(false);
.getNativeConnection();
lom = ((org.postgresql.Connection)jCon).getLargeObjectAPI();
if(rs!=null) {
- System.err.println("res set NOT NULL");
if (rs.next()) {
LargeObject lob = lom.open(rs.getInt(1));
img_data = lob.read(lob.size());
- System.err.println("LOB SIZE: "+lob.size());
lob.close();
- System.err.println("res set NOT NULL2");
//img_data = rs.getBytes(1);
- System.err.println("res set NOT NULL3");
}
rs.close();
}