当前位置: 首页>>代码示例>>Java>>正文


Java Repository类代码示例

本文整理汇总了Java中com.atlassian.bitbucket.repository.Repository的典型用法代码示例。如果您正苦于以下问题:Java Repository类的具体用法?Java Repository怎么用?Java Repository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Repository类属于com.atlassian.bitbucket.repository包,在下文中一共展示了Repository类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRepository

import com.atlassian.bitbucket.repository.Repository; //导入依赖的package包/类
private Repository getRepository(HttpServletRequest req, HttpServletResponse resp) throws IOException
{
	// Get repoSlug from path
	String pathInfo = req.getPathInfo();

	String[] components = pathInfo.split("/");

	if (components.length < 3)
	{
		return null;
	}

	Repository repository = repositoryService.getBySlug(components[1], components[2]);
	if (repository == null)
	{
		return null;
	}
	return repository;
}
 
开发者ID:Eernie,项目名称:bitbucket-webhooks-plugin,代码行数:20,代码来源:RepositoryConfigServlet.java

示例2: onBuildStatusSetEvent

import com.atlassian.bitbucket.repository.Repository; //导入依赖的package包/类
@EventListener
public void onBuildStatusSetEvent(BuildStatusSetEvent event) throws IOException
{
    executorService.submit(() -> {
        BuildStatusEvent buildStatusEvent = new BuildStatusEvent();
        buildStatusEvent.setCommit(event.getCommitId());
        buildStatusEvent.setStatus(event.getBuildStatus().getState().toString());
        buildStatusEvent.setUrl(event.getBuildStatus().getUrl());
        IndexedCommit commit = commitIndex.getCommit(event.getCommitId());
        if (commit != null) {
            for (Repository repo : commit.getRepositories()){
                buildStatusEvent.setRepository(Models.createRepository(repo, applicationPropertiesService));
                sendEvents(buildStatusEvent, repo, EventType.BUILD_STATUS);
            }
        }
    });
}
 
开发者ID:Eernie,项目名称:bitbucket-webhooks-plugin,代码行数:18,代码来源:PullRequestListener.java

示例3: check

import com.atlassian.bitbucket.repository.Repository; //导入依赖的package包/类
@Override
public void check(@Nonnull MergeRequest mergeRequest) {
  PullRequest pr = mergeRequest.getPullRequest();
  Repository repo = pr.getToRef().getRepository();
  final Config config = configDao.getConfigForRepo(repo.getProject().getKey(), repo.getSlug());

  String branch = regexUtils.formatBranchName(pr.getToRef().getId());
  if (regexUtils.match(config.getBlockedPRs(), branch)) {
    mergeRequest.veto("Pull Request Blocked", "Pull requests have been disabled for branch [" + branch + "]");
  } else {
    PullRequestApproval approval = new PullRequestApproval(config, userUtils);
    if (!approval.isPullRequestApproved(pr)) {
      Set<String> missing = approval.missingRevieiwersNames(pr);
      mergeRequest.veto("Required reviewers must approve", (config.getRequiredReviews() - approval.seenReviewers(pr).size()) +
          " more approvals required from the following users: " + Joiner.on(", ").join(missing));
    } else {
      Boolean needsWork = config.getBlockMergeIfPrNeedsWork();
      final Boolean blockAutoMergeBecausePrNeedsWork = needsWork != null && needsWork && needsWork(pr);

      if (blockAutoMergeBecausePrNeedsWork) {
        mergeRequest.veto("Needs work", "PR marked as Needs Work from reviewer(s)");
      }
    }
  }
}
 
开发者ID:monitorjbl,项目名称:pr-harmony,代码行数:26,代码来源:MergeBlocker.java

示例4: onReceive

import com.atlassian.bitbucket.repository.Repository; //导入依赖的package包/类
@Override
public boolean onReceive(Repository repository, Collection<RefChange> collection, HookResponse hookResponse) {
  Config config = configDao.getConfigForRepo(repository.getProject().getKey(), repository.getSlug());

  UserProfile user = userManager.getRemoteUser();
  for(RefChange ch : collection) {
    String branch = regexUtils.formatBranchName(ch.getRef().getId());
    Set<String> excluded = newHashSet(concat(config.getExcludedUsers(), userUtils.dereferenceGroups(config.getExcludedGroups())));
    if(regexUtils.match(config.getBlockedCommits(), branch) && !excluded.contains(user.getUsername())) {
      hookResponse.err().write("\n" +
              "******************************\n" +
              "*    !! Commit Rejected !!   *\n" +
              "******************************\n\n" +
              "Direct commits are not allowed\n" +
              "to branch [" + branch + "].\n\n"
      );
      return false;
    }
  }
  return true;
}
 
