@Override public Optional<GitConfiguration> getConfiguration(Project project) { return propertyService.getProperty(project, GitLabProjectConfigurationPropertyType.class) .option() .map(this::getGitConfiguration); }
@Override public Optional<GitConfiguration> getConfiguration(Project project) { return propertyService.getProperty(project, GitHubProjectConfigurationPropertyType.class) .option() .map(this::getGitConfiguration); }
@Override public Optional<GitConfiguration> getConfiguration(Project project) { return propertyService.getProperty(project, StashProjectConfigurationPropertyType.class) .option() .map(this::getGitConfiguration); }
@Override public List<Decoration<Boolean>> getDecorations(ProjectEntity entity) { return propertyService.getProperty(entity, AutoPromotionPropertyType.class).option() .map(autoPromotionProperty -> Collections.singletonList(Decoration.of(this, Boolean.TRUE))) .orElse(Collections.emptyList()); } }
@Override public List<Decoration<MessageProperty>> getDecorations(ProjectEntity entity) { // Gets the `message` property return propertyService.getProperty(entity, MessagePropertyType.class) .option() .map( messageProperty -> Collections.singletonList( Decoration.of( this, messageProperty ) ) ) .orElse(Collections.<Decoration<MessageProperty>>emptyList()); }
private Job getBranchSyncJob(Branch branch) { return propertyService.getProperty(branch, ArtifactoryPromotionSyncPropertyType.class).option() .map(syncProperty -> new AbstractBranchJob(structureService, branch) { @Override public JobKey getKey() { return getBranchSyncJobKey(branch); } @Override public JobRun getTask() { return runListener -> sync(branch, runListener); } @Override public String getDescription() { return String.format( "Synchronisation of promotions with Artifactory for branch %s/%s", branch.getProject().getName(), branch.getName() ); } @Override public boolean isValid() { return super.isValid() && propertyService.hasProperty(branch, ArtifactoryPromotionSyncPropertyType.class); } } ) .orElseThrow(() -> new IllegalStateException("Branch not configured for Artifactory")); }
@Override public Collection<? extends Issue> getLinkedIssues(Project project, IssueServiceConfiguration issueServiceConfiguration, Issue issue) { // Gets a list of link names to follow return propertyService.getProperty(project, JIRAFollowLinksPropertyType.class).option() .map(property -> { Map<String, JIRAIssue> issues = new LinkedHashMap<>(); followLinks( (JIRAConfiguration) issueServiceConfiguration, (JIRAIssue) issue, Sets.newHashSet(property.getLinkNames()), issues ); return issues.values(); }) .orElse(Collections.singleton((JIRAIssue) issue)); }
@Override public Stream<JobRegistration> collectJobRegistrations() { if (subversionConfProperties.isBuildSyncDisabled()) { return Stream.empty(); } else { return securityService.asAdmin(() -> getSVNConfiguredBranches() .filter(branch -> propertyService.getProperty(branch, SVNSyncPropertyType.class).option().isPresent()) .map(this::getSVNBuildSyncJobRegistration) ); } }
private void cleanPromotionLevel(PromotionLevel promotionLevel, int validationStampId) { Optional<AutoPromotionProperty> oProperty = propertyService.getProperty(promotionLevel, AutoPromotionPropertyType.class).option(); if (oProperty.isPresent()) { AutoPromotionProperty property = oProperty.get(); List<ValidationStamp> keptValidationStamps = property.getValidationStamps().stream().filter( validationStamp -> (validationStampId != validationStamp.id()) ).collect(Collectors.toList()); if (keptValidationStamps.size() < property.getValidationStamps().size()) { property = new AutoPromotionProperty( keptValidationStamps, property.getInclude(), property.getExclude() ); propertyService.editProperty( promotionLevel, AutoPromotionPropertyType.class, property ); } } }
@Override public Optional<SCMPathInfo> getSCMPathInfo(Branch branch) { return propertyService.getProperty( branch, SVNBranchConfigurationPropertyType.class ).option().map(property -> { SVNRepository svnRepository = getSVNRepository(branch).get(); return new SCMPathInfo( "svn", svnRepository.getUrl(property.getCuredBranchPath()), null, null ); } ); } }
@Override public List<Decoration<TestDecorationData>> getDecorations(ProjectEntity entity) { return propertyService.getProperty(entity, TestDecoratorPropertyType.class) .option() .map(data -> Collections.singletonList( Decoration.of( TestDecorator.this, data ) )) .orElse(Collections.emptyList()); }
@Override public Optional<String> download(Branch branch, String path) { // Security check securityService.checkProjectFunction(branch, ProjectConfig.class); // If project configured... Optional<SVNRepository> oSvnRepository = getSVNRepository(branch); if (oSvnRepository.isPresent()) { // SVN Branch configuration Optional<SVNBranchConfigurationProperty> oSvnBranchConfigurationProperty = propertyService.getProperty( branch, SVNBranchConfigurationPropertyType.class ).option(); if (oSvnBranchConfigurationProperty.isPresent()) { String pathInBranch = oSvnBranchConfigurationProperty.get().getCuredBranchPath() + "/" + StringUtils.stripStart(path, "/"); try (Transaction ignored = transactionService.start()) { return svnClient.download(oSvnRepository.get(), pathInBranch); } } else { return Optional.empty(); } } else { return Optional.empty(); } }
private void checkPromotionLevel(Build build, PromotionLevel promotionLevel, List<ValidationStamp> validationStamps) { Optional<AutoPromotionProperty> oProperty = propertyService.getProperty(promotionLevel, AutoPromotionPropertyType.class).option(); if (oProperty.isPresent()) { AutoPromotionProperty property = oProperty.get();
@Override public void validateBuild(Build build) throws BuildValidationException { propertyService.getProperty(build.getBranch(), SVNBranchConfigurationPropertyType.class).option().ifPresent(property -> { // Gets the configured link ConfiguredBuildSvnRevisionLink<Object> revisionLink = buildSvnRevisionLinkService.getConfiguredBuildSvnRevisionLink(property.getBuildRevisionLink()); // Tests the validity of the build name if (!revisionLink.isValidBuildName(build.getName())) { throw new BuildValidationException( String.format( "Build %s does not comply with the SVN configuration", build.getName() ) ); } }); } }