// 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"); } catch (NoSuchRepositoryException e) { getLogger().warn("Repository not found, id=" + repoId); throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, "Repository Not Found"); } return result; }
public RepositoryBaseResource getTemplate(String id) throws IOException { String responseText = RequestFacade.doGetForText("service/local/templates/repositories/" + id, not(inError())); LOG.debug("responseText: \n" + responseText); XStreamRepresentation representation = new XStreamRepresentation( XStreamFactory.getXmlXStream(), responseText, MediaType.APPLICATION_XML); RepositoryResourceResponse resourceResponse = (RepositoryResourceResponse) representation.getPayload(new RepositoryResourceResponse()); return resourceResponse.getData(); }