Search in sources :

Example 1 with RepositoryStateManager

use of jetbrains.buildServer.vcs.impl.RepositoryStateManager in project teamcity-rest by JetBrains.

the class VcsRootInstanceRequest method setRepositoryState.

@PUT
@Path("/{vcsRootInstanceLocator}/repositoryState")
@Consumes({ "application/xml", "application/json" })
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Update the repository state of the matching VCS root instance.", nickname = "setVcsRootInstanceRepositoryState")
public Entries setRepositoryState(@ApiParam(format = LocatorName.VCS_ROOT_INSTANCE) @PathParam("vcsRootInstanceLocator") String vcsRootInstanceLocator, Entries branchesState, @QueryParam("fields") String fields) {
    final jetbrains.buildServer.vcs.VcsRootInstance rootInstance = myVcsRootInstanceFinder.getItem(vcsRootInstanceLocator);
    myVcsRootInstanceFinder.checkPermission(Permission.EDIT_PROJECT, rootInstance);
    final RepositoryStateManager repositoryStateManager = myDataProvider.getBean(RepositoryStateManager.class);
    repositoryStateManager.setRepositoryState(rootInstance, RepositoryStateFactory.createRepositoryState(branchesState.getMap()));
    Loggers.VCS.info("Repository state is set to \"" + StringUtil.propertiesToString(branchesState.getMap(), StringUtil.STD_ESCAPER2) + "\" via REST API call for " + rootInstance.describe(false) + " by " + myBeanContext.getSingletonService(PermissionChecker.class).getCurrentUserDescription());
    final RepositoryState repositoryState = repositoryStateManager.getRepositoryState(rootInstance);
    return new Entries(repositoryState.getBranchRevisions(), new Fields(fields));
}
Also used : RepositoryStateManager(jetbrains.buildServer.vcs.impl.RepositoryStateManager) jetbrains.buildServer.vcs(jetbrains.buildServer.vcs) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

ApiOperation (io.swagger.annotations.ApiOperation)1 jetbrains.buildServer.vcs (jetbrains.buildServer.vcs)1 RepositoryStateManager (jetbrains.buildServer.vcs.impl.RepositoryStateManager)1