| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ResponseError |
|
| 0.0;0 |
| 1 | /* | |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one | |
| 3 | * or more contributor license agreements. See the NOTICE file | |
| 4 | * distributed with this work for additional information | |
| 5 | * regarding copyright ownership. The ASF licenses this file | |
| 6 | * to you under the Apache License, Version 2.0 (the | |
| 7 | * "License"); you may not use this file except in compliance | |
| 8 | * with the License. You may obtain a copy of the License at | |
| 9 | * | |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 11 | * | |
| 12 | * Unless required by applicable law or agreed to in writing, | |
| 13 | * software distributed under the License is distributed on an | |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
| 15 | * KIND, either express or implied. See the License for the | |
| 16 | * specific language governing permissions and limitations under the License. | |
| 17 | */ | |
| 18 | package org.apache.shindig.social; | |
| 19 | ||
| 20 | import javax.servlet.http.HttpServletResponse; | |
| 21 | /** | |
| 22 | * An Enumeration for holding all the responses emitted by the social API. | |
| 23 | */ | |
| 24 | 1 | public enum ResponseError { |
| 25 | /** value representing NOT IMPLEMENTED. */ | |
| 26 | 1 | NOT_IMPLEMENTED("notImplemented", HttpServletResponse.SC_NOT_IMPLEMENTED), |
| 27 | /** value representing UNAUTHORIZED. */ | |
| 28 | 1 | UNAUTHORIZED("unauthorized", HttpServletResponse.SC_UNAUTHORIZED), |
| 29 | /** value representing FORBIDDEN. */ | |
| 30 | 1 | FORBIDDEN("forbidden", HttpServletResponse.SC_FORBIDDEN), |
| 31 | /** value representing BAD REQUEST. */ | |
| 32 | 1 | BAD_REQUEST("badRequest", HttpServletResponse.SC_BAD_REQUEST), |
| 33 | /** value representing INTERNAL SERVER ERROR. */ | |
| 34 | 1 | INTERNAL_ERROR("internalError", HttpServletResponse.SC_INTERNAL_SERVER_ERROR), |
| 35 | /** value representing EXPECTATION FAILED. */ | |
| 36 | 1 | LIMIT_EXCEEDED("limitExceeded", HttpServletResponse.SC_EXPECTATION_FAILED); |
| 37 | ||
| 38 | /** | |
| 39 | * The json value of the error. | |
| 40 | */ | |
| 41 | private final String jsonValue; | |
| 42 | /** | |
| 43 | * The http error code associated with the error. | |
| 44 | */ | |
| 45 | private int httpErrorCode; | |
| 46 | ||
| 47 | /** | |
| 48 | * Construct a Response Error from the jsonValue as a string and the Http Error Code. | |
| 49 | * @param jsonValue the json String representation of the error code. | |
| 50 | * @param httpErrorCode the numeric HTTP error code. | |
| 51 | */ | |
| 52 | 6 | ResponseError(String jsonValue, int httpErrorCode) { |
| 53 | 6 | this.jsonValue = jsonValue; |
| 54 | 6 | this.httpErrorCode = httpErrorCode; |
| 55 | 6 | } |
| 56 | ||
| 57 | /** | |
| 58 | * | |
| 59 | * Converts the ResponseError to a String representation | |
| 60 | */ | |
| 61 | @Override | |
| 62 | public String toString() { | |
| 63 | 2 | return jsonValue; |
| 64 | } | |
| 65 | ||
| 66 | /** | |
| 67 | * Get the HTTP error code. | |
| 68 | * @return the Http Error code. | |
| 69 | */ | |
| 70 | public int getHttpErrorCode() { | |
| 71 | 3 | return httpErrorCode; |
| 72 | } | |
| 73 | } |