Java Code Examples for java.net.HttpURLConnection#HTTP_INTERNAL_ERROR

The following examples show how to use java.net.HttpURLConnection#HTTP_INTERNAL_ERROR . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TkAppFallback.java    From jare with MIT License 6 votes vote down vote up
/**
 * Make fatal error page.
 * @param req Request
 * @return Response
 * @throws IOException If fails
 */
private static Response fatal(final RqFallback req) throws IOException {
    return new RsWithStatus(
        new RsWithType(
            new RsVelocity(
                TkAppFallback.class.getResource("error.html.vm"),
                new RsVelocity.Pair(
                    "err",
                    ExceptionUtils.getStackTrace(req.throwable())
                ),
                new RsVelocity.Pair("rev", TkAppFallback.REV)
            ),
            "text/html"
        ),
        HttpURLConnection.HTTP_INTERNAL_ERROR
    );
}
 
Example 2
Source File: HttpWebResponse.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private void readResponseHeader( HttpURLConnection connection ) throws IOException {
    if (!needStatusWorkaround()) {
        _responseCode = connection.getResponseCode();
        _responseMessage = connection.getResponseMessage();
    } else {
         if (connection.getHeaderField(0) == null) throw new UnknownHostException( connection.getURL().toExternalForm() );

        StringTokenizer st = new StringTokenizer( connection.getHeaderField(0) );
        st.nextToken();
        if (!st.hasMoreTokens()) {
            _responseCode = HttpURLConnection.HTTP_OK;
            _responseMessage = "OK";
        } else try {
            _responseCode = Integer.parseInt( st.nextToken() );
            _responseMessage = getRemainingTokens( st );
        } catch (NumberFormatException e) {
            _responseCode = HttpURLConnection.HTTP_INTERNAL_ERROR;
            _responseMessage = "Cannot parse response header";
        }
    }
}
 
Example 3
Source File: JmsBasedTenantClient.java    From hono with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected TenantResult<TenantObject> getResult(final int status, final Buffer payload, final CacheDirective cacheDirective) {

    if (payload == null) {
        return TenantResult.from(status);
    } else {
        try {
            final JsonObject json = payload.toJsonObject();
            final TenantObject tenant = json.mapTo(TenantObject.class);
            return TenantResult.from(status, tenant, cacheDirective);
        } catch (DecodeException e) {
            LOGGER.warn("Tenant service returned malformed payload", e);
            throw new ServiceInvocationException(
                    HttpURLConnection.HTTP_INTERNAL_ERROR,
                    "Tenant service returned malformed payload");
        }
    }
}
 
Example 4
Source File: FaqManagement.java    From opencps-v2 with GNU Affero General Public License v3.0 5 votes vote down vote up
@PUT
@Path("/questions/{id}")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@ApiOperation(value = "Add a question", response = QuestionDetailModel.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns a question was created", response = QuestionDetailModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Internal error", response = ExceptionModel.class) })
public Response updateQuestion(@Context HttpServletRequest request, @Context HttpHeaders header, @Context Company company,
		@Context Locale locale, @Context User user, @Context ServiceContext serviceContext,
		@PathParam("id") String id,
		@BeanParam QuestionInputModel input);
 
Example 5
Source File: AnalyticsMessages.java    From sa-sdk-android with Apache License 2.0 5 votes vote down vote up
/**
 * 在服务器正常返回状态码的情况下,目前只有 (>= 500 && < 600) || 404 || 403 才不删数据
 *
 * @param httpCode 状态码
 * @return true: 删除数据,false: 不删数据
 */
private boolean isDeleteEventsByCode(int httpCode) {
    boolean shouldDelete = true;
    if (httpCode == HttpURLConnection.HTTP_NOT_FOUND ||
            httpCode == HttpURLConnection.HTTP_FORBIDDEN ||
            (httpCode >= HttpURLConnection.HTTP_INTERNAL_ERROR && httpCode < 600)) {
        shouldDelete = false;
    }
    return shouldDelete;
}
 
Example 6
Source File: ServiceProcessManagement.java    From opencps-v2 with GNU Affero General Public License v3.0 5 votes vote down vote up
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "Add a ServiceProcesses", response = ServiceProcessInputModel.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns the ServiceProcesses was created", response = ServiceProcessInputModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Internal error", response = ExceptionModel.class) })

public Response addServiceProcesses(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext, @BeanParam ServiceProcessInputModel input);
 
Example 7
Source File: DossierActionManagement.java    From opencps-v2 with GNU Affero General Public License v3.0 5 votes vote down vote up
@GET
@Path("/{id}/deliverableState/{state}")
@ApiOperation(value = "deliverableState")
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns list deliverable is success", response = String.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Internal error", response = ExceptionModel.class) })
public Response getByDeliverableState(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext, @PathParam("id") Long id, @PathParam("state") String state);
 
