return;
}
if (target != null) {
// TODO Take into acount the case where the target does exist.
Metadata metadata = (Metadata) getMetadata();
ClientResource resource = createResource(metadata
.getSubpath(source) + "/$links/" + sourceProperty);
try {
// TODO Fix chunked request with net client connector
StringBuilder sb = new StringBuilder("<uri xmlns=\"");
sb.append(WCF_DATASERVICES_NAMESPACE);
sb.append("\">");
sb.append(getServiceRef().toString());
sb.append(metadata.getSubpath(target));
sb.append("</uri>");
StringRepresentation r = new StringRepresentation(
sb.toString(), MediaType.APPLICATION_XML);
resource.put(r);
} catch (ResourceException re) {
throw new ResourceException(re.getStatus(),
"Can't set entity to this entity set "
+ resource.getReference());
} finally {
this.latestRequest = resource.getRequest();
this.latestResponse = resource.getResponse();
}
} else {
ReflectUtils.invokeSetter(source, sourceProperty, null);
updateEntity(source);
}