@Override public Object getPayloadInstance() { return new 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(); }
public RepositoryBaseResource createRepository( RepositoryBaseResource repo ) throws NexusConnectionException, NexusClientException { RepositoryResourceResponse repoResponseRequest = new RepositoryResourceResponse(); repoResponseRequest.setData( repo ); Object tempObj = this.getClientHelper().create( REPO_SERVICE, null, repoResponseRequest ); // Hack around NEXUS-540 if ( tempObj == null ) { return this.getRepository( repo.getId() ); } // type check the object so we can have a meaninful error if needed this.checkType( tempObj, RepositoryResourceResponse.class ); RepositoryResourceResponse repoResponse = (RepositoryResourceResponse) tempObj; return repoResponse.getData(); }
public Response sendMessage( Method method, RepositoryBaseResource resource, String id ) throws IOException { XStreamRepresentation representation = new XStreamRepresentation( xstream, "", mediaType ); String idPart = ( method == Method.POST ) ? "" : "/" + id; String serviceURI = "service/local/repositories" + idPart; RepositoryResourceResponse repoResponseRequest = new RepositoryResourceResponse(); repoResponseRequest.setData( resource ); // now set the payload representation.setPayload( repoResponseRequest ); LOG.debug( "sendMessage: " + representation.getText() ); return RequestFacade.sendMessage( serviceURI, method, representation ); }
public RepositoryResource getResourceFromResponse( Response response ) throws IOException { String responseString = response.getEntity().getText(); LOG.debug( " getResourceFromResponse: " + responseString ); XStreamRepresentation representation = new XStreamRepresentation( xstream, responseString, mediaType ); RepositoryResourceResponse resourceResponse = (RepositoryResourceResponse) representation .getPayload( new RepositoryResourceResponse() ); return (RepositoryResource) resourceResponse.getData(); }
public RepositoryBaseResource updateRepository( RepositoryBaseResource repo ) throws NexusConnectionException, NexusClientException { RepositoryResourceResponse repoResponseRequest = new RepositoryResourceResponse(); repoResponseRequest.setData( repo ); Object tempObj = this.getClientHelper().update( REPO_SERVICE, repo.getId(), repoResponseRequest ); // Hack around NEXUS-540 if ( tempObj == null ) { return this.getRepository( repo.getId() ); } // type check the object so we can have a meaninful error if needed this.checkType( tempObj, RepositoryResourceResponse.class ); RepositoryResourceResponse repoResponse = (RepositoryResourceResponse) tempObj; return repoResponse.getData(); }
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()); }
public RepositoryBaseResource getRepositoryBaseResourceFromResponse(Response response) throws IOException { String responseString = response.getEntity().getText(); LOG.debug(" getRepositoryBaseResourceFromResponse: " + responseString); XStreamRepresentation representation = new XStreamRepresentation(xstream, responseString, mediaType); RepositoryResourceResponse resourceResponse = (RepositoryResourceResponse) representation.getPayload(new RepositoryResourceResponse()); return resourceResponse.getData(); }
S doCreate() { final RepositoryResourceResponse request = new RepositoryResourceResponse(); request.setData( settings() ); try { return (S) getNexusClient() .serviceResource( uri() ) .post( RepositoryResourceResponse.class, request ) .getData(); } catch ( UniformInterfaceException e ) { throw getNexusClient().convert( e ); } catch ( ClientHandlerException e ) { throw getNexusClient().convert( e ); } }
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 ); Status status = RequestFacade.sendMessage( serviceURI, Method.PUT, representation ).getStatus(); Assert.assertEquals( Status.SUCCESS_OK.getCode(), status.getCode() ); }
public RepositoryBaseResource getRepositoryBaseResourceFromResponse( Response response ) throws IOException { String responseString = response.getEntity().getText(); LOG.debug( " getRepositoryBaseResourceFromResponse: " + responseString ); XStreamRepresentation representation = new XStreamRepresentation( xstream, responseString, mediaType ); RepositoryResourceResponse resourceResponse = (RepositoryResourceResponse) representation.getPayload( new RepositoryResourceResponse() ); return resourceResponse.getData(); }
private RepositoryResource getRepository( String repositoryName ) throws IOException { String serviceURI = "service/local/repositories/" + repositoryName; String responseText = RequestFacade.doGetRequest( serviceURI ).getEntity().getText(); RepositoryResourceResponse repository = (RepositoryResourceResponse) xstream.fromXML( responseText ); return (RepositoryResource) repository.getData(); }
@Override public Object getPayloadInstance() { return new RepositoryResourceResponse(); }
S doUpdate() { final RepositoryResourceResponse request = new RepositoryResourceResponse(); request.setData( settings() ); try { return (S) getNexusClient() .serviceResource( uri() + "/" + id() ) .put( RepositoryResourceResponse.class, request ) .getData(); } catch ( UniformInterfaceException e ) { throw getNexusClient().convert( e ); } catch ( ClientHandlerException e ) { throw getNexusClient().convert( e ); } }
/** * IMPORTANT: Make sure to release the Response in a finally block when you are done with it. */ public Response sendMessage(Method method, RepositoryBaseResource resource, String id) throws IOException { if (resource != null && resource.getProviderRole() == null) { if ("virtual".equals(resource.getRepoType())) { resource.setProviderRole(ShadowRepository.class.getName()); } else { resource.setProviderRole(Repository.class.getName()); } } XStreamRepresentation representation = new XStreamRepresentation(xstream, "", mediaType); String idPart = (method == Method.POST) ? "" : "/" + id; String serviceURI = SERVICE_PART + idPart; RepositoryResourceResponse repoResponseRequest = new RepositoryResourceResponse(); repoResponseRequest.setData(resource); // now set the payload representation.setPayload(repoResponseRequest); LOG.debug("sendMessage: " + representation.getText()); return nexusRestClient.sendMessage(serviceURI, method, representation); }
public RepositoryBaseResource getRepository( String repoId ) throws IOException { // accepted return codes: OK or redirect final String responseText = nexusRestClient.doGetForText( SERVICE_PART + "/" + repoId, not( inError() ) ); LOG.debug( "responseText: \n" + responseText ); // this should use call to: getResourceFromResponse XStreamRepresentation representation = new XStreamRepresentation( XStreamFactory.getXmlXStream(), responseText, MediaType.APPLICATION_XML ); RepositoryResourceResponse resourceResponse = (RepositoryResourceResponse) representation.getPayload( new RepositoryResourceResponse() ); return resourceResponse.getData(); }
public RepositoryBaseResource getRepository( String id ) throws NexusConnectionException, NexusClientException { Object tempObj = this.getClientHelper().get( REPO_SERVICE, id ); // type check the object so we can have a meaninful error if needed this.checkType( tempObj, RepositoryResourceResponse.class ); RepositoryResourceResponse repoResponse = (RepositoryResourceResponse) tempObj; return repoResponse.getData(); }
@Override public Object getPayloadInstance() { return new RepositoryResourceResponse(); }
/** * IMPORTANT: Make sure to release the Response in a finally block when you are done with it. */ public Response sendMessage( Method method, RepositoryBaseResource resource, String id ) throws IOException { if ( resource != null && resource.getProviderRole() == null ) { if ( "virtual".equals( resource.getRepoType() ) ) { resource.setProviderRole( ShadowRepository.class.getName() ); } else { resource.setProviderRole( Repository.class.getName() ); } } XStreamRepresentation representation = new XStreamRepresentation( xstream, "", mediaType ); String idPart = ( method == Method.POST ) ? "" : "/" + id; String serviceURI = SERVICE_PART + idPart; RepositoryResourceResponse repoResponseRequest = new RepositoryResourceResponse(); repoResponseRequest.setData( resource ); // now set the payload representation.setPayload( repoResponseRequest ); LOG.debug( "sendMessage: " + representation.getText() ); return nexusRestClient.sendMessage( serviceURI, method, representation ); }
public RepositoryBaseResource getRepository(String repoId) throws IOException { // accepted return codes: OK or redirect final String responseText = RequestFacade.doGetForText(SERVICE_PART + "/" + repoId, not(inError())); LOG.debug("responseText: \n" + responseText); // this should use call to: getResourceFromResponse XStreamRepresentation representation = new XStreamRepresentation(XStreamFactory.getXmlXStream(), responseText, MediaType.APPLICATION_XML); RepositoryResourceResponse resourceResponse = (RepositoryResourceResponse) representation.getPayload(new RepositoryResourceResponse()); return resourceResponse.getData(); }