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 15:01:46 UTC
svn commit: r1501234 - in
/manifoldcf/branches/CONNECTORS-731/connectors/jira/connector/src/main/java/org/apache/manifoldcf:
authorities/authorities/jira/ crawler/connectors/jira/
Author: kwright
Date: Tue Jul 9 13:01:45 2013
New Revision: 1501234
URL: http://svn.apache.org/r1501234
Log:
Finish security for jira (untested)
Added:
manifoldcf/branches/CONNECTORS-731/connectors/jira/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/jira/JiraUserQueryResults.java (with props)
manifoldcf/branches/CONNECTORS-731/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraUserQueryResults.java
- copied, changed from r1501026, manifoldcf/branches/CONNECTORS-731/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraViewQueryResults.java
Removed:
manifoldcf/branches/CONNECTORS-731/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraViewQueryResults.java
Modified:
manifoldcf/branches/CONNECTORS-731/connectors/jira/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/jira/JiraSession.java
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/authorities/authorities/jira/JiraSession.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-731/connectors/jira/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/jira/JiraSession.java?rev=1501234&r1=1501233&r2=1501234&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-731/connectors/jira/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/jira/JiraSession.java (original)
+++ manifoldcf/branches/CONNECTORS-731/connectors/jira/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/jira/JiraSession.java Tue Jul 9 13:01:45 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;
@@ -211,18 +213,28 @@ public class JiraSession {
*/
public Map<String, String> getRepositoryInfo() throws IOException {
HashMap<String, String> statistics = new HashMap<String, String>();
- /*
- JiraQueryResults qr = new JiraQueryResults();
- getRest("search?maxResults=1&jql=", qr);
- statistics.put("Total Issues", qr.getTotal().toString());
- */
+ JiraUserQueryResults qr = new JiraUserQueryResults();
+ getRest("user/search?username=&maxResults=1&startAt=0", qr);
+ statistics.put("Total Users", qr.getTotal().toString());
return statistics;
}
/** Check if user exists.
*/
public boolean checkUserExists(String userName) throws IOException {
- // MHL
+ JiraUserQueryResults qr = new JiraUserQueryResults();
+ getRest("user/search?username="+URLEncoder.encode(userName,"utf-8")+"&maxResults=1&startAt=0", qr);
+ Long total = qr.getTotal();
+ if (total == null || total.longValue() == 0)
+ return false;
+ List<String> values = new ArrayList<String>();
+ qr.getNames(values);
+ if (values.size() == 0)
+ return false;
+ for (String value : values) {
+ if (userName.equals(value))
+ return true;
+ }
return false;
}
}
Added: manifoldcf/branches/CONNECTORS-731/connectors/jira/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/jira/JiraUserQueryResults.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-731/connectors/jira/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/jira/JiraUserQueryResults.java?rev=1501234&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-731/connectors/jira/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/jira/JiraUserQueryResults.java (added)
+++ manifoldcf/branches/CONNECTORS-731/connectors/jira/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/jira/JiraUserQueryResults.java Tue Jul 9 13:01:45 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.authorities.authorities.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 user query, and
+* the ability to parse the corresponding JSON response.
+*/
+public class JiraUserQueryResults 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 JiraUserQueryResults() {
+ 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/authorities/authorities/jira/JiraUserQueryResults.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: manifoldcf/branches/CONNECTORS-731/connectors/jira/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/jira/JiraUserQueryResults.java
------------------------------------------------------------------------------
svn:keywords = Id
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=1501234&r1=1501233&r2=1501234&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 Tue Jul 9 13:01:45 2013
@@ -249,7 +249,7 @@ public class JiraSession {
long setSize = 100L;
long totalAmt = 0L;
do {
- JiraViewQueryResults qr = new JiraViewQueryResults();
+ JiraUserQueryResults qr = new JiraUserQueryResults();
getRest("user/viewissue/search?issueKey="+URLEncoder.encode(issueKey,"utf-8")+"&maxResults=" + setSize + "&startAt=" + startAt, qr);
Long total = qr.getTotal();
if (total == null)
Copied: manifoldcf/branches/CONNECTORS-731/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraUserQueryResults.java (from r1501026, 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/JiraUserQueryResults.java?p2=manifoldcf/branches/CONNECTORS-731/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraUserQueryResults.java&p1=manifoldcf/branches/CONNECTORS-731/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraViewQueryResults.java&r1=1501026&r2=1501234&rev=1501234&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-731/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraViewQueryResults.java (original)
+++ manifoldcf/branches/CONNECTORS-731/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraUserQueryResults.java Tue Jul 9 13:01:45 2013
@@ -28,17 +28,17 @@ 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
+/** An instance of this class represents the results of a Jira user query, and
* the ability to parse the corresponding JSON response.
*/
-public class JiraViewQueryResults extends JiraJSONResponse {
+public class JiraUserQueryResults 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() {
+ public JiraUserQueryResults() {
super();
}