summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2011-04-10 15:39:13 (EDT)
committerChris Aniszczyk2011-04-10 15:41:30 (EDT)
commit185223750c7c8e6e4af6d2cae12c1327735c871a (patch)
tree04de9851c13f04e04438ce8cfa3d61a094fc896a
parent3301f6a91b852f0e181c912601fd05d6fc53e04c (diff)
downloadegit-github-185223750c7c8e6e4af6d2cae12c1327735c871a.zip
egit-github-185223750c7c8e6e4af6d2cae12c1327735c871a.tar.gz
egit-github-185223750c7c8e6e4af6d2cae12c1327735c871a.tar.bz2
Add support for getting an issue using new APIrefs/changes/46/3046/3
Change-Id: I6211b9da6faa44a0185a6fa6cb187e81985adda7 Signed-off-by: Kevin Sawicki <kevin@github.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubClient.java13
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IssueService.java57
2 files changed, 70 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubClient.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubClient.java
index 765e90b..fd2d2ea 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubClient.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubClient.java
@@ -167,6 +167,19 @@ public class GitHubClient {
*
* @param <V>
* @param uri
+ * @param type
+ * @return V
+ * @throws IOException
+ */
+ public <V> V get(String uri, Type type) throws IOException {
+ return get(uri, null, type);
+ }
+
+ /**
+ * Get response from uri and bind to specified type
+ *
+ * @param <V>
+ * @param uri
* @param params
* @param type
* @return V
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IssueService.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IssueService.java
new file mode 100644
index 0000000..4d3e978
--- /dev/null
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IssueService.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Kevin Sawicki (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.mylyn.github.internal;
+
+import java.io.IOException;
+
+import org.eclipse.core.runtime.Assert;
+
+/**
+ * Issue service class for listing, searching, and fetching {@link Issue}
+ * objects using a {@link GitHubClient}.
+ *
+ * @author Kevin Sawicki (kevin@github.com)
+ */
+public class IssueService {
+
+ private GitHubClient client;
+
+ /**
+ * Create issue service
+ *
+ * @param client
+ * cannot be null
+ */
+ public IssueService(GitHubClient client) {
+ Assert.isNotNull(client, "Client cannot be null"); //$NON-NLS-1$
+ this.client = client;
+ }
+
+ /**
+ * Get issue
+ *
+ * @param user
+ * @param repository
+ * @param id
+ * @return issue
+ * @throws IOException
+ */
+ public Issue getIssue(String user, String repository, String id)
+ throws IOException {
+ StringBuilder builder = new StringBuilder(
+ IGitHubConstants.SEGMENT_REPOS);
+ builder.append('/').append(user).append('/').append(repository);
+ builder.append(IGitHubConstants.SEGMENT_ISSUES);
+ builder.append('/').append(id).append(IGitHubConstants.SUFFIX_JSON);
+ return this.client.get(builder.toString(), Issue.class);
+ }
+
+}