Java Code Examples for org.apache.olingo.odata2.api.ep.EntityProviderException#MEDIA_DATA_NOT_INITIAL

The following examples show how to use org.apache.olingo.odata2.api.ep.EntityProviderException#MEDIA_DATA_NOT_INITIAL . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JsonEntryConsumer.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
private void validateMetadata() throws EdmException, EntityProviderException {
  if (eia.getEntityType().hasStream()) {
    if (mediaMetadata.getSourceLink() == null) {
      throw new EntityProviderException(EntityProviderException.MISSING_ATTRIBUTE.addContent(FormatJson.MEDIA_SRC)
          .addContent(FormatJson.METADATA));
    }
    if (mediaMetadata.getContentType() == null) {
      throw new EntityProviderException(EntityProviderException.MISSING_ATTRIBUTE.addContent(FormatJson.CONTENT_TYPE)
          .addContent(FormatJson.METADATA));
    }
  } else {
    if (mediaMetadata.getContentType() != null || mediaMetadata.getEditLink() != null
        || mediaMetadata.getEtag() != null || mediaMetadata.getSourceLink() != null) {
      throw new EntityProviderException(EntityProviderException.MEDIA_DATA_NOT_INITIAL);
    }
  }
}
 
Example 2
Source File: JsonEntryDeserializer.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
/**
 * 
 * @throws EdmException
 * @throws EntityProviderException
 */
private void validateMetadata() throws EdmException, EntityProviderException {
  if (eia.getEntityType().hasStream()) {
    if (mediaMetadata.getSourceLink() == null) {
      throw new EntityProviderException(EntityProviderException.MISSING_ATTRIBUTE.addContent(FormatJson.MEDIA_SRC)
          .addContent(FormatJson.METADATA));
    }
    if (mediaMetadata.getContentType() == null) {
      throw new EntityProviderException(EntityProviderException.MISSING_ATTRIBUTE.addContent(FormatJson.CONTENT_TYPE)
          .addContent(FormatJson.METADATA));
    }
  } else {
    if (mediaMetadata.getContentType() != null || mediaMetadata.getEditLink() != null
        || mediaMetadata.getEtag() != null || mediaMetadata.getSourceLink() != null) {
      throw new EntityProviderException(EntityProviderException.MEDIA_DATA_NOT_INITIAL);
    }
  }
}