Skip to content

Commit

Permalink
#1246 implemented Repo.enableIssues() + puzzles
Browse files Browse the repository at this point in the history
  • Loading branch information
amihaiemil committed Oct 16, 2021
1 parent ecc6a98 commit c596aaa
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 0 deletions.
6 changes: 6 additions & 0 deletions self-api/src/main/java/com/selfxdsd/api/Repo.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ public interface Repo {
*/
String provider();

/**
* Enable Issues for this Repo.
* @return Issues.
*/
Issues enableIssues();

/**
* The repo's Issues.
* @return Issues.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
* @author criske
* @version $Id$
* @since 0.0.67
* @todo #1246:60min Implement enabling of Issues for a BitBucket repository.
* If BitBucket doesn't support this functionality, the method should not do
* anything.
*/
final class BitbucketRepo extends BaseRepo {

Expand Down Expand Up @@ -123,6 +126,11 @@ public String fullName() {
return this.json().getString("full_name");
}

@Override
public Issues enableIssues() {
throw new UnsupportedOperationException("Not yet implemented.");
}

@Override
public Issues issues() {
return new BitbucketIssues(
Expand Down
28 changes: 28 additions & 0 deletions self-core-impl/src/main/java/com/selfxdsd/core/GithubRepo.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,18 @@
import com.selfxdsd.api.Labels;
import com.selfxdsd.api.storage.Storage;

import javax.json.Json;
import javax.json.JsonObject;
import java.net.HttpURLConnection;
import java.net.URI;

/**
* A Github repository.
* @author Mihai Andronache (amihaiemil@gmail.com)
* @version $Id$
* @since 0.0.1
* @todo #1248:60min Write some integration tests using MkGrizzly server for
* method enableIssues().
*/
final class GithubRepo extends BaseRepo {

Expand Down Expand Up @@ -124,6 +128,30 @@ public String fullName() {
return this.json().getString("full_name");
}

@Override
public Issues enableIssues() {
final Resource response = this.resources().patch(
this.repoUri(),
Json.createObjectBuilder()
.add("has_issues", true)
.build()
);
if(response.statusCode() == HttpURLConnection.HTTP_OK) {
return new GithubIssues(
this.resources(),
URI.create(this.repoUri().toString() + "/issues"),
this,
this.storage()
);
} else {
throw new IllegalStateException(
"Could not enable Issues for Repo ["
+ this.repoUri() + "]. Received Status is "
+ response.statusCode() + ", while Status 200 OK was expected."
);
}
}

@Override
public Issues issues() {
return new GithubIssues(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
* @author criske
* @version $Id$
* @since 0.0.1
* @todo #1246:60min Implement enabling of Issues for a GitLab repository.
* If GitLab doesn't support this functionality, the method should not do
* anything.
*/
final class GitlabRepo extends BaseRepo {

Expand Down Expand Up @@ -146,6 +149,11 @@ public String fullName() {
return this.json().getString("path_with_namespace");
}

@Override
public Issues enableIssues() {
throw new UnsupportedOperationException("Not yet implemented.");
}

@Override
public Issues issues() {
return new GitlabIssues(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
* @author Mihai Andronache (amihaiemil@gmail.com)
* @version $Id$
* @since 0.0.13
* @todo #1246:60min Implement an Intermediary Step used to enable Issues for
* a Repo, when it is being activated.
*/
public final class InvitePm extends Intermediary {

Expand Down

1 comment on commit c596aaa

@zoeself
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amihaiemil I've opened the Issues [#1252, #1253, #1254, #1255] for the newly added to-dos.

The to-dos may have been added in an earlier commit, but I've found them just now.

Please sign in to comment.