}
APILoginResult result = new APILoginResult();
try {
HttpRequestBase method = getInitializedPostMethod(loginURL,loginParams);
ExecuteAPILoginThread t = new ExecuteAPILoginThread(client, method, result);
try {
t.start();
t.join();
handleException(t.getException());
} catch (ManifoldCFException e) {
t.interrupt();
throw e;
} catch (ServiceInterruption e) {
t.interrupt();
throw e;
} catch (IOException e) {
t.interrupt();
throw e;
} catch (HttpException e) {
t.interrupt();
throw e;
} catch (InterruptedException e) {
t.interrupt();
// We need the caller to abandon any connections left around, so rethrow in a way that forces them to process the event properly.
throw e;
}
if (result.result)
return true;
// Grab the token from the first call
token = t.getToken();
if (token == null)
{
// We don't need a token, we just couldn't log in
Logging.connectors.debug("WIKI API login error: '" + result.reason + "'");
throw new ManifoldCFException("WIKI API login error: " + result.reason, null, ManifoldCFException.REPOSITORY_CONNECTION_ERROR);
}
} catch (InterruptedException e) {
throw new ManifoldCFException("Interrupted: " + e.getMessage(), e, ManifoldCFException.INTERRUPTED);
} catch (ManifoldCFException e) {
throw e;
} catch (java.net.SocketTimeoutException e) {
long currentTime = System.currentTimeMillis();
throw new ServiceInterruption("Login timed out reading from the Wiki server: " + e.getMessage(), e, currentTime + 300000L, currentTime + 12L * 60000L, -1, false);
} catch (java.net.SocketException e) {
long currentTime = System.currentTimeMillis();
throw new ServiceInterruption("Login received a socket error reading from Wiki server: " + e.getMessage(), e, currentTime + 300000L, currentTime + 12L * 60000L, -1, false);
} catch (ConnectTimeoutException e) {
long currentTime = System.currentTimeMillis();
throw new ServiceInterruption("Login connection timed out reading from Wiki server: " + e.getMessage(), e, currentTime + 300000L, currentTime + 12L * 60000L, -1, false);
} catch (InterruptedIOException e) {
throw new ManifoldCFException("Interrupted: " + e.getMessage(), e, ManifoldCFException.INTERRUPTED);
} catch (IOException e) {
throw new ManifoldCFException("Login had an IO failure: " + e.getMessage(), e);
} catch (HttpException e) {
throw new ManifoldCFException("Login had an Http exception: "+e.getMessage(), e);
}
// First request is finished. Fire off the second one.
loginParams.put("lgtoken", token);
try {
HttpRequestBase method = getInitializedPostMethod(loginURL,loginParams);
ExecuteTokenAPILoginThread t = new ExecuteTokenAPILoginThread(httpClient, method, result);
try {
t.start();
t.join();