Esempio n. 1
0
  private void batchCreate(
      final EntityTypeInvocationHandler handler,
      final ODataEntity entity,
      final ODataChangeset changeset) {

    LOG.debug("Create '{}'", handler);

    final ODataURIBuilder uriBuilder =
        new ODataURIBuilder(factory.getServiceRoot())
            .appendEntitySetSegment(handler.getEntitySetName());
    changeset.addRequest(ODataCUDRequestFactory.getEntityCreateRequest(uriBuilder.build(), entity));
  }
Esempio n. 2
0
  private void batchDelete(
      final EntityTypeInvocationHandler handler,
      final ODataEntity entity,
      final ODataChangeset changeset) {

    LOG.debug("Delete '{}'", entity.getEditLink());

    final ODataDeleteRequest req =
        ODataCUDRequestFactory.getDeleteRequest(
            URIUtils.getURI(factory.getServiceRoot(), entity.getEditLink().toASCIIString()));

    if (StringUtils.isNotBlank(handler.getETag())) {
      req.setIfMatch(handler.getETag());
    }

    changeset.addRequest(req);
  }
Esempio n. 3
0
  private void batchUpdate(
      final EntityTypeInvocationHandler handler,
      final ODataEntity changes,
      final ODataChangeset changeset) {

    LOG.debug("Update '{}'", changes.getEditLink());

    final ODataEntityUpdateRequest req =
        ODataCUDRequestFactory.getEntityUpdateRequest(UpdateType.PATCH, changes);
    req.setPrefer(ODataHeaderValues.preferReturnContent);

    if (StringUtils.isNotBlank(handler.getETag())) {
      req.setIfMatch(handler.getETag());
    }

    changeset.addRequest(req);
  }
Esempio n. 4
0
  private void batchUpdateMediaResource(
      final EntityTypeInvocationHandler handler,
      final URI uri,
      final InputStream input,
      final ODataChangeset changeset) {

    LOG.debug("Update media entity '{}'", uri);

    final ODataStreamUpdateRequest req =
        ODataStreamedRequestFactory.getStreamUpdateRequest(uri, input);

    if (StringUtils.isNotBlank(handler.getETag())) {
      req.setIfMatch(handler.getETag());
    }

    changeset.addRequest(req);
  }
Esempio n. 5
0
  private void batchUpdateMediaEntity(
      final EntityTypeInvocationHandler handler,
      final URI uri,
      final InputStream input,
      final ODataChangeset changeset) {

    LOG.debug("Update media entity '{}'", uri);

    final ODataMediaEntityUpdateRequest req =
        ODataStreamedRequestFactory.getMediaEntityUpdateRequest(uri, input);

    req.setContentType(
        StringUtils.isBlank(handler.getEntity().getMediaContentType())
            ? ODataMediaFormat.WILDCARD.toString()
            : ODataMediaFormat.fromFormat(handler.getEntity().getMediaContentType()).toString());

    if (StringUtils.isNotBlank(handler.getETag())) {
      req.setIfMatch(handler.getETag());
    }

    changeset.addRequest(req);
  }