use of sonia.scm.api.v2.resources.LinkBuilder in project scm-review-plugin by scm-manager.
the class RepositoryLinkEnricher method enrich.
@Override
public void enrich(HalEnricherContext context, HalAppender appender) {
Repository repository = context.oneRequireByType(Repository.class);
if (pullRequestService.supportsPullRequests(repository)) {
if (mayRead(repository)) {
LinkBuilder linkBuilder = new LinkBuilder(scmPathInfoStore.get().get(), PullRequestRootResource.class);
appender.appendLink("pullRequest", linkBuilder.method("getAll").parameters(repository.getNamespace(), repository.getName()).href());
}
if (mayCreate(repository)) {
LinkBuilder linkBuilder = new LinkBuilder(scmPathInfoStore.get().get(), PullRequestRootResource.class);
appender.appendLink("pullRequestCheck", linkBuilder.method("check").parameters(repository.getNamespace(), repository.getName()).href());
}
if (mayConfigure(repository) && !configService.getGlobalPullRequestConfig().isDisableRepositoryConfiguration()) {
LinkBuilder linkBuilder = new LinkBuilder(scmPathInfoStore.get().get(), RepositoryConfigResource.class);
appender.appendLink("pullRequestConfig", linkBuilder.method("getRepositoryConfig").parameters(repository.getNamespace(), repository.getName()).href());
}
if (isWorkflowEngineConfigurable(repository)) {
LinkBuilder linkBuilder = new LinkBuilder(scmPathInfoStore.get().get(), RepositoryEngineConfigResource.class);
appender.appendLink("workflowConfig", linkBuilder.method("getRepositoryEngineConfig").parameters(repository.getNamespace(), repository.getName()).href());
}
}
}
use of sonia.scm.api.v2.resources.LinkBuilder in project scm-review-plugin by scm-manager.
the class CommentPathBuilder method createReplyCommentUri.
String createReplyCommentUri(String namespace, String name, String pullRequestId, String commentId, BranchRevisionResolver.RevisionResult revisions) {
LinkBuilder linkBuilder = new LinkBuilder(pathInfoStore.get().get(), PullRequestRootResource.class, PullRequestResource.class, CommentRootResource.class, CommentResource.class);
String link = linkBuilder.method("getPullRequestResource").parameters(namespace, name, pullRequestId).method("comments").parameters().method("getCommentResource").parameters(commentId).method("reply").parameters().href();
return append(link, revisions);
}
use of sonia.scm.api.v2.resources.LinkBuilder in project scm-review-plugin by scm-manager.
the class CommentPathBuilder method createDeleteReplyUri.
String createDeleteReplyUri(String namespace, String name, String pullRequestId, String commentId, String replyId, BranchRevisionResolver.RevisionResult revisions) {
LinkBuilder linkBuilder = new LinkBuilder(pathInfoStore.get().get(), PullRequestRootResource.class, PullRequestResource.class, CommentRootResource.class, CommentResource.class);
String link = linkBuilder.method("getPullRequestResource").parameters(namespace, name, pullRequestId).method("comments").parameters().method("getCommentResource").parameters(commentId).method("deleteReply").parameters(replyId).href();
return append(link, revisions);
}
use of sonia.scm.api.v2.resources.LinkBuilder in project scm-review-plugin by scm-manager.
the class CommentPathBuilder method createUpdateReplyUri.
String createUpdateReplyUri(String namespace, String name, String pullRequestId, String commentId, String replyId, BranchRevisionResolver.RevisionResult revisions) {
LinkBuilder linkBuilder = new LinkBuilder(pathInfoStore.get().get(), PullRequestRootResource.class, PullRequestResource.class, CommentRootResource.class, CommentResource.class);
String link = linkBuilder.method("getPullRequestResource").parameters(namespace, name, pullRequestId).method("comments").parameters().method("getCommentResource").parameters(commentId).method("updateReply").parameters(replyId).href();
return append(link, revisions);
}
use of sonia.scm.api.v2.resources.LinkBuilder in project scm-review-plugin by scm-manager.
the class GlobalConfigMapper method createForGlobal.
@ObjectFactory
GlobalPullRequestConfigDto createForGlobal(@Context UriInfo uriInfo) {
LinkBuilder linkBuilder = new LinkBuilder(uriInfo::getBaseUri, GlobalConfigResource.class);
Links.Builder halLinks = new Links.Builder();
halLinks.self(linkBuilder.method("getGlobalConfig").parameters().href());
if (PermissionCheck.mayWriteGlobalConfig()) {
halLinks.single(Link.link("update", linkBuilder.method("setGlobalConfig").parameters().href()));
}
return new GlobalPullRequestConfigDto(halLinks.build());
}
Aggregations