1. Atlassian
  2. Project: Atlassian
  3. jira-rest-java-client

Commits

Jacek Jaroczynski [Atlassian]  committed 81c307d

PLE-1516: allow JQL call to retrieve issue with EDITMETA information (allow to provide expandos to jql)

  • Participants
  • Parent commits b47556b
  • Branches IDE-Connectors

Comments (0)

Files changed (2)

File src/main/java/com/atlassian/jira/rest/client/SearchRestClient.java

View file
  • Ignore whitespace
-/*
- * Copyright (C) 2011 Atlassian
- *
- * Licensed 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 com.atlassian.jira.rest.client;
-
-import com.atlassian.jira.rest.client.domain.FavouriteFilter;
-import com.atlassian.jira.rest.client.domain.SearchResult;
-
-import javax.annotation.Nullable;
-
-/**
- * The client handling search REST resource
- *
- * @since 0.2 client, 4.3 server
- */
-public interface SearchRestClient {
-	/**
-	 * Performs a JQL search and returns issues matching the query
-	 *
-	 * @param jql a valid JQL query (will be properly encoded by JIRA client). Restricted JQL characters (like '/') must be properly escaped.
-	 * @param progressMonitor progress monitor
-	 * @return issues matching given JQL query
-	 * @throws RestClientException in case of problems (connectivity, malformed messages, invalid JQL query, etc.)
-	 */
-	SearchResult searchJql(@Nullable String jql, ProgressMonitor progressMonitor);
-
-	/**
-	 * Performs a JQL search and returns issues matching the query using default maxResults (as configured in JIRA - usually 50) and startAt=0
-	 *
-	 * @param jql a valid JQL query (will be properly encoded by JIRA client). Restricted JQL characters (like '/') must be properly escaped.
-	 * @param maxResults maximum results (page/window size) for this search. The page will contain issues from
-	 * <code>startAt div maxResults</code> (no remnant) and will include at most <code>maxResults</code> matching issues.
-	 * @param startAt starting index (0-based) defining the page/window for the results. It will be aligned by the server to the beginning
-	 * on the page (startAt = startAt div maxResults). For example for startAt=5 and maxResults=3 the results will include matching issues
-	 * with index 3, 4 and 5. For startAt = 6 and maxResults=3 the issues returned are from position 6, 7 and 8.
-	 * @param progressMonitor progress monitor
-	 * @return issues matching given JQL query
-	 * @throws RestClientException in case of problems (connectivity, malformed messages, invalid JQL query, etc.)
-	 */
-	SearchResult searchJql(@Nullable String jql, int maxResults, int startAt, ProgressMonitor progressMonitor);
-
-    /**
-     * Performs a JQL search and returns issues matching the query using default maxResults (as configured in JIRA - usually 50) and startAt=0
-     *
-     * @param jql a valid JQL query (will be properly encoded by JIRA client). Restricted JQL characters (like '/') must be properly escaped.
-     * @param maxResults maximum results (page/window size) for this search. The page will contain issues from
-     * <code>startAt div maxResults</code> (no remnant) and will include at most <code>maxResults</code> matching issues.
-     * @param startAt starting index (0-based) defining the page/window for the results. It will be aligned by the server to the beginning
-     * on the page (startAt = startAt div maxResults). For example for startAt=5 and maxResults=3 the results will include matching issues
-     * with index 3, 4 and 5. For startAt = 6 and maxResults=3 the issues returned are from position 6, 7 and 8.
-     * @param progressMonitor progress monitor
-     * @return issues matching given JQL query
-     * @throws RestClientException in case of problems (connectivity, malformed messages, invalid JQL query, etc.)
-     * @since 1.1 client 5.0 server
-     */
-    SearchResult searchJqlWithFullIssues(@Nullable String jql, int maxResults, int startAt, ProgressMonitor progressMonitor);
-
-    /**
-     * @param pm
-     * @return list of your favourite filters
-     * @since 1.1 client 5.0 server
-     */
-    Iterable<FavouriteFilter> getFavouriteFilters(NullProgressMonitor pm);
-}
+/*
+ * Copyright (C) 2011 Atlassian
+ *
+ * Licensed 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 com.atlassian.jira.rest.client;
+
+import com.atlassian.jira.rest.client.domain.FavouriteFilter;
+import com.atlassian.jira.rest.client.domain.SearchResult;
+
+import javax.annotation.Nullable;
+
+/**
+ * The client handling search REST resource
+ *
+ * @since 0.2 client, 4.3 server
+ */
+public interface SearchRestClient {
+	/**
+	 * Performs a JQL search and returns issues matching the query
+	 *
+	 * @param jql a valid JQL query (will be properly encoded by JIRA client). Restricted JQL characters (like '/') must be properly escaped.
+	 * @param progressMonitor progress monitor
+	 * @return issues matching given JQL query
+	 * @throws RestClientException in case of problems (connectivity, malformed messages, invalid JQL query, etc.)
+	 */
+	SearchResult searchJql(@Nullable String jql, ProgressMonitor progressMonitor);
+
+	/**
+	 * Performs a JQL search and returns issues matching the query using default maxResults (as configured in JIRA - usually 50) and startAt=0
+	 *
+	 * @param jql a valid JQL query (will be properly encoded by JIRA client). Restricted JQL characters (like '/') must be properly escaped.
+	 * @param maxResults maximum results (page/window size) for this search. The page will contain issues from
+	 * <code>startAt div maxResults</code> (no remnant) and will include at most <code>maxResults</code> matching issues.
+	 * @param startAt starting index (0-based) defining the page/window for the results. It will be aligned by the server to the beginning
+	 * on the page (startAt = startAt div maxResults). For example for startAt=5 and maxResults=3 the results will include matching issues
+	 * with index 3, 4 and 5. For startAt = 6 and maxResults=3 the issues returned are from position 6, 7 and 8.
+	 * @param progressMonitor progress monitor
+	 * @return issues matching given JQL query
+	 * @throws RestClientException in case of problems (connectivity, malformed messages, invalid JQL query, etc.)
+	 */
+	SearchResult searchJql(@Nullable String jql, int maxResults, int startAt, ProgressMonitor progressMonitor);
+
+    /**
+     * Performs a JQL search and returns issues matching the query using default maxResults (as configured in JIRA - usually 50) and startAt=0
+     *
+     * @param jql a valid JQL query (will be properly encoded by JIRA client). Restricted JQL characters (like '/') must be properly escaped.
+     * @param maxResults maximum results (page/window size) for this search. The page will contain issues from
+     * <code>startAt div maxResults</code> (no remnant) and will include at most <code>maxResults</code> matching issues.
+     * @param startAt starting index (0-based) defining the page/window for the results. It will be aligned by the server to the beginning
+     * on the page (startAt = startAt div maxResults). For example for startAt=5 and maxResults=3 the results will include matching issues
+     * with index 3, 4 and 5. For startAt = 6 and maxResults=3 the issues returned are from position 6, 7 and 8.
+     * @param progressMonitor progress monitor
+     * @return issues matching given JQL query
+     * @throws RestClientException in case of problems (connectivity, malformed messages, invalid JQL query, etc.)
+     * @since 1.1 client 5.0 server
+     */
+    SearchResult searchJqlWithFullIssues(@Nullable String jql, int maxResults, int startAt, ProgressMonitor progressMonitor);
+
+    /**
+     * @param pm
+     * @return list of your favourite filters
+     * @since 1.1 client 5.0 server
+     */
+    Iterable<FavouriteFilter> getFavouriteFilters(NullProgressMonitor pm);
+
+    SearchResult searchJqlWithFullIssues(@Nullable String jql, int maxResults, int startAt, Iterable<IssueRestClient.Expandos> expand, ProgressMonitor progressMonitor);
+}

