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 java.net.*; 016 017import static org.apache.juneau.rest.response.Found.*; 018 019import org.apache.juneau.annotation.BeanIgnore; 020import org.apache.juneau.http.annotation.*; 021 022/** 023 * Represents an <c>HTTP 302 Found</c> response. 024 * 025 * <p> 026 * Tells the client to look at (browse to) another url. 302 has been superseded by 303 and 307. 027 * This is an example of industry practice contradicting the standard. 028 * The HTTP/1.0 specification (RFC 1945) required the client to perform a temporary redirect (the original describing phrase was "Moved Temporarily"), but popular browsers implemented 302 with the functionality of a 303 See Other. 029 * Therefore, HTTP/1.1 added status codes 303 and 307 to distinguish between the two behaviours. 030 * However, some Web applications and frameworks use the 302 status code as if it were the 303. 031 * 032 * @deprecated Use {@link org.apache.juneau.http.response.Found} 033 */ 034@Response(code=CODE, description=MESSAGE) 035@BeanIgnore 036@Deprecated 037public class Found extends HttpResponse { 038 039 /** HTTP status code */ 040 public static final int CODE = 302; 041 042 /** Default message */ 043 public static final String MESSAGE = "Found"; 044 045 /** Reusable instance. */ 046 public static final Found INSTANCE = new Found(); 047 048 private final URI location; 049 050 /** 051 * Constructor using HTTP-standard message. 052 */ 053 public Found() { 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 Found(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 Found(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 Found(URI location) { 084 this(MESSAGE, location); 085 } 086 087 /** 088 * @return <c>Location</c> header value. 089 */ 090 @ResponseHeader(name="Location", description="Location of resource.") 091 public URI getLocation() { 092 return location; 093 } 094}