org.apache.olingo.odata2.api.exception.ODataBadRequestException类的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(10.9k)|赞(0)|评价(0)|浏览(100)

本文整理了Java中org.apache.olingo.odata2.api.exception.ODataBadRequestException类的一些代码示例,展示了ODataBadRequestException类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ODataBadRequestException类的具体详情如下:
包路径:org.apache.olingo.odata2.api.exception.ODataBadRequestException
类名称:ODataBadRequestException

ODataBadRequestException介绍

[英]Exceptions of this class will result in a HTTP status 400 bad request
[中]此类的异常将导致HTTP status 400错误请求

代码示例

代码示例来源:origin: org.apache.olingo/olingo-odata2-core-incubating

public static <T> InputStream contentAsStream(final T content) throws ODataException {
 if (content == null) {
  throw new ODataBadRequestException(ODataBadRequestException.COMMON);
 }
 InputStream inputStream;
 if (content instanceof InputStream) {
  inputStream = (InputStream) content;
 } else if (content instanceof String) {
  try {
   inputStream = new ByteArrayInputStream(((String) content).getBytes("UTF-8"));
  } catch (final UnsupportedEncodingException e) {
   throw new ODataBadRequestException(ODataBadRequestException.COMMON, e);
  }
 } else {
  throw new ODataBadRequestException(ODataBadRequestException.COMMON);
 }
 return inputStream;
}

代码示例来源:origin: com.sap.cloud.servicesdk.prov/odata-core

@Override
public ODataResponse existsEntity(GetEntityCountUriInfo uriInfo,String contentType) throws ODataBadRequestException {
  ODataBadRequestException exception = new ODataBadRequestException(ODataBadRequestException.COMMON);
  LoggerFactory.getLogger(GenericODataProcessor.class).error(exception.getMessage(), exception);
  throw exception;
}

代码示例来源:origin: com.sap.cloud.servicesdk/odata-v2-lib

public static <T> InputStream contentAsStream(final T content) throws ODataException {
 if (content == null) {
  throw new ODataBadRequestException(ODataBadRequestException.COMMON);
 }
 InputStream inputStream;
 if (content instanceof InputStream) {
  inputStream = (InputStream) content;
 } else if (content instanceof String) {
  try {
   inputStream = new ByteArrayInputStream(((String) content).getBytes("UTF-8"));
  } catch (final UnsupportedEncodingException e) {
   throw new ODataBadRequestException(ODataBadRequestException.COMMON, e);
  }
 } else {
  throw new ODataBadRequestException(ODataBadRequestException.COMMON);
 }
 return inputStream;
}

代码示例来源:origin: com.sap.cloud.servicesdk.prov/odata-core

private void initializeContext(ODataContext context, PathInfoExtractor pathInfoExtractor, IServiceInfo gwService) throws ODataException {
  if (pathInfoExtractor.isMultiOrigin() && pathInfoExtractor.hasOrigin()) {
    // combination of both is not supported
    ODataBadRequestException exception = new ODataBadRequestException(ODataBadRequestException.NOTSUPPORTED);
    log.error(exception.getMessage(), exception);
    gwLogger.logErrors(GatewayLogMessage.CoreRtMultiOriginAndOriginNotSupp, exception.getMessage(), exception.getMessage());
    throw exception;
  }
  
  if (pathInfoExtractor.isMultiOrigin()) {
    context.setParameter(ContextConstants.MULTI_ORIGIN, Boolean.TRUE);
  } else if (pathInfoExtractor.hasOrigin()) {
    String origin = pathInfoExtractor.getOrigin();
    origin = DestinationInfoUtil.getDestinationForSid(origin, gwService, context);
    context.setParameter(ContextConstants.ORIGIN, origin);
  }
}

代码示例来源:origin: org.apache.olingo/olingo-odata2-core

public static <T> InputStream contentAsStream(final T content) throws ODataException {
 if (content == null) {
  throw new ODataBadRequestException(ODataBadRequestException.COMMON);
 }
 InputStream inputStream;
 if (content instanceof InputStream) {
  inputStream = (InputStream) content;
 } else if (content instanceof String) {
  try {
   inputStream = new ByteArrayInputStream(((String) content).getBytes("UTF-8"));
  } catch (final UnsupportedEncodingException e) {
   throw new ODataBadRequestException(ODataBadRequestException.COMMON, e);
  }
 } else {
  throw new ODataBadRequestException(ODataBadRequestException.COMMON);
 }
 return inputStream;
}

代码示例来源:origin: com.sap.cloud.servicesdk.prov/odata-core

