Java Code Examples for java.net.HttpURLConnection#HTTP_INTERNAL_ERROR
The following examples show how to use
java.net.HttpURLConnection#HTTP_INTERNAL_ERROR .
These examples are extracted from open source projects.
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 Project: hono File: JmsBasedTenantClient.java License: Eclipse Public License 2.0 | 6 votes |
/** * {@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 2
Source Project: lams File: HttpWebResponse.java License: GNU General Public License v2.0 | 6 votes |
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 Project: jare File: TkAppFallback.java License: MIT License | 6 votes |
/** * 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 4
Source Project: opencps-v2 File: DossierTemplateManagement.java License: GNU Affero General Public License v3.0 | 5 votes |
@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 5
Source Project: opencps-v2 File: MenuRoleManagement.java License: GNU Affero General Public License v3.0 | 5 votes |
@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 6
Source Project: openjdk-jdk9 File: HttpTransportPipe.java License: GNU General Public License v2.0 | 5 votes |
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 7
Source Project: opencps-v2 File: SystemManagement.java License: GNU Affero General Public License v3.0 | 5 votes |
@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 8
Source Project: openjdk-8-source File: HttpTransportPipe.java License: GNU General Public License v2.0 | 5 votes |
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 9
Source Project: opencps-v2 File: PaymentConfigManagement.java License: GNU Affero General Public License v3.0 | 5 votes |
@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 10
Source Project: opencps-v2 File: PaymentFileManagement.java License: GNU Affero General Public License v3.0 | 5 votes |
@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 11
Source Project: opencps-v2 File: VNPostManagement.java License: GNU Affero General Public License v3.0 | 5 votes |
@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 Project: opencps-v2 File: FaqManagement.java License: GNU Affero General Public License v3.0 | 5 votes |
@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 13
Source Project: opencps-v2 File: ApplicantManagement.java License: GNU Affero General Public License v3.0 | 5 votes |
@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 14
Source Project: opencps-v2 File: PaymentConfigManagement.java License: GNU Affero General Public License v3.0 | 5 votes |
@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 15
Source Project: opencps-v2 File: DossierActionManagement.java License: GNU Affero General Public License v3.0 | 5 votes |
@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 16
Source Project: opencps-v2 File: ServiceProcessManagement.java License: GNU Affero General Public License v3.0 | 5 votes |
@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 17
Source Project: sa-sdk-android File: AnalyticsMessages.java License: Apache License 2.0 | 5 votes |
/** * 在服务器正常返回状态码的情况下,目前只有 (>= 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 18
Source Project: cellery-distribution File: RequestProcessor.java License: Apache License 2.0 | 4 votes |
/** * 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 Project: genie File: GenieServerException.java License: Apache License 2.0 | 2 votes |
/** * 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 Project: genie File: GenieServerException.java License: Apache License 2.0 | 2 votes |
/** * Constructor. * * @param msg human readable message */ public GenieServerException(final String msg) { super(HttpURLConnection.HTTP_INTERNAL_ERROR, msg); }