/** * Returns the reference that the client should follow for redirections or * resource creations. * * @return The redirection reference. * @deprecated Use the getLocationRef() method instead. */ @Override @Deprecated public Reference getRedirectRef() { return getWrappedResponse().getRedirectRef(); }
private DataREST handleAddResponse(Response response) { if (! response.getStatus().equals(Status.SUCCESS_CREATED)) { logger.warn("Did not create baclava document"); return null; } if (response.getRedirectRef() == null) { logger.error("Did not get redirect reference for data document"); return null; } invalidate(); return new DataREST(context, response.getRedirectRef()); }
public WorkflowREST add(String workflow) throws NotSuccessException { Response response = context.post(getURIReference(), workflow, RESTContext.scuflType); if (! response.getStatus().equals(Status.SUCCESS_CREATED)) { logger.warn("Did not create workflow: " + workflow); return null; } if (response.getRedirectRef() == null) { logger.error("Did not get redirect reference for workflow " + workflow); return null; } invalidate(); return new WorkflowREST(context, response.getRedirectRef()); }
public UserREST getUser() throws NotSuccessException { if (user == null) { // Find current user through redirect // TODO: Support data directly at currentUserURI? Response response = head(getCurrentUserURI()); user = new UserREST(this, response.getRedirectRef().getTargetRef()); } return user; }
public JobREST add(WorkflowREST wf, DataREST inputs) throws NotSuccessException { JobDocument jobDoc = JobDocument.Factory.newInstance(); jobDoc.addNewJob().addNewWorkflow().setHref(wf.getURI()); if (inputs != null) { jobDoc.getJob().addNewInputs().setHref(inputs.getURI()); } Response response = context.post(getURIReference(), jobDoc); if (response.getRedirectRef() == null) { logger.error("Did not get redirect reference for job for wf " + wf); return null; } invalidate(); return new JobREST(context, response.getRedirectRef()); }
protected File downloadSnapshotArtifact( String repository, Gav gav, File parentDir ) throws IOException { // @see http://issues.sonatype.org/browse/NEXUS-599 // r=<repoId> -- mandatory // g=<groupId> -- mandatory // a=<artifactId> -- mandatory // v=<version> -- mandatory // c=<classifier> -- optional // p=<packaging> -- optional, jar is taken as default // http://localhost:8087/nexus/service/local/artifact/maven/redirect?r=tasks-snapshot-repo&g=nexus&a=artifact& // v=1.0-SNAPSHOT String serviceURI = "service/local/artifact/maven/redirect?r=" + repository + "&g=" + gav.getGroupId() + "&a=" + gav.getArtifactId() + "&v=" + gav.getVersion(); Response response = RequestFacade.doGetRequest( serviceURI ); Status status = response.getStatus(); Assert.assertEquals( "Snapshot download should redirect to a new file\n " + response.getRequest().getResourceRef().toString() + " \n Error: " + status.getDescription(), 301, status.getCode() ); Reference redirectRef = response.getRedirectRef(); Assert.assertNotNull( "Snapshot download should redirect to a new file " + response.getRequest().getResourceRef().toString(), redirectRef ); serviceURI = redirectRef.toString(); File file = FileUtils.createTempFile( gav.getArtifactId(), '.' + gav.getExtension(), parentDir ); RequestFacade.downloadFile( new URL( serviceURI ), file.getAbsolutePath() ); return file; }