ODataBadRequestException exception = new ODataBadRequestException(ODataBadRequestException.COMMON);
LoggerFactory.getLogger(GenericODataProcessor.class).error(exception.getMessage(), exception);
throw exception;

代码示例来源:origin: org.apache.olingo/olingo-odata2-core

/**
 * Validates that <code>dollar format query/syntax</code> is correct for further processing.
 * If some validation error occurs an exception is thrown.
 * 
 * @param uriInfo
 * @throws ODataBadRequestException
 */
private void validateFormatQuery(final UriInfoImpl uriInfo) throws ODataBadRequestException {
 if (uriInfo.isValue()) {
  throw new ODataBadRequestException(ODataBadRequestException.INVALID_SYNTAX);
 }
}

代码示例来源:origin: com.sap.cloud.servicesdk/odata-v2-lib

/**
 * Validates that <code>dollar format query/syntax</code> is correct for further processing.
 * If some validation error occurs an exception is thrown.
 * 
 * @param uriInfo
 * @throws ODataBadRequestException
 */
private void validateFormatQuery(final UriInfoImpl uriInfo) throws ODataBadRequestException {
 if (uriInfo.isValue()) {
  throw new ODataBadRequestException(ODataBadRequestException.INVALID_SYNTAX);
 }
}

代码示例来源:origin: org.apache.olingo/olingo-odata2-core-incubating

/**
 * Validates that <code>dollar format query/syntax</code> is correct for further processing.
 * If some validation error occurs an exception is thrown.
 * 
 * @param uriInfo
 * @throws ODataBadRequestException
 */
private void validateFormatQuery(final UriInfoImpl uriInfo) throws ODataBadRequestException {
 if (uriInfo.isValue()) {
  throw new ODataBadRequestException(ODataBadRequestException.INVALID_SYNTAX);
 }
}

代码示例来源:origin: org.apache.olingo/olingo-odata2-core

private List<ContentType> extractAcceptHeaders(final List<String> acceptHeaderValues)
  throws ODataBadRequestException {
 final List<ContentType> mediaTypes = new ArrayList<ContentType>();
 if (acceptHeaderValues != null) {
  for (final String mediaType : acceptHeaderValues) {
   try {
    mediaTypes.add(ContentType.create(mediaType.toString()));
   } catch (IllegalArgumentException e) {
    throw new ODataBadRequestException(ODataBadRequestException.INVALID_HEADER.addContent("Accept")
      .addContent(mediaType.toString()), e);
   }
  }
 }
 return mediaTypes;
}

代码示例来源:origin: com.sap.cloud.servicesdk/odata-v2-lib

private List<ContentType> extractAcceptHeaders(final List<String> acceptHeaderValues)
  throws ODataBadRequestException {
 final List<ContentType> mediaTypes = new ArrayList<ContentType>();
 if (acceptHeaderValues != null) {
  for (final String mediaType : acceptHeaderValues) {
   try {
    mediaTypes.add(ContentType.create(mediaType.toString()));
   } catch (IllegalArgumentException e) {
    throw new ODataBadRequestException(ODataBadRequestException.INVALID_HEADER.addContent("Accept")
      .addContent(mediaType.toString()), e);
   }
  }
 }
 return mediaTypes;
}

代码示例来源:origin: com.sap.cloud.servicesdk/odata-v2-lib

private static void checkNumberOfNavigationSegments(final UriInfoImpl uriInfo) throws ODataException {
 switch (uriInfo.getUriType()) {
 case URI1:
 case URI6B:
 case URI7A:
 case URI7B:
  if (uriInfo.getNavigationSegments().size() > 1) {
   throw new ODataBadRequestException(ODataBadRequestException.NOTSUPPORTED);
  }
  break;
 case URI3:
 case URI4:
 case URI5:
 case URI17:
  if (!uriInfo.getNavigationSegments().isEmpty()) {
   throw new ODataBadRequestException(ODataBadRequestException.NOTSUPPORTED);
  }
  break;
 default:
  break;
 }
}

代码示例来源:origin: org.apache.olingo/olingo-odata2-core

private static void checkNumberOfNavigationSegments(final UriInfoImpl uriInfo) throws ODataException {
 switch (uriInfo.getUriType()) {
 case URI1:
 case URI6B:
 case URI7A:
 case URI7B:
  if (uriInfo.getNavigationSegments().size() > 1) {
   throw new ODataBadRequestException(ODataBadRequestException.NOTSUPPORTED);
  }
  break;
 case URI3:
 case URI4:
 case URI5:
 case URI17:
  if (!uriInfo.getNavigationSegments().isEmpty()) {
   throw new ODataBadRequestException(ODataBadRequestException.NOTSUPPORTED);
  }
  break;
 default:
  break;
 }
}

