in rest-api/src/jetbrains/buildServer/server/rest/model/change/VcsRoot.java [138:199]
public VcsRoot(@NotNull final SVcsRoot root, @NotNull final Fields fields, @NotNull final BeanContext beanContext) {
id = ValueWithDefault.decideIncludeByDefault(fields.isIncluded("id"), root.getExternalId());
final boolean includeInternalId = TeamCityProperties.getBoolean(APIController.INCLUDE_INTERNAL_ID_PROPERTY_NAME);
internalId = ValueWithDefault.decideDefault(fields.isIncluded("internalId", includeInternalId, includeInternalId), String.valueOf(root.getId()));
final PermissionChecker permissionChecker = beanContext.getServiceLocator().findSingletonService(PermissionChecker.class);
assert permissionChecker != null;
uuid = ValueWithDefault.decideDefault(fields.isIncluded("uuid", false, false), () -> {
final SProject projectOfTheRoot = getProjectByRoot(root);
if (projectOfTheRoot != null && permissionChecker.isPermissionGranted(Permission.EDIT_PROJECT, projectOfTheRoot.getProjectId())) {
return ((SVcsRootEx)root).getEntityId().getConfigId();
}
return null;
});
name = ValueWithDefault.decideIncludeByDefault(fields.isIncluded("name"), root.getName());
href = ValueWithDefault.decideDefault(fields.isIncluded("href"), () -> beanContext.getApiUrlBuilder().getHref(root));
vcsName = ValueWithDefault.decideDefault(fields.isIncluded("vcsName", false), root.getVcsName());
final String ownerProjectId = root.getScope().getOwnerProjectId();
final SProject projectById = beanContext.getSingletonService(ProjectFinder.class).findProjectByInternalId(ownerProjectId);
if (projectById != null) {
project = ValueWithDefault.decideDefault(fields.isIncluded("project", false), () -> new Project(projectById, fields.getNestedField("project"), beanContext));
} else {
project = ValueWithDefault.decideDefault(fields.isIncluded("project", false), () -> new Project(null, ownerProjectId, fields.getNestedField("project"), beanContext));
}
if (!shouldRestrictSettingsViewing(root, permissionChecker)) {
properties = ValueWithDefault.decideDefault(fields.isIncluded("properties", false),
() -> new Properties(root.getProperties(), null, fields.getNestedField("properties", Fields.NONE, Fields.LONG), beanContext));
modificationCheckInterval = ValueWithDefault.decideDefault(
fields.isIncluded("modificationCheckInterval", false),
() -> root.isUseDefaultModificationCheckInterval() ? null : root.getModificationCheckInterval()
);
vcsRootInstances = ValueWithDefault.decideDefault(fields.isIncluded("vcsRootInstances", false), () -> new VcsRootInstances(
CachingValue.simple(() -> beanContext.getSingletonService(VcsRootInstanceFinder.class).getItems(VcsRootInstanceFinder.getLocatorByVcsRoot(root)).getEntries()),
new SinglePagePagerData(VcsRootInstanceRequest.getVcsRootInstancesHref(root)), fields.getNestedField("vcsRootInstances"), beanContext)
);
repositoryIdStrings = ValueWithDefault.decideDefault(fields.isIncluded("repositoryIdStrings", false, false), () -> {
ArrayList<String> result = new ArrayList<>();
try {
Collection<VcsMappingElement> vcsMappingElements = VcsRoot.getRepositoryMappings(root, beanContext.getSingletonService(VcsManager.class));
for (VcsMappingElement vcsMappingElement : vcsMappingElements) {
result.add(vcsMappingElement.getTo());
}
return new Items(result);
} catch (Exception e) {
LOG.debug("Error while retrieving mapping for VCS root " + LogUtil.describe(root) + ", skipping " + "repositoryIdStrings" + " in root details", e);
//ignore
}
return null;
});
} else {
properties = null;
modificationCheckInterval = null;
vcsRootInstances = null;
repositoryIdStrings = null;
}
}