2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * Copyright © 2017 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 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
23 package org.onap.aai.restclient.rest;
\r
25 public class HttpUtil {
\r
28 * Determines if the provided HTTP response is present in the provided list of acceptable response
\r
31 * @param response the http response we got from our request
\r
32 * @param list the list of acceptable response codes
\r
33 * @return true if the http response is in the provided list
\r
35 public static boolean isHttpResponseInList(int response, int... list) {
\r
36 for (int checkCode : list) {
\r
37 if (checkCode == response) {
\r
45 * Determines if the provided http response is of the information class.
\r
47 * @param response the http response we got from our request
\r
48 * @return true if the response is of the informational class and false otherwise
\r
50 public static boolean isHttpResponseClassInformational(int response) {
\r
51 return ( response >= 100 && response <= 199);
\r
55 * Determines if the provided http response is of the success class.
\r
57 * @param response the http response we got from our request
\r
58 * @return true if the response is of the success class and false otherwise
\r
60 public static boolean isHttpResponseClassSuccess(int response) {
\r
61 return ( response >= 200 && response <= 299);
\r
66 * Determines if the provided http response is of the redirection class.
\r
68 * @param response the http response we got from our request
\r
69 * @return true if the response is of the redirection class and false otherwise
\r
71 public static boolean isHttpResponseClassRedirection(int response) {
\r
72 return ( response >= 300 && response <= 399);
\r
76 * Determines if the provided http response is of the client error class.
\r
78 * @param response the http response we got from our request
\r
79 * @return true if the response is of the client error class and false otherwise
\r
81 public static boolean isHttpResponseClassClientError(int response) {
\r
82 return ( response >= 400 && response <= 499);
\r
86 * Determines if the provided http response is of the server error class.
\r
88 * @param response the http response we got from our request
\r
89 * @return true if the response is of the server error class and false otherwise
\r
91 public static boolean isHttpResponseClassServerError(int response) {
\r
92 return ( response >= 500 && response <= 599);
\r