Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrelves2010-06-02 16:23:46 -0400
committerrelves2010-06-02 16:23:46 -0400
commite0e7e0a7dce9bd45ef64f0ffb9a774c9d7c0eb9c (patch)
treeaf61eca48975a524b5cfb912a2b140a4ebe3e4d7 /org.eclipse.mylyn.oslc.core
parent423c9fd8e34ea59a2868a040360f7e23049344c2 (diff)
downloadorg.eclipse.mylyn.tasks-e0e7e0a7dce9bd45ef64f0ffb9a774c9d7c0eb9c.tar.gz
org.eclipse.mylyn.tasks-e0e7e0a7dce9bd45ef64f0ffb9a774c9d7c0eb9c.tar.xz
org.eclipse.mylyn.tasks-e0e7e0a7dce9bd45ef64f0ffb9a774c9d7c0eb9c.zip
NEW - bug 311426: [oslc] add cancellation back to AbstractOslcClient
https://bugs.eclipse.org/bugs/show_bug.cgi?id=311426
Diffstat (limited to 'org.eclipse.mylyn.oslc.core')
-rw-r--r--org.eclipse.mylyn.oslc.core/src/org/eclipse/mylyn/internal/oslc/core/client/AbstractOslcClient.java70
1 files changed, 33 insertions, 37 deletions
diff --git a/org.eclipse.mylyn.oslc.core/src/org/eclipse/mylyn/internal/oslc/core/client/AbstractOslcClient.java b/org.eclipse.mylyn.oslc.core/src/org/eclipse/mylyn/internal/oslc/core/client/AbstractOslcClient.java
index a2f81e84a..b34394a8d 100644
--- a/org.eclipse.mylyn.oslc.core/src/org/eclipse/mylyn/internal/oslc/core/client/AbstractOslcClient.java
+++ b/org.eclipse.mylyn.oslc.core/src/org/eclipse/mylyn/internal/oslc/core/client/AbstractOslcClient.java
@@ -565,7 +565,7 @@ public abstract class AbstractOslcClient {
HostConfiguration hostConfiguration = WebUtil.createHostConfiguration(httpClient, location, monitor);
int code = WebUtil.execute(httpClient, hostConfiguration, method, monitor);
- handler.handleReturnCode(code, method);
+ handleReturnCode(code, method);
return handler.run(method, monitor);
} catch (IOException e) {
@@ -589,6 +589,38 @@ public abstract class AbstractOslcClient {
return WebUtil.getRequestPath(repositoryUrl);
}
+ protected void handleReturnCode(int code, HttpMethodBase method) throws CoreException {
+ try {
+ if (code == java.net.HttpURLConnection.HTTP_OK) {
+ return;// Status.OK_STATUS;
+ } else if (code == java.net.HttpURLConnection.HTTP_MOVED_TEMP
+ || code == java.net.HttpURLConnection.HTTP_CREATED) {
+ // A new resource created...
+ return;// Status.OK_STATUS;
+ } else if (code == java.net.HttpURLConnection.HTTP_UNAUTHORIZED
+ || code == java.net.HttpURLConnection.HTTP_FORBIDDEN) {
+ throw new CoreException(new Status(IStatus.ERROR, IOslcCoreConstants.ID_PLUGIN,
+ "Unable to log into server, ensure repository credentials are correct.")); //$NON-NLS-1$
+ } else if (code == java.net.HttpURLConnection.HTTP_PRECON_FAILED) {
+ // Mid-air collision
+ throw new CoreException(new Status(IStatus.ERROR, IOslcCoreConstants.ID_PLUGIN,
+ "Mid-air collision occurred.")); //$NON-NLS-1$
+ } else if (code == java.net.HttpURLConnection.HTTP_CONFLICT) {
+ throw new CoreException(new Status(IStatus.ERROR, IOslcCoreConstants.ID_PLUGIN, "A conflict occurred.")); //$NON-NLS-1$
+ } else {
+ throw new CoreException(new Status(IStatus.ERROR, IOslcCoreConstants.ID_PLUGIN,
+ "Unknown error occurred. Http Code: " + code + " Request: " + method.getURI() + " Response: " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + method.getResponseBodyAsString()));
+ }
+ } catch (URIException e) {
+ throw new CoreException(new Status(IStatus.ERROR, IOslcCoreConstants.ID_PLUGIN, "Network Error: " //$NON-NLS-1$
+ + e.getMessage()));
+ } catch (IOException e) {
+ throw new CoreException(new Status(IStatus.ERROR, IOslcCoreConstants.ID_PLUGIN, "Network Error: " //$NON-NLS-1$
+ + e.getMessage()));
+ }
+ }
+
public abstract class RequestHandler<T> {
private final String requestName;
@@ -603,41 +635,5 @@ public abstract class AbstractOslcClient {
return requestName;
}
- protected void handleReturnCode(int code, HttpMethodBase method) throws CoreException {
- try {
- if (code == java.net.HttpURLConnection.HTTP_OK) {
- return;// Status.OK_STATUS;
- } else if (code == java.net.HttpURLConnection.HTTP_MOVED_TEMP
- || code == java.net.HttpURLConnection.HTTP_CREATED) {
- // A new resource created...
- return;// Status.OK_STATUS;
- } else if (code == java.net.HttpURLConnection.HTTP_UNAUTHORIZED
- || code == java.net.HttpURLConnection.HTTP_FORBIDDEN) {
- throw new CoreException(new Status(IStatus.ERROR, IOslcCoreConstants.ID_PLUGIN,
- "Unable to log into server, ensure repository credentials are correct.")); //$NON-NLS-1$
- } else if (code == java.net.HttpURLConnection.HTTP_PRECON_FAILED) {
- // Mid-air collision
- throw new CoreException(new Status(IStatus.ERROR, IOslcCoreConstants.ID_PLUGIN,
- "Mid-air collision occurred.")); //$NON-NLS-1$
- } else if (code == java.net.HttpURLConnection.HTTP_CONFLICT) {
- throw new CoreException(new Status(IStatus.ERROR, IOslcCoreConstants.ID_PLUGIN,
- "A conflict occurred.")); //$NON-NLS-1$
- } else {
- throw new CoreException(
- new Status(
- IStatus.ERROR,
- IOslcCoreConstants.ID_PLUGIN,
- "Unknown error occurred. Http Code: " + code + " Request: " + method.getURI() + " Response: " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + method.getResponseBodyAsString()));
- }
- } catch (URIException e) {
- throw new CoreException(new Status(IStatus.ERROR, IOslcCoreConstants.ID_PLUGIN, "Network Error: " //$NON-NLS-1$
- + e.getMessage()));
- } catch (IOException e) {
- throw new CoreException(new Status(IStatus.ERROR, IOslcCoreConstants.ID_PLUGIN, "Network Error: " //$NON-NLS-1$
- + e.getMessage()));
- }
- }
-
}
} \ No newline at end of file

Back to the top