private <C> void validateIssue(I issue, Property<C> property, SCMChangeLog<T> changeLog) { SCMChangeLogIssueValidator<C, S, T, I> validator = (SCMChangeLogIssueValidator<C, S, T, I>) property.getType(); validator.validate(changeLog, issue, property.getValue()); }
protected @Nullable Build lookupBuild(SVNLocation location, SVNLocation firstCopy, Branch branch) { // Gets the SVN configuration for the branch Property<SVNBranchConfigurationProperty> configurationProperty = propertyService.getProperty(branch, SVNBranchConfigurationPropertyType.class); if (configurationProperty.isEmpty()) { return null; } // Gets the build link ConfiguredBuildSvnRevisionLink<Object> revisionLink = buildSvnRevisionLinkService.getConfiguredBuildSvnRevisionLink( configurationProperty.getValue().getBuildRevisionLink() ); // Gets the earliest build return revisionLink.getEarliestBuild(branch, location, firstCopy, configurationProperty.getValue()).orElse(null); }
@Override public List<Decoration<String>> getDecorations(ProjectEntity entity) { Property<StashProjectConfigurationProperty> property = propertyService.getProperty(entity, StashProjectConfigurationPropertyType.class); if (!property.isEmpty()) { return Collections.singletonList( Decoration.of( this, String.format( "%s/%s @ %s", property.getValue().getProject(), property.getValue().getRepository(), property.getValue().getConfiguration().getName() ) ) ); } else { return Collections.emptyList(); } }
@Override public List<Decoration<String>> getDecorations(ProjectEntity entity) { // Argument check Validate.isTrue(entity instanceof Build, "Expecting build"); // Gets the `release` property Property<ReleaseProperty> property = propertyService.getProperty(entity, ReleasePropertyType.class); if (property.isEmpty()) { return Collections.emptyList(); } else { return Collections.singletonList( Decoration.of( this, property.getValue().getName() ) ); } }
@Override public List<Decoration<String>> getDecorations(ProjectEntity entity) { Property<GitHubProjectConfigurationProperty> property = propertyService.getProperty(entity, GitHubProjectConfigurationPropertyType.class); if (!property.isEmpty()) { return Collections.singletonList( Decoration.of( this, String.format( "%s @ %s", property.getValue().getRepository(), property.getValue().getConfiguration().getName() ) ) ); } else { return Collections.emptyList(); } }
@Override public List<Decoration<String>> getDecorations(ProjectEntity entity) { Property<SVNProjectConfigurationProperty> property = propertyService.getProperty(entity, SVNProjectConfigurationPropertyType.class); if (!property.isEmpty()) { return Collections.singletonList( Decoration.of( this, property.getValue().getUrl() ) ); } else { return Collections.emptyList(); } }
@Override public List<Decoration<String>> getDecorations(ProjectEntity entity) { Property<GitLabProjectConfigurationProperty> property = propertyService.getProperty(entity, GitLabProjectConfigurationPropertyType.class); if (!property.isEmpty()) { return Collections.singletonList( Decoration.of( this, String.format( "%s @ %s", property.getValue().getRepository(), property.getValue().getConfiguration().getName() ) ) ); } else { return Collections.emptyList(); } }
@Override public void forEachConfiguredBranch( Predicate<SVNProjectConfigurationProperty> projectConfigurationPredicate, BiConsumer<Branch, SVNBranchConfigurationProperty> branchConsumer) { // Loops over all authorised branches for (Project project : structureService.getProjectList()) { // Filter on SVN configuration: must be present and equal to the one the revision info is looked into Property<SVNProjectConfigurationProperty> projectSvnConfig = propertyService.getProperty(project, SVNProjectConfigurationPropertyType.class); if (!projectSvnConfig.isEmpty() && projectConfigurationPredicate.test(projectSvnConfig.getValue())) { structureService.getBranchesForProject(project.getId()).stream() .filter(branch -> propertyService.hasProperty(branch, SVNBranchConfigurationPropertyType.class)) .forEach(branch -> { // Branch configuration SVNBranchConfigurationProperty branchConfiguration = propertyService.getProperty(branch, SVNBranchConfigurationPropertyType.class).getValue(); // OK branchConsumer.accept(branch, branchConfiguration); }); } } }
@Override public SVNSyncInfo getSyncInfo(ID branchId) { Branch branch = structureService.getBranch(branchId); return new SVNSyncInfo( branch, propertyService.getProperty(branch, SVNSyncPropertyType.class).getValue() ); }
@Override public List<Decoration<JenkinsJob>> getDecorations(ProjectEntity entity) { // Gets the Jenkins Job property for this entity, if any Property<JenkinsJobProperty> property = propertyService.getProperty(entity, JenkinsJobPropertyType.class.getName()); if (property.isEmpty()) { return Collections.emptyList(); } else { // Template branch? Decoration cannot be computed if (entity instanceof Branch && ((Branch) entity).getType() == BranchType.TEMPLATE_DEFINITION) { return Collections.emptyList(); } // Gets a client // FIXME getJob does not need a full HTTP client JenkinsClient jenkinsClient = jenkinsClientFactory.getClient(property.getValue().getConfiguration()); // Gets the Jenkins job JenkinsJob job = jenkinsClient.getJob(property.getValue().getJob()); // Gets the decoration for the job return Collections.singletonList( getDecoration(job) ); } }
protected <T> T getProperty(ProjectEntity projectEntity, Class<? extends PropertyType<T>> propertyTypeClass) throws Exception { return asUser().with(projectEntity, ProjectEdit.class).call(() -> propertyService.getProperty( projectEntity, propertyTypeClass ).getValue() ); }
@Override public <T> void copyProperty(ProjectEntity sourceEntity, Property<T> property, ProjectEntity targetEntity, Function<String, String> replacementFn) { // Property copy T data = property.getType().copy(sourceEntity, property.getValue(), targetEntity, replacementFn); // Direct edition editProperty(targetEntity, property.getType(), data); }
private JobRegistration getSVNBuildSyncJobRegistration(Branch branch) { Property<SVNSyncProperty> svnSync = propertyService.getProperty(branch, SVNSyncPropertyType.class); if (svnSync.isEmpty()) { throw new IllegalStateException("No SVN build sync is set"); } else { return JobRegistration.of(createJob(branch)) .everyMinutes(svnSync.getValue().getInterval()); } }
@Override public Optional<SVNRepository> getSVNRepository(Branch branch) { // Gets the SVN project configuration property Property<SVNProjectConfigurationProperty> projectConfiguration = propertyService.getProperty( branch.getProject(), SVNProjectConfigurationPropertyType.class ); if (projectConfiguration.isEmpty()) { return Optional.empty(); } else { SVNConfiguration configuration = projectConfiguration.getValue().getConfiguration(); return Optional.of( getRepository(configuration.getName()) ); } }
@Override public List<String> getBranches(Branch branch) { Property<SVNProjectConfigurationProperty> svnProperty = propertyService.getProperty( branch.getProject(), SVNProjectConfigurationPropertyType.class ); if (svnProperty.isEmpty()) { return Collections.emptyList(); } else { SVNRepository repository = getSVNRepository(branch).get(); String projectPath = svnProperty.getValue().getProjectPath(); String branchesDir; if (projectPath.endsWith("/trunk")) { branchesDir = projectPath.replace("/trunk", "/branches"); } else { branchesDir = projectPath + "/branches"; } return svnClient.getBranches( repository, SVNUtils.toURL(repository.getUrl(branchesDir)) ); } }
protected String getSVNBuildPath(Build build) { // Gets the build path property value Property<SVNBranchConfigurationProperty> branchConfiguration = propertyService.getProperty( build.getBranch(), SVNBranchConfigurationPropertyType.class ); if (branchConfiguration.isEmpty()) { throw new MissingSVNBranchConfigurationException(build.getBranch().getName()); } else { // Gets the build revision link ConfiguredBuildSvnRevisionLink<Object> revisionLink = buildSvnRevisionLinkService.getConfiguredBuildSvnRevisionLink( branchConfiguration.getValue().getBuildRevisionLink() ); // Gets the path to the build return revisionLink.getBuildPath(build, branchConfiguration.getValue()); } }
public JobRegistration scheduleArtifactoryBuildSync(Branch branch) { ArtifactoryPromotionSyncProperty property = propertyService.getProperty(branch, ArtifactoryPromotionSyncPropertyType.class).getValue(); return JobRegistration.of(getBranchSyncJob(branch)).everyMinutes(property.getInterval()); }
private <T> boolean matchProperty(ProjectEntity e, PropertyFilter filter) { PropertyType<T> type = propertyService.getPropertyTypeByName(filter.getType()); Property<T> property = propertyService.getProperty(e, filter.getType()); return !property.isEmpty() && ( StringUtils.isBlank(filter.getValue()) || type.containsValue(property.getValue(), filter.getValue()) ); }
@Override public OptionalLong getBuildRevision(Build build) { // Gets the branch SVN information Property<SVNBranchConfigurationProperty> branchConfigurationProperty = propertyService.getProperty(build.getBranch(), SVNBranchConfigurationPropertyType.class); Property<SVNProjectConfigurationProperty> projectConfigurationProperty = propertyService.getProperty(build.getBranch().getProject(), SVNProjectConfigurationPropertyType.class); if (branchConfigurationProperty.isEmpty() || projectConfigurationProperty.isEmpty()) { return OptionalLong.empty(); } else { // Gets the branch revision link ConfiguredBuildSvnRevisionLink<Object> revisionLink = buildSvnRevisionLinkService.getConfiguredBuildSvnRevisionLink( branchConfigurationProperty.getValue().getBuildRevisionLink() ); // Returns revision information return revisionLink.getRevision(build, branchConfigurationProperty.getValue()); } }
@Override public Optional<EntityInformation> getInformation(ProjectEntity entity) { if (entity instanceof Build) { Build build = (Build) entity; // Gets the branch SVN information Property<SVNBranchConfigurationProperty> branchConfigurationProperty = propertyService.getProperty(build.getBranch(), SVNBranchConfigurationPropertyType.class); Property<SVNProjectConfigurationProperty> projectConfigurationProperty = propertyService.getProperty(build.getBranch().getProject(), SVNProjectConfigurationPropertyType.class); if (branchConfigurationProperty.isEmpty() || projectConfigurationProperty.isEmpty()) { return Optional.empty(); } else { // Loads the repository SVNRepository repository = svnService.getRepository(projectConfigurationProperty.getValue().getConfiguration().getName()); // Gets the build history try (Transaction ignored = transactionService.start()) { return Optional.of( new EntityInformation( this, svnChangeLogService.getBuildSVNHistory(repository, build) ) ); } } } else { return Optional.empty(); } } }