Package org.sonatype.plexus.rest.representation

Examples of org.sonatype.plexus.rest.representation.XStreamRepresentation


  public RepositoryTargetResource getResourceFromResponse(String responseText)
      throws IOException
  {
    LOG.debug(" getResourceFromResponse: " + responseText);

    XStreamRepresentation representation = new XStreamRepresentation(xstream, responseText, mediaType);

    RepositoryTargetResourceResponse resourceResponse =
        (RepositoryTargetResourceResponse) representation.getPayload(new RepositoryTargetResourceResponse());

    return resourceResponse.getData();

  }
View Full Code Here


      throws IOException
  {
    String responseText = RequestFacade.doGetForText("service/local/repo_targets/" + targetId);
    LOG.debug("responseText: \n" + responseText);

    XStreamRepresentation representation =
        new XStreamRepresentation(XStreamFactory.getXmlXStream(), responseText, MediaType.APPLICATION_XML);

    RepositoryTargetResourceResponse resourceResponse =
        (RepositoryTargetResourceResponse) representation.getPayload(new RepositoryTargetResourceResponse());

    return resourceResponse.getData();
  }
View Full Code Here

  }

  public MirrorResourceListResponse getMirrors(String repositoryId)
      throws IOException
  {
    XStreamRepresentation representation = new XStreamRepresentation(xstream, "", mediaType);

    String serviceURI = "service/local/repository_mirrors/" + repositoryId;

    String responseText = RequestFacade.doGetForText(serviceURI, representation, isSuccessful());
    LOG.debug(" getResourceFromResponse: " + responseText);

    representation = new XStreamRepresentation(xstream, responseText, mediaType);

    // this
    MirrorResourceListResponse resourceResponse =
        (MirrorResourceListResponse) representation.getPayload(new MirrorResourceListResponse());

    Assert.assertNotNull("Resource Response shouldn't be null", resourceResponse);

    for (MirrorResource resource : resourceResponse.getData()) {
      Assert.assertNotNull("Id shouldn't be null", resource.getId());
View Full Code Here

  }

  public MirrorResourceListResponse setMirrors(String repositoryId, MirrorResourceListRequest resourceRequest)
      throws IOException
  {
    XStreamRepresentation representation = new XStreamRepresentation(xstream, "", mediaType);

    String serviceURI = "service/local/repository_mirrors/" + repositoryId;

    // now set the payload
    representation.setPayload(resourceRequest);

    String responseText = RequestFacade.doPostForText(serviceURI, representation, isSuccessful());
    LOG.debug(" getResourceFromResponse: " + responseText);

    representation = new XStreamRepresentation(xstream, responseText, mediaType);

    // this
    MirrorResourceListResponse resourceResponse =
        (MirrorResourceListResponse) representation.getPayload(new MirrorResourceListResponse());

    Assert.assertNotNull("Resource Response shouldn't be null", resourceResponse);

    for (MirrorResource resource : resourceResponse.getData()) {
      Assert.assertNotNull(resource.getId(), "Id shouldn't be null");
View Full Code Here


  public MirrorResourceListResponse getPredefinedMirrors(String repositoryId)
      throws IOException
  {
    XStreamRepresentation representation = new XStreamRepresentation(xstream, "", mediaType);

    String serviceURI = "service/local/repository_predefined_mirrors/" + repositoryId;

    String responseText = RequestFacade.doGetForText(serviceURI, representation, isSuccessful());
    LOG.debug(" getResourceFromResponse: " + responseText);

    representation = new XStreamRepresentation(xstream, responseText, mediaType);

    // this
    MirrorResourceListResponse resourceResponse =
        (MirrorResourceListResponse) representation.getPayload(new MirrorResourceListResponse());

    Assert.assertNotNull("Resource Response shouldn't be null", resourceResponse);

    for (MirrorResource resource : resourceResponse.getData()) {
      Assert.assertNotNull(resource.getUrl(), "URL shouldn't be null");
View Full Code Here

        "{\"data\" : {\"writePolicy\":\""
            + RepositoryWritePolicy.ALLOW_WRITE.name()
            +
            "\", \"browseable\":true,\"defaultLocalStorageUrl\":null,\"id\":\"test1\", \"indexable\":false,\"name\":\"test1\",\"notFoundCacheTTL\":1440,\"overrideLocalStorageUrl\":null,\"repoPolicy\":\"release\", \"repoType\":\"hosted\"}}";

    XStreamRepresentation representation =
        new XStreamRepresentation(xstream, jsonString, MediaType.APPLICATION_JSON);

    RepositoryResourceResponse response =
        (RepositoryResourceResponse) representation.getPayload(new RepositoryResourceResponse());

  }
View Full Code Here

        "{\"data\" : {\"writePolicy\":\""
            + RepositoryWritePolicy.ALLOW_WRITE.name()
            +
            "\", \"artifactMaxAge\":1440,\"browseable\":true,\"defaultLocalStorageUrl\":null,\"id\":\"test1\", \"indexable\":false,\"metadataMaxAge\":1440,\"name\":\"test1\",\"notFoundCacheTTL\":1440,\"overrideLocalStorageUrl\":null,\"repoPolicy\":\"release\", \"repoType\":\"proxy\"}}";

    XStreamRepresentation representation =
        new XStreamRepresentation(xstream, jsonString, MediaType.APPLICATION_JSON);

    RepositoryResourceResponse response =
        (RepositoryResourceResponse) representation.getPayload(new RepositoryResourceResponse());

  }
View Full Code Here

  @Test
  public void testJsonStringWithClassAttribute() {
    String text = "{\"data\":{\"id\":\"11c75e9aea2\",\"ruleType\":\"exclusive\",\"groupId\":\"*\",\"pattern\":\".*\",\"repositories\":[{\"id\":\"central\",\"name\":\"Maven Central\",\"resourceURI\":\"http://localhost:8081/nexus/service/local/repositories/central\",\"@class\":\"repo-routes-member\"},{\"id\":\"thirdparty\",\"name\":\"3rd party\",\"resourceURI\":\"http://localhost:8081/nexus/service/local/repositories/thirdparty\",\"@class\":\"repo-routes-member\"},{\"id\":\"central-m1\",\"name\":\"Central M1 shadow\",\"resourceURI\":\"http://localhost:8081/nexus/service/local/repositories/central-m1\",\"@class\":\"repo-routes-member\"}]}}";

    XStreamRepresentation representation = new XStreamRepresentation(
        this.xstreamJSON,
        text,
        MediaType.APPLICATION_JSON);

    RepositoryRouteResourceResponse repoRouteResourceResponse = (RepositoryRouteResourceResponse) representation
        .getPayload(new RepositoryRouteResourceResponse());

    // System.out.println( "repoRouteResourceResponse: "+ repoRouteResourceResponse.getData().getPattern() );

  }
View Full Code Here

  @Test
  public void testJsonStringWithOutClassAttribute() {
    String text = "{\"data\":{\"id\":\"11c75e9aea2\",\"ruleType\":\"exclusive\",\"groupId\":\"*\",\"pattern\":\".*\",\"repositories\":[{\"id\":\"central\",\"name\":\"Maven Central\",\"resourceURI\":\"http://localhost:8081/nexus/service/local/repositories/central\"},{\"id\":\"thirdparty\",\"name\":\"3rd party\",\"resourceURI\":\"http://localhost:8081/nexus/service/local/repositories/thirdparty\"},{\"id\":\"central-m1\",\"name\":\"Central M1 shadow\",\"resourceURI\":\"http://localhost:8081/nexus/service/local/repositories/central-m1\"}]}}";

    XStreamRepresentation representation = new XStreamRepresentation(
        this.xstreamJSON,
        text,
        MediaType.APPLICATION_JSON);

    RepositoryRouteResourceResponse repoRouteResourceResponse = (RepositoryRouteResourceResponse) representation
        .getPayload(new RepositoryRouteResourceResponse());

    // System.out.println( "repoRouteResourceResponse: "+ repoRouteResourceResponse.getData().getPattern() );

  }
View Full Code Here

  @Test
  public void testScheduleJsonStringWithOutClassAttribute() {
    String text = "{\"data\":{\"id\":null,\"name\":\"clear repo cache\",\"enabled\":true,\"typeId\":\"ExpireCacheTask\",\"schedule\":\"manual\",\"properties\":[{\"id\":\"repositoryId\",\"value\":\"all_repo\"},{\"id\":\"resourceStorePath\",\"value\":\"\"}]}}";

    XStreamRepresentation representation = new XStreamRepresentation(
        this.xstreamJSON,
        text,
        MediaType.APPLICATION_JSON);

    ScheduledServiceResourceResponse repoRouteResourceResponse = (ScheduledServiceResourceResponse) representation
        .getPayload(new ScheduledServiceResourceResponse());

    // System.out.println( "repoRouteResourceResponse: "+ repoRouteResourceResponse.getData().getPattern() );

  }
View Full Code Here

TOP

Related Classes of org.sonatype.plexus.rest.representation.XStreamRepresentation

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.