Java Code Examples for org.apache.olingo.client.api.domain.ClientEntity#setEditLink()

The following examples show how to use org.apache.olingo.client.api.domain.ClientEntity#setEditLink() . 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: ODataRequestImplTest.java    From olingo-odata4 with Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdate() throws URISyntaxException{
  ODataClientImpl client = (ODataClientImpl) ODataClientFactory.getClient();
  URI uri = new URI("test");
  assertNotNull(client);
  CUDRequestFactory factory = client.getCUDRequestFactory();
  assertNotNull(factory);
  FullQualifiedName fqn = new FullQualifiedName("test.entity");
  ClientEntity entity = new ClientEntityImpl(fqn );
  entity.setEditLink(uri);
  ODataEntityUpdateRequestImpl update = (ODataEntityUpdateRequestImpl) factory
      .getEntityUpdateRequest(UpdateType.PATCH, entity);
  assertNotNull(update);
  assertNotNull(update.getDefaultFormat());
  assertNotNull(update.getPayload());
  }
 
Example 2
Source File: ODataRequestImplTest.java    From olingo-odata4 with Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdate2() throws URISyntaxException{
  ODataClientImpl client = (ODataClientImpl) ODataClientFactory.getClient();
  URI uri = new URI("test");
  assertNotNull(client);
  CUDRequestFactory factory = client.getCUDRequestFactory();
  assertNotNull(factory);
  FullQualifiedName fqn = new FullQualifiedName("test.entity");
  ClientEntity entity = new ClientEntityImpl(fqn );
  entity.setEditLink(uri);
  ODataEntityUpdateRequestImpl update = (ODataEntityUpdateRequestImpl) factory
      .getEntityUpdateRequest(uri, UpdateType.PATCH, entity);
  assertNotNull(update);
  assertNotNull(update.getDefaultFormat());
  assertNotNull(update.getPayload());
  }
 
Example 3
Source File: ODataRequestImplTest.java    From olingo-odata4 with Apache License 2.0 6 votes vote down vote up
@Test
public void testRef() throws URISyntaxException{
  ODataClientImpl client = (ODataClientImpl) ODataClientFactory.getClient();
  URI uri = new URI("test");
  assertNotNull(client);
  CUDRequestFactory factory = client.getCUDRequestFactory();
  assertNotNull(factory);
  FullQualifiedName fqn = new FullQualifiedName("test.entity");
  ClientEntity entity = new ClientEntityImpl(fqn );
  entity.setEditLink(uri);
  ODataReferenceAddingRequestImpl ref = (ODataReferenceAddingRequestImpl) factory
      .getReferenceAddingRequest(uri, uri, null);
  assertNotNull(ref);
  assertNotNull(ref.getDefaultFormat());
  assertNotNull(ref.getPayload());
  }
 
Example 4
Source File: ConformanceITCase.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
/**
 * 7. MUST generate PATCH requests for updates, if the client supports updates (section 11.4.3).
 **/
@Test
public void patchEntityRequestForUpdates() {
  final ODataClient client = getClient();
  final ClientEntity patch = client.getObjectFactory().newEntity(ET_TWO_PRIM);     
  final URI uri = client.newURIBuilder(SERVICE_URI)
          .appendEntitySetSegment(ES_TWO_PRIM)
          .appendKeySegment(32766)
          .build();
  patch.setEditLink(uri);
  final String newString = "Seconds: (" + System.currentTimeMillis() + ")";
  patch.getProperties().add(client.getObjectFactory().newPrimitiveProperty("PropertyString",
      client.getObjectFactory().newPrimitiveValueBuilder().buildString(newString)));

  final ODataEntityUpdateRequest<ClientEntity> req =            
      client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.PATCH, patch);
  assertNotNull(req);
  assertEquals(ODATA_MAX_VERSION_NUMBER, req.getHeader(HttpHeader.ODATA_MAX_VERSION));
  
  final ODataEntityUpdateResponse<ClientEntity> res = req.execute();
  assertNotNull(res);
  assertEquals(200, res.getStatusCode());   
          
  final ClientEntity entity = res.getBody();
  assertNotNull(entity);
  assertEquals(newString, entity.getProperty("PropertyString").getPrimitiveValue().toString());
}
 
