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 * <p> 026 * In this case, the request should be repeated with another URI; however, future requests should still use the original URI. 027 * In contrast to how 302 was historically implemented, the request method is not allowed to be changed when reissuing the original request. 028 * For example, a POST request should be repeated using another POST request. 029 * 030 * @deprecated Use {@link org.apache.juneau.http.response.TemporaryRedirect} 031 */ 032@Response(code=CODE, description=MESSAGE) 033@BeanIgnore 034@Deprecated 035public class TemporaryRedirect extends HttpResponse { 036 037 /** HTTP status code */ 038 public static final int CODE = 307; 039 040 /** Default message */ 041 public static final String MESSAGE = "Temporary Redirect"; 042 043 /** Reusable instance. */ 044 public static final TemporaryRedirect INSTANCE = new TemporaryRedirect(); 045 046 private final URI location; 047 048 /** 049 * Constructor using HTTP-standard message. 050 */ 051 public TemporaryRedirect() { 052 this(MESSAGE, null); 053 } 054 055 /** 056 * Constructor with no redirect. 057 * <p> 058 * Used for end-to-end interfaces. 059 * 060 * @param message Message to send as the response. 061 */ 062 public TemporaryRedirect(String message) { 063 super(message); 064 this.location = null; 065 } 066 067 /** 068 * Constructor using custom message. 069 * @param message Message to send as the response. 070 * @param location <c>Location</c> header value. 071 */ 072 public TemporaryRedirect(String message, URI location) { 073 super(message); 074 this.location = location; 075 } 076 077 /** 078 * Constructor. 079 * @param location <c>Location</c> header value. 080 */ 081 public TemporaryRedirect(URI location) { 082 this(MESSAGE, location); 083 } 084 085 /** 086 * @return <c>Location</c> header value. 087 */ 088 @ResponseHeader(name="Location", description="Temporary location of resource.") 089 public URI getLocation() { 090 return location; 091 } 092}