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.SeeOther.*; 016import static org.apache.juneau.internal.StringUtils.*; 017 018import java.net.*; 019import java.text.*; 020 021import org.apache.juneau.annotation.BeanIgnore; 022import org.apache.juneau.http.annotation.*; 023 024/** 025 * Represents an <c>HTTP 303 See Other</c> response. 026 * 027 * <div class='warn'> 028 * <b>Deprecated</b> - Use {@link org.apache.juneau.http.response.SeeOther} 029 * </div> 030 * 031 * <p> 032 * The response to the request can be found under another URI using the GET method. 033 * When received in response to a POST (or PUT/DELETE), the client should presume that the server has received the data and should issue a new GET request to the given URI. 034 */ 035@Response(code=CODE, description=MESSAGE) 036@BeanIgnore 037@Deprecated 038public class SeeOther extends HttpResponse { 039 040 /** HTTP status code */ 041 public static final int CODE = 303; 042 043 /** Default message */ 044 public static final String MESSAGE = "See Other"; 045 046 /** Reusable instance. */ 047 public static final SeeOther INSTANCE = new SeeOther(); 048 049 private final URI location; 050 051 /** 052 * Constructor using HTTP-standard message. 053 */ 054 public SeeOther() { 055 this(MESSAGE, null); 056 } 057 058 /** 059 * Constructor with no redirect. 060 * <p> 061 * Used for end-to-end interfaces. 062 * 063 * @param message Message to send as the response. 064 */ 065 public SeeOther(String message) { 066 super(message); 067 this.location = null; 068 } 069 070 /** 071 * Constructor using custom message. 072 * 073 * @param message Message to send as the response. 074 * @param location <c>Location</c> header value. 075 */ 076 public SeeOther(String message, URI location) { 077 super(message); 078 this.location = location; 079 } 080 081 /** 082 * Constructor. 083 * 084 * @param message Message to send as the response. 085 * @param uri URI containing {@link MessageFormat}-style arguments. 086 * @param uriArgs {@link MessageFormat}-style arguments. 087 */ 088 public SeeOther(String message, String uri, Object uriArgs) { 089 this(message, toURI(format(uri.toString(), uriArgs))); 090 } 091 092 /** 093 * Constructor. 094 * 095 * @param location <c>Location</c> header value. 096 */ 097 public SeeOther(URI location) { 098 this(MESSAGE, location); 099 } 100 101 /** 102 * Constructor. 103 * 104 * @param uri URI containing {@link MessageFormat}-style arguments. 105 * @param uriArgs {@link MessageFormat}-style arguments. 106 */ 107 public SeeOther(String uri, Object uriArgs) { 108 this(toURI(format(uri.toString(), uriArgs))); 109 } 110 111 /** 112 * @return <c>Location</c> header value. 113 */ 114 @ResponseHeader(name="Location", description="Other location.") 115 public URI getLocation() { 116 return location; 117 } 118}