Example 5
Source File: EntityInvocationHandler.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
private EntityInvocationHandler(
    final Object entityKey,
    final ClientEntity entity,
    final URI entitySetURI,
    final Class<?> typeRef,
    final AbstractService<?> service) {

  super(typeRef, entity, service);

  final Object key = entityKey == null ? CoreUtils.getKey(getClient(), this, typeRef, entity) : entityKey;

  if (entity.getEditLink() != null) {
    this.baseURI = entity.getEditLink();
    this.uri = getClient().newURIBuilder(baseURI.toASCIIString());
  } else if (key != null) {
    final URIBuilder uriBuilder =
        CoreUtils.buildEditLink(getClient(), entitySetURI.toASCIIString(), key);

    this.uri = uriBuilder;
    this.baseURI = this.uri.build();
    entity.setEditLink(this.baseURI);
  } else {
    this.baseURI = null;
    this.uri = null;
  }

  this.internal = entity;
  getEntity().setMediaEntity(typeRef.getAnnotation(EntityType.class).hasStream());

  this.uuid = new EntityUUID(entitySetURI, typeRef, key);
}
 
Example 6
Source File: AuthBatchTestITCase.java    From olingo-odata4 with Apache License 2.0 4 votes vote down vote up
private void batchRequest(final ODataClient client, final String baseURL) throws EdmPrimitiveTypeException {
  // create your request
  final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(baseURL);
  request.setAccept(ACCEPT.toContentTypeString());
  request.addCustomHeader("User-Agent", "Apache Olingo OData Client");
  request.addCustomHeader(HttpHeader.ACCEPT_CHARSET, "UTF-8");

  final BatchManager streamManager = request.payloadManager();

  // -------------------------------------------
  // Add retrieve item
  // -------------------------------------------
  // prepare URI
  URIBuilder targetURI = client.newURIBuilder(baseURL);
  targetURI.appendEntitySetSegment("ESAllPrim").appendKeySegment(32767);

  // create new request
  ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());

  streamManager.addRequest(queryReq);
  // -------------------------------------------

  // -------------------------------------------
  // Add changeset item
  // -------------------------------------------
  final ODataChangeset changeset = streamManager.addChangeset();

  // Update Customer into the changeset
  targetURI = client.newURIBuilder(baseURL).appendEntitySetSegment("ESAllPrim").appendKeySegment(32767);
  final URI editLink = targetURI.build();

  final ClientEntity patch = client.getObjectFactory().newEntity(
      new FullQualifiedName(SERVICE_NAMESPACE, "ETAllPrim"));
  patch.setEditLink(editLink);

  patch.getProperties().add(client.getObjectFactory().newPrimitiveProperty(
      "PropertyString",
      client.getObjectFactory().newPrimitiveValueBuilder().buildString("Test")));

  final ODataEntityUpdateRequest<ClientEntity> changeReq =
      client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.PATCH, patch);

  changeset.addRequest(changeReq);
  // -------------------------------------------

  final ODataBatchResponse response = streamManager.getResponse();
  assertEquals(200, response.getStatusCode());
  assertEquals("OK", response.getStatusMessage());
}
 
