本文整理了Java中org.apache.olingo.odata2.api.exception.ODataBadRequestException
类的一些代码示例,展示了ODataBadRequestException
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ODataBadRequestException
类的具体详情如下:
包路径:org.apache.olingo.odata2.api.exception.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);
内容来源于网络,如有侵权,请联系作者删除!