code
stringlengths
23
201k
docstring
stringlengths
17
96.2k
func_name
stringlengths
0
235
language
stringclasses
1 value
repo
stringlengths
8
72
path
stringlengths
11
317
url
stringlengths
57
377
license
stringclasses
7 values
public static boolean canManageCodeComments(Project project) { return canManageCodeComments(getSubject(), project); }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
canManageCodeComments
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static boolean canManageCodeComments(Subject subject, Project project) { return subject.isPermitted(new ProjectPermission(project, new ManageCodeComments())); }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
canManageCodeComments
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static boolean canManageBuild(Build build) { return getSubject().isPermitted(new ProjectPermission(build.getProject(), new JobPermission(build.getJobName(), new ManageJob()))); }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
canManageBuild
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static boolean canUploadCache(Project project) { return canUploadCache(getSubject(), project); }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
canUploadCache
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static boolean canUploadCache(Subject subject, Project project) { return subject.isPermitted(new ProjectPermission(project, new UploadCache())); }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
canUploadCache
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static boolean canAccessLog(Build build) { return getSubject().isPermitted(new ProjectPermission(build.getProject(), new JobPermission(build.getJobName(), new AccessBuildLog()))); }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
canAccessLog
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static boolean canAccessPipeline(Build build) { return getSubject().isPermitted(new ProjectPermission(build.getProject(), new JobPermission(build.getJobName(), new AccessBuildPipeline()))); }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
canAccessPipeline
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static boolean canAccessBuild(Build build) { return canAccessJob(build.getProject(), build.getJobName()); }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
canAccessBuild
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static boolean canAccessJob(Project project, String jobName) { return getSubject().isPermitted(new ProjectPermission(project, new JobPermission(jobName, new AccessBuild()))); }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
canAccessJob
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static boolean canReadPack(Project project) { return getSubject().isPermitted(new ProjectPermission(project, new ReadPack())); }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
canReadPack
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static boolean canAccessReport(Build build, String reportName) { return getSubject().isPermitted(new ProjectPermission(build.getProject(), new JobPermission(build.getJobName(), new AccessBuildReports(reportName)))); }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
canAccessReport
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static boolean canRunJob(Project project, String jobName) { return getSubject().isPermitted(new ProjectPermission(project, new JobPermission(jobName, new RunJob()))); }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
canRunJob
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static boolean canWritePack(Project project) { return getSubject().isPermitted(new ProjectPermission(project, new WritePack())); }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
canWritePack
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static boolean isAdministrator() { return isAdministrator(getSubject()); }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
isAdministrator
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static boolean isAdministrator(Subject subject) { return subject.isPermitted(new SystemAdministration()); }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
isAdministrator
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static boolean canModifyOrDelete(CodeComment comment) { var subject = getSubject(); return canManageCodeComments(subject, comment.getProject()) || comment.getUser().equals(getAuthUser(subject)); }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
canModifyOrDelete
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static boolean canModifyOrDelete(CodeCommentReply reply) { var subject = getSubject(); return canManageCodeComments(subject, reply.getComment().getProject()) || reply.getUser().equals(getAuthUser(subject)); }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
canModifyOrDelete
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static boolean canModifyOrDelete(PullRequestComment comment) { var subject = getSubject(); return canManagePullRequests(subject, comment.getRequest().getTargetProject()) || comment.getUser().equals(getAuthUser(subject)); }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
canModifyOrDelete
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static boolean canModifyOrDelete(IssueComment comment) { var subject = getSubject(); return canManageIssues(subject, comment.getIssue().getProject()) || comment.getUser().equals(getAuthUser(subject)); }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
canModifyOrDelete
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static boolean canModifyOrDelete(IssueWork work) { var subject = getSubject(); return canManageIssues(subject, work.getIssue().getProject()) || work.getUser().equals(getAuthUser(subject)); }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
canModifyOrDelete
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static boolean canModifyOrDelete(IssueVote vote) { var subject = getSubject(); return canManageIssues(subject, vote.getIssue().getProject()) || vote.getUser().equals(getAuthUser(subject)); }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
canModifyOrDelete
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static boolean canModifyOrDelete(IssueWatch watch) { var subject = getSubject(); return canManageIssues(subject, watch.getIssue().getProject()) || watch.getUser().equals(getAuthUser(subject)); }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
canModifyOrDelete
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static boolean canModifyOrDelete(PullRequestWatch watch) { var subject = getSubject(); return canManagePullRequests(subject, watch.getRequest().getProject()) || watch.getUser().equals(getAuthUser(subject)); }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
canModifyOrDelete
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static boolean canModifyOrDelete(PullRequestReview review) { var subject = getSubject(); return canManagePullRequests(subject, review.getRequest().getProject()) || review.getUser().equals(getAuthUser(subject)); }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
canModifyOrDelete
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static boolean canModifyPullRequest(PullRequest request) { var subject = getSubject(); var user = getAuthUser(subject); return canManagePullRequests(subject, request.getTargetProject()) || user != null && (user.equals(request.getSubmitter()) || request.getAssignees().contains(user)); }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
canModifyPullRequest
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static boolean canModifyIssue(Issue issue) { var subject = getSubject(); return canManageIssues(subject, issue.getProject()) || issue.getSubmitter().equals(getAuthUser(subject)); }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
canModifyIssue
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static Runnable inheritSubject(Runnable task) { Subject subject = SecurityUtils.getSubject(); return () -> { ThreadContext.bind(subject); task.run(); }; }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
inheritSubject
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static String getPrevPrincipal() { PrincipalCollection prevPrincipals = SecurityUtils.getSubject().getPreviousPrincipals(); if (prevPrincipals != null) return (String) prevPrincipals.getPrimaryPrincipal(); else return PRINCIPAL_ANONYMOUS; }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
getPrevPrincipal
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static <T> PrioritizedCallable<T> inheritSubject(PrioritizedCallable<T> task) { Subject subject = SecurityUtils.getSubject(); return new PrioritizedCallable<T>(task.getPriority()) { @Override public T call() throws Exception { ThreadContext.bind(subject); return task.call(); } }; }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
inheritSubject
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
@Override public T call() throws Exception { ThreadContext.bind(subject); return task.call(); }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
call
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
@Nullable public static String getBearerToken(HttpServletRequest request) { String authHeader = request.getHeader(KubernetesHelper.AUTHORIZATION); if (authHeader == null) authHeader = request.getHeader(HttpHeaders.AUTHORIZATION); if (authHeader != null) { if (authHeader.startsWith(KubernetesHelper.BEARER +...
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
getBearerToken
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
private static void addIdsPermittedByDefaultRole(ProjectCache cache, Collection<Long> projectIds, Permission permission) { var roleManager = OneDev.getInstance(RoleManager.class); for (ProjectFacade project : cache.values()) { if (project.getDefaultRoleId() != null) { Role defaultRole = roleMana...
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
addIdsPermittedByDefaultRole
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
private static void addSubTreeIds(Collection<Long> projectIds, Project project) { projectIds.add(project.getId()); for (Project descendant : project.getDescendants()) projectIds.add(descendant.getId()); }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
addSubTreeIds
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static Collection<Project> getAuthorizedProjects(BasePermission permission) { return getAuthorizedProjects(getSubject(), permission); }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
getAuthorizedProjects
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
private static SettingManager getSettingManager() { return OneDev.getInstance(SettingManager.class); }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
getSettingManager
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static Collection<Project> getAuthorizedProjects(Subject subject, BasePermission permission) { var projectManager = OneDev.getInstance(ProjectManager.class); String principal = (String) subject.getPrincipal(); var user = getAuthUser(principal); var accessToken = getAccessToken(principal); if (permissio...
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
getAuthorizedProjects
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
private static Collection<User> filterApplicableUsers(Collection<User> users, BasePermission permission) { return users.stream().filter(it -> permission.isApplicable(it.getFacade())).collect(toList()); }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
filterApplicableUsers
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static Collection<User> getAuthorizedUsers(Project project, BasePermission permission) { var userManager = OneDev.getInstance(UserManager.class); UserCache cache = userManager.cloneCache(); Collection<User> authorizedUsers = Sets.newHashSet(userManager.getRoot()); for (Group group: OneDev.getInstance(G...
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
getAuthorizedUsers
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
private static void populateAccessibleJobNames(Collection<String> accessibleJobNames, Collection<String> availableJobNames, Role role) { for (String jobName: availableJobNames) { if (role.implies(new JobPermission(jobName, new AccessBuild()))) accessibleJobNames.add(jobName); } }
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
populateAccessibleJobNames
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static Collection<String> getAccessibleJobNames(Project project, Collection<String> availableJobNames) { Collection<String> accessibleJobNames = new HashSet<>(); var subject = getSubject(); if (subject.isPermitted(new SystemAdministration())) { accessibleJobNames.addAll(availableJobNames); } else { ...
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
getAccessibleJobNames
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
private static void populateAccessibleReportNames(Map<String, Collection<String>> accessibleReportNames, Map<String, Collection<String>> availableReportNames, Project project, Role role) { for (Map.Entry<String, Collection<String>> entry: availableReportNames.entrySet()) { String jobName = entry.getK...
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
populateAccessibleReportNames
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static Map<String, Collection<String>> getAccessibleReportNames(Project project, Class<?> metricClass, Map<String, Collection<String>> availableReportNames) { Map<String, Collection<String>> accessibleReportNames = new HashMap<>(); var subject = getSubject(); if (subject.isPermitted(ne...
This method checks if current user is able to open terminal of specified build. Terminal access means that the user can view secrets used in the build as well as modifying build logic. So as long as the user can modify build spec of the build, it should be allowed to open terminal @param build @return
getAccessibleReportNames
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/security/SecurityUtils.java
MIT
public static boolean isGetter(Method method) { if ((method.getName().startsWith("get") || method.getName().startsWith("is")) && !Modifier.isStatic(method.getModifiers()) && method.getParameterTypes().length == 0) { return true; } else { return false; } }
Check if specified method is a getter method. <p> @param method method to be checked @return whether or not the method represents a getter method
isGetter
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/BeanUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/BeanUtils.java
MIT
public static boolean isSetter(Method method) { if (method.getName().startsWith("set") && !Modifier.isStatic(method.getModifiers()) && method.getParameterTypes().length == 0) { return true; } else { return false; } }
Check if specified method is a getter method. <p> @param method method to be checked @return whether or not the method represents a getter method
isSetter
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/BeanUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/BeanUtils.java
MIT
public static List<Field> findFields(Class<?> clazz) { Map<String, Field> fields = new LinkedHashMap<>(); Class<?> current = clazz; while (current != null) { for (Field field: current.getDeclaredFields()) { if (!field.isSynthetic() && !Modifier.isStatic(field.getModifiers()) && !fields.con...
Get declared fields in the whole class hierarchy. If there are fields with the same name in super-class and sub-class, fields in the sub-class with be returned only.
findFields
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/BeanUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/BeanUtils.java
MIT
@Nullable /** * Get suffix of accessor method name for specified property. For instance, * getter suffix for property &quot;value&quot; would be &quot;Value&quot;. * However if the property name starts with underscore, the accessor suffix * will be the same as property name. * <p> * @param propertyName ...
Get declared fields in the whole class hierarchy. If there are fields with the same name in super-class and sub-class, fields in the sub-class with be returned only.
getAccessorSuffix
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/BeanUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/BeanUtils.java
MIT
private static String getPropertyName(String accessorSuffix) { char[] chars = accessorSuffix.toCharArray(); if (chars[0] != '_') { Preconditions.checkArgument(Character.isUpperCase(chars[0])); chars[0] = Character.toLowerCase(chars[0]); return new String(chars); } else { return accessorSuffix; } }
Get property name given its accessor method name suffix. For instance, accessor suffix &quot;Value&quot; will return property name of &quot;value&quot;. Note that if accessor suffix starts with underscore, the property name will be the same as accessor suffix. @param accessorSuffix name suffix of the getter method...
getPropertyName
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/BeanUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/BeanUtils.java
MIT
public static List<Method> findGetters(Class<?> clazz) { Map<String, Method> getters = new LinkedHashMap<>(); Class<?> current = clazz; while (current != null) { for (Method method: current.getDeclaredMethods()) { if (!method.isSynthetic() && isGetter(method) && !getters.containsKey(method.getName())) {...
Find all getter methods in specified class and all its super classes. Note that if a getter method declared in sub class overrides another getter method declared in super class, only the getter method in sub class will be returned. @param clazz the class to find getter methods. All its super classes will al...
findGetters
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/BeanUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/BeanUtils.java
MIT
public static List<Method> findSetters(Class<?> clazz) { Map<String, Method> setters = new LinkedHashMap<>(); Class<?> current = clazz; while (current != null) { for (Method method: current.getDeclaredMethods()) { if (!method.isSynthetic() && isSetter(method) && !setters.containsKey(method.getName())) {...
Find all getter methods in specified class and all its super classes. Note that if a getter method declared in sub class overrides another getter method declared in super class, only the getter method in sub class will be returned. @param clazz the class to find getter methods. All its super classes will al...
findSetters
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/BeanUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/BeanUtils.java
MIT
public static Method getGetter(Class<?> clazz, String propertyName) { Method getter = findGetter(clazz, propertyName); if (getter == null) { throw new RuntimeException(String.format("Getter not found (class: %s, property: %s)", clazz.getName(), propertyName)); } return getter; }
Find getter method by property name in specified class and super classes. @param clazz class to search getter method. All super classes will also be searched if not found in current class @param propertyName name of the property to search getter for @return getter method @throws RuntimeException if not...
getGetter
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/BeanUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/BeanUtils.java
MIT
public static Method findGetter(Class<?> clazz, String propertyName) { String methodSuffix = getAccessorSuffix(propertyName); Method getter = ReflectionUtils.findMethod(clazz, "get" + methodSuffix); if (getter == null) getter = ReflectionUtils.findMethod(clazz, "is" + methodSuffix); return getter; }
Find getter method by property name in specified class and super classes. @param clazz class to search getter method. All super classes will also be searched if not found in current class @param propertyName name of the property to search getter for @return getter method, or <tt>null</tt> if not found in ...
findGetter
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/BeanUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/BeanUtils.java
MIT
public static Method findSetter(Class<?> clazz, String propertyName, Class<?> paramType) { String methodSuffix = getAccessorSuffix(propertyName); return ReflectionUtils.findMethod(clazz, "set" + methodSuffix, paramType); }
Find getter method by property name in specified class and super classes. @param clazz class to search getter method. All super classes will also be searched if not found in current class @param propertyName name of the property to search getter for @return getter method, or <tt>null</tt> if not found in ...
findSetter
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/BeanUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/BeanUtils.java
MIT
public static String getPropertyName(Method getter) { if (getter.getName().startsWith("get")) { return getPropertyName(getter.getName().substring(3)); } else if (getter.getName().startsWith("is")) { return getPropertyName(getter.getName().substring(2)); } else { throw new RuntimeException(String.format("...
Get property name associated with the getter method. @param getter getter method to retrieve property name from @return property name associated with the getter method @throws RuntimeException if specified method is not a getter method
getPropertyName
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/BeanUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/BeanUtils.java
MIT
public static Method findSetter(Method getter) { String setterName = "set" + getAccessorSuffix(getPropertyName(getter)); try { return getter.getDeclaringClass().getDeclaredMethod(setterName, getter.getReturnType()); } catch (SecurityException e) { throw new RuntimeException(e); } catch (NoSuchMethodExcept...
Find corresponding setter method in declaring class of specified getter. Note that it will not search in super classes as the sub class may intentionally override getter without overriding setter to make some property read only @param getter getter method to find corresponding setter @return setter method, or ...
findSetter
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/BeanUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/BeanUtils.java
MIT
public static Field findField(Method getter) { String fieldName = getPropertyName(getter); try { return getter.getDeclaringClass().getDeclaredField(fieldName); } catch (SecurityException e) { throw new RuntimeException(e); } catch (NoSuchFieldException e) { return null; } }
Find corresponding setter method in declaring class of specified getter. Note that it will not search in super classes as the sub class may intentionally override getter without overriding setter to make some property read only @param getter getter method to find corresponding setter @return setter method, or ...
findField
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/BeanUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/BeanUtils.java
MIT
public static Method getSetter(Method getter) { Method setter = findSetter(getter); if (setter == null) { String message = String.format("Can not find setter (class: %s, property: %s, type: %s)", getter.getDeclaringClass().getName(), getPropertyName(getter), getter.getReturnType().getName()); throw new ...
Find corresponding setter method by getter in specified class and super classes. <p> @param getter getter method to search setter for @return setter method @throws RuntimeException if not found in class hierarchy
getSetter
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/BeanUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/BeanUtils.java
MIT
public static String getDisplayName(AnnotatedElement element) { if (element instanceof Class) return WordUtils.uncamel(((Class<?>)element).getSimpleName()); else if (element instanceof Field) return WordUtils.uncamel(WordUtils.capitalize(((Field)element).getName())); else if (element instanceof Method) ...
Find corresponding setter method by getter in specified class and super classes. <p> @param getter getter method to search setter for @return setter method @throws RuntimeException if not found in class hierarchy
getDisplayName
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/BeanUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/BeanUtils.java
MIT
@Nullable public static Charset detectCharset(byte[] bytes) { if (bytes.length != 0) { var input = new ByteArrayInputStream(bytes); input.mark(bytes.length); try { UniversalEncodingListener listener = new UniversalEncodingListener(new Metadata()); byte[] b = new byte[BUFSIZE]; int n = 0; in...
Read leading information of specified content bytes to detect content charset. @param bytes content to be detected @return charset of the content, or <tt>null</tt> if charset can not be detected
detectCharset
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/ContentDetector.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/ContentDetector.java
MIT
public static boolean isBinary(byte[] contentBytes, @Nullable String fileName) { if (contentBytes.length == 0) return false; MediaType mediaType = detectMediaType(contentBytes, fileName); return !mediaType.getType().equalsIgnoreCase("text") && !mediaType.equals(MediaType.application("rls-services+xml...
Read leading information of specified content bytes to detect content charset. @param bytes content to be detected @return charset of the content, or <tt>null</tt> if charset can not be detected
isBinary
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/ContentDetector.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/ContentDetector.java
MIT
@Nullable public static String convertToText(byte[] contentBytes, @Nullable String fileName) { if (!isBinary(contentBytes, fileName)) { Charset charset = detectCharset(contentBytes); if (charset != null) return new String(contentBytes, charset); else return new String(contentBytes); } else { re...
Get text from specified content bytes, optionally with help of file name. @param contentBytes content bytes to construct text from @param fileName file name to help deciding if supplied content bytes represents text @return text representation of content bytes, or <tt>null</tt> if content can not be conve...
convertToText
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/ContentDetector.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/ContentDetector.java
MIT
public static MediaType detectMediaType(byte[] contentBytes, @Nullable String fileName) { return MediaType.parse(tika.detect(contentBytes, fileName)); }
Get text from specified content bytes, optionally with help of file name. @param contentBytes content bytes to construct text from @param fileName file name to help deciding if supplied content bytes represents text @return text representation of content bytes, or <tt>null</tt> if content can not be conve...
detectMediaType
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/ContentDetector.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/ContentDetector.java
MIT
public static MediaType detectMediaType(InputStream contentStream, @Nullable String fileName) { try { return MediaType.parse(tika.detect(contentStream, fileName)); } catch (IOException e) { throw new RuntimeException(e); } }
Get text from specified content bytes, optionally with help of file name. @param contentBytes content bytes to construct text from @param fileName file name to help deciding if supplied content bytes represents text @return text representation of content bytes, or <tt>null</tt> if content can not be conve...
detectMediaType
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/ContentDetector.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/ContentDetector.java
MIT
public void pump() { SynchronousQueue<Optional<T>> queue = new SynchronousQueue<>(); AtomicReference<Exception> exceptionRef = new AtomicReference<>(null); OneDev.getInstance(ExecutorService.class).execute(new Runnable() { @Override public void run() { try { generate(new Consumer<T>() { @...
A pumper generates elements in a different thread, and consumes the element in current thread. It is designed as some scenario requires that elements should be consumed in current thread, and collecting all generated elements into a collection before processing is not acceptable due to memory constraint @author rob...
pump
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/ElementPumper.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/ElementPumper.java
MIT
@Override public void run() { try { generate(new Consumer<T>() { @Override public void accept(T t) { try { queue.put(Optional.of(t)); } catch (InterruptedException e) { throw new RuntimeException(e); } } }); } catch (Exception e) { ...
A pumper generates elements in a different thread, and consumes the element in current thread. It is designed as some scenario requires that elements should be consumed in current thread, and collecting all generated elements into a collection before processing is not acceptable due to memory constraint @author rob...
run
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/ElementPumper.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/ElementPumper.java
MIT
@Override public void accept(T t) { try { queue.put(Optional.of(t)); } catch (InterruptedException e) { throw new RuntimeException(e); } }
A pumper generates elements in a different thread, and consumes the element in current thread. It is designed as some scenario requires that elements should be consumed in current thread, and collecting all generated elements into a collection before processing is not acceptable due to memory constraint @author rob...
accept
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/ElementPumper.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/ElementPumper.java
MIT
public static <T> List<Class<?>> getTypeArguments(Class<T> baseClass, Class<? extends T> childClass) { Preconditions.checkArgument(!baseClass.isInterface(), "baseClass should not be an interface"); Preconditions.checkArgument(baseClass.isAssignableFrom(childClass), "childClass should be a sub class of baseClass"); ...
Get the actual type arguments a child class has used to extend a generic base class.<p> (Taken from http://www.artima.com/weblogs/viewpost.jsp?thread=208860. Thanks mathieu.grenonville for finding this solution!) <p> @param baseClass the base class @param childClass the child class @return a list...
getTypeArguments
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/ReflectionUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/ReflectionUtils.java
MIT
@Nullable public static Class<?> getClass(Type type) { if (type instanceof Class) { return (Class<?>) type; } else if (type instanceof ParameterizedType) { return getClass(((ParameterizedType) type).getRawType()); } else if (type instanceof GenericArrayType) { Type componentType = ((GenericArrayType) ty...
Get the underlying class for a type. <p> @param type the type to get class from @return the underlying class, or <tt>null</tt> if the type is a variable type
getClass
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/ReflectionUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/ReflectionUtils.java
MIT
public static Method findMethod(Class<?> clazz, String methodName, Class<?>... paramTypes) { Class<?> current = clazz; while (true) { try { return current.getDeclaredMethod(methodName, paramTypes); } catch (SecurityException e) { throw new RuntimeException(e); } catch (NoSuchMethodException e) { ...
Find method of specified name and parameter types in specified class and its super classes in turn. <p> @param clazz class to find method in. Super classes will be searched for the method if not found in current class @param methodName method name to find @param paramTypes parameter types to find @retur...
findMethod
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/ReflectionUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/ReflectionUtils.java
MIT
public static Field findField(Class<?> clazz, String fieldName) { Field field = null; Class<?> current = clazz; while (current != null) { for (Field declaredField: current.getDeclaredFields()) { if (!Modifier.isStatic(declaredField.getModifiers()) && fieldName.equals(declaredField.getName())) { ...
Find non-static field in specified class hierarchy with specified name. <p> @param clazz class to search non-static field in. All the super classes will also be consulted if not found in sub class @param fieldName name of the field to search for @return found non-static field, or <tt>null</tt> if not foun...
findField
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/ReflectionUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/ReflectionUtils.java
MIT
public static List<Field> findFields(Class<?> clazz) { Map<String, Field> fields = new LinkedHashMap<String, Field>(); Class<?> current = clazz; while (current != null) { for (Field field: current.getDeclaredFields()) { if (!Modifier.isStatic(field.getModifiers()) && !field.isSynthetic() && !...
Find all non-static fields in specified class and all its super classes. If a non-static field declared in sub class has the same name as another non-static field declared in super class, only the non-static field in sub class will be returned. <p> @param clazz the class to find non-static fields. All its super c...
findFields
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/ReflectionUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/ReflectionUtils.java
MIT
public static Method getMethod(Class<?> clazz, String methodName, Class<?>...paramTypes) { Method method = findMethod(clazz, methodName, paramTypes); if (method == null) { throw new RuntimeException("Can not find method named '" + methodName + "' in class hierarchy of '" + clazz.getName() + "'."); ...
Get declared method in specified class and super classes. <p> @param clazz clazz to search the method. If not found, its super classes will also be searched @param methodName name of the method to find @param paramTypes parameter types of the method to find @return method matching specified name and par...
getMethod
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/ReflectionUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/ReflectionUtils.java
MIT
public static Object invokeStaticMethod(Class<?> clazz, String methodName, Object...params) { Class<?>[] paramTypes = new Class<?>[params.length]; for (int i = 0; i < params.length; i++) paramTypes[i] = params[i].getClass(); Method method = getMethod(clazz, methodName, paramTypes); if (!Modifier.is...
Invoke specified static method with specified parameters. Parameter types of invoked static method should be compatible with types of specified parameters. The static method will be searched in specified class and all its super classes in turn. <p> @param clazz class to invoke static method in. Static method wil...
invokeStaticMethod
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/ReflectionUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/ReflectionUtils.java
MIT
public static Object invokeMethod(Object object, String methodName, Object...params) { Class<?>[] paramTypes = new Class<?>[params.length]; for (int i = 0; i < params.length; i++) paramTypes[i] = params[i].getClass(); Method method = getMethod(object.getClass(), methodName, paramTypes); if (Modifie...
Invoke specified method with specified parameters. Parameter types of invoked method should be compatible with types of specified parameters. The method will be searched in specified class and all its super classes in turn. <p> @param clazz class to invoke method in. Method will be searched in super classes ...
invokeMethod
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/ReflectionUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/ReflectionUtils.java
MIT
public static <T> T instantiateClass(Class<T> clazz, Object... params) { Class<?>[] paramTypes = new Class<?>[params.length]; for (int i = 0; i < params.length; i++) paramTypes[i] = params[i].getClass(); Constructor<T> constructor = findConstructor(clazz, paramTypes); if (constructor == null) { ...
Instantiate specified class with specified parameters. The constructor used for instantiation should match types of specified parameters. <p> @param clazz class to be instantiated @param params parameters passed to constructor @return instance of the class @throws RuntimeException if constructor with par...
instantiateClass
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/ReflectionUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/ReflectionUtils.java
MIT
@SuppressWarnings("unchecked") public static <T> Constructor<T> findConstructor(Class<T> clazz, Class<?>... expectedParamTypes) { if (expectedParamTypes.length == 0) { try { return clazz.getConstructor(); } catch (Exception e) { throw ExceptionUtils.unchecked(e); } } Constructor<?>[] construc...
Find constructor of specified parameter types in specified class. <p> @param clazz class to find constructor in @param expectedParamTypes expected parameter types of the constructor @return matched constructor, or <tt>null</tt> if not found
findConstructor
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/ReflectionUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/ReflectionUtils.java
MIT
@Nullable public static Class<?> getCollectionElementClass(Type type) { Type elementType = getCollectionElementType(type); return elementType!=null? getClass(elementType): null; }
Find constructor of specified parameter types in specified class. <p> @param clazz class to find constructor in @param expectedParamTypes expected parameter types of the constructor @return matched constructor, or <tt>null</tt> if not found
getCollectionElementClass
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/ReflectionUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/ReflectionUtils.java
MIT
@Nullable public static Type getCollectionElementType(Type type) { if (type instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType)type; Type rawType = parameterizedType.getRawType(); Preconditions.checkState(Collection.class.isAssignableFrom((Class<?>) rawType)); return...
Find constructor of specified parameter types in specified class. <p> @param clazz class to find constructor in @param expectedParamTypes expected parameter types of the constructor @return matched constructor, or <tt>null</tt> if not found
getCollectionElementType
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/ReflectionUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/ReflectionUtils.java
MIT
public static Type getMapKeyType(Type type) { return getMapElementType(type, 0); }
Find constructor of specified parameter types in specified class. <p> @param clazz class to find constructor in @param expectedParamTypes expected parameter types of the constructor @return matched constructor, or <tt>null</tt> if not found
getMapKeyType
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/ReflectionUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/ReflectionUtils.java
MIT
@Nullable public static Type getMapValueType(Type type) { return getMapElementType(type, 1); }
Find constructor of specified parameter types in specified class. <p> @param clazz class to find constructor in @param expectedParamTypes expected parameter types of the constructor @return matched constructor, or <tt>null</tt> if not found
getMapValueType
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/ReflectionUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/ReflectionUtils.java
MIT
@Nullable private static Type getMapElementType(Type type, int index) { if (type instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType)type; Type rawType = parameterizedType.getRawType(); Preconditions.checkState(Map.class.isAssignableFrom((Class<?>) rawType)); return p...
Find constructor of specified parameter types in specified class. <p> @param clazz class to find constructor in @param expectedParamTypes expected parameter types of the constructor @return matched constructor, or <tt>null</tt> if not found
getMapElementType
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/ReflectionUtils.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/ReflectionUtils.java
MIT
@Nullable public static String determineBuildFailureInvestigator() { Build build = Build.get(); if (build != null) { RevCommit commit = Build.get().getProject().getRevCommit(build.getCommitId(), true); EmailAddressManager emailAddressManager = OneDev.getInstance(EmailAddressManager.class); EmailAddress em...
Use abstract class instead of interface here as otherwise groovy can not invoke static methods defined here @author robin
determineBuildFailureInvestigator
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/ScriptContribution.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/ScriptContribution.java
MIT
@Nullable public static Long getBuildNumber() { Build build = Build.get(); if (build != null) return build.getNumber(); else return null; }
Use abstract class instead of interface here as otherwise groovy can not invoke static methods defined here @author robin
getBuildNumber
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/ScriptContribution.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/ScriptContribution.java
MIT
@Nullable public static String getCurrentUser() { User user = User.get(); if (user != null) return user.getName(); else return null; }
Use abstract class instead of interface here as otherwise groovy can not invoke static methods defined here @author robin
getCurrentUser
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/ScriptContribution.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/ScriptContribution.java
MIT
public boolean hasBuildMeta(String tag) { for (String s : buildMeta) { if (s.equals(tag)) { return true; } } return false; }
Check if this version has a given build Meta tags. @param tag the tag to check for. @return true if the tag is found in {@link SemanticVersion#buildMeta}.
hasBuildMeta
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
MIT
public boolean hasPreRelease(String tag) { for (String s : preRelease) { if (s.equals(tag)) { return true; } } return false; }
Check if this version has a given pre release tag. @param tag the tag to check for @return true if the tag is found in {@link SemanticVersion#preRelease}.
hasPreRelease
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
MIT
public String[] getPreRelease() { String[] ret = new String[preRelease.length]; System.arraycopy(preRelease, 0, ret, 0, ret.length); return ret; }
Get the pre release tags @return a potentially empty array, but never null.
getPreRelease
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
MIT
public String[] getBuildMeta() { String ret[] = new String[buildMeta.length]; System.arraycopy(buildMeta, 0, ret, 0, ret.length); return ret; }
Get the build meta tags @return a potentially empty array, but never null.
getBuildMeta
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
MIT
public boolean isUpdateFor(SemanticVersion v) { return compareTo(v) > 0; }
Convenience method to check if this version is an update. @param v the other version object @return true if this version is newer than the other one.
isUpdateFor
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
MIT
public boolean isCompatibleUpdateFor(SemanticVersion v) { return isUpdateFor(v) && (major == v.major) && (major != 0 || v.major != 0); }
Convenience method to check if this version is a compatible update. @param v the other version object. @return true if this version is newer and both have the same major version.
isCompatibleUpdateFor
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
MIT
public boolean isStable() { return major > 0 && preRelease.length == 0; }
Convenience method to check if this is a stable version. @return true if the major version number is greater than zero and there are no pre release tags.
isStable
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
MIT
public SemanticVersion clearBuildMeta() { buildMeta = new String[0]; return this; }
Convenience method to check if this is a stable version. @return true if the major version number is greater than zero and there are no pre release tags.
clearBuildMeta
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
MIT
@Override public String toString() { StringBuilder ret = new StringBuilder(); ret.append(major); ret.append('.'); ret.append(minor); ret.append('.'); ret.append(patch); if (revision != 0) { ret.append('.'); ret.append(revision); } if (preRelease.length > 0) { ret.append('-'); for (int i =...
Convenience method to check if this is a stable version. @return true if the major version number is greater than zero and there are no pre release tags.
toString
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
MIT
@Override public int hashCode() { return toString().hashCode(); // Lazy }
Convenience method to check if this is a stable version. @return true if the major version number is greater than zero and there are no pre release tags.
hashCode
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
MIT
@Override public boolean equals(Object other) { if (this == other) { return true; } if (!(other instanceof SemanticVersion)) { return false; } SemanticVersion ov = (SemanticVersion) other; if (ov.major != major || ov.minor != minor || ov.patch != patch || ov.revision != revision) { return false; ...
Convenience method to check if this is a stable version. @return true if the major version number is greater than zero and there are no pre release tags.
equals
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
MIT
@Override public int compareTo(SemanticVersion v) { int result = major - v.major; if (result == 0) { // Same major result = minor - v.minor; if (result == 0) { // Same minor result = patch - v.patch; if (result == 0) { // Same patch result = revision - v.revision; if (result == 0) { // Same...
Convenience method to check if this is a stable version. @return true if the major version number is greater than zero and there are no pre release tags.
compareTo
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
MIT
private int comparePreReleaseTag(int pos, SemanticVersion ov) { Integer here = null; Integer there = null; try { here = Integer.parseInt(preRelease[pos], 10); } catch (NumberFormatException e) { } try { there = Integer.parseInt(ov.preRelease[pos], 10); } catch (NumberFormatException e) { } i...
Convenience method to check if this is a stable version. @return true if the major version number is greater than zero and there are no pre release tags.
comparePreReleaseTag
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
MIT
private boolean stateMajor() { int pos = 0; while (pos < input.length && input[pos] >= '0' && input[pos] <= '9') { pos++; // match [0..9]+ } if (pos == 0) { // Empty String -> Error return false; } if (input[0] == '0' && pos > 1) { // Leading zero return false; } vParts[0] = Integer.parseInt(n...
Convenience method to check if this is a stable version. @return true if the major version number is greater than zero and there are no pre release tags.
stateMajor
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
MIT
private boolean stateMinor(int index) { int pos = index; while (pos < input.length && input[pos] >= '0' && input[pos] <= '9') { pos++;// match [0..9]+ } if (pos == index) { // Empty String -> Error errPos = index; return false; } if (input[index] == '0' && pos - index > 1) { // Leading zero errP...
Convenience method to check if this is a stable version. @return true if the major version number is greater than zero and there are no pre release tags.
stateMinor
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
MIT
private boolean statePatch(int index) { int pos = index; while (pos < input.length && input[pos] >= '0' && input[pos] <= '9') { pos++;// match [0..9]+ } if (pos == index) { // Empty String -> Error errPos = index; return false; } if (input[index] == '0' && pos - index > 1) { // Leading zero errP...
Convenience method to check if this is a stable version. @return true if the major version number is greater than zero and there are no pre release tags.
statePatch
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
MIT
private boolean stateRevision(int index) { int pos = index; while (pos < input.length && input[pos] >= '0' && input[pos] <= '9') { pos++; // match [0..9]+ } if (pos == index) { // Empty String -> Error errPos = index; return false; } if (input[index] == '0' && pos - index > 1) { // Leading zero ...
Convenience method to check if this is a stable version. @return true if the major version number is greater than zero and there are no pre release tags.
stateRevision
java
theonedev/onedev
server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/SemanticVersion.java
MIT