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 * <p>
026 * 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.
027 * So, for example, submitting a form to a permanently redirected resource may continue smoothly.
028 *
029 * @deprecated Use {@link org.apache.juneau.http.response.PermanentRedirect}
030 */
031@Response(code=CODE, description=MESSAGE)
032@BeanIgnore
033@Deprecated
034public class PermanentRedirect extends HttpResponse {
035
036   /** HTTP status code */
037   public static final int CODE = 308;
038
039   /** Default message */
040   public static final String MESSAGE = "Permanent Redirect";
041
042   /** Reusable instance. */
043   public static final PermanentRedirect INSTANCE = new PermanentRedirect();
044
045   private final URI location;
046
047   /**
048    * Constructor using HTTP-standard message.
049    */
050   public PermanentRedirect() {
051      this(MESSAGE, null);
052   }
053
054   /**
055    * Constructor with no redirect.
056    * <p>
057    * Used for end-to-end interfaces.
058    *
059    * @param message Message to send as the response.
060    */
061   public PermanentRedirect(String message) {
062      super(message);
063      this.location = null;
064   }
065
066   /**
067    * Constructor using custom message.
068    * @param message Message to send as the response.
069    * @param location <c>Location</c> header value.
070    */
071   public PermanentRedirect(String message, URI location) {
072      super(message);
073      this.location = location;
074   }
075
076   /**
077    * Constructor.
078    * @param location <c>Location</c> header value.
079    */
080   public PermanentRedirect(URI location) {
081      this(MESSAGE, location);
082   }
083
084   /**
085    * @return <c>Location</c> header value.
086    */
087   @ResponseHeader(name="Location", description="New location of resource.")
088   public URI getLocation() {
089      return location;
090   }
091}