Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2011-04-11 00:11:33 +0000
committerChris Aniszczyk2011-04-11 11:18:07 +0000
commitad7ca72365ecf4144bb57c25a41a6c2ccc7541f4 (patch)
treedb1ad019cb9675534a199666d53c274d63e12252
parentc093f6e5d6aa9a7cea928cb097ea4fc103f287cc (diff)
downloadegit-github-ad7ca72365ecf4144bb57c25a41a6c2ccc7541f4.tar.gz
egit-github-ad7ca72365ecf4144bb57c25a41a6c2ccc7541f4.tar.xz
egit-github-ad7ca72365ecf4144bb57c25a41a6c2ccc7541f4.zip
Add support for getting labels used in a repository
This will be used in the query dialog to search for issues that match all selected labels. Change-Id: I9726556cc3ad5a7432997e63ce3da14ac1ac0a03 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/IGitHubConstants.java5
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/LabelService.java59
2 files changed, 64 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IGitHubConstants.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IGitHubConstants.java
index 0435edbe..d21984b3 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IGitHubConstants.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IGitHubConstants.java
@@ -33,6 +33,11 @@ public interface IGitHubConstants {
String SEGMENT_COMMENTS = "/comments"; //$NON-NLS-1$
/**
+ * SEGMENT_LABELS
+ */
+ String SEGMENT_LABELS = "/labels"; //$NON-NLS-1$
+
+ /**
* SUFFIX_JSON
*/
String SUFFIX_JSON = ".json"; //$NON-NLS-1$
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/LabelService.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/LabelService.java
new file mode 100644
index 00000000..6740b661
--- /dev/null
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/LabelService.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * 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 com.google.gson.reflect.TypeToken;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+
+/**
+ * Label service class for listing {@link Label} objects in use for a given user
+ * and repository.
+ *
+ * @author Kevin Sawicki (kevin@github.com)
+ */
+public class LabelService {
+
+ private GitHubClient client;
+
+ /**
+ * Create label service for client
+ *
+ * @param client
+ */
+ public LabelService(GitHubClient client) {
+ Assert.isNotNull(client, "Client cannot be null"); //$NON-NLS-1$
+ this.client = client;
+ }
+
+ /**
+ * Get labels
+ *
+ * @param user
+ * @param repository
+ * @return list of labels
+ * @throws IOException
+ */
+ public List<Label> getLabels(String user, String repository)
+ throws IOException {
+ StringBuilder uri = new StringBuilder(IGitHubConstants.SEGMENT_REPOS);
+ uri.append('/').append(user).append('/').append(repository);
+ uri.append(IGitHubConstants.SEGMENT_LABELS).append(
+ IGitHubConstants.SUFFIX_JSON);
+ TypeToken<List<Label>> labelToken = new TypeToken<List<Label>>() {
+ };
+ return this.client.get(uri.toString(), labelToken.getType());
+ }
+
+}

Back to the top