本文整理匯總了Java中org.kohsuke.github.GHRepository.hasPullAccess方法的典型用法代碼示例。如果您正苦於以下問題:Java GHRepository.hasPullAccess方法的具體用法?Java GHRepository.hasPullAccess怎麽用?Java GHRepository.hasPullAccess使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.kohsuke.github.GHRepository
的用法示例。
在下文中一共展示了GHRepository.hasPullAccess方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: withPermission
import org.kohsuke.github.GHRepository; //導入方法依賴的package包/類
private NullSafePredicate<GitHub> withPermission(final GitHubRepositoryName name, GHPermission permission) {
return new NullSafePredicate<GitHub>() {
@Override
protected boolean applyNullSafe(@Nonnull GitHub gh) {
try {
final GHRepository repo = gh.getRepository(name.getUserName() + "/" + name.getRepositoryName());
if (permission == GHPermission.ADMIN) {
return repo.hasAdminAccess();
} else if (permission == GHPermission.PUSH) {
return repo.hasPushAccess();
} else {
return repo.hasPullAccess();
}
} catch (IOException e) {
return false;
}
}
};
}
示例2: doAction
import org.kohsuke.github.GHRepository; //導入方法依賴的package包/類
@Override
public void doAction(
IdentifiedUser user,
GitHubLogin hubLogin,
HttpServletRequest req,
HttpServletResponse resp,
ControllerErrors errors)
throws ServletException, IOException {
String organisation = req.getParameter("organisation");
JsonArray jsonRepos = new JsonArray();
int numRepos = 0;
PagedIterator<GHRepository> repoIter = getRepositories(hubLogin, organisation).iterator();
while (repoIter.hasNext() && numRepos < config.repositoryListLimit) {
GHRepository ghRepository = repoIter.next();
if (ghRepository.hasPushAccess() && ghRepository.hasPullAccess()) {
JsonObject repository = new JsonObject();
String projectName = organisation + "/" + ghRepository.getName();
if (projects.get(Project.NameKey.parse(projectName)) == null) {
repository.add("name", new JsonPrimitive(ghRepository.getName()));
repository.add("organisation", new JsonPrimitive(organisation));
repository.add(
"description", new JsonPrimitive(Strings.nullToEmpty(ghRepository.getDescription())));
repository.add("private", new JsonPrimitive(new Boolean(ghRepository.isPrivate())));
jsonRepos.add(repository);
numRepos++;
}
} else {
log.warn(
"Skipping repository {} because user {} has no push/pull access to it",
ghRepository.getName(),
user.getUserName());
}
}
resp.getWriter().println(jsonRepos.toString());
}
示例3: doCheckRepoAccess
import org.kohsuke.github.GHRepository; //導入方法依賴的package包/類
public FormValidation doCheckRepoAccess(
@QueryParameter("serverAPIUrl") final String serverAPIUrl,
@QueryParameter("credentialsId") final String credentialsId,
@QueryParameter("repo") final String repo) {
try {
GitHubBuilder builder = getBuilder(null, serverAPIUrl, credentialsId);
if (builder == null) {
return FormValidation.error("Unable to look up GitHub credentials using ID: " + credentialsId + "!!");
}
GitHub gh = builder.build();
GHRepository repository = gh.getRepository(repo);
StringBuilder sb = new StringBuilder();
sb.append("User has access to: ");
List<String> permissions = new ArrayList<String>(3);
if (repository.hasAdminAccess()) {
permissions.add("Admin");
}
if (repository.hasPushAccess()) {
permissions.add("Push");
}
if (repository.hasPullAccess()) {
permissions.add("Pull");
}
sb.append(Joiner.on(", ").join(permissions));
return FormValidation.ok(sb.toString());
} catch (Exception ex) {
return FormValidation.error("Unable to connect to GitHub API: " + ex);
}
}