• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ContentType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.olingo.commons.api.format.ContentType的典型用法代码示例。如果您正苦于以下问题:Java ContentType类的具体用法?Java ContentType怎么用?Java ContentType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ContentType类属于org.apache.olingo.commons.api.format包,在下文中一共展示了ContentType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: readServiceDocument

import org.apache.olingo.commons.api.format.ContentType; //导入依赖的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.commons.api.format.ContentType; //导入依赖的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: writePropertyValue

import org.apache.olingo.commons.api.format.ContentType; //导入依赖的package包/类
private void writePropertyValue(ODataResponse response, Property property) throws ODataApplicationException {
	if (property == null) {
		throw new ODataApplicationException("No property found", HttpStatusCode.NOT_FOUND.getStatusCode(),
				Locale.ENGLISH);
	} else {
		if (property.getValue() == null) {
			response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
		} else {
			String value = String.valueOf(property.getValue());
			ByteArrayInputStream serializerContent = new ByteArrayInputStream(value.getBytes());//Charset.forName("UTF-8")));
			response.setContent(serializerContent);
			response.setStatusCode(HttpStatusCode.OK.getStatusCode());
			response.setHeader(HttpHeader.CONTENT_TYPE, ContentType.TEXT_PLAIN.toContentTypeString());
		}
	}
}
 
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:17,代码来源:SparqlPrimitiveValueProcessor.java


示例4: createReference

import org.apache.olingo.commons.api.format.ContentType; //导入依赖的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


示例5: updateReference

import org.apache.olingo.commons.api.format.ContentType; //导入依赖的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


示例6: createSerializer

import org.apache.olingo.commons.api.format.ContentType; //导入依赖的package包/类
@Override
public ODataSerializer createSerializer(ContentType contentType) throws SerializerException {
    ODataSerializer serializer = null;
    if (contentType.isCompatible(ContentType.APPLICATION_JSON)) {
        String metadata = contentType.getParameter(ContentType.PARAMETER_ODATA_METADATA);
        if (metadata == null
                || ContentType.VALUE_ODATA_METADATA_MINIMAL.equalsIgnoreCase(metadata)
                || ContentType.VALUE_ODATA_METADATA_NONE.equalsIgnoreCase(metadata)
                || ContentType.VALUE_ODATA_METADATA_FULL.equalsIgnoreCase(metadata)) {
            serializer = new ElasticODataJsonSerializer(contentType);
        }
    } else if (contentType.isCompatible(ContentType.APPLICATION_XML)
            || contentType.isCompatible(ContentType.APPLICATION_ATOM_XML)) {
        serializer = new ElasticODataXmlSerializer();
    }
    if (serializer == null) {
        throw new SerializerException(
                "Unsupported format: " + contentType.toContentTypeString(),
                SerializerException.MessageKeys.UNSUPPORTED_FORMAT,
                contentType.toContentTypeString());
    }
    return serializer;
}
 
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:24,代码来源:ElasticOData.java


示例7: read

import org.apache.olingo.commons.api.format.ContentType; //导入依赖的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


示例8: countEntitySet

