protected Optional<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 Optional.empty(); } // Gets the build link ConfiguredBuildSvnRevisionLink<Object> revisionLink = buildSvnRevisionLinkService.getConfiguredBuildSvnRevisionLink( configurationProperty.getValue().getBuildRevisionLink()); // Gets the earliest build return revisionLink.getEarliestBuild( branch, location, firstCopy, configurationProperty.getValue()); }
private static void processElement( Object element, ClassLoader classLoader, Method putMethod, Object context, Method putByNameMethod) throws ClassNotFoundException, InstantiationException, InvocationTargetException, ConfigurationException, IllegalAccessException, IllegalArgumentException { if (element instanceof Component) { Component c = (Component) element; Class compClass = Class.forName(c.getClazz(), true, classLoader); String name = c.getName(); Object instance = compClass.newInstance(); for (Property p : c.getProperty()) { setPropertyOnComponent(instance, p.getName(), p.getValue()); log.log( Level.FINER, MessageNames.SET_PROPERTY_ON_COMPONENT, new Object[] {p.getName(), c.getClazz(), c.getName(), p.getValue()}); } if (name == null || name.trim().length() == 0) { putMethod.invoke(context, instance); } else { putByNameMethod.invoke(context, name, instance); } } else if (element instanceof Property) { Property p = (Property) element; putByNameMethod.invoke(context, p.getName(), p.getValue()); } else if (element instanceof DiscoveryContextType) { /* Just drop the element into the context under the appropriate name. */ DiscoveryContextType dct = (DiscoveryContextType) element; if (dct.getName() == null) { putByNameMethod.invoke(context, Strings.DEFAULT_DISCOVERY_CONTEXT, dct); } else { putByNameMethod.invoke(context, dct.getName(), dct); } } else { throw new ConfigurationException( MessageNames.UNSUPPORTED_ELEMENT, element.getClass().getName()); } }
@Override public OntrackSVNRevisionInfo getOntrackRevisionInfo(SVNRepository repository, long revision) { // Gets information about the revision SVNRevisionInfo basicInfo = svnService.getRevisionInfo(repository, revision); SVNChangeLogRevision changeLogRevision = svnService.createChangeLogRevision(repository, basicInfo); // Gets the first copy event on this path after this revision SVNLocation firstCopy = svnService.getFirstCopyAfter(repository, basicInfo.toLocation()); // Data to collect Collection<BuildView> buildViews = new ArrayList<>(); Collection<BranchStatusView> branchStatusViews = new ArrayList<>(); // 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() && repository .getConfiguration() .getName() .equals(projectSvnConfig.getValue().getConfiguration().getName())) { for (Branch branch : structureService.getBranchesForProject(project.getId())) { // Filter on branch type // Filter on SVN configuration: must be present if (branch.getType() != BranchType.TEMPLATE_DEFINITION && propertyService.hasProperty(branch, SVNBranchConfigurationPropertyType.class)) { // Identifies a possible build given the path/revision and the first copy Optional<Build> build = lookupBuild(basicInfo.toLocation(), firstCopy, branch); // Build found if (build.isPresent()) { // Gets the build view BuildView buildView = structureService.getBuildView(build.get()); // Adds it to the list buildViews.add(buildView); // Collects the promotions for the branch branchStatusViews.add(structureService.getEarliestPromotionsAfterBuild(build.get())); } } } } } // OK return new OntrackSVNRevisionInfo( repository.getConfiguration(), changeLogRevision, buildViews, branchStatusViews); }
protected void addPropertyInternal(Property property) { if (property.getKey() == null) { throw new IllegalArgumentException("key is required for property"); } Object propertyValue = property.getValue(); if (propertyValue instanceof PropertyValue && !((PropertyValue) propertyValue).isStore()) { return; } Property existingProperty = getProperty(property.getKey(), property.getName(), property.getVisibility()); if (existingProperty == null) { this.properties.add(property); } else { if (existingProperty instanceof MutableProperty) { ((MutableProperty) existingProperty).update(property); } else { throw new VertexiumException( "Could not update property of type: " + existingProperty.getClass().getName()); } } }