2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
\r
6 * Copyright © 2017-2018 Amdocs
\r
7 * ================================================================================
\r
8 * Licensed under the Apache License, Version 2.0 (the "License");
\r
9 * you may not use this file except in compliance with the License.
\r
10 * You may obtain a copy of the License at
\r
12 * http://www.apache.org/licenses/LICENSE-2.0
\r
14 * Unless required by applicable law or agreed to in writing, software
\r
15 * distributed under the License is distributed on an "AS IS" BASIS,
\r
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
17 * See the License for the specific language governing permissions and
\r
18 * limitations under the License.
\r
19 * ============LICENSE_END=========================================================
\r
21 package org.onap.aai.restclient.rest;
\r
23 public class HttpUtil {
\r
26 * Determines if the provided HTTP response is present in the provided list of acceptable response
\r
29 * @param response the http response we got from our request
\r
30 * @param list the list of acceptable response codes
\r
31 * @return true if the http response is in the provided list
\r
33 public static boolean isHttpResponseInList(int response, int... list) {
\r
34 for (int checkCode : list) {
\r
35 if (checkCode == response) {
\r
43 * Determines if the provided http response is of the information class.
\r
45 * @param response the http response we got from our request
\r
46 * @return true if the response is of the informational class and false otherwise
\r
48 public static boolean isHttpResponseClassInformational(int response) {
\r
49 return ( response >= 100 && response <= 199);
\r
53 * Determines if the provided http response is of the success class.
\r
55 * @param response the http response we got from our request
\r
56 * @return true if the response is of the success class and false otherwise
\r
58 public static boolean isHttpResponseClassSuccess(int response) {
\r
59 return ( response >= 200 && response <= 299);
\r
64 * Determines if the provided http response is of the redirection class.
\r
66 * @param response the http response we got from our request
\r
67 * @return true if the response is of the redirection class and false otherwise
\r
69 public static boolean isHttpResponseClassRedirection(int response) {
\r
70 return ( response >= 300 && response <= 399);
\r
74 * Determines if the provided http response is of the client error class.
\r
76 * @param response the http response we got from our request
\r
77 * @return true if the response is of the client error class and false otherwise
\r
79 public static boolean isHttpResponseClassClientError(int response) {
\r
80 return ( response >= 400 && response <= 499);
\r
84 * Determines if the provided http response is of the server error class.
\r
86 * @param response the http response we got from our request
\r
87 * @return true if the response is of the server error class and false otherwise
\r
89 public static boolean isHttpResponseClassServerError(int response) {
\r
90 return ( response >= 500 && response <= 599);
\r