Example 7
Source File: AtomTest.java    From olingo-odata4 with Apache License 2.0 4 votes vote down vote up
@Test
public void issue1OLINGO1073() throws Exception {
  final ClientEntity message = client.getObjectFactory().
      newEntity(new FullQualifiedName("Microsoft.OData.SampleService.Models.TripPin.Person"));
  
  final ClientComplexValue cityComplexType = getCityComplexType();
  
  final ClientComplexValue locationComplexType = client.getObjectFactory().
      newComplexValue("Microsoft.OData.SampleService.Models.TripPin.Location");
  locationComplexType.add(client.getObjectFactory().newPrimitiveProperty("Address",
      client.getObjectFactory().newPrimitiveValueBuilder().buildString("187 Suffolk Ln.")));
  locationComplexType.add(client.getObjectFactory().newComplexProperty("City",cityComplexType));

  final ClientComplexValue eventLocationComplexType = client.getObjectFactory().
      newComplexValue("Microsoft.OData.SampleService.Models.TripPin.EventLocation");
  eventLocationComplexType.add(client.getObjectFactory().newPrimitiveProperty("BuildingInfo",
      client.getObjectFactory().newPrimitiveValueBuilder().buildString("187 Suffolk Ln12.")));
  eventLocationComplexType.add(client.getObjectFactory().newPrimitiveProperty("Address",
      client.getObjectFactory().newPrimitiveValueBuilder().buildString("187 Suffolk Ln12.")));
  eventLocationComplexType.add(client.getObjectFactory().newComplexProperty("City",cityComplexType));
  
  final ClientComplexValue airportLocationComplexType = client.getObjectFactory().
      newComplexValue("Microsoft.OData.SampleService.Models.TripPin.AirportLocation");
  airportLocationComplexType.add(client.getObjectFactory().newPrimitiveProperty("Address",
      client.getObjectFactory().newPrimitiveValueBuilder().buildString("187 Suffolk Ln123.")));
  airportLocationComplexType.add(client.getObjectFactory().newComplexProperty("City",cityComplexType));
  
  final ClientCollectionValue<ClientValue> collectionAddressInfo = client.getObjectFactory().
      newCollectionValue("Microsoft.OData.SampleService.Models.TripPin.Location");
  collectionAddressInfo.add(locationComplexType);
  collectionAddressInfo.add(eventLocationComplexType);
  collectionAddressInfo.add(airportLocationComplexType);
  
  message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("UserName", 
      client.getObjectFactory().newPrimitiveValueBuilder().buildString("russellwhyte")));
  message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("FirstName", 
      client.getObjectFactory().newPrimitiveValueBuilder().buildString("Russell")));
  message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("LastName", 
      client.getObjectFactory().newPrimitiveValueBuilder().buildString("Whyte")));
  
  final ClientCollectionValue<ClientValue> emailCollectionValue = client.getObjectFactory().
      newCollectionValue("String");
  emailCollectionValue.add(client.getObjectFactory().newPrimitiveValueBuilder().buildString("[email protected]"));
  emailCollectionValue.add(client.getObjectFactory().newPrimitiveValueBuilder().buildString("[email protected]"));
  message.getProperties().add(client.getObjectFactory().newCollectionProperty("Emails", emailCollectionValue));
  
  message.getProperties().add(client.getObjectFactory().newCollectionProperty("AddressInfo", collectionAddressInfo));
  message.getProperties().add(client.getObjectFactory().newEnumProperty("Gender", 
      client.getObjectFactory().newEnumValue(
          "Microsoft.OData.SampleService.Models.TripPin.PersonGender", "Male")));
  message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Concurrency", 
      client.getObjectFactory().newPrimitiveValueBuilder().buildInt64(Long.valueOf("636293755917400747"))));
  message.setId(URI.create("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/"
      + "TripPinServiceRW/People('russellwhyte')"));
  message.setETag("W/\"08D491CCBE417AAB\"");
  message.setEditLink(URI.create("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/"
      + "TripPinServiceRW/People('russellwhyte')"));

  String actual = IOUtils.toString(client.getWriter().writeEntity(message, ContentType.APPLICATION_ATOM_XML));
  actual = actual.substring(actual.indexOf("<entry"));
  assertNotNull(actual);
  String expected = IOUtils.toString(getClass().getResourceAsStream("olingo1073_1.xml"));
  expected = expected.substring(expected.indexOf("<entry"));
  expected = expected.trim().replace("\n", "").replace("\r", "").replace("\t", "");
  assertEquals(expected, actual);
}
 