代码示例来源:origin: org.apache.olingo/olingo-odata2-core-incubating

private List<ContentType> extractAcceptHeaders(final List<String> acceptHeaderValues)
  throws ODataBadRequestException {
 final List<ContentType> mediaTypes = new ArrayList<ContentType>();
 if (acceptHeaderValues != null) {
  for (final String mediaType : acceptHeaderValues) {
   try {
    mediaTypes.add(ContentType.create(mediaType.toString()));
   } catch (IllegalArgumentException e) {
    throw new ODataBadRequestException(ODataBadRequestException.INVALID_HEADER.addContent("Accept")
      .addContent(mediaType.toString()), e);
   }
  }
 }
 return mediaTypes;
}

代码示例来源:origin: org.apache.olingo/olingo-odata2-core-incubating

private static void validateDataServiceVersion(final String serverDataServiceVersion,
  final String requestDataServiceVersion) throws ODataException {
 if (requestDataServiceVersion != null) {
  try {
   final boolean isValid = ODataServiceVersion.validateDataServiceVersion(requestDataServiceVersion);
   if (!isValid || ODataServiceVersion.isBiggerThan(requestDataServiceVersion, serverDataServiceVersion)) {
    throw new ODataBadRequestException(ODataBadRequestException.VERSIONERROR.addContent(requestDataServiceVersion
      .toString()));
   }
  } catch (final IllegalArgumentException e) {
   throw new ODataBadRequestException(ODataBadRequestException.PARSEVERSIONERROR
     .addContent(requestDataServiceVersion), e);
  }
 }
}

代码示例来源:origin: org.apache.olingo/olingo-odata2-core-incubating

private static void checkNumberOfNavigationSegments(final UriInfoImpl uriInfo) throws ODataException {
 switch (uriInfo.getUriType()) {
 case URI1:
 case URI6B:
 case URI7A:
 case URI7B:
  if (uriInfo.getNavigationSegments().size() > 1) {
   throw new ODataBadRequestException(ODataBadRequestException.NOTSUPPORTED);
  }
  break;
 case URI3:
 case URI4:
 case URI5:
 case URI17:
  if (!uriInfo.getNavigationSegments().isEmpty()) {
   throw new ODataBadRequestException(ODataBadRequestException.NOTSUPPORTED);
  }
  break;
 default:
  break;
 }
}

代码示例来源:origin: com.sap.cloud.servicesdk/odata-v2-lib

private static void validateDataServiceVersion(final String serverDataServiceVersion,
  final String requestDataServiceVersion) throws ODataException {
 if (requestDataServiceVersion != null) {
  try {
   final boolean isValid = ODataServiceVersion.validateDataServiceVersion(requestDataServiceVersion);
   if (!isValid || ODataServiceVersion.isBiggerThan(requestDataServiceVersion, serverDataServiceVersion)) {
    throw new ODataBadRequestException(ODataBadRequestException.VERSIONERROR
      .addContent(requestDataServiceVersion));
   }
  } catch (final IllegalArgumentException e) {
   throw new ODataBadRequestException(ODataBadRequestException.PARSEVERSIONERROR
     .addContent(requestDataServiceVersion), e);
  }
 }
}

代码示例来源:origin: org.apache.olingo/olingo-odata2-core

private static void validateDataServiceVersion(final String serverDataServiceVersion,
  final String requestDataServiceVersion) throws ODataException {
 if (requestDataServiceVersion != null) {
  try {
   final boolean isValid = ODataServiceVersion.validateDataServiceVersion(requestDataServiceVersion);
   if (!isValid || ODataServiceVersion.isBiggerThan(requestDataServiceVersion, serverDataServiceVersion)) {
    throw new ODataBadRequestException(ODataBadRequestException.VERSIONERROR
      .addContent(requestDataServiceVersion));
   }
  } catch (final IllegalArgumentException e) {
   throw new ODataBadRequestException(ODataBadRequestException.PARSEVERSIONERROR
     .addContent(requestDataServiceVersion), e);
  }
 }
}

代码示例来源:origin: com.sap.cloud.servicesdk/odata-v2-lib

} else {
 if (segments.size() < pathSplit) {
  throw new ODataBadRequestException(ODataBadRequestException.URLTOOSHORT);

代码示例来源:origin: org.apache.olingo/olingo-odata2-core

} else {
 if (segments.size() < pathSplit) {
  throw new ODataBadRequestException(ODataBadRequestException.URLTOOSHORT);

相关文章

ODataBadRequestException类方法