Example 8
Source File: PaymentConfigManagement.java    From opencps-v2 with GNU Affero General Public License v3.0 5 votes vote down vote up
@GET
@Path("/{id}/epaymentconfig")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "Get the epaymentconfig", response = PaymentConfigSingleInputModel.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns epaymentconfig of PaymentConfig", response = PaymentConfigSingleInputModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Internal error", response = ExceptionModel.class) })

public Response getEpaymentconfig(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext, @PathParam("id") long id);
 
Example 9
Source File: ApplicantManagement.java    From opencps-v2 with GNU Affero General Public License v3.0 5 votes vote down vote up
@POST
@Path("/withcaptcha")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@ApiOperation(value = "Register a applicant", response = ApplicantModel.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns a applicant was created", response = ApplicantModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Internal error", response = ExceptionModel.class) })
public Response registerWithCaptcha(@Context HttpServletRequest request, @Context HttpHeaders header, @Context Company company,
		@Context Locale locale, @Context User user, @Context ServiceContext serviceContext,
		@BeanParam ApplicantInputModel input, @FormParam("j_captcha_response") String jCaptchaResponse);
 
Example 10
Source File: DossierTemplateManagement.java    From opencps-v2 with GNU Affero General Public License v3.0 5 votes vote down vote up
@PUT
@Path("/{id}")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "Update a DossierTemplate", response = DossierTemplateInputModel.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns the DossierTemplate was update", response = DossierTemplateInputModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Internal error", response = ExceptionModel.class) })

public Response updateDossierTemplateDetail(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext, @PathParam("id") long id,
		@BeanParam DossierTemplateInputModel input);
 
Example 11
Source File: VNPostManagement.java    From opencps-v2 with GNU Affero General Public License v3.0 5 votes vote down vote up
@POST
@Path("/cancelOrder")
@ApiOperation(value = "requestsToken")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Send request to VNPost successful", response = String.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Internal error", response = ExceptionModel.class) 
})
public Response cancelOrder(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext,@BeanParam VNPostCancelOrderModel input);
 