Example 8
Source File: AtomTest.java    From olingo-odata4 with Apache License 2.0 4 votes vote down vote up
@Test
public void issue2OLINGO1073() throws Exception {
  final ClientEntity message = client.getObjectFactory().
      newEntity(new FullQualifiedName("Microsoft.OData.SampleService.Models.TripPin.Person"));
  
  final ClientComplexValue cityComplexType = getCityComplexType();
  
  final ClientComplexValue locationComplexType = client.getObjectFactory().
      newComplexValue("Microsoft.OData.SampleService.Models.TripPin.Location");
  locationComplexType.add(client.getObjectFactory().newPrimitiveProperty("Address",
      client.getObjectFactory().newPrimitiveValueBuilder().buildString("187 Suffolk Ln.")));
  locationComplexType.add(client.getObjectFactory().newComplexProperty("City",cityComplexType));

  final ClientComplexValue eventLocationComplexType = client.getObjectFactory().
      newComplexValue("Microsoft.OData.SampleService.Models.TripPin.EventLocation");
  eventLocationComplexType.add(client.getObjectFactory().newPrimitiveProperty("BuildingInfo",
      client.getObjectFactory().newPrimitiveValueBuilder().buildString("187 Suffolk Ln12.")));
  eventLocationComplexType.add(client.getObjectFactory().newPrimitiveProperty("Address",
      client.getObjectFactory().newPrimitiveValueBuilder().buildString("187 Suffolk Ln12.")));
  eventLocationComplexType.add(client.getObjectFactory().newComplexProperty("City",cityComplexType));
  
  final ClientComplexValue airportLocationComplexType = client.getObjectFactory().
      newComplexValue("Microsoft.OData.SampleService.Models.TripPin.AirportLocation");
  airportLocationComplexType.add(client.getObjectFactory().newPrimitiveProperty("Address",
      client.getObjectFactory().newPrimitiveValueBuilder().buildString("187 Suffolk Ln123.")));
  airportLocationComplexType.add(client.getObjectFactory().newComplexProperty("City",cityComplexType));
  
  final ClientCollectionValue<ClientValue> collectionAddressInfo = client.getObjectFactory().
      newCollectionValue("Microsoft.OData.SampleService.Models.TripPin.Location");
  collectionAddressInfo.add(locationComplexType);
  collectionAddressInfo.add(eventLocationComplexType);
  collectionAddressInfo.add(airportLocationComplexType);
  
  message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("UserName", 
      client.getObjectFactory().newPrimitiveValueBuilder().buildString("russellwhyte")));
  message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("FirstName", 
      client.getObjectFactory().newPrimitiveValueBuilder().buildString("Russell")));
  message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("LastName", 
      client.getObjectFactory().newPrimitiveValueBuilder().buildString("Whyte")));
  
  final ClientCollectionValue<ClientValue> emailCollectionValue = client.getObjectFactory().
      newCollectionValue("String");
  emailCollectionValue.add(client.getObjectFactory().newPrimitiveValueBuilder().buildString("[email protected]"));
  emailCollectionValue.add(client.getObjectFactory().newPrimitiveValueBuilder().buildString("[email protected]"));
  message.getProperties().add(client.getObjectFactory().newCollectionProperty("Emails", emailCollectionValue));
  
  message.getProperties().add(client.getObjectFactory().newCollectionProperty("AddressInfo", collectionAddressInfo));
  message.getProperties().add(client.getObjectFactory().newEnumProperty("Gender", 
      client.getObjectFactory().newEnumValue(
          "Microsoft.OData.SampleService.Models.TripPin.PersonGender", "Male")));
  message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Concurrency", 
      client.getObjectFactory().newPrimitiveValueBuilder().buildInt64(Long.valueOf("636293755917400747"))));
  message.setId(URI.create("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/"
      + "TripPinServiceRW/People('russellwhyte')"));
  message.setETag("W/\"08D491CCBE417AAB\"");
  message.setEditLink(URI.create("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/"
      + "TripPinServiceRW/People('russellwhyte')"));

  InputStream inputStream = client.getWriter().writeEntity(message, ContentType.APPLICATION_ATOM_XML);
  ResWrap<Entity> entity = new AtomDeserializer().toEntity(inputStream);
  assertNotNull(entity);
  assertEquals(7, entity.getPayload().getProperties().size());
  assertEquals(3, entity.getPayload().getProperty("AddressInfo").asCollection().size());
  assertEquals("#Microsoft.OData.SampleService.Models.TripPin.Location", 
      ((ComplexValue)entity.getPayload().getProperty("AddressInfo").asCollection().get(0)).getTypeName());
  assertEquals("#Microsoft.OData.SampleService.Models.TripPin.EventLocation", 
      ((ComplexValue)entity.getPayload().getProperty("AddressInfo").asCollection().get(1)).getTypeName());
  assertEquals("#Microsoft.OData.SampleService.Models.TripPin.AirportLocation", 
      ((ComplexValue)entity.getPayload().getProperty("AddressInfo").asCollection().get(2)).getTypeName());
  assertEquals("Collection(Microsoft.OData.SampleService.Models.TripPin.Location)", 
      entity.getPayload().getProperty("AddressInfo").getType());
}
 