开发者ID:monitorjbl,项目名称:pr-harmony,代码行数:22,代码来源:CommitBlockerHook.java

示例5: renderRepoSettings

import com.atlassian.bitbucket.repository.Repository; //导入依赖的package包/类
void renderRepoSettings(String projectKey, String repoSlug, String username, HttpServletResponse response) throws IOException {
  Repository repo = repoService.getBySlug(projectKey, repoSlug);
  if(repo == null) {
    logger.warn("Project/Repo [{}/{}] not found for user {}", projectKey, repoSlug, username);
    response.setStatus(HttpServletResponse.SC_NOT_FOUND);
    return;
  }

  ApplicationUser appUser = userUtils.getApplicationUserByName(username);
  if(permissionService.hasRepositoryPermission(appUser, repo, Permission.REPO_ADMIN)) {
    response.setStatus(HttpServletResponse.SC_OK);
    response.setContentType("text/html;charset=utf-8");
    renderer.render("repo-config.html", ImmutableMap.<String, Object>of(
        "projectKey", projectKey,
        "repositorySlug", repoSlug
                                                                       ), response.getWriter());
  } else {
    logger.debug("Permission denied for user [{}]", username);
    response.setStatus(HttpServletResponse.SC_FORBIDDEN);
  }
}
 
开发者ID:monitorjbl,项目名称:pr-harmony,代码行数:22,代码来源:ConfigServlet.java

示例6: validate

import com.atlassian.bitbucket.repository.Repository; //导入依赖的package包/类
@Override
public void validate(Settings settings,
                     SettingsValidationErrors settingsValidationErrors,
                     Repository repository) {

    String versionPattern = settings.getString(SETTINGS_KEY, "");

    if(versionPattern.isEmpty()) {
        return;
    }

    if (!versionValidationPattern.matcher(versionPattern).matches()) {
        settingsValidationErrors.addFieldError(SETTINGS_KEY,
                                               "Version pattern doesn't contain named capturing group with a name \"version\"");
    }
}
 
开发者ID:infobip,项目名称:jira-version-generator,代码行数:17,代码来源:VersionPatternValidator.java

示例7: getChanges

import com.atlassian.bitbucket.repository.Repository; //导入依赖的package包/类
@Override
public Iterable<Change> getChanges(Iterable<RefChange> refChanges, final Repository repository) {
    List<Change> changes = new ArrayList<>();

    for (RefChange refChange : refChanges) {
        Iterable<String> commitIds = StreamSupport.stream(getCommitsBetween(repository, refChange).spliterator(),false).map(Functions.COMMIT_TO_COMMIT_ID).collect(Collectors.toList());
        if (Iterables.size(commitIds) == 0) {
            return Collections.emptySet();
        }

        Iterable<Changeset> changesets = getChangesets(repository, commitIds);
        for (Changeset changeset : changesets) {
            Iterable<Change> values = changeset.getChanges().getValues();
            for (Change change : values) {
                changes.add(change);
            }
        }
    }

    return changes;
}
 
开发者ID:christiangalsterer,项目名称:stash-filehooks-plugin,代码行数:22,代码来源:ChangesetServiceImpl.java

示例8: IsPluginEnabled

import com.atlassian.bitbucket.repository.Repository; //导入依赖的package包/类
public boolean IsPluginEnabled(final Repository repository)
{
	permissionValidationService.validateForRepository(repository, Permission.REPO_READ);
	try 
	{
		return securityService.withPermission(Permission.REPO_ADMIN, "Retrieving repository hook").call(new Operation<Boolean, Exception>()
		{
			@Override
			public Boolean perform() throws Exception 
			{
				RepositoryHook repositoryHook = repositoryHookService.getByKey(repository, Constants.PLUGIN_KEY); 
				return repositoryHook != null && repositoryHook.isEnabled() && repositoryHookService.getSettings(repository, Constants.PLUGIN_KEY) != null;
			}
		}).booleanValue();
	}
	catch (Exception e)
	{
		logger.error("Failed: IsPluginEnabled({})", repository.getName(), e);
		return false;
	}
}
 
