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

Apr 26, 2011 at 3:53 AM
Edited Apr 26, 2011 at 1: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:


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


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