Example 9
Source File: JSONTest.java    From olingo-odata4 with Apache License 2.0 4 votes vote down vote up
@Test
public void issue3OLINGO1073() throws Exception {
  final ClientEntity message = client.getObjectFactory().
      newEntity(new FullQualifiedName("Microsoft.OData.SampleService.Models.TripPin.Person"));
  
  final ClientComplexValue cityComplexType = getCityComplexType();
  
  final ClientComplexValue locationComplexType = client.getObjectFactory().
      newComplexValue("Microsoft.OData.SampleService.Models.TripPin.Location");
  locationComplexType.add(client.getObjectFactory().newPrimitiveProperty("Address",
      client.getObjectFactory().newPrimitiveValueBuilder().buildString("187 Suffolk Ln.")));
  locationComplexType.add(client.getObjectFactory().newComplexProperty("City",cityComplexType));

  final ClientComplexValue eventLocationComplexType = client.getObjectFactory().
      newComplexValue("Microsoft.OData.SampleService.Models.TripPin.EventLocation");
  eventLocationComplexType.add(client.getObjectFactory().newPrimitiveProperty("BuildingInfo",
      client.getObjectFactory().newPrimitiveValueBuilder().buildString("187 Suffolk Ln12.")));
  eventLocationComplexType.add(client.getObjectFactory().newPrimitiveProperty("Address",
      client.getObjectFactory().newPrimitiveValueBuilder().buildString("187 Suffolk Ln12.")));
  eventLocationComplexType.add(client.getObjectFactory().newComplexProperty("City",cityComplexType));
  
  final ClientComplexValue airportLocationComplexType = client.getObjectFactory().
      newComplexValue("Microsoft.OData.SampleService.Models.TripPin.AirportLocation");
  airportLocationComplexType.add(client.getObjectFactory().newPrimitiveProperty("Address",
      client.getObjectFactory().newPrimitiveValueBuilder().buildString("187 Suffolk Ln123.")));
  airportLocationComplexType.add(client.getObjectFactory().newComplexProperty("City",cityComplexType));
  
  final ClientCollectionValue<ClientValue> collectionAddressInfo = client.getObjectFactory().
      newCollectionValue("Microsoft.OData.SampleService.Models.TripPin.Location");
  collectionAddressInfo.add(locationComplexType);
  collectionAddressInfo.add(eventLocationComplexType);
  collectionAddressInfo.add(airportLocationComplexType);
  
  message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("UserName", 
      client.getObjectFactory().newPrimitiveValueBuilder().buildString("russellwhyte")));
  message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("FirstName", 
      client.getObjectFactory().newPrimitiveValueBuilder().buildString("Russell")));
  message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("LastName", 
      client.getObjectFactory().newPrimitiveValueBuilder().buildString("Whyte")));
  
  final ClientCollectionValue<ClientValue> emailCollectionValue = client.getObjectFactory().
      newCollectionValue("String");
  emailCollectionValue.add(client.getObjectFactory().newPrimitiveValueBuilder().buildString("[email protected]"));
  emailCollectionValue.add(client.getObjectFactory().newPrimitiveValueBuilder().buildString("[email protected]"));
  message.getProperties().add(client.getObjectFactory().newCollectionProperty("Emails", emailCollectionValue));
  
  message.getProperties().add(client.getObjectFactory().newCollectionProperty("AddressInfo", collectionAddressInfo));
  message.getProperties().add(client.getObjectFactory().newEnumProperty("Gender", 
      client.getObjectFactory().newEnumValue(
          "Microsoft.OData.SampleService.Models.TripPin.PersonGender", "Male")));
  message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Concurrency", 
      client.getObjectFactory().newPrimitiveValueBuilder().buildInt64(Long.valueOf("636293755917400747"))));
  message.setId(URI.create("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/"
      + "TripPinServiceRW/People('russellwhyte')"));
  message.setETag("W/\"08D491CCBE417AAB\"");
  message.setEditLink(URI.create("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/"
      + "TripPinServiceRW/People('russellwhyte')"));

  InputStream inputStream = client.getWriter().writeEntity(message, ContentType.JSON_FULL_METADATA);
  ResWrap<Entity> entity = new JsonDeserializer(true).toEntity(inputStream);
  assertNotNull(entity);
  assertEquals(7, entity.getPayload().getProperties().size());
  assertEquals(3, entity.getPayload().getProperty("AddressInfo").asCollection().size());
  assertEquals("#Microsoft.OData.SampleService.Models.TripPin.Location", 
      ((ComplexValue)entity.getPayload().getProperty("AddressInfo").asCollection().get(0)).getTypeName());
  assertEquals("#Microsoft.OData.SampleService.Models.TripPin.EventLocation", 
      ((ComplexValue)entity.getPayload().getProperty("AddressInfo").asCollection().get(1)).getTypeName());
  assertEquals("#Microsoft.OData.SampleService.Models.TripPin.AirportLocation", 
      ((ComplexValue)entity.getPayload().getProperty("AddressInfo").asCollection().get(2)).getTypeName());
  assertEquals("Collection(Microsoft.OData.SampleService.Models.TripPin.Location)", 
      entity.getPayload().getProperty("AddressInfo").getType());
}
 