File src/main/java/com/atlassian/jira/rest/client/internal/jersey/JerseySearchRestClient.java

View file
  • Ignore whitespace
 
 	@Override
 	public SearchResult searchJql(@Nullable String jql, ProgressMonitor progressMonitor) {
-        return searchJqlImpl(jql, null, null, progressMonitor, keyOnlySearchResultJsonParser);
+        return searchJqlImpl(jql, null, null, progressMonitor, keyOnlySearchResultJsonParser, DEFAULT_EXPANDS);
 	}
 
 	@Override
 	public SearchResult searchJql(@Nullable String jql, int maxResults, int startAt, ProgressMonitor progressMonitor) {
-		return searchJqlImpl(jql, maxResults, startAt, progressMonitor, keyOnlySearchResultJsonParser);
+		return searchJqlImpl(jql, maxResults, startAt, progressMonitor, keyOnlySearchResultJsonParser, DEFAULT_EXPANDS);
 	}
 
     @Override
     public SearchResult searchJqlWithFullIssues(@Nullable String jql, int maxResults, int startAt, ProgressMonitor progressMonitor) {
-        return searchJqlImpl(jql, maxResults, startAt, progressMonitor, fullSearchResultJsonParser);
+        return searchJqlImpl(jql, maxResults, startAt, progressMonitor, fullSearchResultJsonParser, DEFAULT_EXPANDS);
     }
 
