本文整理汇总了Java中org.apache.olingo.odata2.api.processor.ODataProcessor类的典型用法代码示例。如果您正苦于以下问题:Java ODataProcessor类的具体用法?Java ODataProcessor怎么用?Java ODataProcessor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ODataProcessor类属于org.apache.olingo.odata2.api.processor包,在下文中一共展示了ODataProcessor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSupportedContentTypes
import org.apache.olingo.odata2.api.processor.ODataProcessor; //导入依赖的package包/类
private List<String> getSupportedContentTypes(final UriInfoImpl uriInfo, final ODataHttpMethod method)
throws ODataException {
Class<? extends ODataProcessor> processorFeature = Dispatcher.mapUriTypeToProcessorFeature(uriInfo);
UriType uriType = uriInfo.getUriType();
//
if (uriType == UriType.URI11) {
processorFeature = EntitySetProcessor.class;
} else if ((uriType == UriType.URI10)) {
processorFeature = EntityProcessor.class;
} else if (ODataHttpMethod.POST.equals(method)) {
if (uriType == UriType.URI1 || uriType == UriType.URI6B) {
processorFeature = EntityProcessor.class;
}
}
return service.getSupportedContentTypes(processorFeature);
}
示例2: serviceInstance
import org.apache.olingo.odata2.api.processor.ODataProcessor; //导入依赖的package包/类
@Test
public void serviceInstance() throws Exception {
ODataServlet servlet = new ODataServlet();
prepareServlet(servlet);
prepareRequest(reqMock, "", "/servlet-path");
Mockito.when(reqMock.getPathInfo()).thenReturn("/request-path-info");
Mockito.when(reqMock.getRequestURI()).thenReturn("http://localhost:8080/servlet-path/request-path-info");
ODataServiceFactory factory = Mockito.mock(ODataServiceFactory.class);
ODataService service = Mockito.mock(ODataService.class);
Mockito.when(factory.createService(Mockito.any(ODataContext.class))).thenReturn(service);
ODataProcessor processor = Mockito.mock(ODataProcessor.class);
Mockito.when(service.getProcessor()).thenReturn(processor);
Mockito.when(reqMock.getAttribute(ODataServiceFactory.FACTORY_INSTANCE_LABEL)).thenReturn(factory);
Mockito.when(respMock.getOutputStream()).thenReturn(Mockito.mock(ServletOutputStream.class));
servlet.service(reqMock, respMock);
Mockito.verify(factory).createService(Mockito.any(ODataContext.class));
}
示例3: setupBatchHandler
import org.apache.olingo.odata2.api.processor.ODataProcessor; //导入依赖的package包/类
@Before
public void setupBatchHandler() throws Exception {
ODataProcessor processor = new LocalProcessor();
ODataService serviceMock = mock(ODataService.class);
when(serviceMock.getBatchProcessor()).thenReturn((BatchProcessor) processor);
when(serviceMock.getEntitySetProcessor()).thenReturn((EntitySetProcessor) processor);
when(serviceMock.getEntitySimplePropertyProcessor()).thenReturn((EntitySimplePropertyProcessor) processor);
when(serviceMock.getProcessor()).thenReturn(processor);
Edm mockEdm = MockFacade.getMockEdm();
when(serviceMock.getEntityDataModel()).thenReturn(mockEdm);
List<String> supportedContentTypes = Arrays.asList(
HttpContentType.APPLICATION_JSON_UTF8, HttpContentType.APPLICATION_JSON);
when(serviceMock.getSupportedContentTypes(EntityMediaProcessor.class)).thenReturn(supportedContentTypes);
when(serviceMock.getSupportedContentTypes(EntityProcessor.class)).thenReturn(supportedContentTypes);
when(serviceMock.getSupportedContentTypes(EntitySimplePropertyProcessor.class)).thenReturn(supportedContentTypes);
handler = new BatchHandlerImpl(mock(ODataServiceFactory.class), serviceMock);
}
示例4: setup
import org.apache.olingo.odata2.api.processor.ODataProcessor; //导入依赖的package包/类
@Before
public void setup() {
edmProvider = new ODataJPAEdmProvider();
emf = EasyMock.createMock(EntityManagerFactory.class);
em = EasyMock.createMock(EntityManager.class);
EasyMock.expect(em.isOpen()).andReturn(false);
EasyMock.replay(em);
EasyMock.expect(emf.createEntityManager()).andStubReturn(em);
EasyMock.replay(emf);
odataContext = EasyMock.createMock(ODataContext.class);
List<Locale> listLocale = new ArrayList<Locale>();
listLocale.add(Locale.ENGLISH);
listLocale.add(Locale.GERMAN);
EasyMock.expect(odataContext.getAcceptableLanguages()).andStubReturn(listLocale);
EasyMock.replay(odataContext);
processor = EasyMock.createMock(ODataProcessor.class);
EasyMock.replay(processor);
odataJPAContext = new ODataJPAContextImpl();
odataJPAContext.setEdmProvider(edmProvider);
odataJPAContext.setEntityManagerFactory(emf);
odataJPAContext.setODataContext(odataContext);
odataJPAContext.setODataProcessor(processor);
odataJPAContext.setPersistenceUnitName(ODataJPAContextMock.PERSISTENCE_UNIT_NAME);
odataJPAContext.setJPAEdmMappingModel(ODataJPAContextMock.MAPPING_MODEL);
}
示例5: checkRequestContentType
import org.apache.olingo.odata2.api.processor.ODataProcessor; //导入依赖的package包/类
/**
* <p>Checks if <code>content type</code> is a valid request content type for the given {@link UriInfoImpl}.</p>
* <p>If the combination of <code>content type</code> and {@link UriInfoImpl} is not valid, an
* {@link ODataUnsupportedMediaTypeException} is thrown.</p>
* @param uriInfo information about request URI
* @param contentType request content type
* @throws ODataException in the case of an error during {@link UriInfoImpl} access;
* if the combination of <code>content type</code> and {@link UriInfoImpl} is invalid, as
* {@link ODataUnsupportedMediaTypeException}
*/
private void checkRequestContentType(final UriInfoImpl uriInfo, final String contentType) throws ODataException {
Class<? extends ODataProcessor> processorFeature = Dispatcher.mapUriTypeToProcessorFeature(uriInfo);
// Don't check the request content type for function imports
// because the request body is not used at all.
if (processorFeature == FunctionImportProcessor.class || processorFeature == FunctionImportValueProcessor.class) {
return;
}
// Adjust processor feature.
if (processorFeature == EntitySetProcessor.class) {
processorFeature = uriInfo.getTargetEntitySet().getEntityType().hasStream() ? EntityMediaProcessor.class :
EntityProcessor.class; // The request must contain a single entity!
} else if (processorFeature == EntityLinksProcessor.class) {
processorFeature = EntityLinkProcessor.class; // The request must contain a single link!
}
final ContentType parsedContentType = ContentType.parse(contentType);
if (parsedContentType == null || parsedContentType.hasWildcard()) {
throw new ODataUnsupportedMediaTypeException(ODataUnsupportedMediaTypeException.NOT_SUPPORTED
.addContent(parsedContentType));
}
// Get list of supported content types based on processor feature.
final List<ContentType> supportedContentTypes =
processorFeature == EntitySimplePropertyValueProcessor.class ? getSupportedContentTypes(getProperty(uriInfo))
: getSupportedContentTypes(processorFeature);
if (!hasMatchingContentType(parsedContentType, supportedContentTypes)) {
throw new ODataUnsupportedMediaTypeException(ODataUnsupportedMediaTypeException.NOT_SUPPORTED
.addContent(parsedContentType));
}
}
示例6: checkFeature
import org.apache.olingo.odata2.api.processor.ODataProcessor; //导入依赖的package包/类
private static void checkFeature(final UriType uriType, final boolean isValue,
final Class<? extends ODataProcessor> feature) throws ODataException {
ODataServiceFactory factory = mock(ODataServiceFactory.class);
new Dispatcher(factory, getMockService());
assertEquals(feature, Dispatcher.mapUriTypeToProcessorFeature(mockUriInfo(uriType, isValue)));
assertEquals(feature, Dispatcher.mapUriTypeToProcessorFeature(mockUriInfo(uriType, isValue)));
}
示例7: getCustomContentTypes
import org.apache.olingo.odata2.api.processor.ODataProcessor; //导入依赖的package包/类
@Override
public List<String> getCustomContentTypes(Class<? extends ODataProcessor> processor_feature)
throws ODataException
{
return CUSTOM_CONTENT_TYPES;
}
示例8: getCustomContentTypes
import org.apache.olingo.odata2.api.processor.ODataProcessor; //导入依赖的package包/类
@Override
public List<String> getCustomContentTypes(Class<? extends ODataProcessor> processor_feature)
throws ODataException
{
return Collections.singletonList(MetalinkBuilder.CONTENT_TYPE);
}
示例9: setODataProcessor
import org.apache.olingo.odata2.api.processor.ODataProcessor; //导入依赖的package包/类
@Override
public void setODataProcessor(final ODataProcessor processor) {
this.processor = processor;
}
示例10: getODataProcessor
import org.apache.olingo.odata2.api.processor.ODataProcessor; //导入依赖的package包/类
@Override
public ODataProcessor getODataProcessor() {
return processor;
}
示例11: getProcessor
import org.apache.olingo.odata2.api.processor.ODataProcessor; //导入依赖的package包/类
/**
* @see ODataService
*/
@Override
public ODataProcessor getProcessor() throws ODataException {
return processor;
}
示例12: getSupportedContentTypes
import org.apache.olingo.odata2.api.processor.ODataProcessor; //导入依赖的package包/类
@Override
public List<String> getSupportedContentTypes(final Class<? extends ODataProcessor> processorFeature)
throws ODataException {
List<String> result = new ArrayList<String>();
if (processor instanceof CustomContentType) {
result.addAll(((CustomContentType) processor).getCustomContentTypes(processorFeature));
}
if (processorFeature == BatchProcessor.class) {
// set wildcard for now to ignore accept header completely, reasoning: there is only one representation for $batch
result.add(HttpContentType.WILDCARD);
} else if (processorFeature == EntityProcessor.class) {
result.add(HttpContentType.APPLICATION_ATOM_XML_ENTRY_UTF8);
result.add(HttpContentType.APPLICATION_ATOM_XML_UTF8);
result.add(HttpContentType.APPLICATION_JSON_UTF8);
result.add(HttpContentType.APPLICATION_JSON_UTF8_VERBOSE);
result.add(HttpContentType.APPLICATION_JSON);
result.add(HttpContentType.APPLICATION_JSON_VERBOSE);
result.add(HttpContentType.APPLICATION_XML_UTF8);
} else if (processorFeature == FunctionImportProcessor.class
|| processorFeature == EntityLinkProcessor.class
|| processorFeature == EntityLinksProcessor.class
|| processorFeature == EntitySimplePropertyProcessor.class
|| processorFeature == EntityComplexPropertyProcessor.class) {
result.add(HttpContentType.APPLICATION_XML_UTF8);
result.add(HttpContentType.APPLICATION_JSON_UTF8);
result.add(HttpContentType.APPLICATION_JSON_UTF8_VERBOSE);
result.add(HttpContentType.APPLICATION_JSON);
result.add(HttpContentType.APPLICATION_JSON_VERBOSE);
} else if (processorFeature == EntityMediaProcessor.class
|| processorFeature == EntitySimplePropertyValueProcessor.class
|| processorFeature == FunctionImportValueProcessor.class) {
result.add(HttpContentType.WILDCARD);
} else if (processorFeature == EntitySetProcessor.class) {
result.add(HttpContentType.APPLICATION_ATOM_XML_FEED_UTF8);
result.add(HttpContentType.APPLICATION_ATOM_XML_UTF8);
result.add(HttpContentType.APPLICATION_JSON_UTF8);
result.add(HttpContentType.APPLICATION_JSON_UTF8_VERBOSE);
result.add(HttpContentType.APPLICATION_JSON);
result.add(HttpContentType.APPLICATION_JSON_VERBOSE);
result.add(HttpContentType.APPLICATION_XML_UTF8);
} else if (processorFeature == MetadataProcessor.class) {
result.add(HttpContentType.APPLICATION_XML_UTF8);
} else if (processorFeature == ServiceDocumentProcessor.class) {
result.add(HttpContentType.APPLICATION_ATOM_SVC_UTF8);
result.add(HttpContentType.APPLICATION_JSON_UTF8);
result.add(HttpContentType.APPLICATION_JSON_UTF8_VERBOSE);
result.add(HttpContentType.APPLICATION_JSON);
result.add(HttpContentType.APPLICATION_JSON_VERBOSE);
result.add(HttpContentType.APPLICATION_XML_UTF8);
} else {
throw new ODataNotImplementedException();
}
return result;
}
示例13: mapUriTypeToProcessorFeature
import org.apache.olingo.odata2.api.processor.ODataProcessor; //导入依赖的package包/类
protected static Class<? extends ODataProcessor> mapUriTypeToProcessorFeature(final UriInfoImpl uriInfo) {
Class<? extends ODataProcessor> feature;
switch (uriInfo.getUriType()) {
case URI0:
feature = ServiceDocumentProcessor.class;
break;
case URI1:
case URI6B:
case URI15:
feature = EntitySetProcessor.class;
break;
case URI2:
case URI6A:
case URI16:
feature = EntityProcessor.class;
break;
case URI3:
feature = EntityComplexPropertyProcessor.class;
break;
case URI4:
case URI5:
feature = uriInfo.isValue() ? EntitySimplePropertyValueProcessor.class : EntitySimplePropertyProcessor.class;
break;
case URI7A:
case URI50A:
feature = EntityLinkProcessor.class;
break;
case URI7B:
case URI50B:
feature = EntityLinksProcessor.class;
break;
case URI8:
feature = MetadataProcessor.class;
break;
case URI9:
feature = BatchProcessor.class;
break;
case URI10:
case URI11:
case URI12:
case URI13:
feature = FunctionImportProcessor.class;
break;
case URI14:
feature = uriInfo.isValue() ? FunctionImportValueProcessor.class : FunctionImportProcessor.class;
break;
case URI17:
feature = EntityMediaProcessor.class;
break;
default:
throw new ODataRuntimeException("Unknown or not implemented URI type: " + uriInfo.getUriType());
}
return feature;
}
示例14: mockODataService
import org.apache.olingo.odata2.api.processor.ODataProcessor; //导入依赖的package包/类
private ODataService mockODataService(final ODataServiceFactory serviceFactory) throws ODataException {
ODataService service = DispatcherTest.getMockService();
when(service.getEntityDataModel()).thenReturn(edm);
when(service.getProcessor()).thenReturn(mock(ODataProcessor.class));
when(serviceFactory.createService(any(ODataContext.class))).thenReturn(service);
when(service.getSupportedContentTypes(BatchProcessor.class)).thenReturn(
Arrays.asList(HttpContentType.MULTIPART_MIXED));
final List<String> jsonAndXml = Arrays.asList(
HttpContentType.APPLICATION_JSON,
HttpContentType.APPLICATION_JSON_VERBOSE,
HttpContentType.APPLICATION_JSON_UTF8,
HttpContentType.APPLICATION_JSON_UTF8_VERBOSE,
HttpContentType.APPLICATION_XML_UTF8);
List<String> atomEntryAndJsonAndXml = new ArrayList<String>();
atomEntryAndJsonAndXml.add(HttpContentType.APPLICATION_ATOM_XML_ENTRY_UTF8);
atomEntryAndJsonAndXml.add(HttpContentType.APPLICATION_ATOM_XML_UTF8);
atomEntryAndJsonAndXml.addAll(jsonAndXml);
when(service.getSupportedContentTypes(EntityProcessor.class)).thenReturn(atomEntryAndJsonAndXml);
when(service.getSupportedContentTypes(FunctionImportProcessor.class)).thenReturn(jsonAndXml);
when(service.getSupportedContentTypes(EntityLinkProcessor.class)).thenReturn(jsonAndXml);
when(service.getSupportedContentTypes(EntityLinksProcessor.class)).thenReturn(jsonAndXml);
when(service.getSupportedContentTypes(EntitySimplePropertyProcessor.class)).thenReturn(jsonAndXml);
when(service.getSupportedContentTypes(EntityComplexPropertyProcessor.class)).thenReturn(jsonAndXml);
final List<String> wildcard = Arrays.asList(HttpContentType.WILDCARD);
when(service.getSupportedContentTypes(EntityMediaProcessor.class)).thenReturn(wildcard);
when(service.getSupportedContentTypes(EntitySimplePropertyValueProcessor.class)).thenReturn(wildcard);
when(service.getSupportedContentTypes(FunctionImportValueProcessor.class)).thenReturn(wildcard);
List<String> atomFeedAndJsonAndXml = new ArrayList<String>();
atomFeedAndJsonAndXml.add(HttpContentType.APPLICATION_ATOM_XML_FEED_UTF8);
atomFeedAndJsonAndXml.add(HttpContentType.APPLICATION_ATOM_XML_UTF8);
atomFeedAndJsonAndXml.addAll(jsonAndXml);
when(service.getSupportedContentTypes(EntitySetProcessor.class)).thenReturn(atomFeedAndJsonAndXml);
when(service.getSupportedContentTypes(MetadataProcessor.class)).thenReturn(Arrays.asList(
HttpContentType.APPLICATION_XML_UTF8));
List<String> atomSvcAndJsonAndXml = new ArrayList<String>();
atomSvcAndJsonAndXml.add(HttpContentType.APPLICATION_ATOM_SVC_UTF8);
atomSvcAndJsonAndXml.addAll(jsonAndXml);
when(service.getSupportedContentTypes(ServiceDocumentProcessor.class)).thenReturn(atomSvcAndJsonAndXml);
return service;
}
示例15: getODataProcessor
import org.apache.olingo.odata2.api.processor.ODataProcessor; //导入依赖的package包/类
/**
* The method gets the OData Processor for JPA from the context.
*
* @return OData JPA Processor
*/
public ODataProcessor getODataProcessor();