Skip to content

Commit

Permalink
Throw an exception on a 'forbidden' no-access error
Browse files Browse the repository at this point in the history
  • Loading branch information
egonw committed Sep 7, 2011
1 parent 10699a9 commit d7e8ad4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Expand Up @@ -20,6 +20,7 @@
package net.bioclipse.opentox.api;

import java.io.IOException;
import java.security.GeneralSecurityException;
import java.util.HashMap;

import org.apache.commons.httpclient.HttpClient;
Expand All @@ -35,7 +36,7 @@ public abstract class ModelAlgorithm extends Algorithm {

public static String calculate(String service, String model,
String dataSetURI, IProgressMonitor monitor)
throws HttpException, IOException, InterruptedException {
throws HttpException, IOException, InterruptedException, GeneralSecurityException {
if (monitor == null) monitor = new NullProgressMonitor();

HttpClient client = new HttpClient();
Expand Down Expand Up @@ -81,6 +82,8 @@ public static String calculate(String service, String model,
dataset = responseString;
logger.debug("No Task, Data set: " + dataset);
}
} else if (status == 401 || status == 403) {
throw new GeneralSecurityException("No Access");
} else {
throw new IllegalStateException("Service error: " + status);
}
Expand Down
Expand Up @@ -20,6 +20,7 @@
package net.bioclipse.opentox.api;

import java.io.IOException;
import java.security.GeneralSecurityException;
import java.util.HashMap;

import org.apache.commons.httpclient.HttpClient;
Expand All @@ -35,7 +36,7 @@ public abstract class MolecularDescriptorAlgorithm extends Algorithm {

public static String calculate(String service, String descriptor,
String dataSetURI, IProgressMonitor monitor)
throws HttpException, IOException, InterruptedException {
throws HttpException, IOException, InterruptedException, GeneralSecurityException {
if (monitor == null) monitor = new NullProgressMonitor();

HttpClient client = new HttpClient();
Expand Down Expand Up @@ -83,6 +84,8 @@ public static String calculate(String service, String descriptor,
// OK, that was quick!
dataset = responseString;
}
} else if (status == 401 || status == 403) {
throw new GeneralSecurityException("No Access");
} else {
throw new IllegalStateException("Service error: " + status);
}
Expand Down

0 comments on commit d7e8ad4

Please sign in to comment.