import org.apache.olingo.commons.api.format.ContentType; //导入依赖的package包/类
@Override
public void countEntitySet(ODataRequest request, ODataResponse response,UriInfo uriInfo) {
    try {
        checkExpand(uriInfo.asUriInfoResource());
        ODataSQLBuilder visitor = new ODataSQLBuilder(this.client.getMetadataStore(), this.prepared);
        visitor.visit(uriInfo);
        Query query = visitor.selectQuery(true);
        List<SQLParam> parameters = visitor.getParameters();

        CountResponse countResponse = this.client.executeCount(query,parameters);
        ByteArrayInputStream bis = new ByteArrayInputStream(String.valueOf(countResponse.getCount()).getBytes());
        response.setContent(bis);
        response.setStatusCode(HttpStatusCode.OK.getStatusCode());
        response.setHeader(HttpHeader.CONTENT_TYPE,ContentType.TEXT_PLAIN.toContentTypeString());
    } catch (Exception e) {
        handleException(response, ContentType.APPLICATION_JSON, e);
    }
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:19,代码来源:TeiidProcessor.java


示例9: readParameters

import org.apache.olingo.commons.api.format.ContentType; //导入依赖的package包/类
private Map<String, Parameter> readParameters(final EdmAction action,
                                              final InputStream body,
                                              final ContentType requestFormat)
        throws ODataApplicationException,
               DeserializerException
{
    if (action.getParameterNames().size() - (action.isBound()
            ? 1
            : 0) > 0)
    {
        checkRequestFormat(requestFormat);

        return odata.createDeserializer(requestFormat).actionParameters(body,
                                                                        action).getActionParameters();
    }

    return Collections.<String, Parameter>emptyMap();
}
 
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:19,代码来源:RedHxDiscoveryProcessor.java


示例10: getEdmTest

import org.apache.olingo.commons.api.format.ContentType; //导入依赖的package包/类
@Test
public void getEdmTest() throws Exception {
  final ODataClient client = getODataClient();
  final String serviceUrl = getServiceUrl();
  final ODataServiceDocumentRequest reqeust =
      client.getRetrieveRequestFactory().getServiceDocumentRequest(serviceUrl);

  reqeust.setFormat(ContentType.APPLICATION_XML);

  final Edm redHelixEdm = readEdm(client, serviceUrl);

  Assert.assertEquals(1, redHelixEdm.getSchemas().size());

  for (EdmSchema schema : redHelixEdm.getSchemas()) {
    Assert.assertEquals(RED_HELIX_NAME_SPACE, schema.getNamespace());
  }
}
 
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:18,代码来源:EdmTest.java


示例11: dispatchPrimitivePropertyValue

import org.apache.olingo.commons.api.format.ContentType; //导入依赖的package包/类
@Test
public void dispatchPrimitivePropertyValue() throws Exception {
  final String uri = "ESAllPrim(0)/PropertyString/$value";
  final PrimitiveValueProcessor processor = mock(PrimitiveValueProcessor.class);

  dispatch(HttpMethod.GET, uri, processor);
  verify(processor).readPrimitiveValue(any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class),
      any(ContentType.class));

  dispatch(HttpMethod.PUT, uri, null, HttpHeader.CONTENT_TYPE, ContentType.TEXT_PLAIN.toContentTypeString(),
      processor);
  verify(processor).updatePrimitiveValue(
      any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class), any(ContentType.class),
      any(ContentType.class));

  dispatch(HttpMethod.DELETE, uri, processor);
  verify(processor).deletePrimitiveValue(any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class));

  dispatchMethodNotAllowed(HttpMethod.POST, uri, processor);
  dispatchMethodNotAllowed(HttpMethod.PATCH, uri, processor);
  dispatchMethodNotAllowed(HttpMethod.HEAD, uri, processor);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:23,代码来源:ODataHandlerImplTest.java


示例12: updateEntity

import org.apache.olingo.commons.api.format.ContentType; //导入依赖的package包/类
public void updateEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo,
                          ContentType requestFormat, ContentType responseFormat)
						throws ODataApplicationException, DeserializerException, SerializerException {
	
	// 1. Retrieve the entity set which belongs to the requested entity 
	List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
	// Note: only in our example we can assume that the first segment is the EntitySet
	UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0); 
	EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();
	EdmEntityType edmEntityType = edmEntitySet.getEntityType();

	// 2. update the data in backend
	// 2.1. retrieve the payload from the PUT request for the entity to be updated 
	InputStream requestInputStream = request.getBody();
	ODataDeserializer deserializer = this.odata.createDeserializer(requestFormat);
	DeserializerResult result = deserializer.entity(requestInputStream, edmEntityType);
	Entity requestEntity = result.getEntity();
	// 2.2 do the modification in backend
	List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
	// Note that this updateEntity()-method is invoked for both PUT or PATCH operations
	HttpMethod httpMethod = request.getMethod();
	storage.updateEntityData(edmEntitySet, keyPredicates, requestEntity, httpMethod);
	
	//3. configure the response object
	response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:27,代码来源:DemoEntityProcessor.java


示例13: readEntity