-    private SearchResult searchJqlImpl(@Nullable String jql, Integer maxResults, Integer startAt, ProgressMonitor progressMonitor, SearchResultJsonParser parser) {
+    @Override
+    public SearchResult searchJqlWithFullIssues(@Nullable String jql, int maxResults, int startAt, Iterable<IssueRestClient.Expandos> expand, ProgressMonitor progressMonitor) {
+        return searchJqlImpl(jql, maxResults, startAt, progressMonitor, fullSearchResultJsonParser, expand);
+    }
+
+    private SearchResult searchJqlImpl(@Nullable String jql, Integer maxResults, Integer startAt, ProgressMonitor progressMonitor, SearchResultJsonParser parser, Iterable<IssueRestClient.Expandos> expand) {
         if (jql == null) {
             jql = "";
         }
 
+        final Iterable<IssueRestClient.Expandos> expands = Iterables.concat(DEFAULT_EXPANDS, expand);
+
         if (jql.length() > MAX_JQL_LENGTH_FOR_HTTP_GET) {
             UriBuilder uriBuilder = UriBuilder.fromUri(searchUri);
             final JSONObject postEntity = new JSONObject();
                     postEntity.put(START_AT_ATTRIBUTE, startAt);
                     postEntity.put(MAX_RESULTS_ATTRIBUTE, maxResults);
                 }
-                uriBuilder = uriBuilder.queryParam(EXPAND_ATTRIBUTE, Joiner.on(',').join(Iterables.transform(DEFAULT_EXPANDS, EXPANDO_TO_PARAM)));
+                uriBuilder = uriBuilder.queryParam(EXPAND_ATTRIBUTE, Joiner.on(',').join(Iterables.transform(expands, EXPANDO_TO_PARAM)));
             } catch (JSONException e) {
                 throw new RestClientException(e);
             }
             if (maxResults != null && startAt != null) {
                 uriBuilder = uriBuilder.queryParam(MAX_RESULTS_ATTRIBUTE, maxResults).queryParam(START_AT_ATTRIBUTE, startAt);
             }
-            URI uri = uriBuilder.queryParam(EXPAND_ATTRIBUTE, Joiner.on(',').join(Iterables.transform(DEFAULT_EXPANDS, EXPANDO_TO_PARAM))).build();
+            URI uri = uriBuilder.queryParam(EXPAND_ATTRIBUTE, Joiner.on(',').join(Iterables.transform(expands, EXPANDO_TO_PARAM))).build();
             return getAndParse(uri, parser, progressMonitor);
         }
     }