Examples of RepositoryResource


Examples of org.sonatype.nexus.rest.model.RepositoryResource

  public void repoTestIndexable()
      throws Exception
  {

    // create a repo
    RepositoryResource resource = new RepositoryResource();

    resource.setId("nexus688-repoTestIndexable");
    resource.setRepoType("hosted");
    resource.setName("Create Test Repo");
    resource.setProvider("maven2");
    // format is neglected by server from now on, provider is the new guy in the town
    resource.setFormat("maven2");
    resource.setRepoPolicy(RepositoryPolicy.RELEASE.name());
    resource.setExposed(true);
    // invalid for hosted repo resource.setChecksumPolicy( "IGNORE" );
    resource.setBrowseable(true);
    resource.setIndexable(true);
    resource.setWritePolicy(RepositoryWritePolicy.ALLOW_WRITE.name());

    // this also validates
    this.messageUtil.createRepository(resource);

    TaskScheduleUtil.waitForAllTasksToStop();

    this.downloadIndexFromRepository(resource.getId(), true);
  }
View Full Code Here

Examples of org.sonatype.nexus.rest.model.RepositoryResource

  @Test
  public void createRepositoryTest()
      throws IOException
  {

    RepositoryResource resource = new RepositoryResource();

    resource.setId("createTestRepo");
    resource.setRepoType("hosted"); // [hosted, proxy, virtual]
    resource.setName("Create Test Repo");
    // resource.setRepoType( ? )
    resource.setProvider("maven2");
    // format is neglected by server from now on, provider is the new guy in the town
    resource.setFormat("maven2"); // Repository Format, maven1, maven2, maven-site, eclipse-update-site
    // resource.setAllowWrite( true );
    // resource.setBrowseable( true );
    // resource.setIndexable( true );
    // resource.setNotFoundCacheTTL( 1440 );
    resource.setRepoPolicy(RepositoryPolicy.RELEASE.name()); // [snapshot, release] Note: needs param name change
    // resource.setRealmnId(?)
    // resource.setOverrideLocalStorageUrl( "" ); //file://repos/internal
    // resource.setDefaultLocalStorageUrl( "" ); //file://repos/internal
    // resource.setDownloadRemoteIndexes( true );
    // only valid for proxy repos resource.setChecksumPolicy( "IGNORE" ); // [ignore, warn, strictIfExists, strict]
View Full Code Here

Examples of org.sonatype.nexus.rest.model.RepositoryResource

  @Test
  public void readTest()
      throws IOException
  {

    RepositoryResource resource = new RepositoryResource();

    resource.setId("readTestRepo");
    resource.setRepoType("hosted"); // [hosted, proxy, virtual]
    resource.setName("Read Test Repo");
    // resource.setRepoType( ? )
    resource.setProvider("maven2");
    // format is neglected by server from now on, provider is the new guy in the town
    resource.setFormat("maven2"); // Repository Format, maven1, maven2, maven-site, eclipse-update-site
    // resource.setAllowWrite( true );
    // resource.setBrowseable( true );
    // resource.setIndexable( true );
    // resource.setNotFoundCacheTTL( 1440 );
    resource.setRepoPolicy(RepositoryPolicy.RELEASE.name()); // [snapshot, release] Note: needs param name change
    // resource.setRealmnId(?)
    // resource.setOverrideLocalStorageUrl( "" ); //file://repos/internal
    // resource.setDefaultLocalStorageUrl( "" ); //file://repos/internal
    // resource.setDownloadRemoteIndexes( true );
    // only valid for proxy repos resource.setChecksumPolicy( "IGNORE" ); // [ignore, warn, strictIfExists, strict]

    // this also validates
    this.messageUtil.createRepository(resource); // this currently also calls GET, but that will change

    RepositoryResource responseRepo = (RepositoryResource) this.messageUtil.getRepository(resource.getId());

    // validate they are the same
    this.messageUtil.validateResourceResponse(resource, responseRepo);

  }
View Full Code Here

Examples of org.sonatype.nexus.rest.model.RepositoryResource

  public void repoTestNotIndexable()
      throws Exception
  {

    // create a repo
    RepositoryResource resource = new RepositoryResource();

    resource.setId("nexus688-repoTestNotIndexable");
    resource.setRepoType("hosted");
    resource.setName("Create Test Repo");
    resource.setProvider("maven2");
    // format is neglected by server from now on, provider is the new guy in the town
    resource.setFormat("maven2");
    resource.setRepoPolicy(RepositoryPolicy.RELEASE.name());
    resource.setExposed(true);
    // invalid for hosted repo resource.setChecksumPolicy( "IGNORE" );
    resource.setBrowseable(true);
    resource.setIndexable(false);
    resource.setWritePolicy(RepositoryWritePolicy.ALLOW_WRITE.name());

    // this also validates
    this.messageUtil.createRepository(resource);

    TaskScheduleUtil.waitForAllTasksToStop();

    this.downloadIndexFromRepository(resource.getId(), false);
  }
View Full Code Here

Examples of org.sonatype.nexus.rest.model.RepositoryResource

    }

    protected void createRepository(final String repoId)
        throws IOException
    {
      RepositoryResource repo = new RepositoryResource();
      repo.setId(repoId);
      repo.setRepoType("hosted");
      repo.setName(repoId);
      repo.setProvider("maven2");
      repo.setFormat("maven2");
      repo.setRepoPolicy(RepositoryPolicy.RELEASE.name());
      repoUtil.createRepository(repo, false);
    }
View Full Code Here

Examples of org.sonatype.nexus.rest.model.RepositoryResource

  @Test
  public void updateTest()
      throws IOException
  {

    RepositoryResource resource = new RepositoryResource();

    resource.setId("updateTestRepo");
    resource.setRepoType("hosted"); // [hosted, proxy, virtual]
    resource.setName("Update Test Repo");
    // resource.setRepoType( ? )
    resource.setProvider("maven2");
    // format is neglected by server from now on, provider is the new guy in the town
    resource.setFormat("maven2"); // Repository Format, maven1, maven2, maven-site, eclipse-update-site
    // resource.setAllowWrite( true );
    // resource.setBrowseable( true );
    // resource.setIndexable( true );
    // resource.setNotFoundCacheTTL( 1440 );
    resource.setRepoPolicy(RepositoryPolicy.RELEASE.name()); // [snapshot, release] Note: needs param name change
    // resource.setRealmnId(?)
    // resource.setOverrideLocalStorageUrl( "" ); //file://repos/internal
    // resource.setDefaultLocalStorageUrl( "" ); //file://repos/internal
    // resource.setDownloadRemoteIndexes( true );
    // only valid for proxy repos resource.setChecksumPolicy( "IGNORE" ); // [ignore, warn, strictIfExists, strict]

    // this also validates
    resource = (RepositoryResource) this.messageUtil.createRepository(resource);

    // udpdate the repo
    resource.setRepoPolicy(RepositoryPolicy.SNAPSHOT.name());

    this.messageUtil.updateRepo(resource);

  }
View Full Code Here

Examples of org.sonatype.nexus.rest.model.RepositoryResource

  }

  private void createRepository()
      throws Exception
  {
    RepositoryResource repo = new RepositoryResource();
    repo.setId("nexus1730-repo");
    repo.setRepoType("hosted");
    repo.setName("nexus1730-repo");
    repo.setProvider("maven2");
    repo.setFormat("maven2");
    repo.setRepoPolicy(RepositoryPolicy.RELEASE.name());
    repoUtil.createRepository(repo);
  }
View Full Code Here

Examples of org.sonatype.nexus.rest.model.RepositoryResource

  @Test
  public void deleteTest()
      throws IOException
  {
    RepositoryResource resource = new RepositoryResource();

    resource.setId("deleteTestRepo");
    resource.setRepoType("hosted"); // [hosted, proxy, virtual]
    resource.setName("Delete Test Repo");
    // resource.setRepoType( ? )
    resource.setProvider("maven2");
    // format is neglected by server from now on, provider is the new guy in the town
    resource.setFormat("maven2"); // Repository Format, maven1, maven2, maven-site, eclipse-update-site
    // resource.setAllowWrite( true );
    // resource.setBrowseable( true );
    // resource.setIndexable( true );
    // resource.setNotFoundCacheTTL( 1440 );
    resource.setRepoPolicy(RepositoryPolicy.RELEASE.name()); // [snapshot, release] Note: needs param name change
    // resource.setRealmnId(?)
    // resource.setOverrideLocalStorageUrl( "" ); //file://repos/internal
    // resource.setDefaultLocalStorageUrl( "" ); //file://repos/internal
    // resource.setDownloadRemoteIndexes( true );
    // only valid for proxy repos resource.setChecksumPolicy( "IGNORE" ); // [ignore, warn, strictIfExists, strict]

    // this also validates
    resource = (RepositoryResource) this.messageUtil.createRepository(resource);

    // now delete it...
    // use the new ID
    Response response = this.messageUtil.sendMessage(Method.DELETE, resource);

    if (!response.getStatus().isSuccess()) {
      Assert.fail("Could not delete Repository: " + response.getStatus());
    }
    Assert.assertNull(getNexusConfigUtil().getRepo(resource.getId()));
  }
View Full Code Here

Examples of org.sonatype.nexus.rest.model.RepositoryResource

  @Test
  public void listTest()
      throws IOException
  {

    RepositoryResource repo = new RepositoryResource();

    repo.setId("listTestRepo");
    repo.setRepoType("hosted"); // [hosted, proxy, virtual]
    repo.setName("List Test Repo");
    repo.setProvider("maven2");
    // format is neglected by server from now on, provider is the new guy in the town
    repo.setFormat("maven2"); // Repository Format, maven1, maven2, maven-site, eclipse-update-site
    repo.setRepoPolicy(RepositoryPolicy.RELEASE.name()); // [snapshot, release] Note: needs param name change
    // only valid for proxy repos repo.setChecksumPolicy( "IGNORE" ); // [ignore, warn, strictIfExists, strict]

    // this also validates
    repo = (RepositoryResource) this.messageUtil.createRepository(repo);

    // now get the lists
    List<RepositoryListResource> repos = this.messageUtil.getList();

    for (Iterator<RepositoryListResource> iter = repos.iterator(); iter.hasNext(); ) {
      RepositoryListResource listRepo = iter.next();

      if (listRepo.getId().equals(repo.getId())) {
        Assert.assertEquals(listRepo.getId(), repo.getId());
        Assert.assertEquals(listRepo.getName(), repo.getName());
        Assert.assertEquals(listRepo.getFormat(), repo.getFormat());
        Assert.assertEquals(listRepo.getRepoPolicy(), repo.getRepoPolicy());
        Assert.assertEquals(listRepo.getRepoType(), repo.getRepoType());
        Assert.assertEquals(listRepo.getRemoteUri(), repo.getRemoteStorage());

        String storageURL =
            repo.getDefaultLocalStorageUrl() != null ? repo.getDefaultLocalStorageUrl()
                : repo.getOverrideLocalStorageUrl();

        storageURL = storageURL.endsWith("/") ? storageURL : storageURL + "/";
        String effectiveLocalStorage =
            listRepo.getEffectiveLocalStorageUrl().endsWith("/") ? listRepo.getEffectiveLocalStorageUrl()
                : listRepo.getEffectiveLocalStorageUrl() + "/";
View Full Code Here

Examples of org.sonatype.nexus.rest.model.RepositoryResource

  public void testCreatePermission()
      throws IOException
  {
    this.giveUserPrivilege(TEST_USER_NAME, "repository-all");

    RepositoryResource repo = new RepositoryResource();
    repo.setId("testCreatePermission");
    repo.setName("testCreatePermission");
    repo.setRepoType("hosted");
    repo.setProvider("maven1");
    // format is neglected by server from now on, provider is the new guy in the town
    repo.setFormat("maven1");
    repo.setRepoPolicy(RepositoryPolicy.SNAPSHOT.name());
    repo.setChecksumPolicy("IGNORE");

    TestContainer.getInstance().getTestContext().setUsername(TEST_USER_NAME);
    TestContainer.getInstance().getTestContext().setPassword("admin123");

    Response response = this.repoUtil.sendMessage(Method.POST, repo);
    Assert.assertEquals("Response status: ", response.getStatus().getCode(), 403);

    // use admin
    TestContainer.getInstance().getTestContext().useAdminForRequests();

    // now give create
    this.giveUserPrivilege(TEST_USER_NAME, "5");

    // now.... it should work...
    TestContainer.getInstance().getTestContext().setUsername(TEST_USER_NAME);
    TestContainer.getInstance().getTestContext().setPassword("admin123");

    response = this.repoUtil.sendMessage(Method.POST, repo);
    Assert.assertEquals("Response status: ", response.getStatus().getCode(), 201);
    repo = (RepositoryResource) this.repoUtil.getRepository(repo.getId());

    // read should succeed (inherited)
    response = this.repoUtil.sendMessage(Method.GET, repo);
    Assert.assertEquals("Response status: ", response.getStatus().getCode(), 200);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.