Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2011-12-27 23:15:03 +0000
committerKevin Sawicki2011-12-27 23:15:03 +0000
commita2271105529c1d7605639b48984371aea5db48e7 (patch)
treecbd99a39771978460781168e3baefd5d59262721 /org.eclipse.egit.github.core
parent65ed388dff22c3f5b64d56bb21c0bb59a83fc6f9 (diff)
downloadegit-github-a2271105529c1d7605639b48984371aea5db48e7.tar.gz
egit-github-a2271105529c1d7605639b48984371aea5db48e7.tar.xz
egit-github-a2271105529c1d7605639b48984371aea5db48e7.zip
Overload methods to take an IRepositoryIdProvider parameter
This commit makes MilestoneService and LabelService consistent with other services Change-Id: Idd08a3e739504989970d297893500600f9e0962e
Diffstat (limited to 'org.eclipse.egit.github.core')
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/LabelService.java110
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/MilestoneService.java121
2 files changed, 222 insertions, 9 deletions
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/LabelService.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/LabelService.java
index 03067864..98499c32 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/LabelService.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/LabelService.java
@@ -19,6 +19,7 @@ import com.google.gson.reflect.TypeToken;
import java.io.IOException;
import java.util.List;
+import org.eclipse.egit.github.core.IRepositoryIdProvider;
import org.eclipse.egit.github.core.Label;
import org.eclipse.egit.github.core.client.GitHubClient;
import org.eclipse.egit.github.core.client.GitHubRequest;
@@ -52,6 +53,19 @@ public class LabelService extends GitHubService {
/**
* Get labels
*
+ * @param repository
+ * @return list of labels
+ * @throws IOException
+ */
+ public List<Label> getLabels(IRepositoryIdProvider repository)
+ throws IOException {
+ String repoId = getId(repository);
+ return getLabels(repoId);
+ }
+
+ /**
+ * Get labels
+ *
* @param user
* @param repository
* @return list of labels
@@ -61,8 +75,13 @@ public class LabelService extends GitHubService {
throws IOException {
verifyRepository(user, repository);
+ String repoId = user + '/' + repository;
+ return getLabels(repoId);
+ }
+
+ private List<Label> getLabels(String id) throws IOException {
StringBuilder uri = new StringBuilder(SEGMENT_REPOS);
- uri.append('/').append(user).append('/').append(repository);
+ uri.append('/').append(id);
uri.append(SEGMENT_LABELS);
PagedRequest<Label> request = createPagedRequest();
request.setUri(uri);
@@ -74,6 +93,21 @@ public class LabelService extends GitHubService {
/**
* Set the labels for an issue
*
+ * @param repository
+ * @param issueId
+ * @param labels
+ * @return list of labels
+ * @throws IOException
+ */
+ public List<Label> setLabels(IRepositoryIdProvider repository,
+ String issueId, List<Label> labels) throws IOException {
+ String repoId = getId(repository);
+ return setLabels(repoId, issueId, labels);
+ }
+
+ /**
+ * Set the labels for an issue
+ *
* @param user
* @param repository
* @param issueId
@@ -84,13 +118,20 @@ public class LabelService extends GitHubService {
public List<Label> setLabels(String user, String repository,
String issueId, List<Label> labels) throws IOException {
verifyRepository(user, repository);
+
+ String repoId = user + '/' + repository;
+ return setLabels(repoId, issueId, labels);
+ }
+
+ private List<Label> setLabels(String id, String issueId, List<Label> labels)
+ throws IOException {
if (issueId == null)
throw new IllegalArgumentException("Issue id cannot be null"); //$NON-NLS-1$
if (issueId.length() == 0)
throw new IllegalArgumentException("Issue id cannot be empty"); //$NON-NLS-1$
StringBuilder uri = new StringBuilder(SEGMENT_REPOS);
- uri.append('/').append(user).append('/').append(repository);
+ uri.append('/').append(id);
uri.append(SEGMENT_ISSUES);
uri.append('/').append(issueId);
uri.append(SEGMENT_LABELS);
@@ -102,6 +143,20 @@ public class LabelService extends GitHubService {
/**
* Create label
*
+ * @param repository
+ * @param label
+ * @return created label
+ * @throws IOException
+ */
+ public Label createLabel(IRepositoryIdProvider repository, Label label)
+ throws IOException {
+ String repoId = getId(repository);
+ return createLabel(repoId, label);
+ }
+
+ /**
+ * Create label
+ *
* @param user
* @param repository
* @param label
@@ -111,11 +166,17 @@ public class LabelService extends GitHubService {
public Label createLabel(String user, String repository, Label label)
throws IOException {
verifyRepository(user, repository);
+
+ String repoId = user + '/' + repository;
+ return createLabel(repoId, label);
+ }
+
+ private Label createLabel(String id, Label label) throws IOException {
if (label == null)
throw new IllegalArgumentException("Label cannot be null"); //$NON-NLS-1$
StringBuilder uri = new StringBuilder(SEGMENT_REPOS);
- uri.append('/').append(user).append('/').append(repository);
+ uri.append('/').append(id);
uri.append(SEGMENT_LABELS);
return client.post(uri.toString(), label, Label.class);
}
@@ -123,6 +184,20 @@ public class LabelService extends GitHubService {
/**
* Get label with given name
*
+ * @param repository
+ * @param label
+ * @return label
+ * @throws IOException
+ */
+ public Label getLabel(IRepositoryIdProvider repository, String label)
+ throws IOException {
+ String repoId = getId(repository);
+ return getLabel(repoId, label);
+ }
+
+ /**
+ * Get label with given name
+ *
* @param user
* @param repository
* @param label
@@ -132,13 +207,19 @@ public class LabelService extends GitHubService {
public Label getLabel(String user, String repository, String label)
throws IOException {
verifyRepository(user, repository);
+
+ String repoId = user + '/' + repository;
+ return getLabel(repoId, label);
+ }
+
+ private Label getLabel(String id, String label) throws IOException {
if (label == null)
throw new IllegalArgumentException("Label cannot be null"); //$NON-NLS-1$
if (label.length() == 0)
throw new IllegalArgumentException("Label cannot be empty"); //$NON-NLS-1$
StringBuilder uri = new StringBuilder(SEGMENT_REPOS);
- uri.append('/').append(user).append('/').append(repository);
+ uri.append('/').append(id);
uri.append(SEGMENT_LABELS);
uri.append('/').append(label);
GitHubRequest request = createRequest();
@@ -150,6 +231,19 @@ public class LabelService extends GitHubService {
/**
* Delete a label with the given id from the given repository
*
+ * @param repository
+ * @param label
+ * @throws IOException
+ */
+ public void deleteLabel(IRepositoryIdProvider repository, String label)
+ throws IOException {
+ String repoId = getId(repository);
+ deleteLabel(repoId, label);
+ }
+
+ /**
+ * Delete a label with the given id from the given repository
+ *
* @param user
* @param repository
* @param label
@@ -158,13 +252,19 @@ public class LabelService extends GitHubService {
public void deleteLabel(String user, String repository, String label)
throws IOException {
verifyRepository(user, repository);
+
+ String repoId = user + '/' + repository;
+ deleteLabel(repoId, label);
+ }
+
+ private void deleteLabel(String id, String label) throws IOException {
if (label == null)
throw new IllegalArgumentException("Label cannot be null"); //$NON-NLS-1$
if (label.length() == 0)
throw new IllegalArgumentException("Label cannot be empty"); //$NON-NLS-1$
StringBuilder uri = new StringBuilder(SEGMENT_REPOS);
- uri.append('/').append(user).append('/').append(repository);
+ uri.append('/').append(id);
uri.append(SEGMENT_LABELS);
uri.append('/').append(label);
client.delete(uri.toString());
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/MilestoneService.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/MilestoneService.java
index eb8ff441..0a958b87 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/MilestoneService.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/MilestoneService.java
@@ -19,6 +19,7 @@ import java.io.IOException;
import java.util.Collections;
import java.util.List;
+import org.eclipse.egit.github.core.IRepositoryIdProvider;
import org.eclipse.egit.github.core.Milestone;
import org.eclipse.egit.github.core.client.GitHubClient;
import org.eclipse.egit.github.core.client.GitHubRequest;
@@ -53,6 +54,20 @@ public class MilestoneService extends GitHubService {
/**
* Get milestones
*
+ * @param repository
+ * @param state
+ * @return list of milestones
+ * @throws IOException
+ */
+ public List<Milestone> getMilestones(IRepositoryIdProvider repository,
+ String state) throws IOException {
+ String repoId = getId(repository);
+ return getMilestones(repoId, state);
+ }
+
+ /**
+ * Get milestones
+ *
* @param user
* @param repository
* @param state
@@ -63,8 +78,15 @@ public class MilestoneService extends GitHubService {
String state) throws IOException {
verifyRepository(user, repository);
+ String repoId = user + '/' + repository;
+ return getMilestones(repoId, state);
+ }
+
+ private List<Milestone> getMilestones(String id, String state)
+ throws IOException {
+
StringBuilder uri = new StringBuilder(SEGMENT_REPOS);
- uri.append('/').append(user).append('/').append(repository);
+ uri.append('/').append(id);
uri.append(SEGMENT_MILESTONES);
PagedRequest<Milestone> request = createPagedRequest();
if (state != null)
@@ -78,6 +100,22 @@ public class MilestoneService extends GitHubService {
/**
* Create a milestone
*
+ * @param repository
+ * must be non-null
+ * @param milestone
+ * must be non-null
+ * @return created milestone
+ * @throws IOException
+ */
+ public Milestone createMilestone(IRepositoryIdProvider repository,
+ Milestone milestone) throws IOException {
+ String repoId = getId(repository);
+ return createMilestone(repoId, milestone);
+ }
+
+ /**
+ * Create a milestone
+ *
* @param user
* must be non-null
* @param repository
@@ -90,11 +128,18 @@ public class MilestoneService extends GitHubService {
public Milestone createMilestone(String user, String repository,
Milestone milestone) throws IOException {
verifyRepository(user, repository);
+
+ String repoId = user + '/' + repository;
+ return createMilestone(repoId, milestone);
+ }
+
+ private Milestone createMilestone(String id, Milestone milestone)
+ throws IOException {
if (milestone == null)
throw new IllegalArgumentException("Milestone cannot be null"); //$NON-NLS-1$
StringBuilder uri = new StringBuilder(SEGMENT_REPOS);
- uri.append('/').append(user).append('/').append(repository);
+ uri.append('/').append(id);
uri.append(SEGMENT_MILESTONES);
return client.post(uri.toString(), milestone, Milestone.class);
}
@@ -102,6 +147,36 @@ public class MilestoneService extends GitHubService {
/**
* Get a milestone
*
+ * @param repository
+ * must be non-null
+ * @param number
+ * @return created milestone
+ * @throws IOException
+ */
+ public Milestone getMilestone(IRepositoryIdProvider repository, int number)
+ throws IOException {
+ return getMilestone(repository, Integer.toString(number));
+ }
+
+ /**
+ * Get a milestone
+ *
+ * @param repository
+ * must be non-null
+ * @param number
+ * must be non-null
+ * @return created milestone
+ * @throws IOException
+ */
+ public Milestone getMilestone(IRepositoryIdProvider repository,
+ String number) throws IOException {
+ String repoId = getId(repository);
+ return getMilestone(repoId, number);
+ }
+
+ /**
+ * Get a milestone
+ *
* @param user
* must be non-null
* @param repository
@@ -130,13 +205,19 @@ public class MilestoneService extends GitHubService {
public Milestone getMilestone(String user, String repository, String number)
throws IOException {
verifyRepository(user, repository);
+
+ String repoId = user + '/' + repository;
+ return getMilestone(repoId, number);
+ }
+
+ private Milestone getMilestone(String id, String number) throws IOException {
if (number == null)
throw new IllegalArgumentException("Milestone cannot be null"); //$NON-NLS-1$
if (number.length() == 0)
throw new IllegalArgumentException("Milestone cannot be empty"); //$NON-NLS-1$
StringBuilder uri = new StringBuilder(SEGMENT_REPOS);
- uri.append('/').append(user).append('/').append(repository);
+ uri.append('/').append(id);
uri.append(SEGMENT_MILESTONES);
uri.append('/').append(number);
GitHubRequest request = createRequest();
@@ -148,6 +229,31 @@ public class MilestoneService extends GitHubService {
/**
* Delete a milestone with the given id from the given repository
*
+ * @param repository
+ * @param milestone
+ * @throws IOException
+ */
+ public void deleteMilestone(IRepositoryIdProvider repository, int milestone)
+ throws IOException {
+ deleteMilestone(repository, Integer.toString(milestone));
+ }
+
+ /**
+ * Delete a milestone with the given id from the given repository
+ *
+ * @param repository
+ * @param milestone
+ * @throws IOException
+ */
+ public void deleteMilestone(IRepositoryIdProvider repository,
+ String milestone) throws IOException {
+ String repoId = getId(repository);
+ deleteMilestone(repoId, milestone);
+ }
+
+ /**
+ * Delete a milestone with the given id from the given repository
+ *
* @param user
* @param repository
* @param milestone
@@ -169,13 +275,20 @@ public class MilestoneService extends GitHubService {
public void deleteMilestone(String user, String repository, String milestone)
throws IOException {
verifyRepository(user, repository);
+
+ String repoId = user + '/' + repository;
+ deleteMilestone(repoId, milestone);
+ }
+
+ private void deleteMilestone(String id, String milestone)
+ throws IOException {
if (milestone == null)
throw new IllegalArgumentException("Milestone cannot be null"); //$NON-NLS-1$
if (milestone.length() == 0)
throw new IllegalArgumentException("Milestone cannot be empty"); //$NON-NLS-1$
StringBuilder uri = new StringBuilder(SEGMENT_REPOS);
- uri.append('/').append(user).append('/').append(repository);
+ uri.append('/').append(id);
uri.append(SEGMENT_MILESTONES);
uri.append('/').append(milestone);
client.delete(uri.toString());

Back to the top