开发者ID:wparad,项目名称:stash-http-request-trigger,代码行数:22,代码来源:RepositoryInformationService.java

示例9: GetSettings

import com.atlassian.bitbucket.repository.Repository; //导入依赖的package包/类
private Settings GetSettings(final Repository repository)
{
	permissionValidationService.validateForRepository(repository, Permission.REPO_READ);
	try 
	{
		return securityService.withPermission(Permission.REPO_ADMIN, "Retrieving settings").call(new Operation<Settings, Exception>()
		{
			@Override
			public Settings perform() throws Exception { return repositoryHookService.getSettings(repository, Constants.PLUGIN_KEY); } 
		});
	}
	catch(Exception e)
	{
		logger.error("Failed: GetSettings({})", repository.getName(), e);
		return null;
	}
}
 
开发者ID:wparad,项目名称:stash-http-request-trigger,代码行数:18,代码来源:RepositoryInformationService.java

示例10: PostChange

import com.atlassian.bitbucket.repository.Repository; //导入依赖的package包/类
public void PostChange(final Repository repository, String ref, String sha, String toRef, String pullRequestNbr)
{
	if(!IsPluginEnabled(repository)) { return; }
	
	Settings settings = GetSettings(repository);
	String url = null;
	if(pullRequestNbr == null)
	{
		String regex = settings.getString(Constants.CONFIG_KEY_REFREGEX);
		logger.error("{} {}", regex, ref);
		if(regex != null && !regex.trim().isEmpty() && !ref.matches(regex)){ return; }
		url = GetUrl(repository, ref, sha);
	}
	else {url = GetPullRequestUrl(repository, ref, sha, toRef, pullRequestNbr, false);}
	
	boolean useSecureSsl = settings != null && settings.getBoolean(Constants.CONFIG_KEY_REQUIRESSLCERTS, false);
	Post(url, useSecureSsl);
}
 
开发者ID:wparad,项目名称:stash-http-request-trigger,代码行数:19,代码来源:RepositoryInformationService.java

示例11: GetUrl

import com.atlassian.bitbucket.repository.Repository; //导入依赖的package包/类
public String GetUrl(final Repository repository, String ref, String sha)
{
	String baseUrl = GetSettings(repository).getString(Constants.CONFIG_KEY_URL);
	StringBuilder urlParams = new StringBuilder();
	try
	{
		urlParams.append("STASH_REF=" + URLEncoder.encode(ref, "UTF-8"));
		urlParams.append("&STASH_SHA=" + URLEncoder.encode(sha, "UTF-8"));
		urlParams.append("&STASH_REPO=" + URLEncoder.encode(repository.getName(), "UTF-8"));
		urlParams.append("&STASH_PROJECT=" + URLEncoder.encode(repository.getProject().getKey(), "UTF-8"));
	}
	catch (UnsupportedEncodingException e)
	{
		logger.error("Failed to get URL ({}, {}, {})", new Object[]{repository.getName(), ref, sha});
		throw new RuntimeException(e);
	}

	return CombineURL(baseUrl, urlParams.toString());
}
 
开发者ID:wparad,项目名称:stash-http-request-trigger,代码行数:20,代码来源:RepositoryInformationService.java

示例12: GetPullRequestUrl

