本文整理汇总了Java中org.apache.olingo.odata2.api.exception.ODataApplicationException类的典型用法代码示例。如果您正苦于以下问题:Java ODataApplicationException类的具体用法?Java ODataApplicationException怎么用?Java ODataApplicationException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ODataApplicationException类属于org.apache.olingo.odata2.api.exception包,在下文中一共展示了ODataApplicationException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: retrieveEntryResult
import org.apache.olingo.odata2.api.exception.ODataApplicationException; //导入依赖的package包/类
@Override
public WriteEntryCallbackResult retrieveEntryResult(WriteEntryCallbackContext context)
throws ODataApplicationException
{
EntityProviderWriteProperties inlineProperties = EntityProviderWriteProperties
.serviceRoot(this.serviceRoot)
.expandSelectTree(context.getCurrentExpandSelectTreeNode())
.build();
WriteEntryCallbackResult result = new WriteEntryCallbackResult();
result.setInlineProperties(inlineProperties);
List<Map<String, Object>> data = getData(context);
if (data.size() > 1)
{
throw new IllegalStateException("cannot expand a feed as an entity");
}
if (data.size() == 1)
{
result.setEntryData(data.get(0));
}
return result;
}
示例2: retrieveFeedResult
import org.apache.olingo.odata2.api.exception.ODataApplicationException; //导入依赖的package包/类
@Override
public WriteFeedCallbackResult retrieveFeedResult(WriteFeedCallbackContext context)
throws ODataApplicationException
{
EntityProviderWriteProperties inlineProperties = EntityProviderWriteProperties
.serviceRoot(this.serviceRoot)
.expandSelectTree(context.getCurrentExpandSelectTreeNode())
.selfLink(context.getSelfLink())
.build();
WriteFeedCallbackResult result = new WriteFeedCallbackResult();
result.setInlineProperties(inlineProperties);
result.setFeedData(getData(context));
return result;
}
示例3: getProducts
import org.apache.olingo.odata2.api.exception.ODataApplicationException; //导入依赖的package包/类
public List<Product> getProducts(User user, String uuid,
FilterExpression filter_expr, OrderByExpression order_expr, int skip,
int top) throws ExceptionVisitExpression, ODataApplicationException
{
ProductSQLVisitor expV = new ProductSQLVisitor();
Object visit_result = null;
if (filter_expr != null)
{
visit_result = filter_expr.accept(expV);
}
if (order_expr != null)
{
visit_result = order_expr.accept(expV);
}
return productService.getProducts((DetachedCriteria) visit_result, uuid,
skip, top);
}
示例4: getUsers
import org.apache.olingo.odata2.api.exception.ODataApplicationException; //导入依赖的package包/类
public List<User> getUsers(
FilterExpression filter_expr, OrderByExpression order_expr, int skip,
int top) throws ExceptionVisitExpression, ODataApplicationException
{
UserSQLVisitor expV = new UserSQLVisitor();
Object visit = null;
if (filter_expr != null)
{
visit = filter_expr.accept(expV);
}
if (order_expr != null)
{
visit = order_expr.accept(expV);
}
return userService.getUsers((DetachedCriteria) visit, skip, top);
}
示例5: readData
import org.apache.olingo.odata2.api.exception.ODataApplicationException; //导入依赖的package包/类
@Override
public Object readData(final EdmEntitySet entitySet, final Map<String, Object> keys)
throws ODataNotFoundException, EdmException, ODataApplicationException {
DataStore<Object> store = getDataStore(entitySet);
if (store != null) {
Object keyInstance = store.createInstance();
ANNOTATION_HELPER.setKeyFields(keyInstance, keys);
Object result = store.read(keyInstance);
if (result != null) {
return result;
}
}
throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
}
示例6: readRelatedData
import org.apache.olingo.odata2.api.exception.ODataApplicationException; //导入依赖的package包/类
@Override
public Object readRelatedData(final EdmEntitySet sourceEntitySet, final Object sourceData,
final EdmEntitySet targetEntitySet,
final Map<String, Object> targetKeys)
throws ODataNotImplementedException, ODataNotFoundException, EdmException, ODataApplicationException {
DataStore<?> sourceStore = dataStoreManager.getDataStore(sourceEntitySet.getName());
DataStore<?> targetStore = dataStoreManager.getDataStore(targetEntitySet.getName());
AnnotationHelper.AnnotatedNavInfo navInfo = ANNOTATION_HELPER.getCommonNavigationInfo(
sourceStore.getDataTypeClass(), targetStore.getDataTypeClass());
final Field sourceField;
if(navInfo.isBiDirectional()) {
sourceField = navInfo.getToField();
} else {
sourceField = navInfo.getFromField();
}
if (sourceField == null) {
throw new AnnotationRuntimeException("Missing source field for related data (sourceStore='" + sourceStore
+ "', targetStore='" + targetStore + "').");
}
List<Object> resultData = readResultData(targetStore, sourceData, sourceField, navInfo);
return extractResultData(targetStore, targetKeys, navInfo, resultData);
}
示例7: readBinaryData
import org.apache.olingo.odata2.api.exception.ODataApplicationException; //导入依赖的package包/类
@Override
public BinaryData readBinaryData(final EdmEntitySet entitySet, final Object mediaLinkEntryData)
throws ODataNotImplementedException, ODataNotFoundException, EdmException, ODataApplicationException {
Object data = ANNOTATION_HELPER.getValueForField(mediaLinkEntryData, EdmMediaResourceContent.class);
Object mimeType = ANNOTATION_HELPER.getValueForField(mediaLinkEntryData, EdmMediaResourceMimeType.class);
if (data == null && mimeType == null) {
DataStore<Object> dataStore = getDataStore(entitySet);
Object readEntry = dataStore.read(mediaLinkEntryData);
if (readEntry != null) {
data = ANNOTATION_HELPER.getValueForField(readEntry, EdmMediaResourceContent.class);
mimeType = ANNOTATION_HELPER.getValueForField(readEntry, EdmMediaResourceMimeType.class);
}
}
return new BinaryData((byte[]) data, String.valueOf(mimeType));
}
示例8: writeBinaryData
import org.apache.olingo.odata2.api.exception.ODataApplicationException; //导入依赖的package包/类
@Override
public void writeBinaryData(final EdmEntitySet entitySet, final Object mediaEntityInstance,
final BinaryData binaryData)
throws ODataNotImplementedException, ODataNotFoundException, EdmException, ODataApplicationException {
try {
DataStore<Object> dataStore = getDataStore(entitySet);
Object readEntry = dataStore.read(mediaEntityInstance);
if (readEntry == null) {
throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
} else {
ANNOTATION_HELPER.setValueForAnnotatedField(
mediaEntityInstance, EdmMediaResourceContent.class, binaryData.getData());
ANNOTATION_HELPER.setValueForAnnotatedField(
mediaEntityInstance, EdmMediaResourceMimeType.class, binaryData.getMimeType());
}
} catch (AnnotationHelper.ODataAnnotationException e) {
throw new AnnotationRuntimeException("Invalid media resource annotation at entity set '" + entitySet.getName()
+ "' with message '" + e.getMessage() + "'.", e);
}
}
示例9: readRelatedData
import org.apache.olingo.odata2.api.exception.ODataApplicationException; //导入依赖的package包/类
@Override
public Object readRelatedData(final EdmEntitySet sourceEntitySet, final Object sourceData,
final EdmEntitySet targetEntitySet,
final Map<String, Object> targetKeys)
throws ODataNotImplementedException, ODataNotFoundException, EdmException, ODataApplicationException {
DataStore<?> sourceStore = dataStores.get(sourceEntitySet.getName());
DataStore<?> targetStore = dataStores.get(targetEntitySet.getName());
AnnotatedNavInfo navInfo = ANNOTATION_HELPER.getCommonNavigationInfo(
sourceStore.getDataTypeClass(), targetStore.getDataTypeClass());
final Field sourceField;
if(navInfo.isBiDirectional()) {
sourceField = navInfo.getToField();
} else {
sourceField = navInfo.getFromField();
}
if (sourceField == null) {
throw new AnnotationRuntimeException("Missing source field for related data (sourceStore='" + sourceStore
+ "', targetStore='" + targetStore + "').");
}
List<Object> resultData = readResultData(targetStore, sourceData, sourceField);
return extractResultData(targetStore, targetKeys, navInfo, resultData);
}
示例10: writeBinaryData
import org.apache.olingo.odata2.api.exception.ODataApplicationException; //导入依赖的package包/类
@Override
public void writeBinaryData(final EdmEntitySet entitySet, final Object mediaEntityInstance,
final BinaryData binaryData)
throws ODataNotImplementedException, ODataNotFoundException, EdmException, ODataApplicationException {
try {
DataStore<Object> dataStore = getDataStore(entitySet);
Object readEntry = dataStore.read(mediaEntityInstance);
if (readEntry == null) {
throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
} else {
ANNOTATION_HELPER.setValueForAnnotatedField(
mediaEntityInstance, EdmMediaResourceContent.class, binaryData.getData());
ANNOTATION_HELPER.setValueForAnnotatedField(
mediaEntityInstance, EdmMediaResourceMimeType.class, binaryData.getMimeType());
}
} catch (ODataAnnotationException e) {
throw new AnnotationRuntimeException("Invalid media resource annotation at entity set '" + entitySet.getName()
+ "' with message '" + e.getMessage() + "'.", e);
}
}
示例11: createInlineProperties
import org.apache.olingo.odata2.api.exception.ODataApplicationException; //导入依赖的package包/类
/**
* Create {@link EntityProviderReadProperties} which can be used for reading of inline properties/entrys of navigation
* links within
* this current read entry.
*
* @param readProperties
* @param navigationProperty
* @return
* @throws EntityProviderException
*/
private EntityProviderReadProperties createInlineProperties(final EntityProviderReadProperties readProperties,
final EdmNavigationProperty navigationProperty) throws EntityProviderException {
final OnReadInlineContent callback = readProperties.getCallback();
EntityProviderReadProperties currentReadProperties = EntityProviderReadProperties.initFrom(readProperties).build();
if (callback == null) {
return currentReadProperties;
} else {
try {
return callback.receiveReadProperties(currentReadProperties, navigationProperty);
} catch (ODataApplicationException e) {
throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
.getSimpleName()), e);
}
}
}
示例12: readBinaryData
import org.apache.olingo.odata2.api.exception.ODataApplicationException; //导入依赖的package包/类
public BinaryData readBinaryData(final EdmEntitySet entitySet, final Object mediaLinkEntryData)
throws ODataNotImplementedException, ODataNotFoundException, EdmException, ODataApplicationException {
if (mediaLinkEntryData == null) {
throw new ODataNotFoundException(null);
}
if (ENTITYSET_1_1.equals(entitySet.getName()) || ENTITYSET_1_4.equals(entitySet.getName())) {
final Employee employee = (Employee) mediaLinkEntryData;
if (employee.getImage() == null) {
throw new ODataNotFoundException(null);
}
return new BinaryData(employee.getImage(), employee.getImageType());
} else if (ENTITYSET_2_1.equals(entitySet.getName())) {
final Photo photo = (Photo) mediaLinkEntryData;
return new BinaryData(photo.getImage(), photo.getImageType());
} else {
throw new ODataNotImplementedException();
}
}
示例13: writeBinaryData
import org.apache.olingo.odata2.api.exception.ODataApplicationException; //导入依赖的package包/类
public void
writeBinaryData(final EdmEntitySet entitySet, final Object mediaLinkEntryData, final BinaryData binaryData)
throws ODataNotImplementedException, ODataNotFoundException, EdmException, ODataApplicationException {
if (mediaLinkEntryData == null) {
throw new ODataNotFoundException(null);
}
if (ENTITYSET_1_1.equals(entitySet.getName()) || ENTITYSET_1_4.equals(entitySet.getName())) {
final Employee employee = (Employee) mediaLinkEntryData;
employee.setImage(binaryData.getData());
employee.setImageType(binaryData.getMimeType());
//Storing the binary data to be used for comparison in the tests
Util.getInstance().setBinaryContent(employee.getImage());
} else if (ENTITYSET_2_1.equals(entitySet.getName())) {
final Photo photo = (Photo) mediaLinkEntryData;
photo.setImage(binaryData.getData());
photo.setImageType(binaryData.getMimeType());
} else {
throw new ODataNotImplementedException();
}
}
示例14: createData
import org.apache.olingo.odata2.api.exception.ODataApplicationException; //导入依赖的package包/类
public void createData(final EdmEntitySet entitySet, final Object data) throws ODataNotImplementedException,
EdmException, ODataApplicationException {
if (ENTITYSET_1_1.equals(entitySet.getName())) {
dataContainer.getEmployees().add((Employee) data);
} else if (ENTITYSET_1_2.equals(entitySet.getName())) {
dataContainer.getTeams().add((Team) data);
} else if (ENTITYSET_1_3.equals(entitySet.getName())) {
dataContainer.getRooms().add((Room) data);
} else if (ENTITYSET_1_4.equals(entitySet.getName())) {
dataContainer.getManagers().add((Manager) data);
} else if (ENTITYSET_1_5.equals(entitySet.getName())) {
dataContainer.getBuildings().add((Building) data);
} else if (ENTITYSET_2_1.equals(entitySet.getName())) {
dataContainer.getPhotos().add((Photo) data);
} else {
throw new ODataNotImplementedException();
}
}
示例15: readEntity
import org.apache.olingo.odata2.api.exception.ODataApplicationException; //导入依赖的package包/类
@Override
public ODataResponse readEntity(GetEntityUriInfo uriInfo, String contentType) throws ODataException {
HashMap<String, Object> data = new HashMap<String, Object>();
if ("Employees".equals(uriInfo.getTargetEntitySet().getName())) {
if ("2".equals(uriInfo.getKeyPredicates().get(0).getLiteral())) {
data.put("EmployeeId", "1");
data.put("TeamId", "420");
}
ODataContext context = getContext();
EntityProviderWriteProperties writeProperties =
EntityProviderWriteProperties.serviceRoot(context.getPathInfo().getServiceRoot()).build();
return EntityProvider.writeEntry(contentType, uriInfo.getTargetEntitySet(), data, writeProperties);
} else {
throw new ODataApplicationException("Wrong testcall", Locale.getDefault(), HttpStatusCodes.NOT_IMPLEMENTED);
}
}