use of jetbrains.buildServer.server.rest.util.BeanContext in project teamcity-rest by JetBrains.
the class BuildTypeRequest method replaceSnapshotDeps.
/**
* Replaces snapshot dependency with those sent in request.
*/
@PUT
@Path("/{btLocator}/snapshot-dependencies")
@Consumes({ "application/xml", "application/json" })
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Update all snapshot dependencies of the matching build configuration.", nickname = "replaceAllSnapshotDependencies")
public PropEntitiesSnapshotDep replaceSnapshotDeps(@ApiParam(format = LocatorName.BUILD_TYPE) @PathParam("btLocator") String buildTypeLocator, @QueryParam("fields") String fields, PropEntitiesSnapshotDep suppliedEntities) {
final BuildTypeOrTemplate buildType = myBuildTypeFinder.getBuildTypeOrTemplate(null, buildTypeLocator, true);
suppliedEntities.setToBuildType(buildType.getSettingsEx(), myServiceLocator);
buildType.persist("Snapshot dependency replaced");
return new PropEntitiesSnapshotDep(buildType.getSettingsEx(), new Fields(fields), new BeanContext(myFactory, myServiceLocator, myApiUrlBuilder));
}
use of jetbrains.buildServer.server.rest.util.BeanContext in project teamcity-rest by JetBrains.
the class BuildTypeRequest method replaceSnapshotDep.
@PUT
@Path("/{btLocator}/snapshot-dependencies/{snapshotDepLocator}")
@Consumes({ "application/xml", "application/json" })
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Update a snapshot dependency of the matching build configuration.", nickname = "replaceSnapshotDependency")
public PropEntitySnapshotDep replaceSnapshotDep(@ApiParam(format = LocatorName.BUILD_TYPE) @PathParam("btLocator") String buildTypeLocator, @PathParam("snapshotDepLocator") String snapshotDepLocator, @QueryParam("fields") String fields, PropEntitySnapshotDep description) {
final BuildTypeOrTemplate buildType = myBuildTypeFinder.getBuildTypeOrTemplate(null, buildTypeLocator, true);
final Dependency dependency = PropEntitySnapshotDep.getSnapshotDep(buildType.get(), snapshotDepLocator, myBuildTypeFinder);
Dependency createdDependency = description.replaceIn(buildType.getSettingsEx(), dependency, myServiceLocator);
buildType.persist("Snapshot dependency replaced");
return new PropEntitySnapshotDep(createdDependency, buildType.getSettingsEx(), new Fields(fields), new BeanContext(myFactory, myServiceLocator, myApiUrlBuilder));
}
use of jetbrains.buildServer.server.rest.util.BeanContext in project teamcity-rest by JetBrains.
the class BuildType method getTemplates.
@Nullable
public static BuildTypes getTemplates(@NotNull final SBuildType buildType, @NotNull final Fields fields, final BeanContext beanContext) {
try {
PermissionChecker permissionChecker = beanContext.getSingletonService(PermissionChecker.class);
List<? extends BuildTypeTemplate> templates = buildType.getTemplates();
Set<String> ownTemplatesIds = buildType.getOwnTemplates().stream().map(t -> t.getInternalId()).collect(Collectors.toSet());
return new BuildTypes(templates.stream().map(t -> shouldRestrictSettingsViewing(t, permissionChecker) ? new BuildTypeOrTemplate.IdsOnly(t.getExternalId(), t.getInternalId()) : new BuildTypeOrTemplate(t)).map(t -> t.markInherited(!ownTemplatesIds.contains(t.getInternalId()))).collect(Collectors.toList()), null, fields, beanContext);
} catch (RuntimeException e) {
LOG.debug("Error retrieving templates for build configuration " + LogUtil.describe(buildType) + ": " + e.toString(), e);
List<String> templateIds = ((BuildTypeImpl) buildType).getOwnTemplateIds();
if (templateIds.isEmpty())
return null;
List<BuildTypeOrTemplate> result = getBuildTypeOrTemplates(templateIds, fields.getNestedField("template"), beanContext);
return result.isEmpty() ? null : new BuildTypes(result, null, fields, beanContext);
}
}
use of jetbrains.buildServer.server.rest.util.BeanContext in project teamcity-rest by JetBrains.
the class PropEntity method getFakeBeanContext.
public static BeanContext getFakeBeanContext(@NotNull final ServiceLocator serviceLocator) {
final ApiUrlBuilder apiUrlBuilder = new ApiUrlBuilder(new PathTransformer() {
public String transform(final String path) {
return path;
}
});
final BeanFactory beanFactory = new BeanFactory(null);
return new BeanContext(beanFactory, serviceLocator, apiUrlBuilder);
}
use of jetbrains.buildServer.server.rest.util.BeanContext in project teamcity-rest by JetBrains.
the class TestOccurrenceRequestTest method setUp.
@Override
@BeforeMethod
public void setUp() throws Exception {
super.setUp();
myRequest = new TestOccurrenceRequest();
BeanContext ctx = BaseFinderTest.getBeanContext(myFixture);
myRequest.initForTests(ctx.getServiceLocator(), ctx.getSingletonService(TestOccurrenceFinder.class), ctx.getApiUrlBuilder(), ctx);
}
Aggregations