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.http.response; 014 015import static org.apache.juneau.http.response.Ok.*; 016 017import java.net.*; 018import java.util.*; 019 020import org.apache.http.*; 021import org.apache.http.Header; 022import org.apache.juneau.annotation.*; 023import org.apache.juneau.http.*; 024import org.apache.juneau.http.annotation.*; 025import org.apache.juneau.http.header.*; 026import org.apache.juneau.internal.*; 027 028/** 029 * Represents an <c>HTTP 200 OK</c> response. 030 * 031 * <p> 032 * Standard response for successful HTTP requests. The actual response will depend on the request method used. 033 * In a GET request, the response will contain an entity corresponding to the requested resource. 034 * In a POST request, the response will contain an entity describing or containing the result of the action. 035 * 036 * <h5 class='section'>See Also:</h5><ul> 037 * <li class='link'><a class="doclink" href="../../../../../index.html#juneau-rest-common">juneau-rest-common</a> 038 * </ul> 039 */ 040@Response 041@StatusCode(STATUS_CODE) 042@Schema(description=REASON_PHRASE) 043@FluentSetters 044public class Ok extends BasicHttpResponse { 045 046 /** HTTP status code */ 047 public static final int STATUS_CODE = 200; 048 049 /** Reason phrase */ 050 public static final String REASON_PHRASE = "OK"; 051 052 /** Default status line */ 053 private static final BasicStatusLine STATUS_LINE = BasicStatusLine.create(STATUS_CODE, REASON_PHRASE); 054 055 /** Default unmodifiable instance */ 056 public static final Ok INSTANCE = new Ok().setUnmodifiable(); 057 058 /** Reusable unmodifiable instance */ 059 public static final Ok OK = INSTANCE; 060 061 /** 062 * Constructor. 063 */ 064 public Ok() { 065 super(STATUS_LINE); 066 } 067 068 /** 069 * Copy constructor. 070 * 071 * @param copyFrom The bean to copy from. 072 */ 073 public Ok(Ok copyFrom) { 074 super(copyFrom); 075 } 076 077 /** 078 * Constructor. 079 * 080 * <p> 081 * This is the constructor used when parsing an HTTP response. 082 * 083 * @param response The HTTP response to copy from. Must not be <jk>null</jk>. 084 * @throws AssertionError If HTTP response status code does not match what was expected. 085 */ 086 public Ok(HttpResponse response) { 087 super(response); 088 assertStatusCode(response); 089 } 090 091 /** 092 * Creates a builder for this class initialized with the contents of this bean. 093 * 094 * @return A new builder bean. 095 */ 096 public Ok copy() { 097 return new Ok(this); 098 } 099 100 // <FluentSetters> 101 102 @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */ 103 public Ok setContent(String value) { 104 super.setContent(value); 105 return this; 106 } 107 108 @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */ 109 public Ok setContent(HttpEntity value) { 110 super.setContent(value); 111 return this; 112 } 113 114 @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */ 115 public Ok setHeader2(Header value) { 116 super.setHeader2(value); 117 return this; 118 } 119 120 @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */ 121 public Ok setHeader2(String name, String value) { 122 super.setHeader2(name, value); 123 return this; 124 } 125 126 @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */ 127 public Ok setHeaders(List<Header> values) { 128 super.setHeaders(values); 129 return this; 130 } 131 132 @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */ 133 public Ok setHeaders(HeaderList value) { 134 super.setHeaders(value); 135 return this; 136 } 137 138 @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */ 139 public Ok setHeaders2(Header...values) { 140 super.setHeaders2(values); 141 return this; 142 } 143 144 @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */ 145 public Ok setLocale2(Locale value) { 146 super.setLocale2(value); 147 return this; 148 } 149 150 @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */ 151 public Ok setLocation(String value) { 152 super.setLocation(value); 153 return this; 154 } 155 156 @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */ 157 public Ok setLocation(URI value) { 158 super.setLocation(value); 159 return this; 160 } 161 162 @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */ 163 public Ok setProtocolVersion(ProtocolVersion value) { 164 super.setProtocolVersion(value); 165 return this; 166 } 167 168 @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */ 169 public Ok setReasonPhrase2(String value) { 170 super.setReasonPhrase2(value); 171 return this; 172 } 173 174 @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */ 175 public Ok setReasonPhraseCatalog(ReasonPhraseCatalog value) { 176 super.setReasonPhraseCatalog(value); 177 return this; 178 } 179 180 @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */ 181 public Ok setStatusCode2(int value) { 182 super.setStatusCode2(value); 183 return this; 184 } 185 186 @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */ 187 public Ok setStatusLine(BasicStatusLine value) { 188 super.setStatusLine(value); 189 return this; 190 } 191 192 @Override /* GENERATED - org.apache.juneau.http.response.BasicHttpResponse */ 193 public Ok setUnmodifiable() { 194 super.setUnmodifiable(); 195 return this; 196 } 197 198 // </FluentSetters> 199}