Package org.sonatype.nexus.plugins.p2.repository.proxy

Examples of org.sonatype.nexus.plugins.p2.repository.proxy.P2ProxyRepositoryConfigurator


  {
    final P2ProxyRepository p2repo = proxy.adaptToFacet(P2ProxyRepository.class);

    Map<String, ArtifactPath> paths;
    try {
      final ArtifactMapping artifactMapping = p2repo.getArtifactMappings().get(baseUrl);
      if (artifactMapping == null) {
        log.debug("Unable to retrive remote has for " + item.getPath());
        return null;
      }
      paths = artifactMapping.getArtifactsPath();
    }
    catch (StorageException e) {
      throw new LocalStorageException(e);
    }
    catch (final IllegalOperationException e) {
View Full Code Here


      final Map<String, ArtifactPath> artifactPaths = new LinkedHashMap<String, ArtifactPath>();
      final ArtifactMapping artifactMapping = new ArtifactMapping(repositoryUri, artifactPaths);
      for (final Xpp3Dom artifactDom : artifactRepositoryDom.getChildren("artifact")) {
        artifactPaths.put(artifactDom.getAttribute("remotePath"),
            new ArtifactPath(artifactDom.getAttribute("remotePath"), artifactDom.getAttribute("md5")));
      }
      tempRemoteArtifactMappings.put(repositoryUri, artifactMapping);

      final String mirrorsURL = artifactRepositoryDom.getAttribute(P2Constants.PROP_MIRRORS_URL);
      tempMirrorsURLsByRepositoryURL.put(repositoryUri, mirrorsURL);
View Full Code Here

    Assert.assertEquals(2, repos.get(0).getArtifacts().size());
    Assert.assertEquals(1, repos.get(1).getArtifacts().size());

    final ArtifactsMerge m = new ArtifactsMerge();

    final Artifacts merged = m.mergeArtifactsMetadata("test", Arrays.asList(item1, item2));

    Assert.assertEquals(3, merged.getArtifacts().size());
    Assert.assertEquals(5, merged.getMappings().size());
  }
View Full Code Here

  private ArrayList<Artifacts> loadArtifactsMetadata(final String[] files)
      throws IOException, XmlPullParserException
  {
    final ArrayList<Artifacts> repos = new ArrayList<Artifacts>();
    for (final String file : files) {
      repos.add(new Artifacts(loadXpp3Dom(file)));
    }
    return repos;
  }
View Full Code Here

      throws RemoteStorageException, ItemNotFoundException
  {
    try {
      final List<StorageFileItem> fileItems = doRetrieveItems(P2Constants.ARTIFACTS_XML, context, repository);
      final ArtifactsMerge m = new ArtifactsMerge();
      final Artifacts metadata = m.mergeArtifactsMetadata(repository.getName(), fileItems);

      return createMetadataItems(
          repository,
          P2Constants.ARTIFACTS_XML,
          P2Constants.ARTIFACTS_JAR,
View Full Code Here

    }
    catch (final IOException e) {
      throw new RemoteStorageException(e);
    }

    final Artifacts metadata = new Artifacts(dom);
    metadata.setRepositoryAttributes(repository.getName());
    final LinkedHashMap<String, String> properties = metadata.getProperties();
    final String mirrorsURL = properties.get(P2Constants.PROP_MIRRORS_URL);
    if (mirrorsURL != null) {
      context.put(CTX_MIRRORS_URL, mirrorsURL);
    }
    properties.remove(P2Constants.PROP_MIRRORS_URL);
    metadata.setProperties(properties);

    try {
      return createMetadataItems(
          repository,
          P2Constants.ARTIFACTS_XML,
View Full Code Here

    // sanity check
    Assert.assertEquals(2, repos.get(0).getArtifacts().size());
    Assert.assertEquals(1, repos.get(1).getArtifacts().size());

    final ArtifactsMerge m = new ArtifactsMerge();

    final Artifacts merged = m.mergeArtifactsMetadata("test", Arrays.asList(item1, item2));

    Assert.assertEquals(3, merged.getArtifacts().size());
    Assert.assertEquals(5, merged.getMappings().size());
  }
View Full Code Here

    // sanity check
    Assert.assertEquals(2, repos.get(0).getArtifacts().size());
    Assert.assertEquals(1, repos.get(1).getArtifacts().size());

    final ArtifactsMerge m = new ArtifactsMerge();

    try {
      m.mergeArtifactsMetadata("test", Arrays.asList(item1, item2));
      Assert.fail("RepositoryMetadataMergeException expected");
    }
    catch (final P2MetadataMergeException e) {
      // expected
    }
View Full Code Here

    // sanity check
    Assert.assertEquals(2, repos.get(0).getArtifacts().size());
    Assert.assertEquals(1, repos.get(1).getArtifacts().size());

    final ArtifactsMerge m = new ArtifactsMerge();

    try {
      m.mergeArtifactsMetadata("test", Arrays.asList(item1, item2));
      Assert.fail("P2MetadataMergeException expected");
    }
    catch (final P2MetadataMergeException e) {
      if (!e.getMessage().startsWith("Incompatible artifact repository mapping rules: filter=")) {
        throw e;
View Full Code Here

    final StorageFileItem item2 = Mockito.mock(StorageFileItem.class);
    Mockito.when(item2.getName()).thenReturn("content.xml");
    Mockito.when(item2.getInputStream()).thenReturn(
        new FileInputStream(new File("src/test/resources", "metadata/merge/content2.xml")));

    final ArtifactsMerge m = new ArtifactsMerge();

    final Content merged = m.mergeContentMetadata("test", Arrays.asList(item1, item2));

    // repo1: bundle, featureJar, featureGroup, jre, jreConfig
    // repo2: feature2Jar, feature2Group (jre and jreConfig ignored)
    Assert.assertEquals(7, merged.getUnits().size());
  }
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.plugins.p2.repository.proxy.P2ProxyRepositoryConfigurator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.