本文整理汇总了Java中org.apache.olingo.odata2.api.processor.ODataResponse类的典型用法代码示例。如果您正苦于以下问题:Java ODataResponse类的具体用法?Java ODataResponse怎么用?Java ODataResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ODataResponse类属于org.apache.olingo.odata2.api.processor包,在下文中一共展示了ODataResponse类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: readOptimizedFilter
import org.apache.olingo.odata2.api.processor.ODataResponse; //导入依赖的package包/类
@Test
public void readOptimizedFilter() throws Exception {
GetEntitySetUriInfo uriInfo = createMockedUriInfo("Rooms");
Edm edm = EdmMock.createMockEdm();
FilterExpression exp = UriParserImpl.parseFilter(edm, edm.getEntityType("RefScenario", "Room"), "Version gt 105");
Mockito.when(uriInfo.getFilter()).thenReturn(exp);
List<Room> results = createRooms(1, 10);
ReadResult<Room> readResult = ReadResult.forResult(results).filterApplied().build();
Mockito.when(mockedDataSource.readData(Mockito.any(EdmEntitySet.class), Mockito.any(ReadOptions.class)))
.thenReturn((ReadResult)readResult);
ODataResponse result = dataSourceProcessor.readEntitySet(uriInfo, "application/json");
StringHelper.Stream resultStream = StringHelper.toStream(result.getEntityAsStream());
List<LinkedTreeMap<?, ?>> parsedResults = JsonHelper.getResults(resultStream.asString());
Assert.assertEquals(10, parsedResults.size());
Assert.assertEquals("Room with id: 1", parsedResults.get(0).get("Name"));
Assert.assertEquals("Room with id: 9", parsedResults.get(9).get("Name"));
}
开发者ID:mibo,项目名称:janos,代码行数:22,代码来源:DataSourceProcessorTest.java
示例2: deleteEntityLink
import org.apache.olingo.odata2.api.processor.ODataResponse; //导入依赖的package包/类
@Override
public ODataResponse deleteEntityLink(DeleteUriInfo uri_info, String content_type)
throws ODataException
{
// uriInfo#getNavigationSegments() does not return a shallow copy.
List<NavigationSegment> lns = new ArrayList<>(uri_info.getNavigationSegments().size());
lns.addAll(uri_info.getNavigationSegments());
// Removes the target for navigation purposes.
if (!lns.isEmpty())
{
lns.remove(lns.size()-1);
}
AbstractEntity entity = Navigator.<AbstractEntity>navigate(uri_info.getStartEntitySet(),
uri_info.getKeyPredicates().get(0), lns, AbstractEntity.class);
// Deletes.
entity.deleteLink(uri_info);
return ODataResponse.newBuilder().build();
}
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:22,代码来源:Processor.java
示例3: executeFunctionImport
import org.apache.olingo.odata2.api.processor.ODataResponse; //导入依赖的package包/类
@Override
public ODataResponse executeFunctionImport(GetFunctionImportUriInfo uri_info, String content_type)
throws ODataException
{
EdmFunctionImport function_import = uri_info.getFunctionImport();
Map<String, EdmLiteral> params = uri_info.getFunctionImportParameters();
EntityProviderWriteProperties entry_props =
EntityProviderWriteProperties.serviceRoot(makeLink()).build();
AbstractOperation op = Model.getServiceOperation(function_import.getName());
fr.gael.dhus.database.object.User current_user =
ApplicationContextProvider.getBean(SecurityService.class).getCurrentUser();
if (!op.canExecute(current_user))
{
throw new NotAllowedException();
}
Object res = op.execute(params);
return EntityProvider.writeFunctionImport(content_type, function_import, res, entry_props);
}
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:23,代码来源:Processor.java
示例4: countEntitySet
import org.apache.olingo.odata2.api.processor.ODataResponse; //导入依赖的package包/类
@Override
public ODataResponse countEntitySet(final GetEntitySetCountUriInfo uriInfo, final String contentType)
throws ODataException {
ArrayList<Object> data = new ArrayList<>();
try {
ReadResult<?> result = retrieveData(
uriInfo.getStartEntitySet(),
uriInfo.getKeyPredicates(),
uriInfo.getFunctionImport(),
mapFunctionParameters(uriInfo.getFunctionImportParameters()),
uriInfo.getNavigationSegments());
data.addAll(result.getResult());
} catch (final ODataNotFoundException e) {
data.clear();
}
applySystemQueryOptions(
uriInfo.getTargetEntitySet(),
data, new QueryOptionsHolder(uriInfo));
return ODataResponse.fromResponse(EntityProvider.writeText(String.valueOf(data.size()))).build();
}
开发者ID:mibo,项目名称:janos,代码行数:23,代码来源:DataSourceProcessor.java
示例5: readEntity
import org.apache.olingo.odata2.api.processor.ODataResponse; //导入依赖的package包/类
@Override
public ODataResponse readEntity(final GetEntityUriInfo uriInfo, final String contentType) throws ODataException {
final Object data = retrieveData(
uriInfo.getStartEntitySet(),
uriInfo.getKeyPredicates(),
uriInfo.getFunctionImport(),
mapFunctionParameters(uriInfo.getFunctionImportParameters()),
uriInfo.getNavigationSegments()).getFirst();
if (!appliesFilter(data, uriInfo.getFilter())) {
throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
}
final ExpandSelectTreeNode expandSelectTreeNode =
UriParser.createExpandSelectTree(uriInfo.getSelect(), uriInfo.getExpand());
return ODataResponse.fromResponse(
writeEntry(uriInfo.getTargetEntitySet(), expandSelectTreeNode, data, contentType)).build();
}
开发者ID:mibo,项目名称:janos,代码行数:20,代码来源:DataSourceProcessor.java
示例6: createEntityLink
import org.apache.olingo.odata2.api.processor.ODataResponse; //导入依赖的package包/类
@Override
public ODataResponse createEntityLink(final PostUriInfo uriInfo, final InputStream content,
final String requestContentType, final String contentType) throws ODataException {
final List<NavigationSegment> navigationSegments = uriInfo.getNavigationSegments();
final List<NavigationSegment> previousSegments = navigationSegments.subList(0, navigationSegments.size() - 1);
final Object sourceData = retrieveData(
uriInfo.getStartEntitySet(),
uriInfo.getKeyPredicates(),
uriInfo.getFunctionImport(),
mapFunctionParameters(uriInfo.getFunctionImportParameters()),
previousSegments).getFirst();
final EdmEntitySet entitySet = previousSegments.isEmpty() ?
uriInfo.getStartEntitySet() : previousSegments.get(previousSegments.size() - 1).getEntitySet();
final EdmEntitySet targetEntitySet = uriInfo.getTargetEntitySet();
final Map<String, Object> targetKeys = parseLink(targetEntitySet, content, requestContentType);
dataSource.writeRelation(entitySet, sourceData, targetEntitySet, targetKeys);
return ODataResponse.newBuilder().build();
}
开发者ID:mibo,项目名称:janos,代码行数:24,代码来源:DataSourceProcessor.java
示例7: readEntitySimplePropertyValue
import org.apache.olingo.odata2.api.processor.ODataResponse; //导入依赖的package包/类
@Override
public ODataResponse readEntitySimplePropertyValue(final GetSimplePropertyUriInfo uriInfo, final String contentType)
throws ODataException {
Object data = retrieveData(
uriInfo.getStartEntitySet(),
uriInfo.getKeyPredicates(),
uriInfo.getFunctionImport(),
mapFunctionParameters(uriInfo.getFunctionImportParameters()),
uriInfo.getNavigationSegments()).getFirst();
// if (!appliesFilter(data, uriInfo.getFilter()))
if (data == null) {
throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
}
final List<EdmProperty> propertyPath = uriInfo.getPropertyPath();
final EdmProperty property = propertyPath.get(propertyPath.size() - 1);
final Object value = property.getMapping() == null || property.getMapping().getMediaResourceMimeTypeKey() == null ?
getPropertyValue(data, propertyPath) : getSimpleTypeValueMap(data, propertyPath);
return ODataResponse.fromResponse(EntityProvider.writePropertyValue(property, value)).eTag(
constructETag(uriInfo.getTargetEntitySet(), data)).build();
}
开发者ID:mibo,项目名称:janos,代码行数:24,代码来源:DataSourceProcessor.java
示例8: deleteEntitySimplePropertyValue
import org.apache.olingo.odata2.api.processor.ODataResponse; //导入依赖的package包/类
@Override
public ODataResponse deleteEntitySimplePropertyValue(final DeleteUriInfo uriInfo, final String contentType)
throws ODataException {
Object data = retrieveData(
uriInfo.getStartEntitySet(),
uriInfo.getKeyPredicates(),
uriInfo.getFunctionImport(),
mapFunctionParameters(uriInfo.getFunctionImportParameters()),
uriInfo.getNavigationSegments()).getFirst();
if (data == null) {
throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
}
final List<EdmProperty> propertyPath = uriInfo.getPropertyPath();
final EdmProperty property = propertyPath.get(propertyPath.size() - 1);
data = getPropertyValue(data, propertyPath.subList(0, propertyPath.size() - 1));
valueAccess.setPropertyValue(data, property, null);
valueAccess.setMappingValue(data, property.getMapping(), null);
return ODataResponse.newBuilder().build();
}
开发者ID:mibo,项目名称:janos,代码行数:24,代码来源:DataSourceProcessor.java
示例9: readEntityMedia
import org.apache.olingo.odata2.api.processor.ODataResponse; //导入依赖的package包/类
@Override
public ODataResponse readEntityMedia(final GetMediaResourceUriInfo uriInfo, final String contentType)
throws ODataException {
final Object data = retrieveData(
uriInfo.getStartEntitySet(),
uriInfo.getKeyPredicates(),
uriInfo.getFunctionImport(),
mapFunctionParameters(uriInfo.getFunctionImportParameters()),
uriInfo.getNavigationSegments()).getFirst();
if (!appliesFilter(data, uriInfo.getFilter())) {
throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
}
final EdmEntitySet entitySet = uriInfo.getTargetEntitySet();
final BinaryData binaryData = dataSource.readBinaryData(entitySet, data);
if (binaryData == null) {
throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
}
final String mimeType = binaryData.getMimeType() == null ?
HttpContentType.APPLICATION_OCTET_STREAM : binaryData.getMimeType();
return ODataResponse.fromResponse(EntityProvider.writeBinary(mimeType, binaryData.getData())).eTag(
constructETag(entitySet, data)).build();
}
开发者ID:mibo,项目名称:janos,代码行数:27,代码来源:DataSourceProcessor.java
示例10: deleteEntityMedia
import org.apache.olingo.odata2.api.processor.ODataResponse; //导入依赖的package包/类
@Override
public ODataResponse deleteEntityMedia(final DeleteUriInfo uriInfo, final String contentType) throws ODataException {
final Object data = retrieveData(
uriInfo.getStartEntitySet(),
uriInfo.getKeyPredicates(),
uriInfo.getFunctionImport(),
mapFunctionParameters(uriInfo.getFunctionImportParameters()),
uriInfo.getNavigationSegments()).getFirst();
if (data == null) {
throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
}
dataSource.writeBinaryData(uriInfo.getTargetEntitySet(), data, new BinaryData(null, null));
return ODataResponse.newBuilder().build();
}
开发者ID:mibo,项目名称:janos,代码行数:18,代码来源:DataSourceProcessor.java
示例11: updateEntityMedia
import org.apache.olingo.odata2.api.processor.ODataResponse; //导入依赖的package包/类
@Override
public ODataResponse updateEntityMedia(final PutMergePatchUriInfo uriInfo, final InputStream content,
final String requestContentType, final String contentType) throws ODataException {
final Object data = retrieveData(
uriInfo.getStartEntitySet(),
uriInfo.getKeyPredicates(),
uriInfo.getFunctionImport(),
mapFunctionParameters(uriInfo.getFunctionImportParameters()),
uriInfo.getNavigationSegments()).getFirst();
if (!appliesFilter(data, uriInfo.getFilter())) {
throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
}
ODataContext context = getContext();
final int timingHandle = context.startRuntimeMeasurement("EntityProvider", "readBinary");
final byte[] value = EntityProvider.readBinary(content);
context.stopRuntimeMeasurement(timingHandle);
final EdmEntitySet entitySet = uriInfo.getTargetEntitySet();
dataSource.writeBinaryData(entitySet, data, new BinaryData(value, requestContentType));
return ODataResponse.newBuilder().eTag(constructETag(entitySet, data)).build();
}
开发者ID:mibo,项目名称:janos,代码行数:27,代码来源:DataSourceProcessor.java
示例12: executeFunctionImportValue
import org.apache.olingo.odata2.api.processor.ODataResponse; //导入依赖的package包/类
@Override
public ODataResponse executeFunctionImportValue(final GetFunctionImportUriInfo uriInfo, final String contentType)
throws ODataException {
final EdmFunctionImport functionImport = uriInfo.getFunctionImport();
final EdmSimpleType type = (EdmSimpleType) functionImport.getReturnType().getType();
final Object data = functionSource.executeFunction(
functionImport,
mapFunctionParameters(uriInfo.getFunctionImportParameters()),
null);
if (data == null) {
throw new ODataNotFoundException(ODataHttpException.COMMON);
}
ODataResponse response;
if (type == EdmSimpleTypeKind.Binary.getEdmSimpleTypeInstance()) {
response = EntityProvider.writeBinary(((BinaryData) data).getMimeType(), ((BinaryData) data).getData());
} else {
final String value = type.valueToString(data, EdmLiteralKind.DEFAULT, null);
response = EntityProvider.writeText(value == null ? "" : value);
}
return ODataResponse.fromResponse(response).build();
}
开发者ID:mibo,项目名称:janos,代码行数:25,代码来源:DataSourceProcessor.java
示例13: writeEntry
import org.apache.olingo.odata2.api.processor.ODataResponse; //导入依赖的package包/类
private <T> ODataResponse writeEntry(final EdmEntitySet entitySet, final ExpandSelectTreeNode expandSelectTree,
final T data, final String contentType) throws ODataException {
final EdmEntityType entityType = entitySet.getEntityType();
final Map<String, Object> values = getStructuralTypeValueMap(data, entityType);
ODataContext context = getContext();
EntityProviderWriteProperties writeProperties = EntityProviderWriteProperties
.serviceRoot(context.getPathInfo().getServiceRoot())
.expandSelectTree(expandSelectTree)
.callbacks(getCallbacks(data, entityType))
.build();
final int timingHandle = context.startRuntimeMeasurement("EntityProvider", "writeEntry");
final ODataResponse response = EntityProvider.writeEntry(contentType, entitySet, values, writeProperties);
context.stopRuntimeMeasurement(timingHandle);
return response;
}
开发者ID:mibo,项目名称:janos,代码行数:21,代码来源:DataSourceProcessor.java
示例14: executeChangeSet
import org.apache.olingo.odata2.api.processor.ODataResponse; //导入依赖的package包/类
@Override
public BatchResponsePart executeChangeSet(final BatchHandler handler, final List<ODataRequest> requests)
throws ODataException {
List<ODataResponse> responses = new ArrayList<>();
for (ODataRequest request : requests) {
ODataResponse response = handler.handleRequest(request);
if (response.getStatus().getStatusCode() >= HttpStatusCodes.BAD_REQUEST.getStatusCode()) {
// Rollback
List<ODataResponse> errorResponses = new ArrayList<>(1);
errorResponses.add(response);
return BatchResponsePart.responses(errorResponses).changeSet(false).build();
}
responses.add(response);
}
return BatchResponsePart.responses(responses).changeSet(true).build();
}
开发者ID:mibo,项目名称:janos,代码行数:17,代码来源:DataSourceProcessor.java
示例15: readOrder
import org.apache.olingo.odata2.api.processor.ODataResponse; //导入依赖的package包/类
@Test
public void readOrder() throws Exception {
GetEntitySetUriInfo uriInfo = createMockedUriInfo("Rooms");
Edm edm = EdmMock.createMockEdm();
OrderByExpression exp = UriParserImpl.parseOrderBy(edm, edm.getEntityType("RefScenario", "Room"), "Name");
Mockito.when(uriInfo.getOrderBy()).thenReturn(exp);
List<Room> results = createRooms(1, 10);
Collections.reverse(results);
ReadResult<Room> readResult = ReadResult.forResult(results).build();
Mockito.when(mockedDataSource.readData(Mockito.any(EdmEntitySet.class), Mockito.any(ReadOptions.class)))
.thenReturn((ReadResult)readResult);
ODataResponse result = dataSourceProcessor.readEntitySet(uriInfo, "application/json");
StringHelper.Stream resultStream = StringHelper.toStream(result.getEntityAsStream());
List<LinkedTreeMap<?, ?>> parsedResults = JsonHelper.getResults(resultStream.asString());
Assert.assertEquals(10, parsedResults.size());
Assert.assertEquals("Room with id: 1", parsedResults.get(0).get("Name"));
Assert.assertEquals("Room with id: 9", parsedResults.get(9).get("Name"));
}
开发者ID:mibo,项目名称:janos,代码行数:23,代码来源:DataSourceProcessorTest.java
示例16: optimizedReadOrder
import org.apache.olingo.odata2.api.processor.ODataResponse; //导入依赖的package包/类
@Test
public void optimizedReadOrder() throws Exception {
GetEntitySetUriInfo uriInfo = createMockedUriInfo("Rooms");
Edm edm = EdmMock.createMockEdm();
OrderByExpression exp = UriParserImpl.parseOrderBy(edm, edm.getEntityType("RefScenario", "Room"), "Name");
Mockito.when(uriInfo.getOrderBy()).thenReturn(exp);
List<Room> results = createRooms(1, 10);
Collections.shuffle(results);
ReadResult<Room> readResult = ReadResult.forResult(results).orderApplied().build();
Mockito.when(mockedDataSource.readData(Mockito.any(EdmEntitySet.class), Mockito.any(ReadOptions.class)))
.thenReturn((ReadResult)readResult);
ODataResponse result = dataSourceProcessor.readEntitySet(uriInfo, "application/json");
StringHelper.Stream resultStream = StringHelper.toStream(result.getEntityAsStream());
List<LinkedTreeMap<?, ?>> parsedResults = JsonHelper.getResults(resultStream.asString());
Assert.assertEquals(10, parsedResults.size());
Assert.assertEquals("Room with id: 1", parsedResults.get(0).get("Name"));
Assert.assertEquals("Room with id: 9", parsedResults.get(9).get("Name"));
}
开发者ID:mibo,项目名称:janos,代码行数:23,代码来源:DataSourceProcessorTest.java
示例17: readFilter
import org.apache.olingo.odata2.api.processor.ODataResponse; //导入依赖的package包/类
@Test
public void readFilter() throws Exception {
GetEntitySetUriInfo uriInfo = createMockedUriInfo("Rooms");
Edm edm = EdmMock.createMockEdm();
FilterExpression exp = UriParserImpl.parseFilter(edm, edm.getEntityType("RefScenario", "Room"), "Version gt 105");
Mockito.when(uriInfo.getFilter()).thenReturn(exp);
List<Room> results = createRooms(1, 10);
ReadResult<Room> readResult = ReadResult.forResult(results).build();
Mockito.when(mockedDataSource.readData(Mockito.any(EdmEntitySet.class), Mockito.any(ReadOptions.class)))
.thenReturn((ReadResult)readResult);
ODataResponse result = dataSourceProcessor.readEntitySet(uriInfo, "application/json");
StringHelper.Stream resultStream = StringHelper.toStream(result.getEntityAsStream());
List<LinkedTreeMap<?, ?>> parsedResults = JsonHelper.getResults(resultStream.asString());
Assert.assertEquals(5, parsedResults.size());
Assert.assertEquals("Room with id: 10", parsedResults.get(0).get("Name"));
Assert.assertEquals("Room with id: 9", parsedResults.get(4).get("Name"));
}
开发者ID:mibo,项目名称:janos,代码行数:22,代码来源:DataSourceProcessorTest.java
示例18: readSkip
import org.apache.olingo.odata2.api.processor.ODataResponse; //导入依赖的package包/类
@Test
public void readSkip() throws Exception {
GetEntitySetUriInfo uriInfo = createMockedUriInfo("Rooms");
Mockito.when(uriInfo.getSkip()).thenReturn(5);
Mockito.when(uriInfo.getSkipToken()).thenReturn("2");
List<Room> results = createRooms(1, 10);
ReadResult<Room> readResult = ReadResult.forResult(results).build();
Mockito.when(mockedDataSource.readData(Mockito.any(EdmEntitySet.class), Mockito.any(ReadOptions.class)))
.thenReturn((ReadResult)readResult);
ODataResponse result = dataSourceProcessor.readEntitySet(uriInfo, "application/json");
StringHelper.Stream resultStream = StringHelper.toStream(result.getEntityAsStream());
List<LinkedTreeMap<?, ?>> parsedResults = JsonHelper.getResults(resultStream.asString());
Assert.assertEquals(3, parsedResults.size());
Assert.assertEquals("Room with id: 7", parsedResults.get(0).get("Name"));
Assert.assertEquals("Room with id: 9", parsedResults.get(2).get("Name"));
}
开发者ID:mibo,项目名称:janos,代码行数:21,代码来源:DataSourceProcessorTest.java
示例19: readOptimizedSkip
import org.apache.olingo.odata2.api.processor.ODataResponse; //导入依赖的package包/类
@Test
public void readOptimizedSkip() throws Exception {
GetEntitySetUriInfo uriInfo = createMockedUriInfo("Rooms");
Mockito.when(uriInfo.getSkip()).thenReturn(5);
Mockito.when(uriInfo.getSkipToken()).thenReturn("2");
List<Room> results = createRooms(1, 10);
ReadResult<Room> readResult = ReadResult.forResult(results).skipApplied().build();
Mockito.when(mockedDataSource.readData(Mockito.any(EdmEntitySet.class), Mockito.any(ReadOptions.class)))
.thenReturn((ReadResult)readResult);
ODataResponse result = dataSourceProcessor.readEntitySet(uriInfo, "application/json");
StringHelper.Stream resultStream = StringHelper.toStream(result.getEntityAsStream());
List<LinkedTreeMap<?, ?>> parsedResults = JsonHelper.getResults(resultStream.asString());
Assert.assertEquals(10, parsedResults.size());
Assert.assertEquals("Room with id: 1", parsedResults.get(0).get("Name"));
Assert.assertEquals("Room with id: 9", parsedResults.get(9).get("Name"));
}
开发者ID:mibo,项目名称:janos,代码行数:21,代码来源:DataSourceProcessorTest.java
示例20: logReadAccess
import org.apache.olingo.odata2.api.processor.ODataResponse; //导入依赖的package包/类
@Extension(entitySetNames="Employees", methods={Method.GET})
public Object logReadAccess(ExtensionContext context) throws Exception {
UriInfo uriInfo = context.getUriInfo();
ODataResponse res;
if(uriInfo.getKeyPredicates().isEmpty()) {
LOG.info("Start READ access for Employees.");
res = context.proceed();
res = ODataResponse.fromResponse(res).header(EXTENSION_TEST, "READ EMPLOYEES SET").build();
LOG.info("Finished READ access for Employees.");
} else {
LOG.info("Start READ access for Employee.");
res = context.proceed();
res = ODataResponse.fromResponse(res).header(EXTENSION_TEST, "READ EMPLOYEE").build();
LOG.info("Finished READ access for Employee.");
}
return res;
}
开发者ID:mibo,项目名称:janos,代码行数:18,代码来源:RefExtensions.java
注:本文中的org.apache.olingo.odata2.api.processor.ODataResponse类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论