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.PermanentRedirect.*;
016
017import java.net.*;
018
019import org.apache.juneau.annotation.BeanIgnore;
020import org.apache.juneau.http.annotation.*;
021
022/**
023 * Represents an <c>HTTP 308 Permanent Redirect</c> response.
024 *
025 * <div class='warn'>
026 *    <b>Deprecated</b> - Use {@link org.apache.juneau.http.response.PermanentRedirect}
027 * </div>
028 *
029 * <p>
030 * The request and all future requests should be repeated using another URI. 307 and 308 parallel the behaviors of 302 and 301, but do not allow the HTTP method to change.
031 * So, for example, submitting a form to a permanently redirected resource may continue smoothly.
032 */
033@Response(code=CODE, description=MESSAGE)
034@BeanIgnore
035@Deprecated
036public class PermanentRedirect extends HttpResponse {
037
038   /** HTTP status code */
039   public static final int CODE = 308;
040
041   /** Default message */
042   public static final String MESSAGE = "Permanent Redirect";
043
044   /** Reusable instance. */
045   public static final PermanentRedirect INSTANCE = new PermanentRedirect();
046
047   private final URI location;
048
049   /**
050    * Constructor using HTTP-standard message.
051    */
052   public PermanentRedirect() {
053      this(MESSAGE, null);
054   }
055
056   /**
057    * Constructor with no redirect.
058    * <p>
059    * Used for end-to-end interfaces.
060    *
061    * @param message Message to send as the response.
062    */
063   public PermanentRedirect(String message) {
064      super(message);
065      this.location = null;
066   }
067
068   /**
069    * Constructor using custom message.
070    * @param message Message to send as the response.
071    * @param location <c>Location</c> header value.
072    */
073   public PermanentRedirect(String message, URI location) {
074      super(message);
075      this.location = location;
076   }
077
078   /**
079    * Constructor.
080    * @param location <c>Location</c> header value.
081    */
082   public PermanentRedirect(URI location) {
083      this(MESSAGE, location);
084   }
085
086   /**
087    * @return <c>Location</c> header value.
088    */
089   @ResponseHeader(name="Location", description="New location of resource.")
090   public URI getLocation() {
091      return location;
092   }
093}