本文整理汇总了Java中org.apache.olingo.server.api.ODataLibraryException类的典型用法代码示例。如果您正苦于以下问题:Java ODataLibraryException类的具体用法?Java ODataLibraryException怎么用?Java ODataLibraryException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ODataLibraryException类属于org.apache.olingo.server.api包,在下文中一共展示了ODataLibraryException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: readServiceDocument
import org.apache.olingo.server.api.ODataLibraryException; //导入依赖的package包/类
@Override
public void readServiceDocument(final ODataRequest request, final ODataResponse response, final UriInfo uriInfo,
final ContentType requestedContentType) throws ODataApplicationException, ODataLibraryException {
boolean isNotModified = false;
ServiceMetadataETagSupport eTagSupport = serviceMetadata.getServiceMetadataETagSupport();
if (eTagSupport != null && eTagSupport.getServiceDocumentETag() != null) {
// Set application etag at response
response.setHeader(HttpHeader.ETAG, eTagSupport.getServiceDocumentETag());
// Check if service document has been modified
ETagHelper eTagHelper = odata.createETagHelper();
isNotModified = eTagHelper.checkReadPreconditions(eTagSupport.getServiceDocumentETag(),
request.getHeaders(HttpHeader.IF_MATCH), request.getHeaders(HttpHeader.IF_NONE_MATCH));
}
// Send the correct response req.getRequestURL().toString().replace(req.getServletPath(), "")
if (isNotModified) {
response.setStatusCode(HttpStatusCode.NOT_MODIFIED.getStatusCode());
} else {
ODataSerializer serializer = odata.createSerializer(requestedContentType);
//Provide serviceRoot with rawBaseUri as Excel PowerQuery does not like relative URIs
response.setContent(serializer.serviceDocument(serviceMetadata, request.getRawBaseUri()).getContent());
response.setStatusCode(HttpStatusCode.OK.getStatusCode());
response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString());
}
}
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:26,代码来源:SparqlDefaultProcessor.java
示例2: readMetadata
import org.apache.olingo.server.api.ODataLibraryException; //导入依赖的package包/类
@Override
public void readMetadata(final ODataRequest request, final ODataResponse response, final UriInfo uriInfo,
final ContentType requestedContentType) throws ODataApplicationException, ODataLibraryException {
boolean isNotModified = false;
ServiceMetadataETagSupport eTagSupport = serviceMetadata.getServiceMetadataETagSupport();
if (eTagSupport != null && eTagSupport.getMetadataETag() != null) {
// Set application etag at response
response.setHeader(HttpHeader.ETAG, eTagSupport.getMetadataETag());
// Check if metadata document has been modified
ETagHelper eTagHelper = odata.createETagHelper();
isNotModified = eTagHelper.checkReadPreconditions(eTagSupport.getMetadataETag(),
request.getHeaders(HttpHeader.IF_MATCH), request.getHeaders(HttpHeader.IF_NONE_MATCH));
}
// Send the correct response
if (isNotModified) {
response.setStatusCode(HttpStatusCode.NOT_MODIFIED.getStatusCode());
} else {
ODataSerializer serializer = odata.createSerializer(requestedContentType);
response.setContent(serializer.metadataDocument(serviceMetadata).getContent());
response.setStatusCode(HttpStatusCode.OK.getStatusCode());
response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString());
}
}
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:25,代码来源:SparqlDefaultProcessor.java
示例3: createReference
import org.apache.olingo.server.api.ODataLibraryException; //导入依赖的package包/类
@Override
public void createReference(ODataRequest request, ODataResponse response, UriInfo uriInfo,
ContentType requestFormat) throws ODataApplicationException, ODataLibraryException {
// 2. create the data in backend
// 2.1. retrieve the payload from the POST request for the entity to create and deserialize it
InputStream requestInputStream = request.getBody();
ODataDeserializer deserializer = this.odata.createDeserializer(requestFormat);
DeserializerResult result = deserializer.entityReferences(requestInputStream);
List<URI> requestEntityReferences = result.getEntityReferences();
// 2.2 do the creation in backend,
try {
SparqlBaseCommand.writeEntityReference(rdfEdmProvider, uriInfo, requestEntityReferences);
} catch (EdmException | OData2SparqlException e) {
throw new ODataApplicationException(e.getMessage(), HttpStatusCode.NO_CONTENT.getStatusCode(),
Locale.ENGLISH);
}
// 3. serialize the response
response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
}
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:21,代码来源:SparqlReferenceProcessor.java
示例4: updateReference
import org.apache.olingo.server.api.ODataLibraryException; //导入依赖的package包/类
@Override
public void updateReference(ODataRequest request, ODataResponse response, UriInfo uriInfo,
ContentType requestFormat) throws ODataApplicationException, ODataLibraryException {
// 1. Retrieve the entity type from the URI
// EdmEntitySet edmEntitySet = Util.getEdmEntitySet(uriInfo);
// EdmEntityType edmEntityType = edmEntitySet.getEntityType();
// 2. create the data in backend
// 2.1. retrieve the payload from the POST request for the entity to create and deserialize it
InputStream requestInputStream = request.getBody();
ODataDeserializer deserializer = this.odata.createDeserializer(requestFormat);
DeserializerResult result = deserializer.entityReferences(requestInputStream);
List<URI> requestEntityReferences = result.getEntityReferences();
// 2.2 do the creation in backend,
try {
SparqlBaseCommand.updateEntityReference(rdfEdmProvider, uriInfo, requestEntityReferences);
} catch (EdmException | OData2SparqlException e) {
throw new ODataApplicationException(e.getMessage(), HttpStatusCode.NO_CONTENT.getStatusCode(),
Locale.ENGLISH);
}
// 3. serialize the response
response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
}
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:25,代码来源:SparqlReferenceProcessor.java
示例5: deleteReference
import org.apache.olingo.server.api.ODataLibraryException; //导入依赖的package包/类
@Override
public void deleteReference(ODataRequest request, ODataResponse response, UriInfo uriInfo)
throws ODataApplicationException, ODataLibraryException {
// 1. Retrieve the entity type from the URI
// EdmEntitySet edmEntitySet = Util.getEdmEntitySet(uriInfo);
// EdmEntityType edmEntityType = edmEntitySet.getEntityType();
try {
SparqlBaseCommand.deleteEntityReference(rdfEdmProvider, uriInfo);
} catch (EdmException | OData2SparqlException e) {
throw new ODataApplicationException(e.getMessage(), HttpStatusCode.NO_CONTENT.getStatusCode(),
Locale.ENGLISH);
}
// 3. serialize the response
response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
}
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:17,代码来源:SparqlReferenceProcessor.java
示例6: read
import org.apache.olingo.server.api.ODataLibraryException; //导入依赖的package包/类
/**
* Method is a template to provide behavior for all read processors.
*/
@Override
public void read(ODataRequest request, ODataResponse response, UriInfo uriInfo,
ContentType responseFormat) throws ODataApplicationException, ODataLibraryException {
this.request = request;
ESRequest searchRequest = createRequest(uriInfo);
ElasticEdmEntitySet entitySet = searchRequest.getEntitySet();
SearchResponse searchResponse = searchRequest.execute();
InstanceData<T, V> data = parseResponse(searchResponse, entitySet);
ODataSerializer serializer = odata.createSerializer(responseFormat);
SerializerResult serializerResult = serialize(serializer, data, entitySet, uriInfo);
response.setContent(serializerResult.getContent());
response.setStatusCode(HttpStatusCode.OK.getStatusCode());
response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
}
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:19,代码来源:AbstractESReadProcessor.java
示例7: getContextUrl
import org.apache.olingo.server.api.ODataLibraryException; //导入依赖的package包/类
private static ContextURL getContextUrl(final EdmEntitySet entitySet,
final EdmEntityType entityType,
final boolean isSingleEntity)
throws ODataLibraryException
{
ContextURL.Builder builder = ContextURL.with();
builder = (entitySet == null)
? isSingleEntity
? builder.type(entityType)
: builder.asCollection().type(entityType)
: builder.entitySet(entitySet);
builder = builder.suffix((isSingleEntity && (entitySet != null))
? ContextURL.Suffix.ENTITY
: null);
return builder.build();
}
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:19,代码来源:RedHxDiscoveryProcessor.java
示例8: countEntityCollection
import org.apache.olingo.server.api.ODataLibraryException; //导入依赖的package包/类
@Override
public void countEntityCollection(final ODataRequest request, final ODataResponse response,
final UriInfo uriInfo) throws ODataApplicationException, ODataLibraryException {
validateOptions(uriInfo.asUriInfoResource());
getEdmEntitySet(uriInfo); // including checks
final EntityCollection entitySetInitial = readEntityCollection(uriInfo);
EntityCollection entitySet = new EntityCollection();
entitySet.getEntities().addAll(entitySetInitial.getEntities());
FilterHandler.applyFilterSystemQuery(uriInfo.getFilterOption(), entitySet, uriInfo, serviceMetadata.getEdm());
int count = entitySet.getEntities().size();
for (SystemQueryOption systemQueryOption : uriInfo.getSystemQueryOptions()) {
if (systemQueryOption.getName().contains(DELTATOKEN)) {
count = count + getDeltaCount(uriInfo);
break;
}
}
response.setContent(odata.createFixedFormatSerializer().count(count));
response.setStatusCode(HttpStatusCode.OK.getStatusCode());
response.setHeader(HttpHeader.CONTENT_TYPE, ContentType.TEXT_PLAIN.toContentTypeString());
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:21,代码来源:TechnicalEntityProcessor.java
示例9: createReference
import org.apache.olingo.server.api.ODataLibraryException; //导入依赖的package包/类
@Override
public void createReference(final ODataRequest request, final ODataResponse response, final UriInfo uriInfo,
final ContentType requestFormat) throws ODataApplicationException, ODataLibraryException {
final ODataDeserializer deserializer = odata.createDeserializer(requestFormat);
final DeserializerResult references = deserializer.entityReferences(request.getBody());
if (references.getEntityReferences().size() != 1) {
throw new ODataApplicationException("A post request to a collection navigation property must "
+ "contain a single entity reference", HttpStatusCode.BAD_REQUEST.getStatusCode(), Locale.ROOT);
}
final Entity entity = readEntity(uriInfo, true);
final UriResourceNavigation navigationProperty = getLastNavigation(uriInfo);
ensureNavigationPropertyNotNull(navigationProperty);
dataProvider.createReference(entity, navigationProperty.getProperty(), references.getEntityReferences().get(0),
request.getRawBaseUri());
response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:21,代码来源:TechnicalEntityProcessor.java
示例10: serializeEntityCollection
import org.apache.olingo.server.api.ODataLibraryException; //导入依赖的package包/类
private SerializerResult serializeEntityCollection(final ODataRequest request, final EntityCollection
entityCollection, final EdmEntitySet edmEntitySet, final EdmEntityType edmEntityType,
final ContentType requestedFormat, final ExpandOption expand, final SelectOption select,
final CountOption countOption, String id, final boolean isContNav) throws ODataLibraryException {
return odata.createSerializer(requestedFormat, request.getHeaders(HttpHeader.ODATA_VERSION))
.entityCollection(
serviceMetadata,
edmEntityType,
entityCollection,
EntityCollectionSerializerOptions.with()
.contextURL(isODataMetadataNone(requestedFormat) ? null :
getContextUrl(request.getRawODataPath(), edmEntitySet, edmEntityType, false, expand, select, isContNav))
.count(countOption)
.expand(expand).select(select)
.id(id)
.build());
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:19,代码来源:TechnicalEntityProcessor.java
示例11: serializeEntity
import org.apache.olingo.server.api.ODataLibraryException; //导入依赖的package包/类
private SerializerResult serializeEntity(final ODataRequest request, final Entity entity,
final EdmEntitySet edmEntitySet, final EdmEntityType edmEntityType,
final ContentType requestedFormat,
final ExpandOption expand, final SelectOption select, final boolean isContNav)
throws ODataLibraryException {
ContextURL contextUrl = isODataMetadataNone(requestedFormat) ? null :
getContextUrl(request.getRawODataPath(), edmEntitySet, edmEntityType, true, expand, null,isContNav);
return odata.createSerializer(requestedFormat, request.getHeaders(HttpHeader.ODATA_VERSION)).entity(
serviceMetadata,
edmEntityType,
entity,
EntitySerializerOptions.with()
.contextURL(contextUrl)
.expand(expand).select(select)
.build());
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:18,代码来源:TechnicalEntityProcessor.java
示例12: deleteMediaEntity
import org.apache.olingo.server.api.ODataLibraryException; //导入依赖的package包/类
@Override
public void deleteMediaEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo)
throws ODataApplicationException, ODataLibraryException {
/*
* In this tutorial, the content of the media entity is stored in a special property.
* So no additional steps to delete the content of the media entity are necessary.
*
* A real service may store the content on the file system. So we have to take care to
* delete external files too.
*
* DELETE request to /Advertisements(ID) will be dispatched to the deleteEntity(...) method
* DELETE request to /Advertisements(ID)/$value will be dispatched to the deleteMediaEntity(...) method
*
* So it is a good idea handle deletes in a central place.
*/
deleteEntity(request, response, uriInfo);
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:20,代码来源:DemoEntityProcessor.java
示例13: readMediaEntity
import org.apache.olingo.server.api.ODataLibraryException; //导入依赖的package包/类
@Override
public void readMediaEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType responseFormat)
throws ODataApplicationException, ODataLibraryException {
final UriResource firstResoucePart = uriInfo.getUriResourceParts().get(0);
if(firstResoucePart instanceof UriResourceEntitySet) {
final EdmEntitySet edmEntitySet = Util.getEdmEntitySet(uriInfo);
final UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) firstResoucePart;
final Entity entity = storage.readEntityData(edmEntitySet, uriResourceEntitySet.getKeyPredicates());
if(entity == null) {
throw new ODataApplicationException("Entity not found", HttpStatusCode.NOT_FOUND.getStatusCode(),
Locale.ENGLISH);
}
final byte[] mediaContent = storage.readMedia(entity);
final InputStream responseContent = odata.createFixedFormatSerializer().binary(mediaContent);
response.setStatusCode(HttpStatusCode.OK.getStatusCode());
response.setContent(responseContent);
response.setHeader(HttpHeader.CONTENT_TYPE, entity.getMediaContentType());
} else {
throw new ODataApplicationException("Not implemented", HttpStatusCode.BAD_REQUEST.getStatusCode(),
Locale.ENGLISH);
}
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:27,代码来源:DemoEntityProcessor.java
示例14: fillODataRequest
import org.apache.olingo.server.api.ODataLibraryException; //导入依赖的package包/类
private ODataRequest fillODataRequest(final ODataRequest odRequest, final HttpServletRequest httpRequest,
final int split) throws ODataLibraryException {
final int requestHandle = debugger.startRuntimeMeasurement("ODataHttpHandlerImpl", "fillODataRequest");
try {
odRequest.setBody(httpRequest.getInputStream());
odRequest.setProtocol(httpRequest.getProtocol());
odRequest.setMethod(extractMethod(httpRequest));
int innerHandle = debugger.startRuntimeMeasurement("ODataHttpHandlerImpl", "copyHeaders");
copyHeaders(odRequest, httpRequest);
debugger.stopRuntimeMeasurement(innerHandle);
innerHandle = debugger.startRuntimeMeasurement("ODataHttpHandlerImpl", "fillUriInformation");
fillUriInformation(odRequest, httpRequest, split);
debugger.stopRuntimeMeasurement(innerHandle);
return odRequest;
} catch (final IOException e) {
throw new DeserializerException("An I/O exception occurred.", e,
DeserializerException.MessageKeys.IO_EXCEPTION);
} finally {
debugger.stopRuntimeMeasurement(requestHandle);
}
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:23,代码来源:ODataHttpHandlerImpl.java
示例15: deleteEntity
import org.apache.olingo.server.api.ODataLibraryException; //导入依赖的package包/类
@Override
public void deleteEntity(DataRequest request, String eTag, EntityResponse response)
throws ODataLibraryException, ODataApplicationException {
EdmEntitySet edmEntitySet = request.getEntitySet();
Entity entity = this.dataModel.getEntity(edmEntitySet.getName(), request.getKeyPredicates());
if (entity == null) {
response.writeNotFound(true);
return;
}
String key = edmEntitySet.getEntityType().getKeyPredicateNames().get(0);
boolean removed = this.dataModel.deleteEntity(edmEntitySet.getName(), eTag, key, entity
.getProperty(key).getValue());
if (removed) {
response.writeDeletedEntityOrReference();
} else {
response.writeNotFound(true);
}
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:21,代码来源:TripPinHandler.java
示例16: execute
import org.apache.olingo.server.api.ODataLibraryException; //导入依赖的package包/类
@Override
public void execute(ServiceHandler handler, ODataResponse response)
throws ODataLibraryException, ODataApplicationException {
// check for valid HTTP Verb
assertHttpMethod(response);
// Functions always have return per 11.5.3
if (isReturnTypePrimitive() || isReturnTypeComplex()) {
// per odata-json-format/v4.0 = 11 Individual Property or Operation Response
handler.invoke(this, getODataRequest().getMethod(), PropertyResponse.getInstance(this, response,
getReturnType().getType(), getContextURL(this.odata), isCollection()));
} else {
// returnType.getType().getKind() == EdmTypeKind.ENTITY
if (isCollection()) {
handler.invoke(this, getODataRequest().getMethod(),
EntitySetResponse.getInstance(this, getContextURL(odata), false, response));
} else {
handler.invoke(this, getODataRequest().getMethod(),
EntityResponse.getInstance(this, getContextURL(odata), false, response));
}
}
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:24,代码来源:FunctionRequest.java
示例17: deleteMediaEntity
import org.apache.olingo.server.api.ODataLibraryException; //导入依赖的package包/类
@Override
public void deleteMediaEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo)
throws ODataApplicationException, ODataLibraryException {
/*
* In this tutorial, the content of the media entity is stored in a special property.
* So no additional steps to delete the content of the media entity are necessary.
*
* A real service may store the content on the file system. So we have to take care to
* delete external files too.
*
* DELETE request to /Advertisments(ID) will be dispatched to the deleteEntity(...) method
* DELETE request to /Advertisments(ID)/$value will be dispatched to the deleteMediaEntity(...) method
*
* So it is a good idea handle deletes in a central place.
*/
deleteEntity(request, response, uriInfo);
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:20,代码来源:DemoEntityProcessor.java
示例18: readEntity
import org.apache.olingo.server.api.ODataLibraryException; //导入依赖的package包/类
@Override
public void readEntity(
ODataRequest request,
ODataResponse response,
UriInfo uriInfo,
ContentType responseFormat) throws ODataApplicationException, ODataLibraryException {
// First path segment is Entity Set.
List<UriResource> resourceParts = uriInfo.getUriResourceParts();
UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourceParts.get(0);
EdmEntitySet entitySet = uriResourceEntitySet.getEntitySet();
List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
// Retrieve entity from backend.
Entity entity = entityRepository.read(entitySet, keyPredicates);
// Serialize to response format.
ContextURL contextUrl = ContextURL.with()
.entitySet(entitySet)
.suffix(ContextURL.Suffix.ENTITY)
.build();
EntitySerializerOptions options = EntitySerializerOptions.with()
.contextURL(contextUrl)
.build();
ODataSerializer serializer = odata.createSerializer(responseFormat);
SerializerResult serializerResult = serializer.entity(
serviceMetadata, entitySet.getEntityType(), entity, options);
// Set response attributes.
response.setContent(serializerResult.getContent());
response.setStatusCode(HttpStatusCode.OK.getStatusCode());
response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
}
开发者ID:pukkaone,项目名称:odata-spring-boot-starter,代码行数:34,代码来源:ElasticsearchEntityProcessor.java
示例19: createEntity
import org.apache.olingo.server.api.ODataLibraryException; //导入依赖的package包/类
@Override
public void createEntity(
ODataRequest request,
ODataResponse response,
UriInfo uriInfo,
ContentType requestFormat,
ContentType responseFormat) throws ODataApplicationException, ODataLibraryException {
throw new NotImplementedException("createEntity not implemented");
}
开发者ID:pukkaone,项目名称:odata-spring-boot-starter,代码行数:11,代码来源:ElasticsearchEntityProcessor.java
示例20: updateEntity
import org.apache.olingo.server.api.ODataLibraryException; //导入依赖的package包/类
@Override
public void updateEntity(
ODataRequest request,
ODataResponse response,
UriInfo uriInfo,
ContentType requestFormat,
ContentType responseFormat) throws ODataApplicationException, ODataLibraryException {
throw new NotImplementedException("updateEntity not implemented");
}
开发者ID:pukkaone,项目名称:odata-spring-boot-starter,代码行数:11,代码来源:ElasticsearchEntityProcessor.java
注:本文中的org.apache.olingo.server.api.ODataLibraryException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论