aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorJonathan Brachthäuser <jonathan@b-studios.de>2015-09-03 22:37:59 +0200
committerJonathan Brachthäuser <jonathan@b-studios.de>2015-09-04 11:38:42 +0200
commit69baef38cbde57293451dc841b1b370ec0708e88 (patch)
tree62cea9821a2691ba8dae5faa7a7f3e65541de403 /src/main/java
parent636cb7acb982f351f36005cbb71292e1c92ff52a (diff)
downloadbbprb-69baef38cbde57293451dc841b1b370ec0708e88.tar.gz
Refactored: Only have one file for JSON POJOs
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketPullRequestsBuilder.java4
-rw-r--r--src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java36
-rw-r--r--src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/ApiClient.java (renamed from src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketApiClient.java)40
-rw-r--r--src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketPullRequestApproval.java20
-rw-r--r--src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketPullRequestComment.java118
-rw-r--r--src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketPullRequestResponse.java58
-rw-r--r--src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketPullRequestResponseValue.java130
-rw-r--r--src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketPullRequestResponseValueRepository.java46
-rw-r--r--src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketPullRequestResponseValueRepositoryBranch.java16
-rw-r--r--src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketPullRequestResponseValueRepositoryCommit.java16
-rw-r--r--src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketPullRequestResponseValueRepositoryRepository.java43
-rw-r--r--src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/Pullrequest.java345
12 files changed, 384 insertions, 488 deletions
diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketPullRequestsBuilder.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketPullRequestsBuilder.java
index 1838607..3671ea6 100644
--- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketPullRequestsBuilder.java
+++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketPullRequestsBuilder.java
@@ -1,6 +1,6 @@
package bitbucketpullrequestbuilder.bitbucketpullrequestbuilder;
-import bitbucketpullrequestbuilder.bitbucketpullrequestbuilder.bitbucket.BitbucketPullRequestResponseValue;
+import bitbucketpullrequestbuilder.bitbucketpullrequestbuilder.bitbucket.Pullrequest;
import hudson.model.AbstractProject;
import java.util.Collection;
@@ -27,7 +27,7 @@ public class BitbucketPullRequestsBuilder {
public void run() {
logger.info("Build Start.");
this.repository.init();
- Collection<BitbucketPullRequestResponseValue> targetPullRequests = this.repository.getTargetPullRequests();
+ Collection<Pullrequest> targetPullRequests = this.repository.getTargetPullRequests();
this.repository.addFutureBuildTasks(targetPullRequests);
}
diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java
index f988d23..bdf5d7c 100644
--- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java
+++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java
@@ -8,10 +8,8 @@ import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import bitbucketpullrequestbuilder.bitbucketpullrequestbuilder.bitbucket.BitbucketApiClient;
-import bitbucketpullrequestbuilder.bitbucketpullrequestbuilder.bitbucket.BitbucketPullRequestComment;
-import bitbucketpullrequestbuilder.bitbucketpullrequestbuilder.bitbucket.BitbucketPullRequestResponseValue;
-import bitbucketpullrequestbuilder.bitbucketpullrequestbuilder.bitbucket.BitbucketPullRequestResponseValueRepository;
+import bitbucketpullrequestbuilder.bitbucketpullrequestbuilder.bitbucket.ApiClient;
+import bitbucketpullrequestbuilder.bitbucketpullrequestbuilder.bitbucket.Pullrequest;
/**
* Created by nishio
@@ -32,7 +30,7 @@ public class BitbucketRepository {
private String projectPath;
private BitbucketPullRequestsBuilder builder;
private BitbucketBuildTrigger trigger;
- private BitbucketApiClient client;
+ private ApiClient client;
public BitbucketRepository(String projectPath, BitbucketPullRequestsBuilder builder) {
this.projectPath = projectPath;
@@ -41,18 +39,18 @@ public class BitbucketRepository {
public void init() {
trigger = this.builder.getTrigger();
- client = new BitbucketApiClient(
+ client = new ApiClient(
trigger.getUsername(),
trigger.getPassword(),
trigger.getRepositoryOwner(),
trigger.getRepositoryName());
}
- public Collection<BitbucketPullRequestResponseValue> getTargetPullRequests() {
+ public Collection<Pullrequest> getTargetPullRequests() {
logger.info("Fetch PullRequests.");
- List<BitbucketPullRequestResponseValue> pullRequests = client.getPullRequests();
- List<BitbucketPullRequestResponseValue> targetPullRequests = new ArrayList<BitbucketPullRequestResponseValue>();
- for(BitbucketPullRequestResponseValue pullRequest : pullRequests) {
+ List<Pullrequest> pullRequests = client.getPullRequests();
+ List<Pullrequest> targetPullRequests = new ArrayList<Pullrequest>();
+ for(Pullrequest pullRequest : pullRequests) {
if (isBuildTarget(pullRequest)) {
targetPullRequests.add(pullRequest);
}
@@ -60,16 +58,16 @@ public class BitbucketRepository {
return targetPullRequests;
}
- public String postBuildStartCommentTo(BitbucketPullRequestResponseValue pullRequest) {
+ public String postBuildStartCommentTo(Pullrequest pullRequest) {
String sourceCommit = pullRequest.getSource().getCommit().getHash();
String destinationCommit = pullRequest.getDestination().getCommit().getHash();
String comment = String.format(BUILD_START_MARKER, builder.getProject().getDisplayName(), sourceCommit, destinationCommit);
- BitbucketPullRequestComment commentResponse = this.client.postPullRequestComment(pullRequest.getId(), comment);
- return commentResponse.getCommentId().toString();
+ Pullrequest.Comment commentResponse = this.client.postPullRequestComment(pullRequest.getId(), comment);
+ return commentResponse.getId().toString();
}
- public void addFutureBuildTasks(Collection<BitbucketPullRequestResponseValue> pullRequests) {
- for(BitbucketPullRequestResponseValue pullRequest : pullRequests) {
+ public void addFutureBuildTasks(Collection<Pullrequest> pullRequests) {
+ for(Pullrequest pullRequest : pullRequests) {
String commentId = postBuildStartCommentTo(pullRequest);
if ( this.trigger.getApproveIfSuccess() ) {
deletePullRequestApproval(pullRequest.getId());
@@ -112,7 +110,7 @@ public class BitbucketRepository {
this.client.postPullRequestApproval(pullRequestId);
}
- private boolean isBuildTarget(BitbucketPullRequestResponseValue pullRequest) {
+ private boolean isBuildTarget(Pullrequest pullRequest) {
boolean shouldBuild = true;
if (pullRequest.getState() != null && pullRequest.getState().equals("OPEN")) {
@@ -122,18 +120,18 @@ public class BitbucketRepository {
String sourceCommit = pullRequest.getSource().getCommit().getHash();
- BitbucketPullRequestResponseValueRepository destination = pullRequest.getDestination();
+ Pullrequest.Revision destination = pullRequest.getDestination();
String owner = destination.getRepository().getOwnerName();
String repositoryName = destination.getRepository().getRepositoryName();
String destinationCommit = destination.getCommit().getHash();
String id = pullRequest.getId();
- List<BitbucketPullRequestComment> comments = client.getPullRequestComments(owner, repositoryName, id);
+ List<Pullrequest.Comment> comments = client.getPullRequestComments(owner, repositoryName, id);
if (comments != null) {
Collections.sort(comments);
Collections.reverse(comments);
- for (BitbucketPullRequestComment comment : comments) {
+ for (Pullrequest.Comment comment : comments) {
String content = comment.getContent();
if (content == null || content.isEmpty()) {
continue;
diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketApiClient.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/ApiClient.java
index 71fc861..ceec1a8 100644
--- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketApiClient.java
+++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/ApiClient.java
@@ -21,8 +21,8 @@ import hudson.ProxyConfiguration;
/**
* Created by nishio
*/
-public class BitbucketApiClient {
- private static final Logger logger = Logger.getLogger(BitbucketApiClient.class.getName());
+public class ApiClient {
+ private static final Logger logger = Logger.getLogger(ApiClient.class.getName());
private static final String BITBUCKET_HOST = "bitbucket.org";
private static final String V1_API_BASE_URL = "https://bitbucket.org/api/1.0/repositories/";
private static final String V2_API_BASE_URL = "https://bitbucket.org/api/2.0/repositories/";
@@ -30,23 +30,23 @@ public class BitbucketApiClient {
private String repositoryName;
private Credentials credentials;
- public BitbucketApiClient(String username, String password, String owner, String repositoryName) {
+ public ApiClient(String username, String password, String owner, String repositoryName) {
this.credentials = new UsernamePasswordCredentials(username, password);
this.owner = owner;
this.repositoryName = repositoryName;
}
- public List<BitbucketPullRequestResponseValue> getPullRequests() {
+ public List<Pullrequest> getPullRequests() {
String response = getRequest(V2_API_BASE_URL + this.owner + "/" + this.repositoryName + "/pullrequests/");
try {
- return parsePullRequestJson(response).getPrValues();
+ return parsePullRequestJson(response).getPullrequests();
} catch(Exception e) {
logger.log(Level.WARNING, "invalid pull request response.", e);
}
return Collections.EMPTY_LIST;
}
- public List<BitbucketPullRequestComment> getPullRequestComments(String commentOwnerName, String commentRepositoryName, String pullRequestId) {
+ public List<Pullrequest.Comment> getPullRequestComments(String commentOwnerName, String commentRepositoryName, String pullRequestId) {
String response = getRequest(
V1_API_BASE_URL + commentOwnerName + "/" + commentRepositoryName + "/pullrequests/" + pullRequestId + "/comments");
try {
@@ -64,7 +64,7 @@ public class BitbucketApiClient {
}
- public BitbucketPullRequestComment postPullRequestComment(String pullRequestId, String comment) {
+ public Pullrequest.Comment postPullRequestComment(String pullRequestId, String comment) {
String path = V1_API_BASE_URL + this.owner + "/" + this.repositoryName + "/pullrequests/" + pullRequestId + "/comments";
try {
NameValuePair content = new NameValuePair("content", comment);
@@ -85,7 +85,7 @@ public class BitbucketApiClient {
deleteRequest(path);
}
- public BitbucketPullRequestApproval postPullRequestApproval(String pullRequestId) {
+ public Pullrequest.Participant postPullRequestApproval(String pullRequestId) {
String path = V2_API_BASE_URL + this.owner + "/" + this.repositoryName + "/pullrequests/" + pullRequestId + "/approve";
try {
String response = postRequest(path, new NameValuePair[]{});
@@ -166,38 +166,38 @@ public class BitbucketApiClient {
}
- private BitbucketPullRequestResponse parsePullRequestJson(String response) throws IOException {
+ private Pullrequest.Response parsePullRequestJson(String response) throws IOException {
ObjectMapper mapper = new ObjectMapper();
- BitbucketPullRequestResponse parsedResponse;
- parsedResponse = mapper.readValue(response, BitbucketPullRequestResponse.class);
+ Pullrequest.Response parsedResponse;
+ parsedResponse = mapper.readValue(response, Pullrequest.Response.class);
return parsedResponse;
}
- private List<BitbucketPullRequestComment> parseCommentJson(String response) throws IOException {
+ private List<Pullrequest.Comment> parseCommentJson(String response) throws IOException {
ObjectMapper mapper = new ObjectMapper();
- List<BitbucketPullRequestComment> parsedResponse;
+ List<Pullrequest.Comment> parsedResponse;
parsedResponse = mapper.readValue(
response,
- new TypeReference<List<BitbucketPullRequestComment>>() {
+ new TypeReference<List<Pullrequest.Comment>>() {
});
return parsedResponse;
}
- private BitbucketPullRequestComment parseSingleCommentJson(String response) throws IOException {
+ private Pullrequest.Comment parseSingleCommentJson(String response) throws IOException {
ObjectMapper mapper = new ObjectMapper();
- BitbucketPullRequestComment parsedResponse;
+ Pullrequest.Comment parsedResponse;
parsedResponse = mapper.readValue(
response,
- BitbucketPullRequestComment.class);
+ Pullrequest.Comment.class);
return parsedResponse;
}
- private BitbucketPullRequestApproval parseApprovalJson(String response) throws IOException {
+ private Pullrequest.Participant parseApprovalJson(String response) throws IOException {
ObjectMapper mapper = new ObjectMapper();
- BitbucketPullRequestApproval parsedResponse;
+ Pullrequest.Participant parsedResponse;
parsedResponse = mapper.readValue(
response,
- BitbucketPullRequestApproval.class);
+ Pullrequest.Participant.class);
return parsedResponse;
}
}
diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketPullRequestApproval.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketPullRequestApproval.java
deleted file mode 100644
index a7fe813..0000000
--- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketPullRequestApproval.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package bitbucketpullrequestbuilder.bitbucketpullrequestbuilder.bitbucket;
-
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
-
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class BitbucketPullRequestApproval {
- private String role;
- private Boolean approved;
-
- @JsonProperty("role")
- public String getRole() {
- return role;
- }
-
- @JsonProperty("approved")
- public Boolean getApproved() {
- return approved;
- }
-}
diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketPullRequestComment.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketPullRequestComment.java
deleted file mode 100644
index 2e1e18e..0000000
--- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketPullRequestComment.java
+++ /dev/null
@@ -1,118 +0,0 @@
-package bitbucketpullrequestbuilder.bitbucketpullrequestbuilder.bitbucket;
-
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
-
-import java.util.Comparator;
-
-/**
- * Created by nishio
- */
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class BitbucketPullRequestComment implements Comparable<BitbucketPullRequestComment> {
- private Boolean isEntityAuthor;
- private Integer pullRequestId;
- private String contentRendered;
- private Boolean deleted;
- private String UtcLastUpdated;
- private Integer commentId;
- private String content;
- private String UtcCreatedOn;
- private Boolean isSpam;
-
- @JsonProperty("is_entity_author")
- public Boolean getIsEntityAuthor() {
- return isEntityAuthor;
- }
-
- @JsonProperty("is_entity_author")
- public void setIsEntityAuthor(Boolean isEntityAuthor) {
- this.isEntityAuthor = isEntityAuthor;
- }
-
- @JsonProperty("pull_request_id")
- public Integer getPullRequestId() {
- return pullRequestId;
- }
-
- @JsonProperty("pull_request_id")
- public void setPullRequestId(Integer pullRequestId) {
- this.pullRequestId = pullRequestId;
- }
-
- @JsonProperty("content_rendered")
- public String getContentRendered() {
- return contentRendered;
- }
-
- @JsonProperty("content_rendered")
- public void setContentRendered(String contentRendered) {
- this.contentRendered = contentRendered;
- }
-
- public Boolean getDeleted() {
- return deleted;
- }
-
- public void setDeleted(Boolean deleted) {
- this.deleted = deleted;
- }
-
- @JsonProperty("utc_last_updated")
- public String getUtcLastUpdated() {
- return UtcLastUpdated;
- }
-
- @JsonProperty("utc_last_updated")
- public void setUtcLastUpdated(String utcLastUpdated) {
- UtcLastUpdated = utcLastUpdated;
- }
-
- @JsonProperty("comment_id")
- public Integer getCommentId() {
- return commentId;
- }
-
- @JsonProperty("comment_id")
- public void setCommentId(Integer commentId) {
- this.commentId = commentId;
- }
-
- public String getContent() {
- return content;
- }
-
- public void setContent(String content) {
- this.content = content;
- }
-
- @JsonProperty("utc_created_on")
- public String getUtcCreatedOn() {
- return UtcCreatedOn;
- }
-
- @JsonProperty("utc_created_on")
- public void setUtcCreatedOn(String utcCreatedOn) {
- UtcCreatedOn = utcCreatedOn;
- }
-
- @JsonProperty("is_spam")
- public Boolean getIsSpam() {
- return isSpam;
- }
-
- @JsonProperty("is_spam")
- public void setIsSpam(Boolean isSpam) {
- this.isSpam = isSpam;
- }
-
- public int compareTo(BitbucketPullRequestComment target) {
- if (this.getCommentId() > target.getCommentId()) {
- return 1;
- } else if (this.getCommentId().equals(target.getCommentId())) {
- return 0;
- } else {
- return -1;
- }
- }
-}
diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketPullRequestResponse.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketPullRequestResponse.java
deleted file mode 100644
index 82e6009..0000000
--- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketPullRequestResponse.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package bitbucketpullrequestbuilder.bitbucketpullrequestbuilder.bitbucket;
-
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
-
-import java.util.List;
-
-/**
- * Created by nishio
- */
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class BitbucketPullRequestResponse {
- private int pageLength;
- private List<BitbucketPullRequestResponseValue> prValues;
- private int page;
- private int size;
-
- @JsonProperty("pagelen")
- public int getPageLength() {
- return pageLength;
- }
-
- @JsonProperty("pagelen")
- public void setPageLength(int pageLength) {
- this.pageLength = pageLength;
- }
-
- @JsonProperty("values")
- public List<BitbucketPullRequestResponseValue> getPrValues() {
- return prValues;
- }
-
- @JsonProperty("values")
- public void setPrValues(List<BitbucketPullRequestResponseValue> prValues) {
- this.prValues = prValues;
- }
-
- @JsonProperty("page")
- public int getPage() {
- return page;
- }
-
- @JsonProperty("page")
- public void setPage(int page) {
- this.page = page;
- }
-
- @JsonProperty("size")
- public int getSize() {
- return size;
- }
-
- @JsonProperty("size")
- public void setSize(int size) {
- this.size = size;
- }
-
-}
diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketPullRequestResponseValue.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketPullRequestResponseValue.java
deleted file mode 100644
index e8be708..0000000
--- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketPullRequestResponseValue.java
+++ /dev/null
@@ -1,130 +0,0 @@
-package bitbucketpullrequestbuilder.bitbucketpullrequestbuilder.bitbucket;
-
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
-
-/**
- * Created by nishio
- */
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class BitbucketPullRequestResponseValue {
- private String description;
- private Boolean closeSourceBranch;
- private String title;
- private BitbucketPullRequestResponseValueRepository destination;
- private String reason;
- private String closedBy;
- private BitbucketPullRequestResponseValueRepository source;
- private String state;
- private String createdOn;
- private String updatedOn;
- private String mergeCommit;
- private String id;
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- @JsonProperty("close_source_branch")
- public Boolean getCloseSourceBranch() {
- return closeSourceBranch;
- }
-
- @JsonProperty("close_source_branch")
- public void setCloseSourceBranch(Boolean closeSourceBranch) {
- this.closeSourceBranch = closeSourceBranch;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public BitbucketPullRequestResponseValueRepository getDestination() {
- return destination;
- }
-
- public void setDestination(BitbucketPullRequestResponseValueRepository destination) {
- this.destination = destination;
- }
-
- public String getReason() {
- return reason;
- }
-
- public void setReason(String reason) {
- this.reason = reason;
- }
-
- @JsonProperty("closed_by")
- public String getClosedBy() {
- return closedBy;
- }
-
- @JsonProperty("closed_by")
- public void setClosedBy(String closedBy) {
- this.closedBy = closedBy;
- }
-
- public BitbucketPullRequestResponseValueRepository getSource() {
- return source;
- }
-
- public void setSource(BitbucketPullRequestResponseValueRepository source) {
- this.source = source;
- }
-
- public String getState() {
- return state;
- }
-
- public void setState(String state) {
- this.state = state;
- }
-
- @JsonProperty("created_on")
- public String getCreatedOn() {
- return createdOn;
- }
-
- @JsonProperty("created_on")
- public void setCreatedOn(String createdOn) {
- this.createdOn = createdOn;
- }
-
- @JsonProperty("updated_on")
- public String getUpdatedOn() {
- return updatedOn;
- }
-
- @JsonProperty("updated_on")
- public void setUpdatedOn(String updatedOn) {
- this.updatedOn = updatedOn;
- }
-
- @JsonProperty("merge_commit")
- public String getMergeCommit() {
- return mergeCommit;
- }
-
- @JsonProperty("merge_commit")
- public void setMergeCommit(String mergeCommit) {
- this.mergeCommit = mergeCommit;
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
-}
diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketPullRequestResponseValueRepository.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketPullRequestResponseValueRepository.java
deleted file mode 100644
index f97c010..0000000
--- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketPullRequestResponseValueRepository.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package bitbucketpullrequestbuilder.bitbucketpullrequestbuilder.bitbucket;
-
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
-
-/**
- * Created by nishio
- */
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class BitbucketPullRequestResponseValueRepository {
- private BitbucketPullRequestResponseValueRepositoryRepository repository;
- private BitbucketPullRequestResponseValueRepositoryBranch branch;
- private BitbucketPullRequestResponseValueRepositoryCommit commit;
-
- @JsonProperty("repository")
- public BitbucketPullRequestResponseValueRepositoryRepository getRepository() {
- return repository;
- }
-
- @JsonProperty("repository")
- public void setRepository(BitbucketPullRequestResponseValueRepositoryRepository repository) {
- this.repository = repository;
- }
-
- @JsonProperty("branch")
- public BitbucketPullRequestResponseValueRepositoryBranch getBranch() {
- return branch;
- }
-
- @JsonProperty("branch")
- public void setBranch(BitbucketPullRequestResponseValueRepositoryBranch branch) {
- this.branch = branch;
- }
-
- @JsonProperty("commit")
- public BitbucketPullRequestResponseValueRepositoryCommit getCommit() {
- return commit;
- }
-
- @JsonProperty("commit")
- public void setCommit(BitbucketPullRequestResponseValueRepositoryCommit commit) {
- this.commit = commit;
- }
-}
-
-
diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketPullRequestResponseValueRepositoryBranch.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketPullRequestResponseValueRepositoryBranch.java
deleted file mode 100644
index 2fa2eee..0000000
--- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketPullRequestResponseValueRepositoryBranch.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package bitbucketpullrequestbuilder.bitbucketpullrequestbuilder.bitbucket;
-
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class BitbucketPullRequestResponseValueRepositoryBranch {
- private String Name;
-
- public String getName() {
- return Name;
- }
-
- public void setName(String name) {
- Name = name;
- }
-} \ No newline at end of file
diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketPullRequestResponseValueRepositoryCommit.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketPullRequestResponseValueRepositoryCommit.java
deleted file mode 100644
index 5846d71..0000000
--- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketPullRequestResponseValueRepositoryCommit.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package bitbucketpullrequestbuilder.bitbucketpullrequestbuilder.bitbucket;
-
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class BitbucketPullRequestResponseValueRepositoryCommit {
- private String Hash;
-
- public String getHash() {
- return Hash;
- }
-
- public void setHash(String hash) {
- Hash = hash;
- }
-} \ No newline at end of file
diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketPullRequestResponseValueRepositoryRepository.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketPullRequestResponseValueRepositoryRepository.java
deleted file mode 100644
index d8ff67e..0000000
--- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketPullRequestResponseValueRepositoryRepository.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package bitbucketpullrequestbuilder.bitbucketpullrequestbuilder.bitbucket;
-
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
-
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class BitbucketPullRequestResponseValueRepositoryRepository {
- private String fullName;
- private String name;
-
- @JsonProperty("full_name")
- public String getFullName() {
- return fullName;
- }
-
- @JsonProperty("full_name")
- public void setFullName(String fullName) {
- this.fullName = fullName;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getOwnerName() {
- if (this.fullName != null) {
- return this.fullName.split("/")[0];
- }
- return null;
- }
-
- public String getRepositoryName() {
- if (this.fullName != null) {
- return this.fullName.split("/")[1];
- }
- return null;
- }
-}
-
diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/Pullrequest.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/Pullrequest.java
new file mode 100644
index 0000000..1e8bf5c
--- /dev/null
+++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/Pullrequest.java
@@ -0,0 +1,345 @@
+package bitbucketpullrequestbuilder.bitbucketpullrequestbuilder.bitbucket;
+
+import java.util.List;
+import java.util.Comparator;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * POJOs representing the pull-requests extracted from the
+ * JSON response of the Bitbucket API V2.
+ *
+ * @see https://confluence.atlassian.com/bitbucket/pullrequests-resource-423626332.html#pullrequestsResource-GETaspecificpullrequest
+ */
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Pullrequest {
+
+ private String description;
+ private Boolean closeSourceBranch;
+ private String title;
+ private Revision destination;
+ private String reason;
+ private String closedBy;
+ private Revision source;
+ private String state;
+ private String createdOn;
+ private String updatedOn;
+ private String mergeCommit;
+ private String id;
+
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ public static class Response {
+ private int pageLength;
+ private List<Pullrequest> pullrequests;
+ private int page;
+ private int size;
+
+ @JsonProperty("pagelen")
+ public int getPageLength() {
+ return pageLength;
+ }
+ @JsonProperty("pagelen")
+ public void setPageLength(int pageLength) {
+ this.pageLength = pageLength;
+ }
+ @JsonProperty("values")
+ public List<Pullrequest> getPullrequests() {
+ return pullrequests;
+ }
+ @JsonProperty("values")
+ public void setPullrequests(List<Pullrequest> pullrequests) {
+ this.pullrequests = pullrequests;
+ }
+ public int getPage() {
+ return page;
+ }
+ public void setPage(int page) {
+ this.page = page;
+ }
+ public int getSize() {
+ return size;
+ }
+ public void setSize(int size) {
+ this.size = size;
+ }
+ }
+
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ public static class Revision {
+ private Repository repository;
+ private Branch branch;
+ private Commit commit;
+
+ public Repository getRepository() {
+ return repository;
+ }
+ public void setRepository(Repository repository) {
+ this.repository = repository;
+ }
+ public Branch getBranch() {
+ return branch;
+ }
+ public void setBranch(Branch branch) {
+ this.branch = branch;
+ }
+ public Commit getCommit() {
+ return commit;
+ }
+ public void setCommit(Commit commit) {
+ this.commit = commit;
+ }
+ }
+
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ public static class Repository {
+ private String fullName;
+ private String name;
+ private String ownerName;
+ private String repositoryName;
+
+ @JsonProperty("full_name")
+ public String getFullName() {
+ return fullName;
+ }
+ @JsonProperty("full_name")
+ public void setFullName(String fullName) {
+ // Also extract owner- and reponame
+ if (name != null) {
+ this.ownerName = fullName.split("/")[0];
+ this.repositoryName = fullName.split("/")[1];
+ }
+ this.fullName = fullName;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public String getOwnerName() {
+ return ownerName;
+ }
+ public String getRepositoryName() {
+ return repositoryName;
+ }
+ }
+
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ public static class Branch {
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+ }
+
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ public static class Commit {
+ private String hash;
+
+ public String getHash() {
+ return hash;
+ }
+
+ public void setHash(String hash) {
+ this.hash = hash;
+ }
+ }
+
+ // Was: Approval
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ public static class Participant {
+ private String role;
+ private Boolean approved;
+
+ public String getRole() {
+ return role;
+ }
+ public void setRole(String role) {
+ this.role = role;
+ }
+ public Boolean getApproved() {
+ return approved;
+ }
+ public void setApproved(Boolean approved) {
+ this.approved = approved;
+ }
+ }
+
+ // https://confluence.atlassian.com/bitbucket/pullrequests-resource-1-0-296095210.html#pullrequestsResource1.0-POSTanewcomment
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ public static class Comment implements Comparable<Comment> {
+ private Integer id;
+ private String filename;
+ private String content;
+ private String updatedOn;
+ private String createdOn;
+
+ public int compareTo(Comment target) {
+ if (this.getId() > target.getId()) {
+ return 1;
+ } else if (this.getId().equals(target.getId())) {
+ return 0;
+ } else {
+ return -1;
+ }
+ }
+
+ @JsonProperty("comment_id")
+ public Integer getId() {
+ return id;
+ }
+
+ @JsonProperty("comment_id")
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getFilename() {
+ return filename;
+ }
+
+ public void setFilename(String filename) {
+ this.filename = filename;
+ }
+
+ public String getContent() {
+ return content;
+ }
+
+ public void setContent(String content) {
+ this.content = content;
+ }
+ @JsonProperty("utc_last_updated")
+ public String getUpdatedOn() {
+ return updatedOn;
+ }
+ @JsonProperty("utc_last_updated")
+ public void setUpdatedOn(String updatedOn) {
+ this.updatedOn = updatedOn;
+ }
+ @JsonProperty("utc_created_on")
+ public String getCreatedOn() {
+ return createdOn;
+ }
+ @JsonProperty("utc_created_on")
+ public void setCreatedOn(String createdOn) {
+ this.createdOn = createdOn;
+ }
+ }
+
+ //-------------------- only getters and setters follow -----------------
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ @JsonProperty("close_source_branch")
+ public Boolean getCloseSourceBranch() {
+ return closeSourceBranch;
+ }
+
+ @JsonProperty("close_source_branch")
+ public void setCloseSourceBranch(Boolean closeSourceBranch) {
+ this.closeSourceBranch = closeSourceBranch;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public Revision getDestination() {
+ return destination;
+ }
+
+ public void setDestination(Revision destination) {
+ this.destination = destination;
+ }
+
+ public String getReason() {
+ return reason;
+ }
+
+ public void setReason(String reason) {
+ this.reason = reason;
+ }
+
+ @JsonProperty("closed_by")
+ public String getClosedBy() {
+ return closedBy;
+ }
+
+ @JsonProperty("closed_by")
+ public void setClosedBy(String closedBy) {
+ this.closedBy = closedBy;
+ }
+
+ public Revision getSource() {
+ return source;
+ }
+
+ public void setSource(Revision source) {
+ this.source = source;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
+ @JsonProperty("created_on")
+ public String getCreatedOn() {
+ return createdOn;
+ }
+
+ @JsonProperty("created_on")
+ public void setCreatedOn(String createdOn) {
+ this.createdOn = createdOn;
+ }
+
+ @JsonProperty("updated_on")
+ public String getUpdatedOn() {
+ return updatedOn;
+ }
+
+ @JsonProperty("updated_on")
+ public void setUpdatedOn(String updatedOn) {
+ this.updatedOn = updatedOn;
+ }
+
+ @JsonProperty("merge_commit")
+ public String getMergeCommit() {
+ return mergeCommit;
+ }
+
+ @JsonProperty("merge_commit")
+ public void setMergeCommit(String mergeCommit) {
+ this.mergeCommit = mergeCommit;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+}