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/09 01:55:03 UTC
svn commit: r1501026 - in
/manifoldcf/branches/CONNECTORS-731/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira:
JiraSession.java JiraViewQueryResults.java
Author: kwright
Date: Mon Jul 8 23:55:03 2013
New Revision: 1501026
URL: http://svn.apache.org/r1501026
Log:
Add session support for get an issue's viewable user list.
Added:
manifoldcf/branches/CONNECTORS-731/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraViewQueryResults.java (with props)
Modified:
manifoldcf/branches/CONNECTORS-731/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraSession.java
Modified: manifoldcf/branches/CONNECTORS-731/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraSession.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-731/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraSession.java?rev=1501026&r1=1501025&r2=1501026&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-731/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraSession.java (original)
+++ manifoldcf/branches/CONNECTORS-731/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraSession.java Mon Jul 8 23:55:03 2013
@@ -35,6 +35,8 @@ import java.net.URLEncoder;
import java.util.Map;
import java.util.HashMap;
+import java.util.List;
+import java.util.ArrayList;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.client.HttpClient;
@@ -238,6 +240,28 @@ public class JiraSession {
}
/**
+ * Get the list of users that can see the specified issue.
+ */
+ public List<String> getUsers(String issueKey)
+ throws IOException {
+ List<String> rval = new ArrayList<String>();
+ long startAt = 0L;
+ long setSize = 100L;
+ long totalAmt = 0L;
+ do {
+ JiraViewQueryResults qr = new JiraViewQueryResults();
+ getRest("user/viewissue/search?issueKey="+URLEncoder.encode(issueKey,"utf-8")+"&maxResults=" + setSize + "&startAt=" + startAt, qr);
+ Long total = qr.getTotal();
+ if (total == null)
+ break;
+ totalAmt = total.longValue();
+ qr.getNames(rval);
+ startAt += setSize;
+ } while (startAt < totalAmt);
+ return rval;
+ }
+
+ /**
* Get an individual issue.
*/
public JiraIssue getIssue(String id) throws IOException {
Added: manifoldcf/branches/CONNECTORS-731/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraViewQueryResults.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-731/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraViewQueryResults.java?rev=1501026&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-731/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraViewQueryResults.java (added)
+++ manifoldcf/branches/CONNECTORS-731/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraViewQueryResults.java Mon Jul 8 23:55:03 2013
@@ -0,0 +1,59 @@
+/* $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;
+
+import org.apache.manifoldcf.core.common.*;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.ArrayList;
+
+import org.json.simple.JSONObject;
+import org.json.simple.JSONArray;
+
+/** An instance of this class represents the results of a Jira view issue query, and
+* the ability to parse the corresponding JSON response.
+*/
+public class JiraViewQueryResults extends JiraJSONResponse {
+
+ // Specific keys we care about
+ private final static String KEY_TOTAL = "total";
+ private final static String KEY_USERS = "users";
+ private final static String KEY_NAME = "name";
+
+ public JiraViewQueryResults() {
+ super();
+ }
+
+ public void getNames(List<String> nameBuffer) {
+ JSONArray issues = (JSONArray)object.get(KEY_USERS);
+ for (Object issue : issues) {
+ if (issue instanceof JSONObject) {
+ JSONObject jo = (JSONObject)issue;
+ nameBuffer.add(jo.get(KEY_NAME).toString());
+ }
+ }
+ }
+
+ public Long getTotal() {
+ return (Long)object.get(KEY_TOTAL);
+ }
+
+}
Propchange: manifoldcf/branches/CONNECTORS-731/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraViewQueryResults.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: manifoldcf/branches/CONNECTORS-731/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraViewQueryResults.java
------------------------------------------------------------------------------
svn:keywords = Id