private void populateVirtualP2Values(
     P2TypeSpecificConfigModel model, VirtualRepoDescriptor descriptor) {
   if (descriptor.getP2() == null || descriptor.getP2().getUrls() == null) {
     return;
   }
   Map<String, String> urlToRepoKeyMap = getUrlToRepoKeyMapping(descriptor.getRepositories());
   List<P2Repo> p2Repos = Lists.newArrayList();
   descriptor
       .getP2()
       .getUrls()
       .stream()
       .forEach(
           url -> {
             if (StringUtils.startsWith(url, "local://")) {
               Optional.ofNullable(resolveLocalP2RepoFromUrl(url)).ifPresent(p2Repos::add);
             } else {
               urlToRepoKeyMap
                   .keySet()
                   .stream()
                   .map(RepoConfigDescriptorBuilder::getUrlWithoutSubpath)
                   .filter(
                       p2Url ->
                           RepoConfigDescriptorBuilder.getUrlWithoutSubpath(url).equals(p2Url))
                   .findAny()
                   .ifPresent(
                       containingUrl ->
                           p2Repos.add(new P2Repo(null, urlToRepoKeyMap.get(containingUrl), url)));
             }
           });
   model.setP2Repos(p2Repos);
 }
 private TypeSpecificConfigModel createVirtualTypeSpecific(
     RepoType type, VirtualRepoDescriptor descriptor) {
   TypeSpecificConfigModel typeSpecific = null;
   MavenTypeSpecificConfigModel mavenModel = null;
   switch (type) {
     case Maven:
       mavenModel = new MavenTypeSpecificConfigModel();
       break;
     case Gradle:
       mavenModel = new GradleTypeSpecificConfigModel();
       break;
     case Ivy:
       mavenModel = new IvyTypeSpecificConfigModel();
       break;
     case SBT:
       mavenModel = new SbtTypeSpecificConfigModel();
       break;
     case P2:
       P2TypeSpecificConfigModel p2 = new P2TypeSpecificConfigModel();
       populateVirtualP2Values(p2, descriptor);
       mavenModel = p2;
       break;
     case Gems:
       typeSpecific = new GemsTypeSpecificConfigModel();
       break;
     case Npm:
       typeSpecific = new NpmTypeSpecificConfigModel();
       break;
     case Bower:
       typeSpecific = new BowerTypeSpecificConfigModel();
       break;
     case NuGet:
       typeSpecific = new NugetTypeSpecificConfigModel();
       populateSharedNuGetValues((NugetTypeSpecificConfigModel) typeSpecific, descriptor);
       break;
     case Pypi:
       typeSpecific = new PypiTypeSpecificConfigModel();
       break;
     case Docker:
       DockerTypeSpecificConfigModel dockerType = new DockerTypeSpecificConfigModel();
       dockerType.setForceDockerAuthentication(descriptor.isForceDockerAuthentication());
       typeSpecific = dockerType;
       break;
     case Generic:
       typeSpecific = new GenericTypeSpecificConfigModel();
       break;
   }
   if (typeSpecific != null) {
     return typeSpecific;
   }
   populateMavenVirtualValues(mavenModel, descriptor);
   return mavenModel;
 }
  /** Populate model configuration from virtual repository descriptor */
  public void populateVirtualRepositoryConfigValuesToModel(
      VirtualRepoDescriptor descriptor, VirtualRepositoryConfigModel model) {
    // General
    GeneralRepositoryConfigModel general = new GeneralRepositoryConfigModel();
    general.setRepoKey(descriptor.getKey());
    model.setGeneral(general);

    // Basic
    VirtualBasicRepositoryConfigModel basic = new VirtualBasicRepositoryConfigModel();
    Optional.ofNullable(descriptor.getRepoLayout())
        .ifPresent(layout -> basic.setLayout(layout.getName()));
    basic.setPublicDescription(descriptor.getDescription());
    basic.setInternalDescription(descriptor.getNotes());
    basic.setExcludesPattern(descriptor.getExcludesPattern());
    basic.setIncludesPattern(descriptor.getIncludesPattern());
    List<RepoDescriptor> repositories = descriptor.getRepositories();
    VirtualRepoResolver resolver = new VirtualRepoResolver(descriptor);
    List<String> resolvedDesc =
        resolver
            .getOrderedRepos()
            .stream()
            .map(RealRepoDescriptor::getKey)
            .collect(Collectors.toList());
    basic.setResolvedRepositories(resolvedDesc);
    basic.setSelectedRepositories(
        repositories.stream().map(VirtualSelectedRepository::new).collect(Collectors.toList()));
    model.setBasic(basic);

    // Advanced
    VirtualAdvancedRepositoryConfigModel advanced = new VirtualAdvancedRepositoryConfigModel();
    advanced.setRetrieveRemoteArtifacts(
        descriptor.isArtifactoryRequestsCanRetrieveRemoteArtifacts());
    model.setAdvanced(advanced);

    // Type specific
    TypeSpecificConfigModel typeSpecific =
        createVirtualTypeSpecific(descriptor.getType(), descriptor);
    model.setTypeSpecific(typeSpecific);
  }
 private void populateMavenVirtualValues(
     MavenTypeSpecificConfigModel model, VirtualRepoDescriptor descriptor) {
   model.setPomCleanupPolicy(descriptor.getPomRepositoryReferencesCleanupPolicy());
   model.setKeyPair(descriptor.getKeyPair());
 }