2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright © 2017 AT&T Intellectual Property.
\r
6 * Copyright © 2017 Amdocs
\r
7 * All rights reserved.
\r
8 * ================================================================================
\r
9 * Licensed under the Apache License, Version 2.0 (the "License");
\r
10 * you may not use this file except in compliance with the License.
\r
11 * You may obtain a copy of the License at
\r
13 * http://www.apache.org/licenses/LICENSE-2.0
\r
15 * Unless required by applicable law or agreed to in writing, software
\r
16 * distributed under the License is distributed on an "AS IS" BASIS,
\r
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
18 * See the License for the specific language governing permissions and
\r
19 * limitations under the License.
\r
20 * ============LICENSE_END=========================================================
\r
22 * ECOMP and OpenECOMP are trademarks
\r
23 * and service marks of AT&T Intellectual Property.
\r
25 package org.openecomp.restclient.rest;
\r
27 public class HttpUtil {
\r
30 * Determines if the provided HTTP response is present in the provided list of acceptable response
\r
33 * @param response the http response we got from our request
\r
34 * @param list the list of acceptable response codes
\r
35 * @return true if the http response is in the provided list
\r
37 public static boolean isHttpResponseInList(int response, int... list) {
\r
38 for (int checkCode : list) {
\r
39 if (checkCode == response) {
\r
47 * Determines if the provided http response is of the information class.
\r
49 * @param response the http response we got from our request
\r
50 * @return true if the response is of the informational class and false otherwise
\r
52 public static boolean isHttpResponseClassInformational(int response) {
\r
53 return ( response >= 100 && response <= 199);
\r
57 * Determines if the provided http response is of the success class.
\r
59 * @param response the http response we got from our request
\r
60 * @return true if the response is of the success class and false otherwise
\r
62 public static boolean isHttpResponseClassSuccess(int response) {
\r
63 return ( response >= 200 && response <= 299);
\r
68 * Determines if the provided http response is of the redirection class.
\r
70 * @param response the http response we got from our request
\r
71 * @return true if the response is of the redirection class and false otherwise
\r
73 public static boolean isHttpResponseClassRedirection(int response) {
\r
74 return ( response >= 300 && response <= 399);
\r
78 * Determines if the provided http response is of the client error class.
\r
80 * @param response the http response we got from our request
\r
81 * @return true if the response is of the client error class and false otherwise
\r
83 public static boolean isHttpResponseClassClientError(int response) {
\r
84 return ( response >= 400 && response <= 499);
\r
88 * Determines if the provided http response is of the server error class.
\r
90 * @param response the http response we got from our request
\r
91 * @return true if the response is of the server error class and false otherwise
\r
93 public static boolean isHttpResponseClassServerError(int response) {
\r
94 return ( response >= 500 && response <= 599);
\r