public void connect( String baseUrl, String username, String password ) { this.clientHelper = new RestClientHelper( baseUrl, username, password ); }
public Object get( String service, Map<String, String> args ) throws NexusClientException, NexusConnectionException { String url; try { url = this.buildUrl( service, null ) + this.buildParamString( args ); } catch ( UnsupportedEncodingException e ) { throw new NexusClientException( e.getMessage(), e ); } return this.sendMessage( Method.GET, url, (NexusResponse) null ); }
public void deleteRepository( String id ) throws NexusConnectionException, NexusClientException { this.getClientHelper().delete( REPO_SERVICE, id ); }
public Object update( String service, String id, NexusResponse nexusResponse ) throws NexusConnectionException { return this.sendMessage( Method.PUT, this.buildUrl( service, id ), nexusResponse ); }
public void delete( String service, String id ) throws NexusClientException { String url = this.buildUrl( service, id ); Response response = this.sendRequest( Method.DELETE, url, (Representation) null ); if ( !response.getStatus().isSuccess() ) { throw new NexusClientException( "Error in response from the server: " + response.getStatus() ); } // thats it }
public NexusArtifact searchBySHA1( String sha1 ) throws NexusClientException, NexusConnectionException { Object tempObj = this.getClientHelper().get( "identify/sha1", sha1 ); if ( tempObj != null ) { // type check the object so we can have a meaninful error if needed this.checkType( tempObj, NexusArtifact.class ); return (NexusArtifact) tempObj; } return null; }
public void restartNexus() throws NexusClientException, NexusConnectionException { this.getClientHelper().sendCommand( STATE_SERVICE, "RESTART" ); }
public Object sendMessage( Method method, String url, NexusResponse nexusResponse ) throws NexusConnectionException { XStreamRepresentation representation = new XStreamRepresentation( this.xstream, "", MediaType.APPLICATION_XML ); // now set the payload representation.setPayload( nexusResponse ); return this.sendMessage( method, url, representation ); }
@SuppressWarnings( "unchecked" ) public List<RepositoryListResource> getRepositories() throws NexusConnectionException, NexusClientException { Object tempObj = this.getClientHelper().getList( REPO_SERVICE ); // type check the object so we can have a meaninful error if needed this.checkType( tempObj, RepositoryListResourceResponse.class ); RepositoryListResourceResponse repoResponse = (RepositoryListResourceResponse) tempObj; return repoResponse.getData(); }
Response response = this.sendRequest( method, url, representation );
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 Object getList( String service ) throws NexusClientException, NexusConnectionException { String url = this.buildUrl( service, "" ); return this.sendMessage( Method.GET, url, (NexusResponse) null ); }
public boolean isNexusStarted() throws NexusClientException, NexusConnectionException { Object tempObj = this.getClientHelper().get( STATE_SERVICE, (String) null ); // StatusResourceResponse.getData ->StatusResource // type check the object so we can have a meaninful error if needed this.checkType( tempObj, StatusResourceResponse.class ); // everything should be smooth sailing from here. return ( (StatusResourceResponse) tempObj ).getData().getState().endsWith( "STARTED" ); }
public void startNexus() throws NexusClientException, NexusConnectionException { this.getClientHelper().sendCommand( STATE_SERVICE, "START" ); }
public Object create( String service, String id, NexusResponse nexusResponse ) throws NexusConnectionException { return this.sendMessage( Method.POST, this.buildUrl( service, null ), nexusResponse ); // FIXME: The repositories service doesn't return anything for create, see NEXUS-540 }
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(); }
public void stopNexus() throws NexusClientException, NexusConnectionException { this.getClientHelper().sendCommand( STATE_SERVICE, "STOP" ); }
public Object sendCommand( String service, String command ) throws NexusConnectionException { return this.sendMessage( Method.PUT, this.buildUrl( service, "command" ), new StringRepresentation( command, MediaType.TEXT_ALL ) ); }
Object tempObj = this.getClientHelper().get( "data_index", params );