Batch saving links to non-post (modified) entities, should not use resource aliases

Apr 26, 2011 at 2:53 AM
Edited Apr 26, 2011 at 12:52 PM

I tracked down a bug in saving in which I was getting "Resource not found for the segment '$x" when calling setLink.

It turns out that you should not reference an alias when setting a link to a modified entity, only on when setting a link on additions.  So the if statement in the following lines should be changed to only look for additions:

createChangesetHeaderForBinding:

//if (Added == [sourceResourceBox getState] || Modified == [sourceResourceBox getState])
if (Added == [sourceResourceBox getState])
{
	absoluteUri = [NSString stringWithFormat:@"$%d/$links/%@",[sourceResourceBox getChangeOrder],uri];
}
else
{
	absoluteUri = [NSString stringWithFormat:@"%@/$links/%@",[sourceResourceBox getResourceUri:[m_context getBaseUriWithSlash]],uri];
}

createChangesetBodyForBinding:

//if([targetResourcebox getState] == Added || [targetResourcebox getState] == Modified)
if([targetResourcebox getState] == Added)
	targetObjectUri = [NSString stringWithFormat:@"$%d",[targetResourcebox getChangeOrder]];
else
	targetObjectUri = [targetResourcebox getEditMediaResourceUri:[m_context getBaseUriWithSlash]];