use of jetbrains.buildServer.server.rest.data.Locator in project teamcity-rest by JetBrains.
the class Change method getChangeFromPosted.
@NotNull
public SVcsModification getChangeFromPosted(final ChangeFinder changeFinder) {
String locatorText;
if (submittedId != null) {
if (submittedLocator != null) {
throw new BadRequestException("Both 'locator' and 'id' attributes are specified. Only one should be present.");
}
final Locator locator = Locator.createEmptyLocator().setDimension(ChangeFinder.DIMENSION_ID, String.valueOf(submittedId));
if (submittedPersonal != null && submittedPersonal) {
locator.setDimension(ChangeFinder.PERSONAL, "true");
}
locatorText = locator.getStringRepresentation();
} else {
if (submittedLocator == null) {
throw new BadRequestException("No change specified. Either 'id' or 'locator' attribute should be present.");
}
locatorText = submittedLocator;
}
return changeFinder.getItem(locatorText).getSVcsModification();
}
use of jetbrains.buildServer.server.rest.data.Locator in project teamcity-rest by JetBrains.
the class TestScopesRequest method serveGroupedTestOccurrences.
// Very highly experimental
@GET
@Path("/{scopeName}")
@Produces({ "application/xml", "application/json" })
@ApiOperation(hidden = true, value = "highly experimental")
public TestScopes serveGroupedTestOccurrences(@QueryParam("locator") String locatorText, @PathParam("scopeName") String scopeName, @QueryParam("fields") String fields, @Context UriInfo uriInfo, @Context HttpServletRequest request) {
Set<String> supportedGroupings = new HashSet<>(Arrays.asList("package", "suite", "class"));
if (!supportedGroupings.contains(scopeName)) {
throw new BadRequestException("Invalid scope. Only scopes " + String.join(",", supportedGroupings) + " are supported.");
}
Locator patchedLocator = new Locator(locatorText);
patchedLocator.setDimension(TestScopesCollector.SCOPE_TYPE, scopeName);
PagedSearchResult<TestScope> items = myTestScopesCollector.getPagedItems(patchedLocator);
PagerData pager = new PagerData(uriInfo.getRequestUriBuilder(), request.getContextPath(), items, locatorText, "locator");
return new TestScopes(items.myEntries, new Fields(fields), pager, uriInfo, myBeanContext);
}
use of jetbrains.buildServer.server.rest.data.Locator in project teamcity-rest by JetBrains.
the class ChangeRequest method getUniqueCommiters.
/**
* Experimental support only!
* @since 2021.1.1
*/
@GET
@Path("/{changeLocator}/commiters")
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Get unique commiters of the matching changes.", nickname = "getUniqueCommiters", hidden = true)
public Commiters getUniqueCommiters(@ApiParam(format = LocatorName.CHANGE) @PathParam("changeLocator") String changeLocator, @QueryParam("fields") String fields) {
Locator patchedChangeLocator = Locator.createPotentiallyEmptyLocator(changeLocator);
if (!patchedChangeLocator.isAnyPresent(PagerData.COUNT)) {
String lookupLimit = TeamCityProperties.getProperty("rest.request.changes.committersLookupLimit", DEFAULT_CHANGES_LOOKUP_LIMIT_FOR_COMMITERS);
patchedChangeLocator.setDimension(PagerData.COUNT, lookupLimit);
}
PagedSearchResult<SVcsModificationOrChangeDescriptor> changes = myChangeFinder.getItems(patchedChangeLocator.getStringRepresentation());
List<CommiterData> commiters = ChangeUtil.getUniqueCommiters(changes.myEntries.stream().map(modOrDesc -> modOrDesc.getSVcsModification()));
return new Commiters(commiters, new Fields(fields), myBeanContext);
}
use of jetbrains.buildServer.server.rest.data.Locator in project teamcity-rest by JetBrains.
the class ChangeRequest method getChangeProblemsTree.
/**
* Experimental, subject to change
* @since 2021.2
*/
@GET
@Path("/{changeLocator}/problemsTree")
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Get problems tree for the matching change.", nickname = "getChangeProblemsTree", hidden = true)
public ProblemOccurrencesTree getChangeProblemsTree(@ApiParam(format = LocatorName.CHANGE) @PathParam("changeLocator") String changeLocator, // todo: remove after ui migration
@QueryParam(ProblemOccurrencesTreeCollector.SUB_TREE_ROOT_ID) String subTreeRootId, @QueryParam("treeLocator") String treeLocatorText, @QueryParam("fields") String fields) {
final SVcsModification change = myChangeFinder.getItem(changeLocator).getSVcsModification();
ChangeStatusProvider myStatusProvider = myServiceLocator.getSingletonService(ChangeStatusProvider.class);
ChangeStatus changeStatus = myStatusProvider.getMergedChangeStatus(change);
Stream<BuildPromotion> firstBuildsPromotions = changeStatus.getBuildTypesStatusMap().values().stream().filter(Objects::nonNull);
Locator treeLocator = Locator.createPotentiallyEmptyLocator(treeLocatorText);
if (subTreeRootId != null) {
treeLocator.setDimension(ProblemOccurrencesTreeCollector.SUB_TREE_ROOT_ID, subTreeRootId);
}
return new ProblemOccurrencesTree(myProblemOccurrencesTreeCollector.getTreeFromBuildPromotions(firstBuildsPromotions, treeLocator), new Fields(fields), myBeanContext);
}
use of jetbrains.buildServer.server.rest.data.Locator in project teamcity-rest by JetBrains.
the class DownloadedArtifacts method getFilteredInfo.
@NotNull
private Map<SBuild, List<ArtifactInfo>> getFilteredInfo() {
Map<SBuild, List<ArtifactInfo>> result = new HashMap<>();
String buildLocatorText = myFields.getLocator();
FilterConditionChecker<BuildPromotion> buildFilter;
if (StringUtil.isNotEmpty(buildLocatorText)) {
Locator buildLocator = Locator.locator(buildLocatorText);
buildFilter = myBeanContext.getSingletonService(BuildPromotionFinder.class).getFilter(buildLocator);
buildLocator.checkLocatorFullyProcessed();
} else {
buildFilter = b -> true;
}
for (Map.Entry<Build, List<ArtifactInfo>> buildArtifacts : myArtifacts.getArtifacts().entrySet()) {
SBuild build = (SBuild) buildArtifacts.getKey();
if (!buildFilter.isIncluded(build.getBuildPromotion())) {
continue;
}
result.put(build, buildArtifacts.getValue());
}
return result;
}
Aggregations