use of jetbrains.buildServer.server.rest.data.Locator in project teamcity-rest by JetBrains.
the class FilesSubResource method getChildren.
@GET
@Path(FilesSubResource.CHILDREN + "{path:(/.*)?}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "getChildren", hidden = true)
public Files getChildren(@PathParam("path") @DefaultValue("") final String path, @QueryParam("basePath") final String basePath, @QueryParam("locator") final String locator, @QueryParam("fields") String fields) {
if (!myArchiveBrowsingSupported && locator != null) {
final Boolean browseArchives = new Locator(locator).getSingleDimensionValueAsBoolean(BuildArtifactsFinder.ARCHIVES_DIMENSION_NAME);
if (browseArchives != null && browseArchives) {
throw new BadRequestException("Archive browsing is not supported for this request, remove '" + BuildArtifactsFinder.ARCHIVES_DIMENSION_NAME + "' dimension");
}
}
final FileApiUrlBuilder builder = fileApiUrlBuilder(locator, myUrlPrefix);
final Element rootElement = myProvider.getElement(myProvider.preprocess(StringUtil.removeLeadingSlash(path)));
return new Files(null, new Files.DefaultFilesProvider(builder, myBeanContext) {
@Override
@NotNull
public List<? extends Element> getItems() {
return BuildArtifactsFinder.getItems(rootElement, myProvider.preprocess(basePath), locator, builder, myBeanContext.getServiceLocator());
}
}, new Fields(fields), myBeanContext);
}
use of jetbrains.buildServer.server.rest.data.Locator in project teamcity-rest by JetBrains.
the class ChangeRequest method getChangeFailedTestsTree.
/**
* Experimental, subject to change
* @since 2021.2
*/
@GET
@Path("/{changeLocator}/testsTree")
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Get failed tests tree for the matching change.", nickname = "getChangeFailedTestsTree", hidden = true)
public TestScopeTree getChangeFailedTestsTree(@ApiParam(format = LocatorName.CHANGE) @PathParam("changeLocator") String changeLocator, // todo: remove after ui migration
@QueryParam(TestScopeTreeCollector.SUBTREE_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 TestScopeTree(myTestScopeTreeCollector.getSlicedTreeFromBuildPromotions(firstBuildsPromotions, treeLocator), new Fields(fields), myBeanContext);
}
use of jetbrains.buildServer.server.rest.data.Locator in project teamcity-rest by JetBrains.
the class ChangeRequest method getFilteredFiles.
/**
* Experimental support only!
* todo: Is it better to have this somewhere in Change model? E.g. fields=change(files($filterByBuildType(<buildTypeId>),name,...)))
* @since 2021.1.1
*/
@GET
@Path("/{changeLocator}/files")
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Get files of the matching change filtered by relation to a given buildType.", nickname = "getFilteredFiles", hidden = true)
public FileChanges getFilteredFiles(@ApiParam(format = LocatorName.CHANGE) @PathParam("changeLocator") String changeLocatorString, @QueryParam("buildTypeId") String builtTypeId, @QueryParam("fields") String fields) {
Locator changeLocator = Locator.createPotentiallyEmptyLocator(changeLocatorString);
SVcsModification change = myChangeFinder.getItem(changeLocator.getStringRepresentation()).getSVcsModification();
if (builtTypeId == null) {
// Convenience method, same as Change.getFileChanges()
ChangeStatusProvider myStatusProvider = myServiceLocator.getSingletonService(ChangeStatusProvider.class);
ChangeStatus changeStatus = myStatusProvider.getMergedChangeStatus(change);
return new FileChanges(new ArrayList<>(changeStatus.getMergedVcsModificationInfo().getChangedFiles()), new Fields(fields));
}
SBuildType buildType = myBuildTypeFinder.getItem(builtTypeId).getBuildType();
if (buildType == null) {
throw new NotFoundException("Build type not found.");
}
if (change.getRelatedConfigurations().stream().noneMatch(relatedBt -> relatedBt.getExternalId().equals(buildType.getExternalId()))) {
ChangeStatusProvider myStatusProvider = myServiceLocator.getSingletonService(ChangeStatusProvider.class);
ChangeStatus changeStatus = myStatusProvider.getMergedChangeStatus(change);
return new FileChanges(new ArrayList<>(changeStatus.getMergedVcsModificationInfo().getChangedFiles()), new Fields(fields));
}
return new FileChanges(change.getFilteredChanges(buildType), new Fields(fields));
}
use of jetbrains.buildServer.server.rest.data.Locator in project teamcity-rest by JetBrains.
the class ProblemOccurrencesTreeCollector method prepareLocator.
private String prepareLocator(@NotNull Locator original) {
Locator result = Locator.createEmptyLocator();
result.setDimension(ProblemOccurrenceFinder.AFFECTED_PROJECT, original.getDimensionValue(ProblemOccurrenceFinder.AFFECTED_PROJECT));
result.setDimension(ProblemOccurrenceFinder.BUILD, original.getDimensionValue(ProblemOccurrenceFinder.BUILD));
result.setDimension(ProblemOccurrenceFinder.TYPE, original.getDimensionValue(ProblemOccurrenceFinder.TYPE));
result.setDimension(ProblemOccurrenceFinder.CURRENTLY_INVESTIGATED, original.getDimensionValue(ProblemOccurrenceFinder.CURRENTLY_INVESTIGATED));
result.setDimension(ProblemOccurrenceFinder.CURRENTLY_MUTED, original.getDimensionValue(ProblemOccurrenceFinder.CURRENTLY_MUTED));
result.setDimension(PagerData.COUNT, "-1");
return result.toString();
}
Aggregations