protected boolean canApplyTo(Branch branch) { return propertyService.hasProperty(branch.getProject(), SVNProjectConfigurationPropertyType.class) && propertyService.hasProperty(branch, SVNBranchConfigurationPropertyType.class); }
/** * One can edit the SVN synchronisation only if he can configure the project and if the branch * is configured for SVN. */ @Override public boolean canEdit(ProjectEntity entity, SecurityService securityService) { return securityService.isProjectFunctionGranted(entity, ProjectConfig.class) && propertyService.hasProperty( entity, SVNBranchConfigurationPropertyType.class); }
/** * Gets the list of all branches, for all projects, which are properly configured for SVN. */ protected Stream<Branch> getSVNConfiguredBranches() { return structureService.getProjectList() .stream() // ...which have a SVN configuration .filter(project -> propertyService.hasProperty(project, SVNProjectConfigurationPropertyType.class)) // ...gets all their branches .flatMap(project -> structureService.getBranchesForProject(project.getId()).stream()) // ...which have a SVN configuration .filter(branch -> propertyService.hasProperty(branch, SVNBranchConfigurationPropertyType.class)); } }
@Override public boolean isValid() { return super.isValid() && propertyService.hasProperty(branch, SVNSyncPropertyType.class) && svnService.getSVNRepository(branch).isPresent() ; } };
@Override public Optional<Action> getAction(ProjectEntity entity) { if (entity instanceof Branch && propertyService.hasProperty(entity, SVNBranchConfigurationPropertyType.class) && securityService.isProjectFunctionGranted(entity, BuildCreate.class)) { return Optional.of(Action.of( "svn-sync", "SVN <-> Build sync", String.format("sync/%d", entity.id()) )); } else { return Optional.empty(); } }
@Override public Stream<JobRegistration> collectJobRegistrations() { if (artifactoryConfProperties.isBuildSyncDisabled()) { return Stream.empty(); } else { return securityService.asAdmin(() -> // For all projects... structureService.getProjectList().stream() // ... and their branches .flatMap(project -> structureService.getBranchesForProject(project.getId()).stream()) // ... only if not a template .filter(branch -> branch.getType() != BranchType.TEMPLATE_DEFINITION) // ... gets those with the sync. property .filter(branch -> propertyService.hasProperty(branch, ArtifactoryPromotionSyncPropertyType.class)) // ... creates the job .map(this::scheduleArtifactoryBuildSync) ); } }
/** * One can edit the SVN configuration of a branch only if he can configurure a project and if the project * is itself configured with SVN. */ @Override public boolean canEdit(ProjectEntity entity, SecurityService securityService) { return securityService.isProjectFunctionGranted(entity.projectId(), ProjectConfig.class) && propertyService.hasProperty( entity.getProject(), SVNProjectConfigurationPropertyType.class); }
@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); }); } } }
propertyService.hasProperty(branch, SVNBranchConfigurationPropertyType.class)) {