You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2018/08/02 20:51:04 UTC
[juneau] branch master updated: Remote Redirect class.
This is an automated email from the ASF dual-hosted git repository.
jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/master by this push:
new af69c35 Remote Redirect class.
af69c35 is described below
commit af69c35c16092da110c5b73fe566480b009ad02d
Author: JamesBognar <ja...@apache.org>
AuthorDate: Thu Aug 2 16:49:22 2018 -0400
Remote Redirect class.
---
juneau-doc/src/main/javadoc/overview.html | 4 +-
.../src/main/resources/ReleaseNotes/7.2.0.html | 6 +-
.../06.RestMethod/17.PredefinedHelperBeans.html | 2 +-
.../examples/rest/SystemPropertiesResource.java | 16 +--
.../juneau/examples/rest/TempDirResource.java | 4 +-
.../rest/addressbook/AddressBookResource.java | 10 +-
.../microservice/resources/DirectoryResource.java | 2 +-
.../microservice/resources/LogsResource.java | 2 +-
.../org/apache/juneau/rest/ResponseHandler.java | 3 -
.../java/org/apache/juneau/rest/RestContext.java | 1 -
.../org/apache/juneau/rest/RestContextBuilder.java | 1 -
.../org/apache/juneau/rest/helper/Redirect.java | 123 ---------------------
...ToServletRoot.java => SeeOtherServletRoot.java} | 13 ++-
.../juneau/rest/reshandlers/RedirectHandler.java | 43 -------
.../org/apache/juneau/rest/response/SeeOther.java | 26 +++++
15 files changed, 59 insertions(+), 197 deletions(-)
diff --git a/juneau-doc/src/main/javadoc/overview.html b/juneau-doc/src/main/javadoc/overview.html
index b7d0af4..70336e6 100644
--- a/juneau-doc/src/main/javadoc/overview.html
+++ b/juneau-doc/src/main/javadoc/overview.html
@@ -14107,7 +14107,7 @@ TODO(7.2.0)
<li class='jc'>{@link org.apache.juneau.rest.helper.ReaderResource}
<li class='jc'>{@link org.apache.juneau.rest.helper.ReaderResourceBuilder}
<li class='jc'>{@link org.apache.juneau.rest.helper.Redirect}
- <li class='jc'>{@link org.apache.juneau.rest.helper.RedirectToServletRoot}
+ <li class='jc'>{@link org.apache.juneau.rest.helper.SeeOtherServletRoot}
<li class='jc'>{@link org.apache.juneau.rest.helper.ResourceDescription}
<li class='jc'>{@link org.apache.juneau.rest.helper.StreamResource}
<li class='jc'>{@link org.apache.juneau.rest.helper.StreamResourceBuilder}
@@ -30540,7 +30540,7 @@ TODO(7.2.0)
<li class='jc'>{@link org.apache.juneau.rest.helper.ReaderResource}
<li class='jc'>{@link org.apache.juneau.rest.helper.ReaderResourceBuilder}
<li class='jc'>{@link org.apache.juneau.rest.helper.Redirect}
- <li class='jc'>{@link org.apache.juneau.rest.helper.RedirectToServletRoot}
+ <li class='jc'>{@link org.apache.juneau.rest.helper.SeeOtherServletRoot}
<li class='jc'>{@link org.apache.juneau.rest.helper.ResourceDescription}
<li class='jc'>{@link org.apache.juneau.rest.helper.StreamResource}
<li class='jc'>{@link org.apache.juneau.rest.helper.StreamResourceBuilder}
diff --git a/juneau-doc/src/main/resources/ReleaseNotes/7.2.0.html b/juneau-doc/src/main/resources/ReleaseNotes/7.2.0.html
index e8bff8f..63981c4 100644
--- a/juneau-doc/src/main/resources/ReleaseNotes/7.2.0.html
+++ b/juneau-doc/src/main/resources/ReleaseNotes/7.2.0.html
@@ -277,7 +277,7 @@
<li class='jc'>{@link org.apache.juneau.rest.helper.ReaderResource}
<li class='jc'>{@link org.apache.juneau.rest.helper.ReaderResourceBuilder}
<li class='jc'>{@link org.apache.juneau.rest.helper.Redirect}
- <li class='jc'>{@link org.apache.juneau.rest.helper.RedirectToServletRoot}
+ <li class='jc'>{@link org.apache.juneau.rest.helper.SeeOtherServletRoot}
<li class='jc'>{@link org.apache.juneau.rest.helper.ResourceDescription}
<li class='jc'>{@link org.apache.juneau.rest.helper.StreamResource}
<li class='jc'>{@link org.apache.juneau.rest.helper.StreamResourceBuilder}
@@ -438,6 +438,10 @@
have changed.
<br>If not specified, the values are inferred from the Java method name.
<br>See also:<a class="doclink" href="#juneau-rest-server.RestMethod">Overview > juneau-rest-server > @RestMethod</a>
+ <li>
+ <code>Redirect</code> class has been removed. Use {@link org.apache.juneau.rest.response.SeeOther} instead.
+ <li>
+ <code>RedirectToServletRoot</code> class has been renamed to {@link org.apache.juneau.rest.response.SeeOtherServletRoot}.
</ul>
<h5 class='topic w800'>juneau-rest-client</h5>
diff --git a/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/06.RestMethod/17.PredefinedHelperBeans.html b/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/06.RestMethod/17.PredefinedHelperBeans.html
index ed8145e..1e869bd 100644
--- a/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/06.RestMethod/17.PredefinedHelperBeans.html
+++ b/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/06.RestMethod/17.PredefinedHelperBeans.html
@@ -27,7 +27,7 @@
<li class='jc'>{@link org.apache.juneau.rest.helper.ReaderResource}
<li class='jc'>{@link org.apache.juneau.rest.helper.ReaderResourceBuilder}
<li class='jc'>{@link org.apache.juneau.rest.helper.Redirect}
- <li class='jc'>{@link org.apache.juneau.rest.helper.RedirectToServletRoot}
+ <li class='jc'>{@link org.apache.juneau.rest.helper.SeeOtherServletRoot}
<li class='jc'>{@link org.apache.juneau.rest.helper.ResourceDescription}
<li class='jc'>{@link org.apache.juneau.rest.helper.StreamResource}
<li class='jc'>{@link org.apache.juneau.rest.helper.StreamResourceBuilder}
diff --git a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SystemPropertiesResource.java b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SystemPropertiesResource.java
index 91cd718..64537ea 100644
--- a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SystemPropertiesResource.java
+++ b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SystemPropertiesResource.java
@@ -135,13 +135,13 @@ public class SystemPropertiesResource extends BasicRestServlet {
description="Sets a new value for the specified system property.",
guards=AdminGuard.class
)
- public RedirectToServletRoot setSystemProperty(
+ public SeeOtherServletRoot setSystemProperty(
@Path(name="propertyName", description="The system property name") String propertyName,
@Body(description="The new system property value") String value
) throws UserNotAdminException, NotAcceptable, UnsupportedMediaType {
System.setProperty(propertyName, value);
- return RedirectToServletRoot.INSTANCE;
+ return SeeOtherServletRoot.INSTANCE;
}
@RestMethod(
@@ -149,12 +149,12 @@ public class SystemPropertiesResource extends BasicRestServlet {
description="Takes in a map of key/value pairs and creates a set of new system properties.",
guards=AdminGuard.class
)
- public RedirectToServletRoot post(
+ public SeeOtherServletRoot post(
@Body(description="The new system property values", example="{key1:'val1',key2:123}") java.util.Properties newProperties
) throws UserNotAdminException, NotAcceptable, UnsupportedMediaType {
System.setProperties(newProperties);
- return RedirectToServletRoot.INSTANCE;
+ return SeeOtherServletRoot.INSTANCE;
}
@RestMethod(
@@ -163,12 +163,12 @@ public class SystemPropertiesResource extends BasicRestServlet {
description="Deletes the specified system property.",
guards=AdminGuard.class
)
- public RedirectToServletRoot deleteSystemProperty(
+ public SeeOtherServletRoot deleteSystemProperty(
@Path(name="propertyName", description="The system property name", example="PATH") String propertyName
) throws UserNotAdminException, NotAcceptable {
System.clearProperty(propertyName);
- return RedirectToServletRoot.INSTANCE;
+ return SeeOtherServletRoot.INSTANCE;
}
@RestMethod(
@@ -205,13 +205,13 @@ public class SystemPropertiesResource extends BasicRestServlet {
description="Accepts a simple form post of a system property name/value pair.",
guards=AdminGuard.class
)
- public RedirectToServletRoot postFormPagePost(
+ public SeeOtherServletRoot postFormPagePost(
@FormData("name") String name,
@FormData("value") String value
) throws UserNotAdminException, NotAcceptable, UnsupportedMediaType {
System.setProperty(name, value);
- return RedirectToServletRoot.INSTANCE;
+ return SeeOtherServletRoot.INSTANCE;
}
diff --git a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/TempDirResource.java b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/TempDirResource.java
index 5d0d300..195c9b5 100644
--- a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/TempDirResource.java
+++ b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/TempDirResource.java
@@ -112,7 +112,7 @@ public class TempDirResource extends DirectoryResource {
},
matchers=TempDirResource.MultipartFormDataMatcher.class
)
- public RedirectToServletRoot postUpload(RestRequest req) throws Exception {
+ public SeeOtherServletRoot postUpload(RestRequest req) throws Exception {
ServletFileUpload upload = new ServletFileUpload();
FileItemIterator iter = upload.getItemIterator(req);
while (iter.hasNext()) {
@@ -124,7 +124,7 @@ public class TempDirResource extends DirectoryResource {
}
}
}
- return RedirectToServletRoot.INSTANCE;
+ return SeeOtherServletRoot.INSTANCE;
}
/** Causes a 404 if POST isn't multipart/form-data */
diff --git a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/addressbook/AddressBookResource.java b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/addressbook/AddressBookResource.java
index 4f36691..b070e06 100644
--- a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/addressbook/AddressBookResource.java
+++ b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/addressbook/AddressBookResource.java
@@ -31,7 +31,7 @@ import org.apache.juneau.rest.*;
import org.apache.juneau.rest.annotation.*;
import org.apache.juneau.rest.converters.*;
import org.apache.juneau.rest.exception.*;
-import org.apache.juneau.rest.helper.*;
+import org.apache.juneau.rest.response.*;
import org.apache.juneau.rest.widget.*;
import org.apache.juneau.transform.*;
import org.apache.juneau.utils.*;
@@ -225,9 +225,9 @@ public class AddressBookResource extends BasicRestServletJena {
@RestMethod(name=POST, path="/people",
guards=AdminGuard.class
)
- public Redirect createPerson(@Body CreatePerson cp) throws Exception {
+ public SeeOther createPerson(@Body CreatePerson cp) throws Exception {
Person p = addressBook.createPerson(cp);
- return new Redirect("people/{0}", p.id);
+ return new SeeOther("people/{0}", p.id);
}
/**
@@ -237,10 +237,10 @@ public class AddressBookResource extends BasicRestServletJena {
@RestMethod(name=POST, path="/people/{id}/addresses",
guards=AdminGuard.class
)
- public Redirect createAddress(@Path("id") int id, @Body CreateAddress ca) throws Exception {
+ public SeeOther createAddress(@Path("id") int id, @Body CreateAddress ca) throws Exception {
Person p = findPerson(id);
Address a = p.createAddress(ca);
- return new Redirect("addresses/{0}", a.id);
+ return new SeeOther("addresses/{0}", a.id);
}
/**
diff --git a/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java b/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java
index 6a1095f..c3c406e 100755
--- a/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java
+++ b/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java
@@ -218,7 +218,7 @@ public class DirectoryResource extends BasicRestServlet {
}
@Response(description="Redirect to root page on success")
- static class RedirectToRoot extends RedirectToServletRoot {}
+ static class RedirectToRoot extends SeeOtherServletRoot {}
@Response(description="File action")
public static class Action extends LinkString {
diff --git a/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/resources/LogsResource.java b/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/resources/LogsResource.java
index 595936b..d12fc4d 100755
--- a/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/resources/LogsResource.java
+++ b/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/resources/LogsResource.java
@@ -258,7 +258,7 @@ public class LogsResource extends BasicRestServlet {
}
@Response(description="Redirect to root page on success")
- static class RedirectToRoot extends RedirectToServletRoot {}
+ static class RedirectToRoot extends SeeOtherServletRoot {}
@Response(description="File action")
public static class Action extends LinkString {
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/ResponseHandler.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/ResponseHandler.java
index 50bf57c..f84857f 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/ResponseHandler.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/ResponseHandler.java
@@ -18,7 +18,6 @@ import javax.servlet.http.*;
import org.apache.juneau.*;
import org.apache.juneau.rest.annotation.*;
-import org.apache.juneau.rest.helper.*;
import org.apache.juneau.rest.reshandlers.*;
/**
@@ -48,8 +47,6 @@ import org.apache.juneau.rest.reshandlers.*;
* {@link InputStreamHandler} - Pipes the output of {@link InputStream InputStreams} to the response output
* stream ({@link RestResponse#getOutputStream()}).
* <li class='jc'>
- * {@link RedirectHandler} - Handles {@link Redirect} objects.
- * <li class='jc'>
* {@link WritableHandler} - Handles {@link Writable} objects.
* <li class='jc'>
* {@link StreamableHandler} - Handles {@link Streamable} objects.
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
index 23b01ad..4771c2e 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
@@ -2154,7 +2154,6 @@ public final class RestContext extends BeanContext {
* <li class='jc'>{@link WritableHandler} - {@link Writable} objects.
* <li class='jc'>{@link ReaderHandler} - {@link Reader} objects.
* <li class='jc'>{@link InputStreamHandler} - {@link InputStream} objects.
- * <li class='jc'>{@link RedirectHandler} - {@link Redirect} objects.
* <li class='jc'>{@link ZipFileListResponseHandler} - {@link ZipFileList} objects.
* <li class='jc'>{@link DefaultHandler} - All other POJOs.
* </ul>
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextBuilder.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextBuilder.java
index 8d17ed4..f6a8505 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextBuilder.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextBuilder.java
@@ -244,7 +244,6 @@ public class RestContextBuilder extends BeanContextBuilder implements ServletCon
WritableHandler.class,
ReaderHandler.class,
InputStreamHandler.class,
- RedirectHandler.class,
DefaultHandler.class
);
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/helper/Redirect.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/helper/Redirect.java
deleted file mode 100644
index 38cdd36..0000000
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/helper/Redirect.java
+++ /dev/null
@@ -1,123 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.rest.helper;
-
-import static org.apache.juneau.internal.StringUtils.*;
-
-import java.net.*;
-import java.text.*;
-
-import org.apache.juneau.http.annotation.*;
-
-/**
- * REST methods can return this object as a shortcut for performing <code>HTTP 302</code> redirects.
- *
- * <h5 class='section'>See Also:</h5>
- * <ul>
- * <li class='link'><a class="doclink" href="../../../../../overview-summary.html#juneau-rest-server.RestMethod.Redirect">Overview > juneau-rest-server > Redirect</a>
- * </ul>
- */
-@Response(code=302, description="Redirect", headers=@ResponseHeader(name="Location",description="Redirect URI",type="string",format="uri"), schema=@Schema(ignore=true))
-public class Redirect {
-
- private final int httpResponseCode;
- private final URI uri;
-
- /**
- * Redirect to the specified URL.
- *
- * <p>
- * Relative paths are interpreted as relative to the servlet path.
- *
- * @param uri
- * The URL to redirect to.
- * <br>Can be any of the following:
- * <ul>
- * <li><code>URL</code>
- * <li><code>URI</code>
- * <li><code>CharSequence</code>
- * </ul>
- * @param args Optional {@link MessageFormat}-style arguments.
- */
- public Redirect(Object uri, Object...args) {
- this(0, uri, args);
- }
-
- /**
- * Convenience method for redirecting to instance of {@link URL} and {@link URI}.
- *
- * <p>
- * Same as calling <code>toString()</code> on the object and using the other constructor.
- *
- * @param uri
- * The URL to redirect to.
- * <br>Can be any of the following:
- * <ul>
- * <li><code>URL</code>
- * <li><code>URI</code>
- * <li><code>CharSequence</code>
- * </ul>
- */
- public Redirect(Object uri) {
- this(0, uri, (Object[])null);
- }
-
- /**
- * Redirect to the specified URL.
- *
- * <p>
- * Relative paths are interpreted as relative to the servlet path.
- *
- * @param httpResponseCode The HTTP response code.
- * @param url
- * The URL to redirect to.
- * <br>Can be any of the following:
- * <ul>
- * <li><code>URL</code>
- * <li><code>URI</code>
- * <li><code>CharSequence</code>
- * </ul>
- * @param args Optional {@link MessageFormat}-style arguments.
- */
- public Redirect(int httpResponseCode, Object url, Object...args) {
- this.httpResponseCode = httpResponseCode;
- if (url == null)
- url = "";
- this.uri = toURI(format(url.toString(), args));
- }
-
- /**
- * Shortcut for redirecting to the servlet root.
- */
- public Redirect() {
- this(0, null, (Object[])null);
- }
-
- /**
- * Returns the response code passed in through the constructor.
- *
- * @return The response code passed in through the constructor, or <code>0</code> if response code wasn't specified.
- */
- public int getHttpResponseCode() {
- return httpResponseCode;
- }
-
- /**
- * Returns the URI to redirect to.
- *
- * @return The URI to redirect to.
- */
- public URI getURI() {
- return uri;
- }
-}
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/helper/RedirectToServletRoot.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/helper/SeeOtherServletRoot.java
similarity index 84%
rename from juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/helper/RedirectToServletRoot.java
rename to juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/helper/SeeOtherServletRoot.java
index 8683d14..ce5187a 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/helper/RedirectToServletRoot.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/helper/SeeOtherServletRoot.java
@@ -12,23 +12,26 @@
// ***************************************************************************************************************************
package org.apache.juneau.rest.helper;
+import java.net.*;
+
import org.apache.juneau.http.annotation.*;
+import org.apache.juneau.rest.response.*;
/**
- * Convenience subclass of {@link Redirect} for redirecting a response to the servlet root.
+ * Convenience subclass of {@link SeeOther} for redirecting a response to the servlet root.
*/
@Response(description="Redirect to servlet root")
-public class RedirectToServletRoot extends Redirect {
+public class SeeOtherServletRoot extends SeeOther {
/**
* Reusable instance.
*/
- public static final RedirectToServletRoot INSTANCE = new RedirectToServletRoot();
+ public static final SeeOtherServletRoot INSTANCE = new SeeOtherServletRoot();
/**
* Constructor.
*/
- public RedirectToServletRoot() {
- super("servlet:/");
+ public SeeOtherServletRoot() {
+ super(URI.create("servlet:/"));
}
}
\ No newline at end of file
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/RedirectHandler.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/RedirectHandler.java
deleted file mode 100644
index 750193f..0000000
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/RedirectHandler.java
+++ /dev/null
@@ -1,43 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.rest.reshandlers;
-
-import java.io.*;
-
-import org.apache.juneau.rest.*;
-import org.apache.juneau.rest.helper.*;
-
-/**
- * Response handler for {@link Redirect} objects.
- *
- * <h5 class='section'>See Also:</h5>
- * <ul>
- * <li class='link'><a class="juneau-rest-server > " href="../../../../../overview-summary.html#juneau-rest-server.RestMethod.MethodReturnTypes">Overview > Method Return Types</a>
- * </ul>
- */
-public final class RedirectHandler implements ResponseHandler {
-
- @Override /* ResponseHandler */
- public boolean handle(RestRequest req, RestResponse res) throws IOException, RestException {
- if (res.isOutputType(Redirect.class)) {
- Redirect r = res.getOutput(Redirect.class);
- String uri = req.getUriResolver().resolve(r.getURI());
- int rc = r.getHttpResponseCode();
- if (rc != 0)
- res.setStatus(rc); // TODO - This may get ignored by the call below.
- res.sendRedirect(uri);
- return true;
- }
- return false;
- }
-}
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/SeeOther.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/SeeOther.java
index dcd6ff6..bf3bc86 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/SeeOther.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/SeeOther.java
@@ -12,7 +12,10 @@
// ***************************************************************************************************************************
package org.apache.juneau.rest.response;
+import static org.apache.juneau.internal.StringUtils.*;
+
import java.net.*;
+import java.text.*;
import org.apache.juneau.http.annotation.*;
@@ -40,6 +43,7 @@ public class SeeOther extends HttpResponse {
/**
* Constructor using custom message.
+ *
* @param message Message to send as the response.
* @param location <code>Location</code> header value.
*/
@@ -50,6 +54,18 @@ public class SeeOther extends HttpResponse {
/**
* Constructor.
+ *
+ * @param message Message to send as the response.
+ * @param uri URI containing {@link MessageFormat}-style arguments.
+ * @param uriArgs {@link MessageFormat}-style arguments.
+ */
+ public SeeOther(String message, String uri, Object uriArgs) {
+ this(message, toURI(format(uri.toString(), uriArgs)));
+ }
+
+ /**
+ * Constructor.
+ *
* @param location <code>Location</code> header value.
*/
public SeeOther(URI location) {
@@ -57,6 +73,16 @@ public class SeeOther extends HttpResponse {
}
/**
+ * Constructor.
+ *
+ * @param uri URI containing {@link MessageFormat}-style arguments.
+ * @param uriArgs {@link MessageFormat}-style arguments.
+ */
+ public SeeOther(String uri, Object uriArgs) {
+ this(toURI(format(uri.toString(), uriArgs)));
+ }
+
+ /**
* @return <code>Location</code> header value.
*/
@ResponseHeader(name="Location")