Search in sources :

Example 1 with LinkBuilder

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());
        }
    }
}
Also used : Repository(sonia.scm.repository.Repository) LinkBuilder(sonia.scm.api.v2.resources.LinkBuilder)

Example 2 with LinkBuilder

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);
}
Also used : LinkBuilder(sonia.scm.api.v2.resources.LinkBuilder)

Example 3 with LinkBuilder

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);
}
Also used : LinkBuilder(sonia.scm.api.v2.resources.LinkBuilder)

Example 4 with LinkBuilder

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);
}
Also used : LinkBuilder(sonia.scm.api.v2.resources.LinkBuilder)

Example 5 with LinkBuilder

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());
}
Also used : LinkBuilder(sonia.scm.api.v2.resources.LinkBuilder) LinkBuilder(sonia.scm.api.v2.resources.LinkBuilder) Links(de.otto.edison.hal.Links) ObjectFactory(org.mapstruct.ObjectFactory)

Aggregations

LinkBuilder (sonia.scm.api.v2.resources.LinkBuilder)9 Links (de.otto.edison.hal.Links)2 ObjectFactory (org.mapstruct.ObjectFactory)2 GlobalConfigResource (com.cloudogu.scm.review.config.api.GlobalConfigResource)1 GlobalEngineConfigResource (com.cloudogu.scm.review.workflow.GlobalEngineConfigResource)1 Repository (sonia.scm.repository.Repository)1