private void validateEntityData(ODataRequest oDataRequest, ODataUri oDataUri, Object entityData) throws ODataException { Type targetType = getRequestType(oDataRequest, oDataUri); if (!MetaType.ENTITY.equals(targetType.getMetaType())) { throw new ODataBadRequestException("The body of the write request must contain a valid entity."); } WriteMethodUtil.validateProperties(entityData, entityDataModel); } }
LOG.warn("Unsupported type {}.", type.getMetaType().name()); throw new UnsupportedOperationException("Unsupported type: " + typeName);
private void validateEntityData(ODataRequest oDataRequest, ODataUri oDataUri, Object entityData) throws ODataException { Type targetType = getRequestType(oDataRequest, oDataUri); if (!MetaType.ENTITY.equals(targetType.getMetaType())) { throw new ODataBadRequestException("The body of the write request must contain a valid entity."); } WriteMethodUtil.validateProperties(entityData, entityDataModel); } }
LOG.warn("Unsupported type {}.", type.getMetaType().name()); throw new UnsupportedOperationException("Unsupported type: " + typeName);
if (elementType.getMetaType().equals(MetaType.PRIMITIVE)) { xmlWriter.writeAttribute(METADATA, odataMetadataNs, TYPE, HASH + COLLECTION + "(" + elementType.getName() + ")");
if (elementType.getMetaType().equals(MetaType.PRIMITIVE)) { xmlWriter.writeAttribute(METADATA, odataMetadataNs, TYPE, HASH + COLLECTION + "(" + elementType.getName() + ")");
private ProcessorResult processEntity(Object entity) throws ODataException { TargetType targetType = getTargetType(); if (targetType.isCollection()) { Type type = getEntityDataModel().getType(targetType.typeName()); if (!MetaType.ENTITY.equals(type.getMetaType())) { throw new ODataBadRequestException("The body of a POST request must contain a valid entity."); } validateProperties(entity, getEntityDataModel()); DataSource dataSource = getDataSource(type.getFullyQualifiedName()); log.debug("Data source found for type '{}'", type.getFullyQualifiedName()); // Get the location header before trying to create the entity Map<String, String> headers = getResponseHeaders(entity); validateTargetType(entity); Object createdEntity = dataSource.create(getoDataUri(), entity, getEntityDataModel()); if (isMinimalReturnPreferred()) { return new ProcessorResult(NO_CONTENT, headers); } return new ProcessorResult(CREATED, QueryResult.from(createdEntity), headers); } else { throw new ODataBadRequestException("The URI for a POST request should refer to a collection in which " + "to create the entity, not to a single entity."); } }
private ProcessorResult processEntity(Object entity) throws ODataException { TargetType targetType = getTargetType(); if (targetType.isCollection()) { Type type = getEntityDataModel().getType(targetType.typeName()); if (!MetaType.ENTITY.equals(type.getMetaType())) { throw new ODataBadRequestException("The body of a POST request must contain a valid entity."); } validateProperties(entity, getEntityDataModel()); DataSource dataSource = getDataSource(type.getFullyQualifiedName()); log.debug("Data source found for type '{}'", type.getFullyQualifiedName()); // Get the location header before trying to create the entity Map<String, String> headers = getResponseHeaders(entity); validateTargetType(entity); Object createdEntity = dataSource.create(getoDataUri(), entity, getEntityDataModel()); if (isMinimalReturnPreferred()) { return new ProcessorResult(NO_CONTENT, headers); } return new ProcessorResult(CREATED, QueryResult.from(createdEntity), headers); } else { throw new ODataBadRequestException("The URI for a POST request should refer to a collection in which " + "to create the entity, not to a single entity."); } }
private ProcessorResult processRequest(Object entity) throws ODataException { TargetType targetType = getTargetType(); if (!targetType.isCollection()) { Type type = getEntityDataModel().getType(targetType.typeName()); if (!MetaType.ENTITY.equals(type.getMetaType())) { throw new ODataBadRequestException("The body of a PATCH request must contain a valid entity."); } validateProperties(entity, getEntityDataModel()); DataSource dataSource = getDataSource(type.getFullyQualifiedName()); log.debug("Data source found for type '{}'", type.getFullyQualifiedName()); // Get the location header before trying to create the entity Map<String, String> headers = getResponseHeaders(entity); validateTargetType(entity); validateKeys(entity, (EntityType) type); Object updatedEntity = dataSource.update(getoDataUri(), entity, getEntityDataModel()); if (isMinimalReturnPreferred()) { return new ProcessorResult(NO_CONTENT, headers); } return new ProcessorResult(OK, QueryResult.from(updatedEntity), headers); } else { throw new ODataBadRequestException("The URI for a PATCH request should refer to the single entity " + "to be updated, not to a collection of entities."); } } }
private ProcessorResult processEntity(Object entity) throws ODataException { TargetType targetType = getTargetType(); if (!targetType.isCollection()) { Type type = getEntityDataModel().getType(targetType.typeName()); if (!MetaType.ENTITY.equals(type.getMetaType())) { throw new ODataBadRequestException("The body of a PUT request must contain a valid entity."); } validateProperties(entity, getEntityDataModel()); DataSource dataSource = getDataSource(type.getFullyQualifiedName()); log.debug("Data source found for type '{}'", type.getFullyQualifiedName()); // Get the location header before trying to create the entity Map<String, String> headers = getResponseHeaders(entity); validateTargetType(entity); validateKeys(entity, (EntityType) type); Object updatedEntity = dataSource.update(getoDataUri(), entity, getEntityDataModel()); if (isMinimalReturnPreferred()) { return new ProcessorResult(NO_CONTENT, headers); } return new ProcessorResult(OK, QueryResult.from(updatedEntity), headers); } else { throw new ODataBadRequestException("The URI for a PUT request should refer to the single entity " + "to be updated, not to a collection of entities."); } }
private ProcessorResult processEntity(Object entity) throws ODataException { TargetType targetType = getTargetType(); if (!targetType.isCollection()) { Type type = getEntityDataModel().getType(targetType.typeName()); if (!MetaType.ENTITY.equals(type.getMetaType())) { throw new ODataBadRequestException("The body of a PUT request must contain a valid entity."); } validateProperties(entity, getEntityDataModel()); DataSource dataSource = getDataSource(type.getFullyQualifiedName()); log.debug("Data source found for type '{}'", type.getFullyQualifiedName()); // Get the location header before trying to create the entity Map<String, String> headers = getResponseHeaders(entity); validateTargetType(entity); validateKeys(entity, (EntityType) type); Object updatedEntity = dataSource.update(getoDataUri(), entity, getEntityDataModel()); if (isMinimalReturnPreferred()) { return new ProcessorResult(NO_CONTENT, headers); } return new ProcessorResult(OK, QueryResult.from(updatedEntity), headers); } else { throw new ODataBadRequestException("The URI for a PUT request should refer to the single entity " + "to be updated, not to a collection of entities."); } }
private ProcessorResult processRequest(Object entity) throws ODataException { TargetType targetType = getTargetType(); if (!targetType.isCollection()) { Type type = getEntityDataModel().getType(targetType.typeName()); if (!MetaType.ENTITY.equals(type.getMetaType())) { throw new ODataBadRequestException("The body of a PATCH request must contain a valid entity."); } validateProperties(entity, getEntityDataModel()); DataSource dataSource = getDataSource(type.getFullyQualifiedName()); log.debug("Data source found for type '{}'", type.getFullyQualifiedName()); // Get the location header before trying to create the entity Map<String, String> headers = getResponseHeaders(entity); validateTargetType(entity); validateKeys(entity, (EntityType) type); Object updatedEntity = dataSource.update(getoDataUri(), entity, getEntityDataModel()); if (isMinimalReturnPreferred()) { return new ProcessorResult(NO_CONTENT, headers); } return new ProcessorResult(OK, QueryResult.from(updatedEntity), headers); } else { throw new ODataBadRequestException("The URI for a PATCH request should refer to the single entity " + "to be updated, not to a collection of entities."); } } }