mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-13 11:12:22 -05:00
Merged network down (with firewall) code from Dan Foody
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@615 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
22cd9e7841
commit
76889311ea
@ -154,7 +154,7 @@ public class CaldavConnection extends AbstractConnection {
|
||||
} catch (SocketException e) {
|
||||
DavGatewayTray.debug(new BundleMessage("LOG_CONNECTION_CLOSED"));
|
||||
} catch (Exception e) {
|
||||
DavGatewayTray.error(e);
|
||||
DavGatewayTray.log(e);
|
||||
try {
|
||||
sendErr(e);
|
||||
} catch (IOException e2) {
|
||||
|
@ -186,7 +186,7 @@ public class ExchangeSession {
|
||||
LOGGER.error(exc.getLogMessage());
|
||||
throw exc;
|
||||
} catch (UnknownHostException exc) {
|
||||
BundleMessage message = new BundleMessage("EXCEPTION_UNKNOWN_HOST", exc.getMessage());
|
||||
BundleMessage message = new BundleMessage("EXCEPTION_CONNECT", exc.getClass().getName(), exc.getMessage());
|
||||
ExchangeSession.LOGGER.error(message);
|
||||
throw new DavMailException("EXCEPTION_DAVMAIL_CONFIGURATION", message);
|
||||
} catch (IOException exc) {
|
||||
|
@ -10,10 +10,7 @@ import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.methods.GetMethod;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.NoRouteToHostException;
|
||||
import java.net.SocketException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.net.*;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -124,10 +121,12 @@ public final class ExchangeSessionFactory {
|
||||
handleNetworkDown(exc);
|
||||
} catch (NoRouteToHostException exc) {
|
||||
handleNetworkDown(exc);
|
||||
// Could not open the port (probably because it is blocked behind a firewall)
|
||||
} catch (ConnectException exc) {
|
||||
handleNetworkDown(exc);
|
||||
} catch (NetworkDownException exc) {
|
||||
throw exc;
|
||||
} catch (Exception exc) {
|
||||
ExchangeSession.LOGGER.error(BundleMessage.formatLog("EXCEPTION_DAVMAIL_CONFIGURATION", exc), exc);
|
||||
throw new DavMailException("EXCEPTION_DAVMAIL_CONFIGURATION", exc);
|
||||
} finally {
|
||||
testMethod.releaseConnection();
|
||||
@ -137,10 +136,10 @@ public final class ExchangeSessionFactory {
|
||||
|
||||
private static void handleNetworkDown(Exception exc) throws DavMailException {
|
||||
if (!checkNetwork() || configChecked) {
|
||||
ExchangeSession.LOGGER.error(BundleMessage.formatLog("EXCEPTION_NETWORK_DOWN"));
|
||||
ExchangeSession.LOGGER.warn(BundleMessage.formatLog("EXCEPTION_NETWORK_DOWN"));
|
||||
throw new NetworkDownException("EXCEPTION_NETWORK_DOWN");
|
||||
} else {
|
||||
BundleMessage message = new BundleMessage("EXCEPTION_UNKNOWN_HOST", exc.getMessage());
|
||||
BundleMessage message = new BundleMessage("EXCEPTION_CONNECT", exc.getClass().getName(), exc.getMessage());
|
||||
ExchangeSession.LOGGER.error(message);
|
||||
throw new DavMailException("EXCEPTION_DAVMAIL_CONFIGURATION", message);
|
||||
}
|
||||
@ -171,7 +170,7 @@ public final class ExchangeSessionFactory {
|
||||
}
|
||||
|
||||
public static void reset() {
|
||||
configChecked=false;
|
||||
configChecked = false;
|
||||
poolMap.clear();
|
||||
}
|
||||
}
|
||||
|
@ -447,7 +447,7 @@ public class ImapConnection extends AbstractConnection {
|
||||
} catch (SocketException e) {
|
||||
DavGatewayTray.debug(new BundleMessage("LOG_CONNECTION_CLOSED"));
|
||||
} catch (Exception e) {
|
||||
DavGatewayTray.error(e);
|
||||
DavGatewayTray.log(e);
|
||||
try {
|
||||
String message = (e.getMessage() == null) ? e.toString() : e.getMessage();
|
||||
if (commandId != null) {
|
||||
|
@ -382,7 +382,7 @@ public class LdapConnection extends AbstractConnection {
|
||||
} catch (SocketTimeoutException e) {
|
||||
DavGatewayTray.debug(new BundleMessage("LOG_CLOSE_CONNECTION_ON_TIMEOUT"));
|
||||
} catch (Exception e) {
|
||||
DavGatewayTray.error(e);
|
||||
DavGatewayTray.log(e);
|
||||
try {
|
||||
sendErr(0, LDAP_REP_BIND, e);
|
||||
} catch (IOException e2) {
|
||||
|
@ -235,7 +235,7 @@ public class PopConnection extends AbstractConnection {
|
||||
} catch (SocketException e) {
|
||||
DavGatewayTray.debug(new BundleMessage("LOG_CONNECTION_CLOSED"));
|
||||
} catch (Exception e) {
|
||||
DavGatewayTray.error(e);
|
||||
DavGatewayTray.log(e);
|
||||
try {
|
||||
sendERR(e.getMessage());
|
||||
} catch (IOException e2) {
|
||||
|
@ -140,7 +140,7 @@ public class SmtpConnection extends AbstractConnection {
|
||||
} catch (SocketException e) {
|
||||
DavGatewayTray.debug(new BundleMessage("LOG_CONNECTION_CLOSED"));
|
||||
} catch (Exception e) {
|
||||
DavGatewayTray.error(e);
|
||||
DavGatewayTray.log(e);
|
||||
try {
|
||||
sendClient("500 " + ((e.getMessage()==null)?e:e.getMessage()));
|
||||
} catch (IOException e2) {
|
||||
|
@ -55,7 +55,11 @@ public class DavGatewayTray {
|
||||
}
|
||||
|
||||
protected static void displayMessage(BundleMessage message, Exception e, Level level) {
|
||||
LOGGER.log(level, BundleMessage.getExceptionLogMessage(message, e), e);
|
||||
if (e instanceof NetworkDownException) {
|
||||
LOGGER.log(level, BundleMessage.getExceptionLogMessage(message, e));
|
||||
} else {
|
||||
LOGGER.log(level, BundleMessage.getExceptionLogMessage(message, e), e);
|
||||
}
|
||||
if (davGatewayTray != null
|
||||
&& (!(e instanceof NetworkDownException))) {
|
||||
davGatewayTray.displayMessage(BundleMessage.getExceptionMessage(message, e), level);
|
||||
@ -77,10 +81,23 @@ public class DavGatewayTray {
|
||||
displayMessage(message, Level.WARN);
|
||||
}
|
||||
|
||||
public static void warn(Exception e) {
|
||||
displayMessage(null, e, Level.WARN);
|
||||
}
|
||||
|
||||
public static void error(BundleMessage message) {
|
||||
displayMessage(message, Level.ERROR);
|
||||
}
|
||||
|
||||
public static void log(Exception e) {
|
||||
// only warn on network down
|
||||
if (e instanceof NetworkDownException) {
|
||||
warn(e);
|
||||
} else {
|
||||
error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void error(Exception e) {
|
||||
displayMessage(null, e, Level.ERROR);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ EXCEPTION_UNABLE_TO_MOVE_FOLDER=Unable to move folder, target already exists
|
||||
EXCEPTION_UNABLE_TO_MOVE_MESSAGE=Unable to move message, target already exists
|
||||
EXCEPTION_UNABLE_TO_PATCH_MESSAGE=Unable to patch message {0}: {1}{2}{3}
|
||||
EXCEPTION_UNABLE_TO_UPDATE_MESSAGE=Unable to update message properties
|
||||
EXCEPTION_UNKNOWN_HOST=Unknown host {0}
|
||||
EXCEPTION_CONNECT=Connect exception: {0} {1}
|
||||
EXCEPTION_UNSUPPORTED_AUTHORIZATION_MODE=Unsupported authorization mode: {0}
|
||||
EXCEPTION_UNSUPPORTED_VALUE=Unsupported value: {0}
|
||||
LOG_CLIENT_CLOSED_CONNECTION=Client closed connection
|
||||
|
@ -36,7 +36,7 @@ EXCEPTION_UNABLE_TO_MOVE_FOLDER=Impossible de d
|
||||
EXCEPTION_UNABLE_TO_MOVE_MESSAGE=Impossible de déplacer le message, la cible existe
|
||||
EXCEPTION_UNABLE_TO_PATCH_MESSAGE=Impossible de mettre ) jour le message {0} : {1}{2}{3}
|
||||
EXCEPTION_UNABLE_TO_UPDATE_MESSAGE=Impossible de mettre à jour les propriétés du message
|
||||
EXCEPTION_UNKNOWN_HOST=Nom de serveur {0} invalide
|
||||
EXCEPTION_CONNECT=Exception lors de la connexion : {0} {1}
|
||||
EXCEPTION_UNSUPPORTED_AUTHORIZATION_MODE=Mode d'authentification invalide : {0}
|
||||
EXCEPTION_UNSUPPORTED_VALUE=Valeur non supportée : {0}
|
||||
LOG_CLIENT_CLOSED_CONNECTION=Connection fermée par le client
|
||||
|
Loading…
Reference in New Issue
Block a user