import com.atlassian.bitbucket.repository.Repository; //导入依赖的package包/类
public String GetPullRequestUrl(final Repository repository, String ref, String sha, String toRef, String pullRequestNbr, boolean fromWebUI)
{
	String baseUrl = GetSettings(repository).getString(Constants.CONFIG_KEY_PRURL);
	StringBuilder urlParams = new StringBuilder();
	try
	{
		urlParams.append("STASH_REF=" + URLEncoder.encode(ref, "UTF-8"));
		urlParams.append("&STASH_SHA=" + URLEncoder.encode(sha, "UTF-8"));
		urlParams.append("&STASH_TO_REF=" + URLEncoder.encode(toRef, "UTF-8"));
		urlParams.append("&STASH_REPO=" + URLEncoder.encode(repository.getName(), "UTF-8"));
		urlParams.append("&STASH_PROJECT=" + URLEncoder.encode(repository.getProject().getKey(), "UTF-8"));
		urlParams.append("&STASH_PULL_REQUEST=" + pullRequestNbr);
		if(fromWebUI) {urlParams.append("&STASH_TRIGGER=" + URLEncoder.encode("build_button", "UTF-8"));}
	}
	catch (UnsupportedEncodingException e)
	{
		logger.error("Failed to get URL ({}, {}, {}, {})", new Object[]{repository.getName(), ref, sha, pullRequestNbr});
		throw new RuntimeException(e);
	}

	return CombineURL(baseUrl, urlParams.toString());
}
 
开发者ID:wparad,项目名称:stash-http-request-trigger,代码行数:23,代码来源:RepositoryInformationService.java

示例13: triggerexternalurl

import com.atlassian.bitbucket.repository.Repository; //导入依赖的package包/类
/**
 * Trigger a build on the Teamcity instance using vcs root
 * @param repository The repository to trigger
 * @return The response. Ok if it worked. Otherwise, an error.
 */
@GET
@Path(value = "triggerexternalurl")
public String triggerexternalurl(@Context Repository repository,
    @QueryParam("url") String url,
    @QueryParam("method") String method) {

    HttpConnector dummyConnector = new HttpConnector();
    String returnData;
  try {
    returnData = dummyConnector.Get(url, this.settingsService.getSettings(repository));
    return "{\"status\": \"ok\", \"message\": \" " + returnData + "\" }";
  } catch (IOException ex) {
    return "{\"status\": \"failed\", \"message\": \" " + ex.getMessage() + "\" }";
  }
}
 
开发者ID:TrimbleSolutionsCorporation,项目名称:TeamcityTriggerHook,代码行数:21,代码来源:TeamctiyRest.java

示例14: testconnection

import com.atlassian.bitbucket.repository.Repository; //导入依赖的package包/类
/**
 * Trigger a build on the Teamcity instance using vcs root
 * @param repository The repository to trigger
 * @return The response. Ok if it worked. Otherwise, an error.
 */
@GET
@Path(value = "testconnection")
public String testconnection(@Context Repository repository,
    @QueryParam("url") String url,
    @QueryParam("username") String username,
    @QueryParam("password") String password) {

    TeamcityConfiguration conf = new TeamcityConfiguration(url, username, password);
    String returnData = this.connector.TestTeamcityConnection(conf, this.settingsService.getSettings(repository));
    if (!"Ok".equals(returnData)) {
      if (returnData.contains("401")) {
        return "{\"status\": \"failed\", \"message\": \" User or password invalid\" }";
      }
      else {
        return "{\"status\": \"failed\", \"message\": \" Host is not reachable\" }";          
      }                 
    } else {
      this.connectionSettings.SavePassword(password, repository);
      return "{\"status\": \"ok\"}";
    }
}
 
开发者ID:TrimbleSolutionsCorporation,项目名称:TeamcityTriggerHook,代码行数:27,代码来源:TeamctiyRest.java

示例15: triggervcs

import com.atlassian.bitbucket.repository.Repository; //导入依赖的package包/类
/**
 * Trigger a build on the Teamcity instance using vcs root
 * @param repository The repository to trigger
 * @return The response. Ok if it worked. Otherwise, an error.
 */
@POST
@Path(value = "triggervcs")
public Response triggervcs(@Context Repository repository,
    @QueryParam("vcs") String vcs,
    @QueryParam("url") String sha1,
    @QueryParam("username") String username,
    @QueryParam("password") String password) {

  try {
    return Response.noContent().build();
  }
  catch (Exception e) {
    return Response.status(Status.INTERNAL_SERVER_ERROR)
        .entity(e.getMessage()).build();
  }
}
 
开发者ID:TrimbleSolutionsCorporation,项目名称:TeamcityTriggerHook,代码行数:22,代码来源:TeamctiyRest.java


注:本文中的com.atlassian.bitbucket.repository.Repository类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。