Example 12
Source File: PaymentFileManagement.java    From opencps-v2 with GNU Affero General Public License v3.0 5 votes vote down vote up
@GET
@Path("/{id}/payments/{referenceUid}/epaymentprofile")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@ApiOperation(value = "get info epayment profile", response = String.class)
@ApiResponses(value = {
			@ApiResponse (code = HttpURLConnection.HTTP_OK, message = "Get info epayment profile", response = String.class),
			@ApiResponse (code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not Found", response = ExceptionModel.class),
			@ApiResponse (code = HttpURLConnection.HTTP_FORBIDDEN, message = "Accsess denied", response = ExceptionModel.class),
			@ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Internal error", response = ExceptionModel.class)})
public Response getEpaymentProfile(@Context HttpServletRequest request, @Context HttpHeaders header, @Context Company company,
		@Context Locale locale, @Context User user, @Context ServiceContext serviceContext,
		@ApiParam(value = "id of dossier", required = true) @PathParam("id") String id,
		@ApiParam (value = "referenceUid of Payment", required = true) @PathParam("referenceUid") String referenceUid);
 
Example 13
Source File: PaymentConfigManagement.java    From opencps-v2 with GNU Affero General Public License v3.0 5 votes vote down vote up
@GET
@Path("/{id}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "Get the PaymentConfig by primekey", response = PaymentConfigInputModel.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns detail of PaymentConfig", response = PaymentConfigInputModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Internal error", response = ExceptionModel.class) })

public Response getPaymentConfigDetail(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext, @PathParam("id") long id);
 
Example 14
Source File: HttpTransportPipe.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private void checkStatusCode(InputStream in, HttpClientTransport con) throws IOException {
    int statusCode = con.statusCode;
    String statusMessage = con.statusMessage;
    // SOAP1.1 and SOAP1.2 differ here
    if (binding instanceof SOAPBinding) {
        if (binding.getSOAPVersion() == SOAPVersion.SOAP_12) {
            //In SOAP 1.2, Fault messages can be sent with 4xx and 5xx error codes
            if (statusCode == HttpURLConnection.HTTP_OK || statusCode == HttpURLConnection.HTTP_ACCEPTED || isErrorCode(statusCode)) {
                // acceptable status codes for SOAP 1.2
                if (isErrorCode(statusCode) && in == null) {
                    // No envelope for the error, so throw an exception with http error details
                    throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
                }
                return;
            }
        } else {
            // SOAP 1.1
            if (statusCode == HttpURLConnection.HTTP_OK || statusCode == HttpURLConnection.HTTP_ACCEPTED || statusCode == HttpURLConnection.HTTP_INTERNAL_ERROR) {
                // acceptable status codes for SOAP 1.1
                if (statusCode == HttpURLConnection.HTTP_INTERNAL_ERROR && in == null) {
                    // No envelope for the error, so throw an exception with http error details
                    throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
                }
                return;
            }
        }
        if (in != null) {
            in.close();
        }
        throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
    }
    // Every status code is OK for XML/HTTP
}
 
Example 15
Source File: SystemManagement.java    From opencps-v2 with GNU Affero General Public License v3.0 5 votes vote down vote up
@GET
@Path("/progress/{backgroundTaskId}")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "Clean a site", response = BackgroundTaskProgress.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns a background was created", response = BackgroundTaskProgress.class),
		@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Internal error", response = ExceptionModel.class) })

public Response getProgress(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext, @PathParam("backgroundTaskId") Long backgroundTaskId);
 
Example 16
Source File: HttpTransportPipe.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void checkStatusCode(InputStream in, HttpClientTransport con) throws IOException {
    int statusCode = con.statusCode;
    String statusMessage = con.statusMessage;
    // SOAP1.1 and SOAP1.2 differ here
    if (binding instanceof SOAPBinding) {
        if (binding.getSOAPVersion() == SOAPVersion.SOAP_12) {
            //In SOAP 1.2, Fault messages can be sent with 4xx and 5xx error codes
            if (statusCode == HttpURLConnection.HTTP_OK || statusCode == HttpURLConnection.HTTP_ACCEPTED || isErrorCode(statusCode)) {
                // acceptable status codes for SOAP 1.2
                if (isErrorCode(statusCode) && in == null) {
                    // No envelope for the error, so throw an exception with http error details
                    throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
                }
                return;
            }
        } else {
            // SOAP 1.1
            if (statusCode == HttpURLConnection.HTTP_OK || statusCode == HttpURLConnection.HTTP_ACCEPTED || statusCode == HttpURLConnection.HTTP_INTERNAL_ERROR) {
                // acceptable status codes for SOAP 1.1
                if (statusCode == HttpURLConnection.HTTP_INTERNAL_ERROR && in == null) {
                    // No envelope for the error, so throw an exception with http error details
                    throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
                }
                return;
            }
        }
        if (in != null) {
            in.close();
        }
        throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
    }
    // Every status code is OK for XML/HTTP
}
 
Example 17
Source File: MenuRoleManagement.java    From opencps-v2 with GNU Affero General Public License v3.0 5 votes vote down vote up
@POST
@Path("/autogenerate")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Internal error", response = ExceptionModel.class) })
public Response autoGenerateId(@Context HttpServletRequest request, @Context HttpHeaders header, @Context Company company,
		@Context Locale locale, @Context User user, @Context ServiceContext serviceContext);
 
Example 18
Source File: RequestProcessor.java    From cellery-distribution with Apache License 2.0 4 votes vote down vote up
/**
 * Validate the http response.
 * @param statusCode status code
 * @return boolean to validate response
 */
private boolean responseValidate(int statusCode, String response) throws IOException {
    boolean isValid = false;
    switch (statusCode) {
        case HttpURLConnection.HTTP_OK:
            isValid = true;
            break;
        case HttpURLConnection.HTTP_CREATED:
            isValid = true;
            break;
        case HttpURLConnection.HTTP_ACCEPTED:
            isValid = true;
            break;
        case HttpURLConnection.HTTP_BAD_REQUEST:
            if (response != null && !Constants.Utils.EMPTY_STRING.equals(response)) {
                if (response.contains(Constants.Utils.DIFFERENT_CONTEXT_ERROR) ||
                    response.contains(Constants.Utils.DUPLICATE_CONTEXT_ERROR)) {
                    // skip the error when trying to add the same api with different context.
                    isValid = true;
                }
            }
            break;
        case HttpURLConnection.HTTP_UNAUTHORIZED:
            isValid = false;
            break;
        case HttpURLConnection.HTTP_NOT_FOUND:
            isValid = false;
            break;
        case HttpURLConnection.HTTP_CONFLICT:
            if (response != null && !Constants.Utils.EMPTY_STRING.equals(response)) {
                if (response.contains(Constants.Utils.DUPLICATE_API_ERROR)) {
                    // skip the error when trying to add the same api.
                    isValid = true;
                }
            }
            break;
        case HttpURLConnection.HTTP_INTERNAL_ERROR:
            if (response != null && !Constants.Utils.EMPTY_STRING.equals(response)) {
                if (response.contains(Constants.Utils.DUPLICATE_LABEL_ERROR)) {
                    // skip the error when trying to add the same label.
                    isValid = true;
                }
            }
            break;
        default:
            isValid = false;
    }
    return isValid;
}
 
Example 19
Source File: GenieServerException.java    From genie with Apache License 2.0 2 votes vote down vote up
/**
 * Constructor.
 *
 * @param msg   human readable message
 * @param cause reason for this exception
 */
public GenieServerException(final String msg, final Throwable cause) {
    super(HttpURLConnection.HTTP_INTERNAL_ERROR, msg, cause);
}
 
Example 20
Source File: GenieServerException.java    From genie with Apache License 2.0 2 votes vote down vote up
/**
 * Constructor.
 *
 * @param msg human readable message
 */
public GenieServerException(final String msg) {
    super(HttpURLConnection.HTTP_INTERNAL_ERROR, msg);
}