001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.rest.response;
014
015import static org.apache.juneau.rest.response.TemporaryRedirect.*;
016
017import java.net.*;
018
019import org.apache.juneau.annotation.BeanIgnore;
020import org.apache.juneau.http.annotation.*;
021
022/**
023 * Represents an <c>HTTP 307 Temporary Redirect</c> response.
024 *
025 * <div class='warn'>
026 *    <b>Deprecated</b> - Use {@link org.apache.juneau.http.response.TemporaryRedirect}
027 * </div>
028 *
029 * <p>
030 * In this case, the request should be repeated with another URI; however, future requests should still use the original URI.
031 * In contrast to how 302 was historically implemented, the request method is not allowed to be changed when reissuing the original request.
032 * For example, a POST request should be repeated using another POST request.
033 */
034@Response(code=CODE, description=MESSAGE)
035@BeanIgnore
036@Deprecated
037public class TemporaryRedirect extends HttpResponse {
038
039   /** HTTP status code */
040   public static final int CODE = 307;
041
042   /** Default message */
043   public static final String MESSAGE = "Temporary Redirect";
044
045   /** Reusable instance. */
046   public static final TemporaryRedirect INSTANCE = new TemporaryRedirect();
047
048   private final URI location;
049
050   /**
051    * Constructor using HTTP-standard message.
052    */
053   public TemporaryRedirect() {
054      this(MESSAGE, null);
055   }
056
057   /**
058    * Constructor with no redirect.
059    * <p>
060    * Used for end-to-end interfaces.
061    *
062    * @param message Message to send as the response.
063    */
064   public TemporaryRedirect(String message) {
065      super(message);
066      this.location = null;
067   }
068
069   /**
070    * Constructor using custom message.
071    * @param message Message to send as the response.
072    * @param location <c>Location</c> header value.
073    */
074   public TemporaryRedirect(String message, URI location) {
075      super(message);
076      this.location = location;
077   }
078
079   /**
080    * Constructor.
081    * @param location <c>Location</c> header value.
082    */
083   public TemporaryRedirect(URI location) {
084      this(MESSAGE, location);
085   }
086
087   /**
088    * @return <c>Location</c> header value.
089    */
090   @ResponseHeader(name="Location", description="Temporary location of resource.")
091   public URI getLocation() {
092      return location;
093   }
094}