Java Code Examples for org.apache.olingo.odata2.api.commons.HttpStatusCodes#INTERNAL_SERVER_ERROR

The following examples show how to use org.apache.olingo.odata2.api.commons.HttpStatusCodes#INTERNAL_SERVER_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: AnnotationRefServiceFactory.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public ODataResponse handleError(final ODataErrorContext context) throws ODataApplicationException {
  if (context.getHttpStatus() == HttpStatusCodes.INTERNAL_SERVER_ERROR) {
    LOG.error("Internal Server Error", context.getException());
  }

  return EntityProvider.writeErrorDocument(context);
}
 
Example 2
Source File: ODataExceptionMapperImplTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Test
public void testErrorCodeForApplicationException() throws Exception {
  // prepare
  String errorCode = "ErrorCode";
  String message = "expected exception message";
  Exception exception =
      new ODataApplicationException(message, Locale.ENGLISH, HttpStatusCodes.INTERNAL_SERVER_ERROR, errorCode);

  // execute
  Response response = exceptionMapper.toResponse(exception);

  // verify
  String errorMessage = verifyResponse(response, message, HttpStatusCodes.INTERNAL_SERVER_ERROR);
  assertXpathEvaluatesTo(errorCode, "/a:error/a:code", errorMessage);
}
 
Example 3
Source File: ScenarioErrorCallback.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public ODataResponse handleError(final ODataErrorContext context) throws ODataApplicationException {
  if (context.getHttpStatus() == HttpStatusCodes.INTERNAL_SERVER_ERROR) {
    LOG.error("Internal Server Error", context.getException());
  }

  return EntityProvider.writeErrorDocument(context);
}
 
Example 4
Source File: FitErrorCallback.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public ODataResponse handleError(final ODataErrorContext context) throws ODataApplicationException {
  if (context.getHttpStatus() == HttpStatusCodes.INTERNAL_SERVER_ERROR) {
    LOG.error("Internal Server Error", context.getException());
  }
  return EntityProvider.writeErrorDocument(context);
}
 
Example 5
Source File: AnnotationSampleServiceFactory.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public ODataResponse handleError(final ODataErrorContext context) throws ODataApplicationException {
  if (context.getHttpStatus() == HttpStatusCodes.INTERNAL_SERVER_ERROR) {
    LOG.error("Internal Server Error", context.getException());
  }

  return EntityProvider.writeErrorDocument(context);
}
 
Example 6
Source File: SalesOrderProcessor.java    From cloud-espm-v2 with Apache License 2.0 4 votes vote down vote up
/**
 * Function Import implementation for getting all the Sales Order Items
 * under a Sales Order Header
 * 
 * @param SalesOrderId
 *            Sales Order Id of a Sales Order
 * @return SalesOrderItem entity.
 * @throws ODataException
 */
@SuppressWarnings("unchecked")
@EdmFunctionImport(name = "GetSalesOrderItemsById", entitySet = "SalesOrderItems", returnType = @ReturnType(type = Type.ENTITY, isCollection = true))
public List<SalesOrderItem> getSalesOrderById(
		@EdmFunctionImportParameter(name = "SalesOrderId") String salesOrderId) throws ODataException {
	EntityManagerFactory emf = Utility.getEntityManagerFactory();
	EntityManager em = emf.createEntityManager();
	List<SalesOrderItem> soiList = null;
	try {

		Query query = em.createNamedQuery("SalesOrderItem.getSOIBySalesOrderItemId");
		query.setParameter("id", salesOrderId);

		try {

			soiList = query.getResultList();
			if (soiList != null && soiList.size() >= 1) {

				for (SalesOrderItem salesOrderItem : soiList) {
					query = em.createNamedQuery("Product.getProductByProductId");
					query.setParameter("productId", salesOrderItem.getProductId());
					Product product = (Product) query.getSingleResult();
					salesOrderItem.setProduct(product);

				}
				// if the sales order are fetched successfully, generate the
				// pdf report data.
				try {
					if (CMISSessionHelper.getInstance().getSession() != null) {
						InvoiceBuilder builder = new InvoiceBuilder();
						String reportPath = builder.generateInvoice(soiList);
						updateSalesOrderHeader(reportPath, soiList, em);
					}
				} catch (CMISConnectionException cmisConnectionException) {
					// There was an exception while generating the report.
					LOGGER.error(cmisConnectionException.getMessage());
				}
				
				

			}

		} catch (NoResultException e) {
			throw new ODataApplicationException("No matching Sales Order with Sales Order Id:" + salesOrderId,
					Locale.ENGLISH, HttpStatusCodes.BAD_REQUEST, e);
		} catch (ReportGenerationException reportGenerationException) {
			//LOGGER.error("Exception while generating the report : " + reportGenerationException.getMessage());
			reportGenerationException.printStackTrace();
			throw new ODataApplicationException("PDF Report Generation Error for :" + salesOrderId,
					Locale.ENGLISH, HttpStatusCodes.INTERNAL_SERVER_ERROR, reportGenerationException);
		}

		return soiList;
	} finally {
		em.close();
	}
}
 
Example 7
Source File: ODataInternalServerErrorException.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
public ODataInternalServerErrorException(final MessageReference messageReference) {
  super(messageReference, HttpStatusCodes.INTERNAL_SERVER_ERROR);
}
 
Example 8
Source File: ODataInternalServerErrorException.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
public ODataInternalServerErrorException(final MessageReference messageReference, final String errorCode) {
  super(messageReference, HttpStatusCodes.INTERNAL_SERVER_ERROR, errorCode);
}
 
Example 9
Source File: ODataInternalServerErrorException.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
public ODataInternalServerErrorException(final MessageReference messageReference, final Throwable cause) {
  super(messageReference, cause, HttpStatusCodes.INTERNAL_SERVER_ERROR);
}
 
Example 10
Source File: ODataInternalServerErrorException.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
public ODataInternalServerErrorException(final MessageReference messageReference, final Throwable cause,
    final String errorCode) {
  super(messageReference, cause, HttpStatusCodes.INTERNAL_SERVER_ERROR, errorCode);
}