Search in sources :

Example 11 with BeanContext

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));
}
Also used : BuildTypeOrTemplate(jetbrains.buildServer.server.rest.util.BuildTypeOrTemplate) BeanContext(jetbrains.buildServer.server.rest.util.BeanContext) ApiOperation(io.swagger.annotations.ApiOperation)

Example 12 with BeanContext

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));
}
Also used : BuildTypeOrTemplate(jetbrains.buildServer.server.rest.util.BuildTypeOrTemplate) BeanContext(jetbrains.buildServer.server.rest.util.BeanContext) Dependency(jetbrains.buildServer.serverSide.dependency.Dependency) SArtifactDependency(jetbrains.buildServer.serverSide.artifacts.SArtifactDependency) ApiOperation(io.swagger.annotations.ApiOperation)

Example 13 with BeanContext

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);
    }
}
Also used : AuthorityHolder(jetbrains.buildServer.serverSide.auth.AuthorityHolder) BuildTypeOrTemplate(jetbrains.buildServer.server.rest.util.BuildTypeOrTemplate) jetbrains.buildServer.server.rest.data(jetbrains.buildServer.server.rest.data) InvestigationFinder(jetbrains.buildServer.server.rest.data.investigations.InvestigationFinder) BadRequestException(jetbrains.buildServer.server.rest.errors.BadRequestException) jetbrains.buildServer.server.rest.model(jetbrains.buildServer.server.rest.model) Agents(jetbrains.buildServer.server.rest.model.agent.Agents) XmlType(javax.xml.bind.annotation.XmlType) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) BuildTypeIdentifiersManager(jetbrains.buildServer.serverSide.identifiers.BuildTypeIdentifiersManager) ParametersPersistableEntity(jetbrains.buildServer.server.rest.data.parameters.ParametersPersistableEntity) InvestigationWrapper(jetbrains.buildServer.server.rest.data.investigations.InvestigationWrapper) StringUtil(jetbrains.buildServer.util.StringUtil) SecurityContext(jetbrains.buildServer.serverSide.auth.SecurityContext) LogUtil(jetbrains.buildServer.serverSide.impl.LogUtil) Logger(com.intellij.openapi.diagnostic.Logger) BuildTypeRequest(jetbrains.buildServer.server.rest.request.BuildTypeRequest) ModelDescription(jetbrains.buildServer.server.rest.swagger.annotations.ModelDescription) XmlAttribute(javax.xml.bind.annotation.XmlAttribute) Lazy(jetbrains.buildServer.util.impl.Lazy) ServiceLocator(jetbrains.buildServer.ServiceLocator) Branches(jetbrains.buildServer.server.rest.model.build.Branches) jetbrains.buildServer.serverSide(jetbrains.buildServer.serverSide) Builds(jetbrains.buildServer.server.rest.model.build.Builds) Set(java.util.Set) CachingValue(jetbrains.buildServer.server.rest.util.CachingValue) EntityWithParameters(jetbrains.buildServer.server.rest.data.parameters.EntityWithParameters) XmlRootElement(javax.xml.bind.annotation.XmlRootElement) ValueWithDefault(jetbrains.buildServer.server.rest.util.ValueWithDefault) Collectors(java.util.stream.Collectors) APIController(jetbrains.buildServer.server.rest.APIController) Objects(java.util.Objects) Project(jetbrains.buildServer.server.rest.model.project.Project) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) Permission(jetbrains.buildServer.serverSide.auth.Permission) AgentRequest(jetbrains.buildServer.server.rest.request.AgentRequest) AuthUtil(jetbrains.buildServer.serverSide.auth.AuthUtil) InheritableUserParametersHolderEntityWithParameters(jetbrains.buildServer.server.rest.data.parameters.InheritableUserParametersHolderEntityWithParameters) BeanContext(jetbrains.buildServer.server.rest.util.BeanContext) NotNull(org.jetbrains.annotations.NotNull) Collections(java.util.Collections) ApiModelProperty(io.swagger.annotations.ApiModelProperty) InvestigationRequest(jetbrains.buildServer.server.rest.request.InvestigationRequest) SUser(jetbrains.buildServer.users.SUser) XmlElement(javax.xml.bind.annotation.XmlElement) BuildTypeOrTemplate(jetbrains.buildServer.server.rest.util.BuildTypeOrTemplate) List(java.util.List) Nullable(org.jetbrains.annotations.Nullable)

Example 14 with 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);
}
Also used : BeanContext(jetbrains.buildServer.server.rest.util.BeanContext) ApiUrlBuilder(jetbrains.buildServer.server.rest.ApiUrlBuilder) BeanFactory(jetbrains.buildServer.server.rest.util.BeanFactory) PathTransformer(jetbrains.buildServer.server.rest.PathTransformer)

Example 15 with BeanContext

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);
}
Also used : BeanContext(jetbrains.buildServer.server.rest.util.BeanContext) TestOccurrenceFinder(jetbrains.buildServer.server.rest.data.problem.TestOccurrenceFinder) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

BeanContext (jetbrains.buildServer.server.rest.util.BeanContext)21 ApiOperation (io.swagger.annotations.ApiOperation)12 BuildTypeOrTemplate (jetbrains.buildServer.server.rest.util.BuildTypeOrTemplate)10 SArtifactDependency (jetbrains.buildServer.serverSide.artifacts.SArtifactDependency)6 BeanFactory (jetbrains.buildServer.server.rest.util.BeanFactory)5 ApiUrlBuilder (jetbrains.buildServer.server.rest.ApiUrlBuilder)4 Test (org.testng.annotations.Test)4 PathTransformer (jetbrains.buildServer.server.rest.PathTransformer)3 Dependency (jetbrains.buildServer.serverSide.dependency.Dependency)3 File (java.io.File)2 FakeHttpServletRequest (jetbrains.buildServer.controllers.fakes.FakeHttpServletRequest)2 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)2 Build (jetbrains.buildServer.server.rest.model.build.Build)2 TestOccurrences (jetbrains.buildServer.server.rest.model.problem.TestOccurrences)2 TestFor (jetbrains.buildServer.util.TestFor)2 BeforeMethod (org.testng.annotations.BeforeMethod)2 Logger (com.intellij.openapi.diagnostic.Logger)1 ApiModelProperty (io.swagger.annotations.ApiModelProperty)1 Collections (java.util.Collections)1 List (java.util.List)1