You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2013/07/10 11:11:04 UTC
svn commit: r1501683 - in
/manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf:
authorities/authorities/jira/ crawler/connectors/jira/
Author: kwright
Date: Wed Jul 10 09:11:04 2013
New Revision: 1501683
URL: http://svn.apache.org/r1501683
Log:
Add explicit response exception to Jira connector, because otherwise a bad URL looks like an IO exception.
Added:
manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/jira/ResponseException.java (with props)
manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/ResponseException.java (with props)
Modified:
manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/jira/JiraAuthorityConnector.java
manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/jira/JiraSession.java
manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraRepositoryConnector.java
manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraSession.java
Modified: manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/jira/JiraAuthorityConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/jira/JiraAuthorityConnector.java?rev=1501683&r1=1501682&r2=1501683&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/jira/JiraAuthorityConnector.java (original)
+++ manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/jira/JiraAuthorityConnector.java Wed Jul 10 09:11:04 2013
@@ -399,6 +399,11 @@ public class JiraAuthorityConnector exte
throw new ManifoldCFException("IO exception: "+e.getMessage(), e);
}
+ private static void handleResponseException(ResponseException e)
+ throws ManifoldCFException {
+ throw new ManifoldCFException("Response exception: "+e.getMessage(),e);
+ }
+
// Background threads
protected static class CheckUserExistsThread extends Thread {
@@ -423,12 +428,14 @@ public class JiraAuthorityConnector exte
}
public void finishUp()
- throws InterruptedException, IOException {
+ throws InterruptedException, IOException, ResponseException {
join();
Throwable thr = exception;
if (thr != null) {
if (thr instanceof IOException) {
throw (IOException) thr;
+ } else if (thr instanceof ResponseException) {
+ throw (ResponseException) thr;
} else if (thr instanceof RuntimeException) {
throw (RuntimeException) thr;
} else {
@@ -460,6 +467,8 @@ public class JiraAuthorityConnector exte
handleIOException(e);
} catch (IOException e) {
handleIOException(e);
+ } catch (ResponseException e) {
+ handleResponseException(e);
}
return false;
}
@@ -484,12 +493,14 @@ public class JiraAuthorityConnector exte
}
public void finishUp()
- throws InterruptedException, IOException {
+ throws InterruptedException, IOException, ResponseException {
join();
Throwable thr = exception;
if (thr != null) {
if (thr instanceof IOException) {
throw (IOException) thr;
+ } else if (thr instanceof ResponseException) {
+ throw (ResponseException) thr;
} else if (thr instanceof RuntimeException) {
throw (RuntimeException) thr;
} else {
@@ -516,6 +527,8 @@ public class JiraAuthorityConnector exte
handleIOException(e);
} catch (IOException e) {
handleIOException(e);
+ } catch (ResponseException e) {
+ handleResponseException(e);
}
}
Modified: manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/jira/JiraSession.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/jira/JiraSession.java?rev=1501683&r1=1501682&r2=1501683&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/jira/JiraSession.java (original)
+++ manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/jira/JiraSession.java Wed Jul 10 09:11:04 2013
@@ -191,7 +191,8 @@ public class JiraSession {
return "";
}
- private void getRest(String rightside, JiraJSONResponse response) throws IOException {
+ private void getRest(String rightside, JiraJSONResponse response)
+ throws IOException, ResponseException {
final HttpRequestBase method = new HttpGet(URLbase + rightside);
method.addHeader("Accept", "application/json");
@@ -200,7 +201,7 @@ public class JiraSession {
HttpResponse httpResponse = httpClient.execute(method);
int resultCode = httpResponse.getStatusLine().getStatusCode();
if (resultCode != 200)
- throw new IOException("Unexpected result code "+resultCode+": "+convertToString(httpResponse));
+ throw new ResponseException("Unexpected result code "+resultCode+": "+convertToString(httpResponse));
Object jo = convertToJSON(httpResponse);
response.acceptJSONObject(jo);
} finally {
@@ -211,7 +212,7 @@ public class JiraSession {
/**
* Obtain repository information.
*/
- public Map<String, String> getRepositoryInfo() throws IOException {
+ public Map<String, String> getRepositoryInfo() throws IOException, ResponseException {
HashMap<String, String> statistics = new HashMap<String, String>();
JiraUserQueryResults qr = new JiraUserQueryResults();
getRest("user/search?username=&maxResults=1&startAt=0", qr);
@@ -220,7 +221,7 @@ public class JiraSession {
/** Check if user exists.
*/
- public boolean checkUserExists(String userName) throws IOException {
+ public boolean checkUserExists(String userName) throws IOException, ResponseException {
JiraUserQueryResults qr = new JiraUserQueryResults();
getRest("user/search?username="+URLEncoder.encode(userName,"utf-8")+"&maxResults=1&startAt=0", qr);
List<String> values = new ArrayList<String>();
Added: manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/jira/ResponseException.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/jira/ResponseException.java?rev=1501683&view=auto
==============================================================================
--- manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/jira/ResponseException.java (added)
+++ manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/jira/ResponseException.java Wed Jul 10 09:11:04 2013
@@ -0,0 +1,34 @@
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.manifoldcf.authorities.authorities.jira;
+
+/** This exception is thrown when the response from REST is not what
+* was expected.
+ */
+public class ResponseException extends Exception {
+
+ public ResponseException(String msg) {
+ super(msg);
+ }
+
+ public ResponseException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+}
Propchange: manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/jira/ResponseException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/jira/ResponseException.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraRepositoryConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraRepositoryConnector.java?rev=1501683&r1=1501682&r2=1501683&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraRepositoryConnector.java (original)
+++ manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraRepositoryConnector.java Wed Jul 10 09:11:04 2013
@@ -761,6 +761,8 @@ public class JiraRepositoryConnector ext
handleIOException(e);
} catch (IOException e) {
handleIOException(e);
+ } catch (ResponseException e) {
+ handleResponseException(e);
}
}
@@ -1015,6 +1017,11 @@ public class JiraRepositoryConnector ext
currentTime + 3 * 60 * 60000L,-1,false);
}
+ private static void handleResponseException(ResponseException e)
+ throws ManifoldCFException, ServiceInterruption {
+ throw new ManifoldCFException("Unexpected response: "+e.getMessage(),e);
+ }
+
// Background threads
protected static class GetUsersThread extends Thread {
@@ -1040,12 +1047,14 @@ public class JiraRepositoryConnector ext
}
public void finishUp()
- throws InterruptedException, IOException {
+ throws InterruptedException, IOException, ResponseException {
join();
Throwable thr = exception;
if (thr != null) {
if (thr instanceof IOException) {
throw (IOException) thr;
+ } else if (thr instanceof ResponseException) {
+ throw (ResponseException) thr;
} else if (thr instanceof RuntimeException) {
throw (RuntimeException) thr;
} else {
@@ -1077,6 +1086,8 @@ public class JiraRepositoryConnector ext
handleIOException(e);
} catch (IOException e) {
handleIOException(e);
+ } catch (ResponseException e) {
+ handleResponseException(e);
}
return null;
}
@@ -1101,12 +1112,14 @@ public class JiraRepositoryConnector ext
}
public void finishUp()
- throws InterruptedException, IOException {
+ throws InterruptedException, IOException, ResponseException {
join();
Throwable thr = exception;
if (thr != null) {
if (thr instanceof IOException) {
throw (IOException) thr;
+ } else if (thr instanceof ResponseException) {
+ throw (ResponseException) thr;
} else if (thr instanceof RuntimeException) {
throw (RuntimeException) thr;
} else {
@@ -1133,6 +1146,8 @@ public class JiraRepositoryConnector ext
handleIOException(e);
} catch (IOException e) {
handleIOException(e);
+ } catch (ResponseException e) {
+ handleResponseException(e);
}
}
@@ -1167,13 +1182,15 @@ public class JiraRepositoryConnector ext
}
public void finishUp()
- throws InterruptedException, IOException {
+ throws InterruptedException, IOException, ResponseException {
seedBuffer.abandon();
join();
Throwable thr = exception;
if (thr != null) {
if (thr instanceof IOException)
throw (IOException) thr;
+ else if (thr instanceof ResponseException)
+ throw (ResponseException) thr;
else if (thr instanceof RuntimeException)
throw (RuntimeException) thr;
else if (thr instanceof Error)
@@ -1201,6 +1218,8 @@ public class JiraRepositoryConnector ext
handleIOException(e);
} catch (IOException e) {
handleIOException(e);
+ } catch (ResponseException e) {
+ handleResponseException(e);
}
return t.getResponse();
}
@@ -1231,12 +1250,14 @@ public class JiraRepositoryConnector ext
return response;
}
- public void finishUp() throws InterruptedException, IOException {
+ public void finishUp() throws InterruptedException, IOException, ResponseException {
join();
Throwable thr = exception;
if (thr != null) {
if (thr instanceof IOException) {
throw (IOException) thr;
+ } else if (thr instanceof ResponseException) {
+ throw (ResponseException) thr;
} else if (thr instanceof RuntimeException) {
throw (RuntimeException) thr;
} else {
Modified: manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraSession.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraSession.java?rev=1501683&r1=1501682&r2=1501683&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraSession.java (original)
+++ manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraSession.java Wed Jul 10 09:11:04 2013
@@ -191,7 +191,8 @@ public class JiraSession {
return "";
}
- private void getRest(String rightside, JiraJSONResponse response) throws IOException {
+ private void getRest(String rightside, JiraJSONResponse response)
+ throws IOException, ResponseException {
final HttpRequestBase method = new HttpGet(URLbase + rightside);
method.addHeader("Accept", "application/json");
@@ -211,7 +212,8 @@ public class JiraSession {
/**
* Obtain repository information.
*/
- public Map<String, String> getRepositoryInfo() throws IOException {
+ public Map<String, String> getRepositoryInfo()
+ throws IOException, ResponseException {
HashMap<String, String> statistics = new HashMap<String, String>();
JiraQueryResults qr = new JiraQueryResults();
getRest("search?maxResults=1&jql=", qr);
@@ -223,9 +225,9 @@ public class JiraSession {
* Get the list of matching root documents, e.g. seeds.
*/
public void getSeeds(XThreadStringBuffer idBuffer, String jiraDriveQuery)
- throws IOException, InterruptedException {
+ throws IOException, ResponseException, InterruptedException {
long startAt = 0L;
- long setSize = 100L;
+ long setSize = 800L;
long totalAmt = 0L;
do {
JiraQueryResults qr = new JiraQueryResults();
@@ -243,10 +245,10 @@ public class JiraSession {
* Get the list of users that can see the specified issue.
*/
public List<String> getUsers(String issueKey)
- throws IOException {
+ throws IOException, ResponseException {
List<String> rval = new ArrayList<String>();
long startAt = 0L;
- long setSize = 100L;
+ long setSize = 800L;
while (true) {
JiraUserQueryResults qr = new JiraUserQueryResults();
getRest("user/viewissue/search?username=&issueKey="+URLEncoder.encode(issueKey,"utf-8")+"&maxResults=" + setSize + "&startAt=" + startAt, qr);
@@ -261,7 +263,8 @@ public class JiraSession {
/**
* Get an individual issue.
*/
- public JiraIssue getIssue(String issueKey) throws IOException {
+ public JiraIssue getIssue(String issueKey)
+ throws IOException, ResponseException {
JiraIssue ji = new JiraIssue();
getRest("issue/" + URLEncoder.encode(issueKey,"utf-8"), ji);
return ji;
Added: manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/ResponseException.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/ResponseException.java?rev=1501683&view=auto
==============================================================================
--- manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/ResponseException.java (added)
+++ manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/ResponseException.java Wed Jul 10 09:11:04 2013
@@ -0,0 +1,34 @@
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.manifoldcf.crawler.connectors.jira;
+
+/** This exception is thrown when the response from REST is not what
+* was expected.
+ */
+public class ResponseException extends Exception {
+
+ public ResponseException(String msg) {
+ super(msg);
+ }
+
+ public ResponseException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+}
Propchange: manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/ResponseException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: manifoldcf/trunk/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/ResponseException.java
------------------------------------------------------------------------------
svn:keywords = Id