/** * Returns the associated request * * @return The associated request */ @Override public Request getRequest() { return getWrappedResponse().getRequest(); }
@Override public boolean isConfidential() { return getRequest().isConfidential(); }
/** * Returns the request associated to the current thread. This is reusing the * {@link Response#getCurrent()} method. * * Warning: this method should only be used under duress. You should by * default prefer obtaining the current context using methods such as * {@link org.restlet.resource.Resource#getRequest()}. * * @return The thread's request. */ public static Request getCurrent() { return (Response.getCurrent() == null) ? null : Response.getCurrent() .getRequest(); }
/** * Sets the reference that the client should follow for redirections or * resource creations. If you pass a relative location URI, it will be * resolved with the current base reference of the request's resource * reference (see {@link Request#getResourceRef()} and * {@link Reference#getBaseRef()}. * * @param locationUri * The URI to set. */ public void setLocationRef(String locationUri) { Reference baseRef = null; if (getRequest().getResourceRef() != null) { if (getRequest().getResourceRef().getBaseRef() != null) { baseRef = getRequest().getResourceRef().getBaseRef(); } else { baseRef = getRequest().getResourceRef(); } } setLocationRef(new Reference(baseRef, locationUri).getTargetRef()); }
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; }