public static <T extends ProjectEntity, P extends ProjectFunction> BiPredicate<T, ResourceContext> withProjectFn(Class<P> projectFn) { return (T e, ResourceContext resourceContext) -> resourceContext.isProjectFunctionGranted(e, projectFn); }
/** * Checks if the <code>fn</code> function is granted for the current user * for the <code>projectEntity</code>'s project. */ default boolean isProjectFunctionGranted(ProjectEntity projectEntity, Class<? extends ProjectFunction> fn) { return isProjectFunctionGranted(projectEntity.projectId(), fn); }
@Override public List<LinkDefinition<Branch>> getLinkDefinitions() { return Collections.singletonList( LinkDefinitions.link( "_download", branch -> MvcUriComponentsBuilder.on(SVNController.class).download( branch.getId(), "" ), (branch, rc) -> rc.isProjectFunctionGranted(branch, ProjectConfig.class) && svnService.getSVNRepository(branch).isPresent() ) ); }
@Override public List<LinkDefinition<Build>> getLinkDefinitions() { return Arrays.asList( LinkDefinitions.link( "_changeLog", build -> { BuildDiffRequest request = new BuildDiffRequest(); request.setFrom(build.getId()); return MvcUriComponentsBuilder.on(SVNController.class).changeLog(request); }, (build, rc) -> rc.isProjectFunctionGranted(build, ProjectView.class) && svnService.getSVNRepository(build.getBranch()).isPresent() ), LinkDefinitions.page( "_changeLogPage", (build, resourceContext) -> resourceContext.isProjectFunctionGranted(build, ProjectView.class) && svnService.getSVNRepository(build.getBranch()).isPresent(), "extension/svn/changelog" ) ); }