diff --git a/notifications/java/full-eGwNotifier.jar b/notifications/java/full-eGwNotifier.jar index b6b2ff6486..b37d4ac266 100755 Binary files a/notifications/java/full-eGwNotifier.jar and b/notifications/java/full-eGwNotifier.jar differ diff --git a/notifications/java/src/egroupwaretray/BaseHttp.java b/notifications/java/src/egroupwaretray/BaseHttp.java index 44e5c6f593..d4adc8873f 100755 --- a/notifications/java/src/egroupwaretray/BaseHttp.java +++ b/notifications/java/src/egroupwaretray/BaseHttp.java @@ -32,7 +32,7 @@ public class BaseHttp private boolean _isSSL = false; private boolean _isAjax = false; private String _cookie = ""; - private int _sockettimeout = 10; + private int _sockettimeout = 10000; static private BaseHttpsTrustManager _bhtm = null; @@ -215,6 +215,7 @@ public class BaseHttp } catch( Exception exp ) { + egwDebuging.log.log(Level.SEVERE, null, exp); throw new Exception("NETERROR"); } @@ -322,6 +323,7 @@ public class BaseHttp } catch(Exception exp) { + egwDebuging.log.log(Level.SEVERE, null, exp); throw new Exception("NETERROR"); } @@ -499,6 +501,7 @@ public class BaseHttp } catch( IOException ex) { + egwDebuging.log.log(Level.SEVERE, null, ex); } return false; diff --git a/notifications/java/src/egroupwaretray/BaseHttpsTrustManager.java b/notifications/java/src/egroupwaretray/BaseHttpsTrustManager.java index 85054592f4..2e1bddb0ce 100755 --- a/notifications/java/src/egroupwaretray/BaseHttpsTrustManager.java +++ b/notifications/java/src/egroupwaretray/BaseHttpsTrustManager.java @@ -20,6 +20,7 @@ import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; import java.util.ArrayList; +import java.util.logging.Level; import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.X509TrustManager; @@ -86,6 +87,8 @@ public class BaseHttpsTrustManager implements javax.net.ssl.X509TrustManager } this.acceptcerts.add(cs); + + egwDebuging.log.log(Level.SEVERE, null, exp); } } } diff --git a/notifications/java/src/egroupwaretray/EgroupwareTrayApp.java b/notifications/java/src/egroupwaretray/EgroupwareTrayApp.java index e79bf58ec7..764d9ec70a 100755 --- a/notifications/java/src/egroupwaretray/EgroupwareTrayApp.java +++ b/notifications/java/src/egroupwaretray/EgroupwareTrayApp.java @@ -50,6 +50,13 @@ public class EgroupwareTrayApp extends SingleFrameApplication { public static void main(String[] args) { // Trayer Main Classe erstellen - new jegwMain(); + try + { + jegwMain jegwMain = new jegwMain(); + } + catch (Throwable uncaught) + { + egwDebuging.dumpUncaughtError(uncaught); + } } } diff --git a/notifications/java/src/egroupwaretray/egwDebuging.java b/notifications/java/src/egroupwaretray/egwDebuging.java new file mode 100644 index 0000000000..2da1189b43 --- /dev/null +++ b/notifications/java/src/egroupwaretray/egwDebuging.java @@ -0,0 +1,132 @@ +/** + * EGroupware - Notifications Java Desktop App + * + * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License + * @package notifications + * @subpackage jdesk + * @link http://www.egroupware.org + * @author Stefan Werfling + * @author Maik Hüttner + */ + +package egroupwaretray; + +import java.io.*; +import java.util.Date; +import java.util.logging.FileHandler; +import java.util.logging.Handler; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * egwDebuging + * + * @author Stefan Werfling + */ +public class egwDebuging { + + public static final Logger log = Logger.getLogger( egwDebuging.class.getName() ); + public static Handler handler = null; + + /** + * setLevel + * set Logging Level + * + * @param uselevel + */ + public static void setLevel(Level uselevel) + { + egwDebuging.log.setLevel(uselevel); + } + + /** + * setDebuging + * enable/disable Debuging + * + * @param enable + */ + public static void setDebuging(Boolean enable) + { + if( enable && (handler == null) ) + { + long now = System.currentTimeMillis(); + + try + { + egwDebuging.handler = new FileHandler( + String.format("egroupwarenotifier_log_%d.txt", now) ); + + egwDebuging.log.addHandler(egwDebuging.handler); + } + catch( IOException ex ) + { + Logger.getLogger(egwDebuging.class.getName()).log( + Level.SEVERE, null, ex); + } + catch (SecurityException ex) + { + Logger.getLogger(egwDebuging.class.getName()).log( + Level.SEVERE, null, ex); + } + } + else if( !enable && (handler != null) ) + { + egwDebuging.log.removeHandler(egwDebuging.handler); + egwDebuging.handler = null; + } + } + + /** + * + * @param err + */ + protected static void dumpUncaughtError(Throwable err) + { + err.printStackTrace(System.err); + + try + { + long now = System.currentTimeMillis(); + + String report = String.format("%s\n%s\n%s\n", + new Date(now), + err.getLocalizedMessage(), + egwDebuging.stackTraceToStr(err)); + + egwDebuging.writeFile( + new File(System.getProperty("java.io.tmpdir"), + String.format("egroupwarenotifier_uncaught_%d.txt", now)), + report.getBytes()); + } + catch (Throwable ignored) + { + } + } + + public static String stackTraceToStr(Throwable err) + { + StringWriter result = new StringWriter(); + PrintWriter pwr = new PrintWriter(result); + + err.printStackTrace(pwr); + + pwr.flush(); + pwr.close(); + + return result.toString(); + } + + public static void writeFile(File fl, byte[] data) throws IOException + { + FileOutputStream fos = new FileOutputStream(fl); + + try + { + fos.write(data); + } + finally + { + fos.close(); + } + } +} \ No newline at end of file diff --git a/notifications/java/src/egroupwaretray/jegwMain.java b/notifications/java/src/egroupwaretray/jegwMain.java index 5e461abc8b..2a5870074d 100755 --- a/notifications/java/src/egroupwaretray/jegwMain.java +++ b/notifications/java/src/egroupwaretray/jegwMain.java @@ -80,6 +80,15 @@ public class jegwMain implements ActionListener System.exit(0); } + // Debuging + Boolean _debuging = ( jegwConst.getConstTag("egw_debuging").trim() + == "1" ? true : false); + + egwDebuging.setDebuging(_debuging); + egwDebuging.setLevel(Level.parse( + jegwConst.getConstTag("egw_debuging_level").trim())); + // END + if( this.egwconfig.getCXMLM().countConf() < 1 ) { String turl = jegwConst.getConstTag("egw_dc_url").trim(); @@ -162,6 +171,7 @@ public class jegwMain implements ActionListener { Logger.getLogger(jegwMain.class.getName()).log(Level.SEVERE, null, ex); jegwMain.debugDialog(ex.getMessage()); + egwDebuging.log.log(Level.SEVERE, null, ex); } } @@ -412,6 +422,8 @@ public class jegwMain implements ActionListener jegwConst.getConstTag("info_info"), jegwConst.getConstTag("egw_msg_start_browser_error"), TrayIcon.MessageType.ERROR); + + egwDebuging.log.log(Level.SEVERE, null, exp); } } } @@ -479,6 +491,7 @@ public class jegwMain implements ActionListener dialog.setIconImage(hwTrayIcon.getImage(jegwConst.getConstTag("egwicon"))); } catch (IOException ex) { Logger.getLogger(hwTrayIcon.class.getName()).log(Level.SEVERE, null, ex); + egwDebuging.log.log(Level.SEVERE, null, ex); } dialog.setAlwaysOnTop(true); @@ -629,6 +642,8 @@ public class jegwMain implements ActionListener } catch(Exception exp) { + egwDebuging.log.log(Level.SEVERE, null, exp); + // Fehler this.hwtray.showBallon( jegwConst.getConstTag("info_info"), @@ -705,5 +720,6 @@ public class jegwMain implements ActionListener } Logger.getLogger(jegwMain.class.getName()).log(Level.SEVERE, null, ex); + egwDebuging.log.log(Level.SEVERE, null, ex); } } \ No newline at end of file diff --git a/notifications/java/src/egroupwaretray/jegwapplications.java b/notifications/java/src/egroupwaretray/jegwapplications.java index f7e8b24bb0..bd3125888e 100755 --- a/notifications/java/src/egroupwaretray/jegwapplications.java +++ b/notifications/java/src/egroupwaretray/jegwapplications.java @@ -150,6 +150,7 @@ public class jegwapplications dialog.setIconImage(hwTrayIcon.getImage(jegwConst.getConstTag("egwicon"))); } catch (IOException ex) { Logger.getLogger(hwTrayIcon.class.getName()).log(Level.SEVERE, null, ex); + egwDebuging.log.log(Level.SEVERE, null, ex); } ((jegwInfoDialog)dialog).setNotifiyId(app.getString("notify_id")); diff --git a/notifications/java/src/egroupwaretray/jegwhttp.java b/notifications/java/src/egroupwaretray/jegwhttp.java index e97ce217d8..5ad628c474 100755 --- a/notifications/java/src/egroupwaretray/jegwhttp.java +++ b/notifications/java/src/egroupwaretray/jegwhttp.java @@ -14,6 +14,7 @@ package egroupwaretray; import java.awt.event.ActionListener; import java.net.InetAddress; import java.util.*; +import java.util.logging.Level; import org.json.simple.parser.ContainerFactory; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; @@ -146,6 +147,7 @@ public class jegwhttp } catch( Exception exp) { + egwDebuging.log.log(Level.SEVERE, null, exp); throw new Exception("HOSTNOTFOUND"); } @@ -705,6 +707,8 @@ public class jegwhttp } catch( ParseException pe ) { + egwDebuging.log.log(Level.SEVERE, null, pe); + throw new Exception("NOAPPS"); } } diff --git a/notifications/java/src/lib/conf/egwnotifier.const.xml b/notifications/java/src/lib/conf/egwnotifier.const.xml index ebd465eb9a..220bef6725 100755 --- a/notifications/java/src/lib/conf/egwnotifier.const.xml +++ b/notifications/java/src/lib/conf/egwnotifier.const.xml @@ -15,8 +15,10 @@ - 10 + 1000 30000 + 0 + ALL Login