import org.apache.olingo.commons.api.format.ContentType; //导入依赖的package包/类
public void readEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType responseFormat)
    throws ODataApplicationException, SerializerException {

  // The sample service supports only functions imports and entity sets.
  // We do not care about bound functions and composable functions.

  UriResource uriResource = uriInfo.getUriResourceParts().get(0);

  if (uriResource instanceof UriResourceEntitySet) {
    readEntityInternal(request, response, uriInfo, responseFormat);
  } else if (uriResource instanceof UriResourceFunction) {
    readFunctionImportInternal(request, response, uriInfo, responseFormat);
  } else {
    throw new ODataApplicationException("Only EntitySet is supported",
        HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ENGLISH);
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:18,代码来源:DemoEntityProcessor.java


示例14: nextAtomEntityFromEntitySet

import org.apache.olingo.commons.api.format.ContentType; //导入依赖的package包/类
private ResWrap<Entity> nextAtomEntityFromEntitySet(
        final InputStream input, final OutputStream osEntitySet, final String namespaces) {

  final ByteArrayOutputStream entity = new ByteArrayOutputStream();

  ResWrap<Entity> atomEntity = null;

  try {
    if (consume(input, "<entry>", osEntitySet, false) >= 0) {
      entity.write("<entry ".getBytes(Constants.UTF8));
      entity.write(namespaces.getBytes(Constants.UTF8));
      entity.write(">".getBytes(Constants.UTF8));

      if (consume(input, "</entry>", entity, true) >= 0) {
        atomEntity = odataClient.getDeserializer(ContentType.APPLICATION_ATOM_XML).
                toEntity(new ByteArrayInputStream(entity.toByteArray()));
      }
    }
  } catch (Exception e) {
    LOG.error("Error retrieving entities from EntitySet", e);
  }

  return atomEntity;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:25,代码来源:ClientEntitySetIterator.java


示例15: streamCountFalseJson

import org.apache.olingo.commons.api.format.ContentType; //导入依赖的package包/类
@Test
public void streamCountFalseJson() throws Exception {
  URL url = new URL(SERVICE_URI + "ESStreamServerSidePaging?$count=false&$format=json");

  HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  connection.setRequestMethod(HttpMethod.GET.name());
  connection.connect();

  assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode());
  assertEquals(ContentType.JSON, ContentType.create(connection.getHeaderField(HttpHeader.CONTENT_TYPE)));

  final String content = IOUtils.toString(connection.getInputStream());

  assertTrue(content.contains("{\"PropertyInt16\":2,"+
  "\"[email protected]\":\"eTag\",\"[email protected]\":\"image/jpeg\"}"));
  assertTrue(content.contains("\"@odata.nextLink\""));
  assertTrue(content.contains("ESStreamServerSidePaging?$count=false&$format=json&%24skiptoken=1%2A10"));
  assertFalse(content.contains("\"@odata.count\":504"));
  }
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:20,代码来源:BasicStreamITCase.java


示例16: complex

import org.apache.olingo.commons.api.format.ContentType; //导入依赖的package包/类
private void complex(final ContentType contentType) throws ODataDeserializerException, ODataSerializerException {
  final InputStream input = getClass().getResourceAsStream("Employees_3_HomeAddress." + getSuffix(contentType));
  final ClientProperty property = client.getReader().readProperty(input, contentType);
  assertNotNull(property);
  assertTrue(property.hasComplexValue());
  assertEquals(3, property.getComplexValue().size());

  final ClientProperty written = client.getReader().readProperty(
          client.getWriter().writeProperty(property, contentType), contentType);
  // This is needed because type information gets lost with JSON serialization
  final ClientComplexValue typedValue = client.getObjectFactory().
          newComplexValue(property.getComplexValue().getTypeName());
  for (final Iterator<ClientProperty> itor = written.getComplexValue().iterator(); itor.hasNext();) {
    final ClientProperty prop = itor.next();
    typedValue.add(prop);
  }
  final ClientProperty comparable = client.getObjectFactory().
          newComplexProperty(property.getName(), typedValue);

  assertEquals(property, comparable);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:22,代码来源:PropertyTest.java


示例17: getDefaultSupportedContentTypes

import org.apache.olingo.commons.api.format.ContentType; //导入依赖的package包/类
private static List<ContentType> getDefaultSupportedContentTypes(final RepresentationType type) {
  switch (type) {
  case METADATA:
    return Collections.unmodifiableList(Arrays.asList(ContentType.APPLICATION_XML,
        ContentType.APPLICATION_JSON));
  case MEDIA:
  case BINARY:
    return Collections.singletonList(ContentType.APPLICATION_OCTET_STREAM);
  case VALUE:
  case COUNT:
    return Collections.singletonList(ContentType.TEXT_PLAIN);
  case BATCH:
    return Collections.singletonList(ContentType.MULTIPART_MIXED);
  default:
    return DEFAULT_SUPPORTED_CONTENT_TYPES;
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:18,代码来源:ContentNegotiator.java


示例18: item12

import org.apache.olingo.commons.api.format.ContentType; //导入依赖的package包/类
/**
 * 12. MAY support odata.metadata=minimal in a JSON response (see [OData-JSON]).
 */
@Test
public void item12() {
  final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
      appendEntitySetSegment("Customers").appendKeySegment(1).expand("Company");

  final ODataEntityRequest<ClientEntity> req =
      client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
  req.setFormat(ContentType.JSON);

  assertEquals("application/json;odata.metadata=minimal", req.getHeader("Accept"));
  assertEquals("application/json;odata.metadata=minimal", req.getAccept());

  final ODataRetrieveResponse<ClientEntity> res = req.execute();
  assertTrue(res.getContentType().startsWith("application/json; odata.metadata=minimal"));

  assertNotNull(res.getBody());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:21,代码来源:ConformanceTestITCase.java


示例19: updateEntity

import org.apache.olingo.commons.api.format.ContentType; //导入依赖的package包/类
public void updateEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo,
                          ContentType requestFormat, ContentType responseFormat)
						throws ODataApplicationException, DeserializerException, SerializerException {
	
	// 1. Retrieve the entity set which belongs to the requested entity 
	List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
	// Note: only in our example we can assume that the first segment is the EntitySet
	UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0); 
	EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();
	EdmEntityType edmEntityType = edmEntitySet.getEntityType();

	// 2. update the data in backend
	// 2.1. retrieve the payload from the PUT request for the entity to be updated 
	InputStream requestInputStream = request.getBody();
	ODataDeserializer deserializer = odata.createDeserializer(requestFormat);
	DeserializerResult result = deserializer.entity(requestInputStream, edmEntityType);
	Entity requestEntity = result.getEntity();
	// 2.2 do the modification in backend
	List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
	// Note that this updateEntity()-method is invoked for both PUT or PATCH operations
	HttpMethod httpMethod = request.getMethod();
	storage.updateEntityData(edmEntitySet, keyPredicates, requestEntity, httpMethod);
	
	//3. configure the response object
	response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:27,代码来源:DemoEntityProcessor.java


示例20: readPrimitiveCollectionCount

import org.apache.olingo.commons.api.format.ContentType; //导入依赖的package包/类
@Test
public void readPrimitiveCollectionCount() {
  ODataValueRequest request = getClient().getRetrieveRequestFactory()
      .getValueRequest(getClient().newURIBuilder(SERVICE_URI)
          .appendEntitySetSegment("ESCollAllPrim").appendKeySegment(1)
          .appendPropertySegment("CollPropertyBoolean").appendCountSegment().build());
  assertNotNull(request);
  setCookieHeader(request);

  final ODataRetrieveResponse<ClientPrimitiveValue> response = request.execute();
  saveCookieHeader(response);
  assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
  assertEquals(ContentType.TEXT_PLAIN.toContentTypeString(), response.getContentType());

  final ClientPrimitiveValue value = response.getBody();
  assertNotNull(value);
  assertEquals("3", value.toValue());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:19,代码来源:PrimitiveComplexITCase.java



注:本文中的org.apache.olingo.commons.api.format.ContentType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SimpleCredentialsMatcher类代码示例发布时间:2022-05-22
下一篇:
Java BrowserInformationControl类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap