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

Java HttpStatusCode类代码示例

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

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



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

示例1: readServiceDocument

import org.apache.olingo.commons.api.http.HttpStatusCode; //导入依赖的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.http.HttpStatusCode; //导入依赖的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.http.HttpStatusCode; //导入依赖的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.http.HttpStatusCode; //导入依赖的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.http.HttpStatusCode; //导入依赖的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: deleteReference

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


示例7: readReferenceCollection

import org.apache.olingo.commons.api.http.HttpStatusCode; //导入依赖的package包/类
static public EntityCollection readReferenceCollection(RdfEdmProvider rdfEdmProvider, UriInfo uriInfo,
		UriType uriType) throws OData2SparqlException, EdmException, ODataApplicationException, ExpressionVisitException {
	List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
	RdfEntityType rdfEntityType = null;
	EdmEntitySet edmEntitySet = null;

	UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0);
	edmEntitySet = uriResourceEntitySet.getEntitySet();
	rdfEntityType = rdfEdmProvider.getRdfEntityTypefromEdmEntitySet(edmEntitySet);
	SparqlQueryBuilder sparqlBuilder = new SparqlQueryBuilder(rdfEdmProvider.getRdfModel(),
			rdfEdmProvider.getEdmMetadata(), uriInfo, uriType);

	//prepareQuery
	SparqlStatement sparqlStatement = sparqlBuilder.prepareEntityLinksSparql();
	SparqlEntityCollection rdfResults = sparqlStatement.executeConstruct(rdfEdmProvider, rdfEntityType, null, null);

	if (rdfResults == null) {
		throw new ODataApplicationException("No results", HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(),
				Locale.ENGLISH);
	} else {
		return rdfResults;
	}
}
 
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:24,代码来源:SparqlBaseCommand.java


示例8: getEqQuery

import org.apache.olingo.commons.api.http.HttpStatusCode; //导入依赖的package包/类
/**
 * Gets query for equals and not equals operations.
 * 
 * @param expressionMember
 *            member with value
 * @return appropriate query
 * @throws ODataApplicationException
 *             if any error occurred during creating query
 */
protected QueryBuilder getEqQuery(ExpressionMember expressionMember)
        throws ODataApplicationException {
    Object value = ((LiteralMember) expressionMember).getValue();
    if (getField().equals(ID_FIELD_NAME)) {
        if (value == null) {
            throw new ODataApplicationException("Id value can not be null",
                    HttpStatusCode.BAD_REQUEST.getStatusCode(), Locale.ROOT);
        }
        return idsQuery().addIds(value.toString());
    } else {
        String fieldName = addKeywordIfNeeded(getField(), getAnnotations());
        if (value == null) {
            return boolQuery().mustNot(existsQuery(fieldName));
        } else {
            return termQuery(fieldName, value);
        }
    }
}
 
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:28,代码来源:AnnotatedMember.java


示例9: read

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


示例10: visitLiteral

import org.apache.olingo.commons.api.http.HttpStatusCode; //导入依赖的package包/类
@Override
public Object visitLiteral(Literal literal) throws ExpressionVisitException, ODataApplicationException {
    String literalAsString = literal.getText();
    if(literal.getType() instanceof EdmString) {
        String stringLiteral = "";
        if (literal.getText().length() > 2) {
            stringLiteral = literalAsString.substring(1, literalAsString.length() - 1);
        }
        return stringLiteral;
    }
    else {
        try {
            return Integer.parseInt(literalAsString);
        } catch (NumberFormatException e) {
            throw new ODataApplicationException("Only Edm.Int32 and Edm.String literals are implemented", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ENGLISH);
        }
    }
}
 
开发者ID:sbcd90,项目名称:olingo-jersey,代码行数:19,代码来源:FilterExpressionVisitor.java


示例11: evaluateArithmeticOperation

import org.apache.olingo.commons.api.http.HttpStatusCode; //导入依赖的package包/类
private Object evaluateArithmeticOperation(BinaryOperatorKind binaryOperatorKind, Object left, Object right) throws ODataApplicationException {
    if (left instanceof Integer && right instanceof Integer) {
        Integer valueLeft = (Integer) left;
        Integer valueRight = (Integer) right;

        if (binaryOperatorKind == BinaryOperatorKind.ADD)
            return valueLeft + valueRight;
        else if (binaryOperatorKind == BinaryOperatorKind.SUB)
            return valueLeft - valueRight;
        else if (binaryOperatorKind == BinaryOperatorKind.DIV)
            return valueLeft / valueRight;
        else if ( binaryOperatorKind == BinaryOperatorKind.MUL)
            return valueLeft * valueRight;
        else
            return valueLeft % valueRight;
    }
    else
        throw new ODataApplicationException("Arithmetic operations needs two numeric operands", HttpStatusCode.BAD_REQUEST.getStatusCode(), Locale.ENGLISH);
}
 
开发者ID:sbcd90,项目名称:olingo-jersey,代码行数:20,代码来源:FilterExpressionVisitor.java


示例12: countEntitySet

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


示例13: getEntityByReference

import org.apache.olingo.commons.api.http.HttpStatusCode; //导入依赖的package包/类
protected Entity getEntityByReference(final String entityId, final String rawServiceRoot)
    throws DataProviderException {
  try {
    final UriResourceEntitySet uriResource =
        odata.createUriHelper().parseEntityId(edm, entityId, rawServiceRoot);
    final Entity targetEntity = read(uriResource.getEntitySet(), uriResource.getKeyPredicates());

    if (targetEntity != null) {
      return targetEntity;
    } else {
      throw new DataProviderException("Entity not found", HttpStatusCode.NOT_FOUND);
    }
  } catch (DeserializerException e) {
    throw new DataProviderException("Invalid entity-id", HttpStatusCode.BAD_REQUEST);
  }
}
 
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:17,代码来源:DataProvider.java


示例14: blockTypeFilters

import org.apache.olingo.commons.api.http.HttpStatusCode; //导入依赖的package包/类
private void blockTypeFilters(final UriResource uriResource)
        throws ODataApplicationException
{
    if (((uriResource instanceof UriResourceEntitySet)
            && (((UriResourceEntitySet) uriResource).getTypeFilterOnCollection() != null
            || ((UriResourceEntitySet) uriResource).getTypeFilterOnEntry()
            != null)) || ((uriResource instanceof UriResourceFunction)
            && (((UriResourceFunction) uriResource).getTypeFilterOnCollection() != null
            || ((UriResourceFunction) uriResource).getTypeFilterOnEntry()
            != null)) || ((uriResource instanceof UriResourceNavigation)
            && (((UriResourceNavigation) uriResource).getTypeFilterOnCollection() != null
            || ((UriResourceNavigation) uriResource).getTypeFilterOnEntry() != null)))
    {
        throw new ODataApplicationException("Type filters are not supported.",
                                            HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(),
                                            Locale.ROOT);
    }
}
 
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:19,代码来源:RedHxDiscoveryProcessor.java


示例15: twoLevelsToEntityWithKey

import org.apache.olingo.commons.api.http.HttpStatusCode; //导入依赖的package包/类
@Test
public void twoLevelsToEntityWithKey() throws Exception {
  final ODataRetrieveResponse<ClientEntity> response =
      getClient().getRetrieveRequestFactory().getEntityRequest(
          getClient().newURIBuilder(TecSvcConst.BASE_URI)
              .appendEntitySetSegment("ESTwoPrim").appendKeySegment(32767)
              .appendNavigationSegment("NavPropertyETAllPrimOne")
              .appendNavigationSegment("NavPropertyETTwoPrimMany").appendKeySegment(-365).build())
          .execute();
  assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());

  final ClientEntity entity = response.getBody();
  assertNotNull(entity);
  final ClientProperty property = entity.getProperty("PropertyString");
  assertNotNull(property);
  assertNotNull(property.getPrimitiveValue());
  assertEquals("Test String2", property.getPrimitiveValue().toValue());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:19,代码来源:NavigationITCase.java


示例16: updateEntity

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


示例17: updateEntity

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


示例18: readPrimitiveValue

import org.apache.olingo.commons.api.http.HttpStatusCode; //导入依赖的package包/类
/**
 * This method returns the object which is the value of the property.
 *
 * @param edmProperty EdmProperty
 * @param value       String value
 * @return Object
 * @throws ODataApplicationException
 */
private Object readPrimitiveValue(EdmProperty edmProperty, String value) throws ODataApplicationException {
    if (value == null) {
        return null;
    }
    try {
        if (value.startsWith("'") && value.endsWith("'")) {
            value = value.substring(1, value.length() - 1);
        }
        EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) edmProperty.getType();
        Class<?> javaClass = getJavaClassForPrimitiveType(edmProperty, edmPrimitiveType);
        return edmPrimitiveType.valueOfString(value, edmProperty.isNullable(), edmProperty.getMaxLength(),
                                              edmProperty.getPrecision(), edmProperty.getScale(),
                                              edmProperty.isUnicode(), javaClass);
    } catch (EdmPrimitiveTypeException e) {
        throw new ODataApplicationException("Invalid value: " + value + " for property: " + edmProperty.getName(),
                                            HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(),
                                            Locale.getDefault());
    }
}
 
开发者ID:wso2,项目名称:carbon-data,代码行数:28,代码来源:ODataAdapter.java


示例19: getProduct

import org.apache.olingo.commons.api.http.HttpStatusCode; //导入依赖的package包/类
private Entity getProduct(EdmEntityType edmEntityType, List<UriParameter> keyParams)
				throws ODataApplicationException{

	// the list of entities at runtime
	EntityCollection entitySet = getProducts();
	
	/*  generic approach  to find the requested entity */
	Entity requestedEntity = Util.findEntity(edmEntityType, entitySet, keyParams);
	
	if(requestedEntity == null){
		// this variable is null if our data doesn't contain an entity for the requested key
		// Throw suitable exception
		throw new ODataApplicationException("Entity for requested key doesn't exist",
         HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
	}

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


示例20: primitiveCollectionBoundAction

import org.apache.olingo.commons.api.http.HttpStatusCode; //导入依赖的package包/类
protected static Property primitiveCollectionBoundAction(final String name, final Map<String, Parameter> parameters,
    final Map<String, EntityCollection> data, 
    EdmEntitySet edmEntitySet, List<UriParameter> keyList, final OData oData) throws DataProviderException {
  List<Object> collectionValues = new ArrayList<Object>();
  if ("BAETTwoPrimRTCollString".equals(name)) {
    EdmPrimitiveType strType = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.String);
    try {
      String strValue1 = strType.valueToString("ABC", false, 100, null, null, false);
      collectionValues.add(strValue1);
      String strValue2 = strType.valueToString("XYZ", false, 100, null, null, false);
      collectionValues.add(strValue2);
    } catch (EdmPrimitiveTypeException e) {
      throw new DataProviderException("EdmPrimitiveTypeException", HttpStatusCode.BAD_REQUEST, e);
    }
    return new Property(null, name, ValueType.COLLECTION_PRIMITIVE, collectionValues);
  }
  throw new DataProviderException("Action " + name + " is not yet implemented.",
      HttpStatusCode.NOT_IMPLEMENTED);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:20,代码来源:ActionData.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java AMInfoProto类代码示例发布时间:2022-05-22
下一篇:
Java EigenvalueDecomposition类代码示例发布时间: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