Package org.sonatype.nexus.rest.model

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


   * this method only return after all Tasks and Asynchronous events to finish
   */
  public void setBlockProxy(final String repoId, final boolean block)
      throws Exception
  {
    RepositoryStatusResource status = new RepositoryStatusResource();
    status.setId(repoId);
    status.setRepoType("proxy");
    status.setLocalStatus(LocalStatus.IN_SERVICE.name());
    if (block) {
      status.setRemoteStatus(RemoteStatus.AVAILABLE.name());
      status.setProxyMode(ProxyMode.BLOCKED_MANUAL.name());
    }
    else {
      status.setRemoteStatus(RemoteStatus.UNAVAILABLE.name());
      status.setProxyMode(ProxyMode.ALLOW.name());
    }
    Response response = changeStatus(status);

    try {
      assertThat("Could not unblock proxy: " + repoId + ", status: " + response.getStatus().getName() + " ("
View Full Code Here


   */
  public void setOutOfServiceProxy(final String repoId, final boolean outOfService)
      throws Exception
  {

    RepositoryStatusResource status = new RepositoryStatusResource();
    status.setId(repoId);
    status.setRepoType("proxy");
    if (outOfService) {
      status.setLocalStatus(LocalStatus.OUT_OF_SERVICE.name());
    }
    else {
      status.setLocalStatus(LocalStatus.IN_SERVICE.name());
    }
    Response response = changeStatus(status);
    try {
      assertThat("Could not set proxy out of service status (Status: " + response.getStatus() + ": " + repoId
          + "\n" + response.getEntity().getText(), response, isSuccessful());
View Full Code Here

  }

  public Response putOutOfService(String repoId, String repoType)
      throws IOException
  {
    RepositoryStatusResource status = new RepositoryStatusResource();
    status.setId(repoId);
    status.setRepoType(repoType);
    status.setLocalStatus(LocalStatus.OUT_OF_SERVICE.name());
    return changeStatus(status);
  }
View Full Code Here

  }

  public Response putInService(String repoId, String repoType)
      throws IOException
  {
    RepositoryStatusResource status = new RepositoryStatusResource();
    status.setId(repoId);
    status.setRepoType(repoType);
    status.setLocalStatus(LocalStatus.IN_SERVICE.name());
    return changeStatus(status);
  }
View Full Code Here

  {
    final int timeout = 30000; // 30 secs
    final long start = System.currentTimeMillis();
    String status = RemoteStatus.UNKNOWN.toString();
    while (RemoteStatus.UNKNOWN.toString().equals(status) && (System.currentTimeMillis() - start) < timeout) {
      final RepositoryStatusResource statusResource = repoUtil.getStatus(repoId);
      status = statusResource.getRemoteStatus();
      Thread.sleep(100);
    }
    assertThat(expectedStatus.toString(), is(status));
  }
View Full Code Here

    // check for auto block
    // TODO: interestingly RepositoryMessageUtil.getStatus() neglects JSON here, so
    // not using it and switched back to XML as it is wired in it this util class.
    RepositoryMessageUtil util = new RepositoryMessageUtil(this.getXMLXStream(), MediaType.APPLICATION_XML);

    RepositoryStatusResource status = util.getStatus(getTestRepositoryId());

    Assert.assertEquals("Repository should be auto-blocked", status.getProxyMode(), ProxyMode.BLOCKED_AUTO.name());

    // stop the error server, start the healthy server
    return500Server.stop();
    serverResource.getServerProvider().start();

    // unblock it manually
    // NEXUS-4410: since this issue is implemented, the lines below are not enough,
    // since NFC will still contain the artifact do be downloaded, so we need to make it manually blocked and then allow proxy
    // those steps DOES clean NFC
    status.setProxyMode(ProxyMode.BLOCKED_MANUAL.name());
    util.updateStatus(status);
    status.setProxyMode(ProxyMode.ALLOW.name());
    util.updateStatus(status);

    // and now, all should go well
    downloadArtifact(getNexusTestRepoUrl(),
        "nexus1111", "artifact", "1.1", "jar", null, "target/downloads");
View Full Code Here

          passed);
    }

    final RepositoryMessageUtil repoUtil =
        new RepositoryMessageUtil(getXMLXStream(), MediaType.APPLICATION_XML);
    final RepositoryStatusResource repoStatusResource = repoUtil.getStatus(getTestRepositoryId());

    assertThat(repoStatusResource.getProxyMode(), is(equalTo(ProxyMode.ALLOW.name())));
    assertThat(repoStatusResource.getLocalStatus(), is(equalTo(LocalStatus.IN_SERVICE.name())));
  }
View Full Code Here

   */
  protected RepositoryStatusResource waitFor(RemoteStatus status, ProxyMode mode, boolean force)
      throws Exception
  {
    repoUtil.getStatus(REPO, force);
    RepositoryStatusResource s = null;
    for (int i = 0; i < 1000; i++) {
      s = repoUtil.getStatus(REPO, false);
      log.debug("Waiting for: " + status + "," + mode + " - " + getJsonXStream().toXML(s));
      if (status.name().equals(s.getRemoteStatus()) && mode.name().equals(s.getProxyMode())) {
        return s;
      }
      Thread.sleep(1500);
    }

View Full Code Here

    this.giveUserPrivilege(TEST_USER_NAME, "55"); //nexus:repostatus:read
    this.giveUserPrivilege(TEST_USER_NAME, "56"); //nexus:repostatus:update

    String repoId = this.getTestRepositoryId();

    RepositoryStatusResource repoStatus = repoUtil.getStatus(repoId);
    repoStatus.setProxyMode(ProxyMode.BLOCKED_AUTO.name());

    // use test user
    TestContainer.getInstance().getTestContext().setUsername(TEST_USER_NAME);
    TestContainer.getInstance().getTestContext().setPassword(TEST_USER_PASSWORD);
View Full Code Here

    }
    catch (IOException e) {
      // expected, remote will answer with 401
    }

    RepositoryStatusResource status = getStatus();

    assertThat(ProxyMode.valueOf(status.getProxyMode()), is(ProxyMode.BLOCKED_AUTO));
  }
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.rest.model.RepositoryStatusResource

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.