Search in sources :

Example 1 with SingleVersionRepositoryStateAdapter

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

the class VcsRootInstance method setFieldValue.

public static void setFieldValue(final jetbrains.buildServer.vcs.VcsRootInstance rootInstance, final String field, final String newValue, @NotNull final BeanContext beanContext) {
    if (LAST_VERSION_INTERNAL.equals(field) || (LAST_VERSION.equals(field) && StringUtil.isEmpty(newValue))) {
        if (!StringUtil.isEmpty(newValue)) {
            beanContext.getSingletonService(RepositoryStateManager.class).setRepositoryState(rootInstance, new SingleVersionRepositoryStateAdapter(newValue));
            Loggers.VCS.info("Repository state is set to \"" + newValue + "\" via REST API call for " + rootInstance.describe(false) + " by " + beanContext.getSingletonService(PermissionChecker.class).getCurrentUserDescription());
        } else {
            beanContext.getSingletonService(RepositoryStateManager.class).setRepositoryState(rootInstance, new SingleVersionRepositoryStateAdapter((String) null));
            Loggers.VCS.info("Repository state is reset via REST API call for " + rootInstance.describe(false) + " by " + beanContext.getSingletonService(PermissionChecker.class).getCurrentUserDescription());
        }
        return;
    } else if (COMMIT_HOOK_MODE.equals(field)) {
        boolean pollingMode = !Locator.getStrictBooleanOrReportError(newValue);
        ((VcsRootInstanceEx) rootInstance).setPollingMode(pollingMode);
        Loggers.VCS.info("Poling mode is set to \"" + pollingMode + "\" via REST API call for " + rootInstance.describe(false) + " by " + beanContext.getSingletonService(PermissionChecker.class).getCurrentUserDescription());
        return;
    }
    throw new NotFoundException("Setting of field '" + field + "' is not supported. Supported are: " + LAST_VERSION_INTERNAL + ", " + COMMIT_HOOK_MODE);
}
Also used : RepositoryStateManager(jetbrains.buildServer.vcs.impl.RepositoryStateManager) SingleVersionRepositoryStateAdapter(jetbrains.buildServer.vcs.SingleVersionRepositoryStateAdapter) PermissionChecker(jetbrains.buildServer.server.rest.data.PermissionChecker) NotFoundException(jetbrains.buildServer.server.rest.errors.NotFoundException)

Aggregations

PermissionChecker (jetbrains.buildServer.server.rest.data.PermissionChecker)1 NotFoundException (jetbrains.buildServer.server.rest.errors.NotFoundException)1 SingleVersionRepositoryStateAdapter (jetbrains.buildServer.vcs.SingleVersionRepositoryStateAdapter)1 RepositoryStateManager (jetbrains.buildServer.vcs.impl.RepositoryStateManager)1