Example 10
Source File: AbstractInvocationHandler.java    From olingo-odata4 with Apache License 2.0 4 votes vote down vote up
protected <S extends EntityType<?>> void deleteEntity(final EntityInvocationHandler handler, final URI entitySetURI) {
  final EntityContext entityContext = getContext().entityContext();

  final URI baseURI = entitySetURI == null ? handler.getEntitySetURI() : entitySetURI;

  if (baseURI == null) {
    throw new IllegalStateException("Entity base URI not available");
  }

  final String name = handler.getUUID().getType().
      getAnnotation(org.apache.olingo.ext.proxy.api.annotations.EntityType.class).name();

  final String namespace = handler.getUUID().getType().getAnnotation(Namespace.class).value();

  final ClientEntity template;

  final URI entityURI;
  if (handler.getEntityURI() == null || handler.getUUID().getKey() == null) {
    template = service.getClient().getObjectFactory().newEntity(new FullQualifiedName(namespace, name));
    CoreUtils.addProperties(getClient(), handler.getPropertyChanges(), template);
    final Object key = CoreUtils.getKey(getClient(), handler, handler.getUUID().getType(), template);

    entityURI = CoreUtils.buildEditLink(getClient(), baseURI.toASCIIString(), key).build();
    template.setEditLink(entityURI);
  } else {
    entityURI = handler.getEntityURI();
    template = handler.getEntity();
  }

  // https://issues.apache.org/jira/browse/OLINGO-395
  if (entityContext.isAttached(handler)) {
    entityContext.addFurtherDeletes(entityURI);
  } else {
    if (handler.getUUID().getKey() == null) {
      // objects created ad-hoc to generate deletion requests
      handler.updateEntityUUID(baseURI, handler.getUUID().getType(), template);
    } else {
      handler.updateUUID(baseURI, handler.getUUID().getType(), handler.getUUID().getKey());
    }
    entityContext.attach(handler, AttachedEntityStatus.DELETED, true);
  }
}