Examples of RepositoryResourceResponse


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

  @Override
  @GET
  public RepositoryResourceResponse get(Context context, Request request, Response response, Variant variant)
      throws ResourceException
  {
    RepositoryResourceResponse result = new RepositoryResourceResponse();

    try {
      RepositoryTemplate template = getRepositoryTemplateById(getRepositoryId(request));

      RepositoryBaseResource repoRes = null;

      if (ProxyRepository.class.isAssignableFrom(template.getMainFacet())) {
        repoRes = createProxy(template);
      }
      else if (HostedRepository.class.isAssignableFrom(template.getMainFacet())) {
        repoRes = createHosted(template);
      }
      else if (ShadowRepository.class.isAssignableFrom(template.getMainFacet())) {
        repoRes = createShadow(template);
      }
      else if (GroupRepository.class.isAssignableFrom(template.getMainFacet())) {
        repoRes = new RepositoryGroupResource();

        repoRes.setRepoType("group");
      }
      else {
        // huh?
        throw new ResourceException(Status.SERVER_ERROR_INTERNAL, "Unrecognized repository template with ID='"
            + template.getId() + "' and mainFacet='" + template.getMainFacet().getName() + "'!");
      }

      repoRes.setId(template.getId());

      repoRes.setName(template.getDescription());

      repoRes.setProvider(template.getRepositoryProviderHint());

      repoRes.setProviderRole(template.getRepositoryProviderRole());

      repoRes.setFormat(template.getContentClass().getId());

      result.setData(repoRes);
    }
    catch (NoSuchTemplateIdException e) {
      throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, e.getMessage());
    }
View Full Code Here

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

  // clean
  protected RepositoryResourceResponse getRepositoryResourceResponse(Request request, String repoId)
      throws ResourceException
  {
    RepositoryResourceResponse result = new RepositoryResourceResponse();

    try {
      RepositoryBaseResource resource = null;

      Repository repository = getRepositoryRegistry().getRepository(repoId);

      if (repository.getRepositoryKind().isFacetAvailable(GroupRepository.class)) {
        // it is a group, not a repo
        throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, "Repository Not Found");
      }

      resource = getRepositoryRestModel(request, repository);

      result.setData(resource);
    }
    catch (NoSuchRepositoryAccessException e) {
      getLogger().warn("Repository access denied, id=" + repoId);

      throw new ResourceException(Status.CLIENT_ERROR_FORBIDDEN, "Access Denied to Repository");
View Full Code Here

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

{
  public static final String RESOURCE_URI = "/templates/repositories";

  @Override
  public Object getPayloadInstance() {
    return new RepositoryResourceResponse();
  }
View Full Code Here

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

    this.setModifiable(true);
  }

  @Override
  public Object getPayloadInstance() {
    return new RepositoryResourceResponse();
  }
View Full Code Here

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

  @Override
  @POST
  public RepositoryResourceResponse post(Context context, Request request, Response response, Object payload)
      throws ResourceException
  {
    RepositoryResourceResponse repoRequest = (RepositoryResourceResponse) payload;
    String repoId = null;

    if (repoRequest != null) {
      RepositoryBaseResource resource = repoRequest.getData();
      repoId = resource.getId();

      try {
        CRepository config = getRepositoryAppModel(resource, null);
View Full Code Here

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

    this.setModifiable(true);
  }

  @Override
  public Object getPayloadInstance() {
    return new RepositoryResourceResponse();
  }
View Full Code Here

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

  @Override
  @PUT
  public RepositoryResourceResponse put(Context context, Request request, Response response, Object payload)
      throws ResourceException
  {
    RepositoryResourceResponse repoRequest = (RepositoryResourceResponse) payload;

    String repoId = this.getRepositoryId(request);

    if (repoRequest != null) {
      try {
        RepositoryBaseResource resource = repoRequest.getData();

        if (RepositoryBaseResourceConverter.REPO_TYPE_VIRTUAL.equals(resource.getRepoType())) {
          RepositoryShadowResource model = (RepositoryShadowResource) resource;

          try {
View Full Code Here

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

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

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

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

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

  private RepositoryResource getRepository(String repositoryName)
      throws IOException
  {
    String serviceURI = "service/local/repositories/" + repositoryName;
    String entityText = RequestFacade.doGetForText(serviceURI);
    RepositoryResourceResponse repository = (RepositoryResourceResponse) xstream.fromXML(entityText);
    return (RepositoryResource) repository.getData();
  }
View Full Code Here

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

  private void saveRepository(RepositoryResource repository, String repositoryName)
      throws IOException
  {
    String serviceURI = "service/local/repositories/" + repositoryName;

    RepositoryResourceResponse repositoryResponse = new RepositoryResourceResponse();
    XStreamRepresentation representation = new XStreamRepresentation(xstream, "", MediaType.APPLICATION_XML);
    repositoryResponse.setData(repository);
    representation.setPayload(repositoryResponse);

    RequestFacade.doPutForStatus(serviceURI, representation, isSuccessful());

  }
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.